File indexing completed on 2025-02-23 09:22:33
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030 #include "Par02FastSimModelEMCal.hh"
0031
0032 #include "Par02EventInformation.hh"
0033 #include "Par02Output.hh"
0034 #include "Par02PrimaryParticleInformation.hh"
0035 #include "Par02Smearer.hh"
0036
0037 #include "G4AnalysisManager.hh"
0038 #include "G4Electron.hh"
0039 #include "G4Event.hh"
0040 #include "G4Gamma.hh"
0041 #include "G4Positron.hh"
0042 #include "G4RunManager.hh"
0043 #include "G4SystemOfUnits.hh"
0044 #include "G4Track.hh"
0045 #include "Randomize.hh"
0046
0047
0048
0049 Par02FastSimModelEMCal::Par02FastSimModelEMCal(G4String aModelName, G4Region* aEnvelope,
0050 Par02DetectorParametrisation::Parametrisation aType)
0051 : G4VFastSimulationModel(aModelName, aEnvelope),
0052 fCalculateParametrisation(),
0053 fParametrisation(aType)
0054 {}
0055
0056
0057
0058 Par02FastSimModelEMCal::Par02FastSimModelEMCal(G4String aModelName, G4Region* aEnvelope)
0059 : G4VFastSimulationModel(aModelName, aEnvelope),
0060 fCalculateParametrisation(),
0061 fParametrisation(Par02DetectorParametrisation::eCMS)
0062 {}
0063
0064
0065
0066 Par02FastSimModelEMCal::Par02FastSimModelEMCal(G4String aModelName)
0067 : G4VFastSimulationModel(aModelName),
0068 fCalculateParametrisation(),
0069 fParametrisation(Par02DetectorParametrisation::eCMS)
0070 {}
0071
0072
0073
0074 Par02FastSimModelEMCal::~Par02FastSimModelEMCal() = default;
0075
0076
0077
0078 G4bool Par02FastSimModelEMCal::IsApplicable(const G4ParticleDefinition& aParticleType)
0079 {
0080
0081 return &aParticleType == G4Electron::Definition() || &aParticleType == G4Positron::Definition()
0082 || &aParticleType == G4Gamma::Definition();
0083 }
0084
0085
0086
0087 G4bool Par02FastSimModelEMCal::ModelTrigger(const G4FastTrack& )
0088 {
0089 return true;
0090 }
0091
0092
0093
0094 void Par02FastSimModelEMCal::DoIt(const G4FastTrack& aFastTrack, G4FastStep& aFastStep)
0095 {
0096
0097
0098
0099 aFastStep.KillPrimaryTrack();
0100 aFastStep.ProposePrimaryTrackPathLength(0.0);
0101 G4double Edep = aFastTrack.GetPrimaryTrack()->GetKineticEnergy();
0102
0103
0104 G4ThreeVector Pos = aFastTrack.GetPrimaryTrack()->GetPosition();
0105 if (!aFastTrack.GetPrimaryTrack()->GetParentID()) {
0106 auto info = (Par02EventInformation*)G4EventManager::GetEventManager()->GetUserInformation();
0107 if (info->GetDoSmearing()) {
0108
0109 G4ThreeVector Porg = aFastTrack.GetPrimaryTrack()->GetMomentum();
0110 G4double res = fCalculateParametrisation->GetResolution(Par02DetectorParametrisation::eEMCAL,
0111 fParametrisation, Porg.mag());
0112 G4double eff = fCalculateParametrisation->GetEfficiency(Par02DetectorParametrisation::eEMCAL,
0113 fParametrisation, Porg.mag());
0114 G4double Esm;
0115 Esm = std::abs(Par02Smearer::Instance()->SmearEnergy(aFastTrack.GetPrimaryTrack(), res));
0116 Par02Output::Instance()->FillHistogram(1, (Esm / MeV) / (Edep / MeV));
0117
0118 ((Par02PrimaryParticleInformation*)(const_cast<G4PrimaryParticle*>(
0119 aFastTrack.GetPrimaryTrack()
0120 ->GetDynamicParticle()
0121 ->GetPrimaryParticle())
0122 ->GetUserInformation()))
0123 ->SetEMCalPosition(Pos);
0124 ((Par02PrimaryParticleInformation*)(const_cast<G4PrimaryParticle*>(
0125 aFastTrack.GetPrimaryTrack()
0126 ->GetDynamicParticle()
0127 ->GetPrimaryParticle())
0128 ->GetUserInformation()))
0129 ->SetEMCalEnergy(Esm);
0130 ((Par02PrimaryParticleInformation*)(const_cast<G4PrimaryParticle*>(
0131 aFastTrack.GetPrimaryTrack()
0132 ->GetDynamicParticle()
0133 ->GetPrimaryParticle())
0134 ->GetUserInformation()))
0135 ->SetEMCalResolution(res);
0136 ((Par02PrimaryParticleInformation*)(const_cast<G4PrimaryParticle*>(
0137 aFastTrack.GetPrimaryTrack()
0138 ->GetDynamicParticle()
0139 ->GetPrimaryParticle())
0140 ->GetUserInformation()))
0141 ->SetEMCalEfficiency(eff);
0142
0143
0144 aFastStep.ProposeTotalEnergyDeposited(Esm);
0145 }
0146 else {
0147
0148 ((Par02PrimaryParticleInformation*)(const_cast<G4PrimaryParticle*>(
0149 aFastTrack.GetPrimaryTrack()
0150 ->GetDynamicParticle()
0151 ->GetPrimaryParticle())
0152 ->GetUserInformation()))
0153 ->SetEMCalEnergy(Edep);
0154
0155
0156 aFastStep.ProposeTotalEnergyDeposited(Edep);
0157 }
0158 }
0159 }
0160
0161