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