Geant4 Cross Reference |
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 // 27 /// \file Par02FastSimModelEMCal.cc 28 /// \brief Implementation of the Par02FastSimModelEMCal class 29 30 #include "Par02FastSimModelEMCal.hh" 31 32 #include "Par02EventInformation.hh" 33 #include "Par02Output.hh" 34 #include "Par02PrimaryParticleInformation.hh" 35 #include "Par02Smearer.hh" 36 37 #include "G4AnalysisManager.hh" 38 #include "G4Electron.hh" 39 #include "G4Event.hh" 40 #include "G4Gamma.hh" 41 #include "G4Positron.hh" 42 #include "G4RunManager.hh" 43 #include "G4SystemOfUnits.hh" 44 #include "G4Track.hh" 45 #include "Randomize.hh" 46 47 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 48 49 Par02FastSimModelEMCal::Par02FastSimModelEMCal(G4String aModelName, G4Region* aEnvelope, 50 Par02DetectorParametrisation::Parametrisation aType) 51 : G4VFastSimulationModel(aModelName, aEnvelope), 52 fCalculateParametrisation(), 53 fParametrisation(aType) 54 {} 55 56 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 57 58 Par02FastSimModelEMCal::Par02FastSimModelEMCal(G4String aModelName, G4Region* aEnvelope) 59 : G4VFastSimulationModel(aModelName, aEnvelope), 60 fCalculateParametrisation(), 61 fParametrisation(Par02DetectorParametrisation::eCMS) 62 {} 63 64 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 65 66 Par02FastSimModelEMCal::Par02FastSimModelEMCal(G4String aModelName) 67 : G4VFastSimulationModel(aModelName), 68 fCalculateParametrisation(), 69 fParametrisation(Par02DetectorParametrisation::eCMS) 70 {} 71 72 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 73 74 Par02FastSimModelEMCal::~Par02FastSimModelEMCal() = default; 75 76 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 77 78 G4bool Par02FastSimModelEMCal::IsApplicable(const G4ParticleDefinition& aParticleType) 79 { 80 // Applicable for electrons, positrons, and gammas 81 return &aParticleType == G4Electron::Definition() || &aParticleType == G4Positron::Definition() 82 || &aParticleType == G4Gamma::Definition(); 83 } 84 85 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 86 87 G4bool Par02FastSimModelEMCal::ModelTrigger(const G4FastTrack& /*aFastTrack*/) 88 { 89 return true; // No kinematical restrictions to apply the parametrisation 90 } 91 92 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 93 94 void Par02FastSimModelEMCal::DoIt(const G4FastTrack& aFastTrack, G4FastStep& aFastStep) 95 { 96 // G4cout << " ________EMCal model triggered _________" << G4endl; 97 98 // Kill the parameterised particle at the entrance of the electromagnetic calorimeter 99 aFastStep.KillPrimaryTrack(); 100 aFastStep.ProposePrimaryTrackPathLength(0.0); 101 G4double Edep = aFastTrack.GetPrimaryTrack()->GetKineticEnergy(); 102 103 // Consider only primary tracks (do nothing else for secondary e-, e+, gammas) 104 G4ThreeVector Pos = aFastTrack.GetPrimaryTrack()->GetPosition(); 105 if (!aFastTrack.GetPrimaryTrack()->GetParentID()) { 106 auto info = (Par02EventInformation*)G4EventManager::GetEventManager()->GetUserInformation(); 107 if (info->GetDoSmearing()) { 108 // Smearing according to the electromagnetic calorimeter resolution 109 G4ThreeVector Porg = aFastTrack.GetPrimaryTrack()->GetMomentum(); 110 G4double res = fCalculateParametrisation->GetResolution(Par02DetectorParametrisation::eEMCAL, 111 fParametrisation, Porg.mag()); 112 G4double eff = fCalculateParametrisation->GetEfficiency(Par02DetectorParametrisation::eEMCAL, 113 fParametrisation, Porg.mag()); 114 G4double Esm; 115 Esm = std::abs(Par02Smearer::Instance()->SmearEnergy(aFastTrack.GetPrimaryTrack(), res)); 116 Par02Output::Instance()->FillHistogram(1, (Esm / MeV) / (Edep / MeV)); 117 // Setting the values of Pos, Esm, res and eff 118 ((Par02PrimaryParticleInformation*)(const_cast<G4PrimaryParticle*>( 119 aFastTrack.GetPrimaryTrack() 120 ->GetDynamicParticle() 121 ->GetPrimaryParticle()) 122 ->GetUserInformation())) 123 ->SetEMCalPosition(Pos); 124 ((Par02PrimaryParticleInformation*)(const_cast<G4PrimaryParticle*>( 125 aFastTrack.GetPrimaryTrack() 126 ->GetDynamicParticle() 127 ->GetPrimaryParticle()) 128 ->GetUserInformation())) 129 ->SetEMCalEnergy(Esm); 130 ((Par02PrimaryParticleInformation*)(const_cast<G4PrimaryParticle*>( 131 aFastTrack.GetPrimaryTrack() 132 ->GetDynamicParticle() 133 ->GetPrimaryParticle()) 134 ->GetUserInformation())) 135 ->SetEMCalResolution(res); 136 ((Par02PrimaryParticleInformation*)(const_cast<G4PrimaryParticle*>( 137 aFastTrack.GetPrimaryTrack() 138 ->GetDynamicParticle() 139 ->GetPrimaryParticle()) 140 ->GetUserInformation())) 141 ->SetEMCalEfficiency(eff); 142 // The (smeared) energy of the particle is deposited in the step 143 // (which corresponds to the entrance of the electromagnetic calorimeter) 144 aFastStep.ProposeTotalEnergyDeposited(Esm); 145 } 146 else { 147 // No smearing: simply setting the value of Edep 148 ((Par02PrimaryParticleInformation*)(const_cast<G4PrimaryParticle*>( 149 aFastTrack.GetPrimaryTrack() 150 ->GetDynamicParticle() 151 ->GetPrimaryParticle()) 152 ->GetUserInformation())) 153 ->SetEMCalEnergy(Edep); 154 // The (initial) energy of the particle is deposited in the step 155 // (which corresponds to the entrance of the electromagnetic calorimeter) 156 aFastStep.ProposeTotalEnergyDeposited(Edep); 157 } 158 } 159 } 160 161 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 162