Geant4  10.02.p02
Par02FastSimModelEMCal.cc
Go to the documentation of this file.
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 // $Id: $
27 //
30 
32 #include "Par02EventInformation.hh"
34 #include "Par02Smearer.hh"
35 #include "Par02Output.hh"
36 
37 #include "G4Track.hh"
38 #include "G4Event.hh"
39 #include "G4RunManager.hh"
40 #include "g4root.hh"
41 
42 #include "Randomize.hh"
43 #include "G4SystemOfUnits.hh"
44 
45 #include "G4Electron.hh"
46 #include "G4Positron.hh"
47 #include "G4Gamma.hh"
48 
49 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
50 
53  G4VFastSimulationModel( aModelName, aEnvelope ), fCalculateParametrisation(),
54  fParametrisation( aType ) {}
55 
56 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
57 
59  G4Region* aEnvelope ) :
60  G4VFastSimulationModel( aModelName, aEnvelope ), fCalculateParametrisation(),
61  fParametrisation( Par02DetectorParametrisation::eCMS ) {}
62 
63 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
64 
66  G4VFastSimulationModel( aModelName ), fCalculateParametrisation(),
67  fParametrisation( Par02DetectorParametrisation::eCMS ) {}
68 
69 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
70 
72 
73 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
74 
76  const G4ParticleDefinition& aParticleType ) {
77  // Applicable for electrons, positrons, and gammas
78  return &aParticleType == G4Electron::Definition() ||
79  &aParticleType == G4Positron::Definition() ||
80  &aParticleType == G4Gamma::Definition();
81 }
82 
83 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
84 
86  return true; // No kinematical restrictions to apply the parametrisation
87 }
88 
89 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
90 
91 void Par02FastSimModelEMCal::DoIt( const G4FastTrack& aFastTrack,
92  G4FastStep& aFastStep ) {
93  //G4cout << " ________EMCal model triggered _________" << G4endl;
94 
95  // Kill the parameterised particle at the entrance of the electromagnetic calorimeter
96  aFastStep.KillPrimaryTrack();
97  aFastStep.ProposePrimaryTrackPathLength( 0.0 );
98  G4double Edep = aFastTrack.GetPrimaryTrack()->GetKineticEnergy();
99 
100  // Consider only primary tracks (do nothing else for secondary e-, e+, gammas)
101  G4ThreeVector Pos = aFastTrack.GetPrimaryTrack()->GetPosition();
102  if ( ! aFastTrack.GetPrimaryTrack()->GetParentID() ) {
105  if ( info->GetDoSmearing() ) {
106  // Smearing according to the electromagnetic calorimeter resolution
107  G4ThreeVector Porg = aFastTrack.GetPrimaryTrack()->GetMomentum();
112  G4double Esm;
113  Esm = std::abs( Par02Smearer::Instance()->
114  SmearEnergy( aFastTrack.GetPrimaryTrack(), res ) );
115  Par02Output::Instance()->FillHistogram( 1, (Esm/MeV) / (Edep/MeV) );
116  // Setting the values of Pos, Esm, res and eff
117  ( (Par02PrimaryParticleInformation*) ( const_cast< G4PrimaryParticle* >
118  ( aFastTrack.GetPrimaryTrack()->GetDynamicParticle()->GetPrimaryParticle() )->
119  GetUserInformation() ) )->SetEMCalPosition( Pos );
120  ( (Par02PrimaryParticleInformation*) ( const_cast< G4PrimaryParticle* >
121  ( aFastTrack.GetPrimaryTrack()->GetDynamicParticle()->GetPrimaryParticle() )->
122  GetUserInformation() ) )->SetEMCalEnergy( Esm );
123  ( (Par02PrimaryParticleInformation*) ( const_cast< G4PrimaryParticle* >
124  ( aFastTrack.GetPrimaryTrack()->GetDynamicParticle()->GetPrimaryParticle() )->
125  GetUserInformation() ) )->SetEMCalResolution( res );
126  ( (Par02PrimaryParticleInformation*) ( const_cast< G4PrimaryParticle* >
127  ( aFastTrack.GetPrimaryTrack()->GetDynamicParticle()->GetPrimaryParticle() )->
128  GetUserInformation() ) )->SetEMCalEfficiency( eff );
129  // The (smeared) energy of the particle is deposited in the step
130  // (which corresponds to the entrance of the electromagnetic calorimeter)
131  aFastStep.ProposeTotalEnergyDeposited( Esm );
132  } else {
133  // No smearing: simply setting the value of Edep
134  ( (Par02PrimaryParticleInformation*) ( const_cast< G4PrimaryParticle* >
135  ( aFastTrack.GetPrimaryTrack()->GetDynamicParticle()->GetPrimaryParticle() )->
136  GetUserInformation() ) )->SetEMCalEnergy( Edep );
137  // The (initial) energy of the particle is deposited in the step
138  // (which corresponds to the entrance of the electromagnetic calorimeter)
139  aFastStep.ProposeTotalEnergyDeposited( Edep );
140  }
141  }
142 }
143 
144 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
145 
G4int GetParentID() const
Definition of the Par02EventInformation class.
static const double MeV
Definition: G4SIunits.hh:211
const G4Track * GetPrimaryTrack() const
Definition: G4FastTrack.hh:208
Definition of detector resolution and efficiency.
static Par02Smearer * Instance()
Allows the access to the unique Par02Smearer class object.
Definition: Par02Smearer.cc:59
CLHEP::Hep3Vector G4ThreeVector
virtual G4bool IsApplicable(const G4ParticleDefinition &aParticle)
Checks if this model should be applied to this particle type.
const G4DynamicParticle * GetDynamicParticle() const
const G4ThreeVector & GetPosition() const
Par02DetectorParametrisation::Parametrisation fParametrisation
A parametrisation type.
static G4Electron * Definition()
Definition: G4Electron.cc:49
Parametrisation
A parametrisation type (CMS, ATLAS, ALEPH).
static G4Positron * Definition()
Definition: G4Positron.cc:49
Definition of the Par02FastSimModelEMCal class.
Definition of the Par02PrimaryParticleInformation class.
void FillHistogram(G4int HNo, G4double value) const
Fills the histogram.
Definition: Par02Output.cc:219
Definition of the Par02Smearer class.
G4double GetKineticEnergy() const
bool G4bool
Definition: G4Types.hh:79
void ProposePrimaryTrackPathLength(G4double)
Definition of the Par02Output class.
static Par02Output * Instance()
Allows the access to the unique Par02Output object.
Definition: Par02Output.cc:60
G4double GetResolution(Detector aDetector, Parametrisation aParametrisation, G4double aMomentum)
Gets the resolution of a detector for a given particle.
G4PrimaryParticle * GetPrimaryParticle() const
Par02DetectorParametrisation * fCalculateParametrisation
A pointer to Par02DetectorParametrisation used to get the efficiency and resolution of the detector f...
G4ThreeVector GetMomentum() const
virtual void DoIt(const G4FastTrack &aFastTrack, G4FastStep &aFastStep)
Smears the energy deposit and saves it, together with the position of the deposit, the electromagnetic calorimeter resolution and efficiency to the Par02PrimaryParticleInformation.
static G4EventManager * GetEventManager()
Par02FastSimModelEMCal(G4String aModelName, G4Region *aEnvelope, Par02DetectorParametrisation::Parametrisation aParamType)
A constructor.
void ProposeTotalEnergyDeposited(G4double anEnergyPart)
G4double GetEfficiency(Detector aDetector, Parametrisation aParametrisation, G4double aMomentum)
Gets the efficiency of a detector for a given particle.
void KillPrimaryTrack()
Definition: G4FastStep.cc:87
double G4double
Definition: G4Types.hh:76
G4bool GetDoSmearing()
Gets the flag indicating if smearing should be done.
virtual G4bool ModelTrigger(const G4FastTrack &aFastTrack)
Checks if the model should be applied, taking into account the kinematics of a track.
static G4Gamma * Definition()
Definition: G4Gamma.cc:49
G4VUserEventInformation * GetUserInformation()