ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Par02FastSimModelEMCal.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file Par02FastSimModelEMCal.cc
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 //
29 
31 #include "Par02EventInformation.hh"
33 #include "Par02Smearer.hh"
34 #include "Par02Output.hh"
35 
36 #include "G4Track.hh"
37 #include "G4Event.hh"
38 #include "G4RunManager.hh"
39 #include "g4root.hh"
40 
41 #include "Randomize.hh"
42 #include "G4SystemOfUnits.hh"
43 
44 #include "G4Electron.hh"
45 #include "G4Positron.hh"
46 #include "G4Gamma.hh"
47 
48 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
49 
52  G4VFastSimulationModel( aModelName, aEnvelope ), fCalculateParametrisation(),
53  fParametrisation( aType ) {}
54 
55 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
56 
58  G4Region* aEnvelope ) :
59  G4VFastSimulationModel( aModelName, aEnvelope ), fCalculateParametrisation(),
60  fParametrisation( Par02DetectorParametrisation::eCMS ) {}
61 
62 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
63 
65  G4VFastSimulationModel( aModelName ), fCalculateParametrisation(),
66  fParametrisation( Par02DetectorParametrisation::eCMS ) {}
67 
68 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
69 
71 
72 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
73 
75  const G4ParticleDefinition& aParticleType ) {
76  // Applicable for electrons, positrons, and gammas
77  return &aParticleType == G4Electron::Definition() ||
78  &aParticleType == G4Positron::Definition() ||
79  &aParticleType == G4Gamma::Definition();
80 }
81 
82 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
83 
85  return true; // No kinematical restrictions to apply the parametrisation
86 }
87 
88 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
89 
90 void Par02FastSimModelEMCal::DoIt( const G4FastTrack& aFastTrack,
91  G4FastStep& aFastStep ) {
92  //G4cout << " ________EMCal model triggered _________" << G4endl;
93 
94  // Kill the parameterised particle at the entrance of the electromagnetic calorimeter
95  aFastStep.KillPrimaryTrack();
96  aFastStep.ProposePrimaryTrackPathLength( 0.0 );
97  G4double Edep = aFastTrack.GetPrimaryTrack()->GetKineticEnergy();
98 
99  // Consider only primary tracks (do nothing else for secondary e-, e+, gammas)
100  G4ThreeVector Pos = aFastTrack.GetPrimaryTrack()->GetPosition();
101  if ( ! aFastTrack.GetPrimaryTrack()->GetParentID() ) {
104  if ( info->GetDoSmearing() ) {
105  // Smearing according to the electromagnetic calorimeter resolution
106  G4ThreeVector Porg = aFastTrack.GetPrimaryTrack()->GetMomentum();
111  G4double Esm;
113  SmearEnergy( aFastTrack.GetPrimaryTrack(), res ) );
114  Par02Output::Instance()->FillHistogram( 1, (Esm/MeV) / (Edep/MeV) );
115  // Setting the values of Pos, Esm, res and eff
116  ( (Par02PrimaryParticleInformation*) ( const_cast< G4PrimaryParticle* >
117  ( aFastTrack.GetPrimaryTrack()->GetDynamicParticle()->GetPrimaryParticle() )->
118  GetUserInformation() ) )->SetEMCalPosition( Pos );
119  ( (Par02PrimaryParticleInformation*) ( const_cast< G4PrimaryParticle* >
120  ( aFastTrack.GetPrimaryTrack()->GetDynamicParticle()->GetPrimaryParticle() )->
121  GetUserInformation() ) )->SetEMCalEnergy( Esm );
122  ( (Par02PrimaryParticleInformation*) ( const_cast< G4PrimaryParticle* >
123  ( aFastTrack.GetPrimaryTrack()->GetDynamicParticle()->GetPrimaryParticle() )->
124  GetUserInformation() ) )->SetEMCalResolution( res );
125  ( (Par02PrimaryParticleInformation*) ( const_cast< G4PrimaryParticle* >
126  ( aFastTrack.GetPrimaryTrack()->GetDynamicParticle()->GetPrimaryParticle() )->
127  GetUserInformation() ) )->SetEMCalEfficiency( eff );
128  // The (smeared) energy of the particle is deposited in the step
129  // (which corresponds to the entrance of the electromagnetic calorimeter)
130  aFastStep.ProposeTotalEnergyDeposited( Esm );
131  } else {
132  // No smearing: simply setting the value of Edep
133  ( (Par02PrimaryParticleInformation*) ( const_cast< G4PrimaryParticle* >
134  ( aFastTrack.GetPrimaryTrack()->GetDynamicParticle()->GetPrimaryParticle() )->
135  GetUserInformation() ) )->SetEMCalEnergy( Edep );
136  // The (initial) energy of the particle is deposited in the step
137  // (which corresponds to the entrance of the electromagnetic calorimeter)
138  aFastStep.ProposeTotalEnergyDeposited( Edep );
139  }
140  }
141 }
142 
143 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
144