Loading...
Searching...
No Matches
Par03EMShowerModel.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#include "Par03EMShowerModel.hh"
28
29#include "G4Electron.hh"
30#include "G4Positron.hh"
31#include "G4Gamma.hh"
32#include "G4SystemOfUnits.hh"
33#include "G4UnitsTable.hh"
34#include "G4FastHit.hh"
35#include "Randomize.hh"
36#include "G4FastSimHitMaker.hh"
37
39 : G4VFastSimulationModel(aModelName, aEnvelope)
40 , fMessenger(new Par03EMShowerMessenger(this))
41 , fHitMaker(new G4FastSimHitMaker)
42{}
43
44//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
45
47 : G4VFastSimulationModel(aModelName)
48 , fMessenger(new Par03EMShowerMessenger(this))
49 , fHitMaker(new G4FastSimHitMaker)
50{}
51
52//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
53
55
56//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
57
59 const G4ParticleDefinition& aParticleType)
60{
61 return &aParticleType == G4Electron::ElectronDefinition() ||
62 &aParticleType == G4Positron::PositronDefinition() ||
63 &aParticleType == G4Gamma::GammaDefinition();
64}
65
66//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
67
69{
70 // Check energy
71 if(aFastTrack.GetPrimaryTrack()->GetKineticEnergy() < 1 * GeV)
72 {
73 return false;
74 }
75 // Check length of detector
76 // Calculate depth of the detector along shower axis to verify if shower
77 // will fit inside. Required max shower depth is defined by fLongMaxDepth, and
78 // can be changed with UI command `/Par03/fastSim/longitudinalProfile/maxDepth
79 G4double X0 = aFastTrack.GetPrimaryTrack()->GetMaterial()->GetRadlen();
80 auto particleDirection = aFastTrack.GetPrimaryTrackLocalDirection();
81 auto particlePosition = aFastTrack.GetPrimaryTrackLocalPosition();
82 G4double detectorDepthInMM = aFastTrack.GetEnvelopeSolid()->DistanceToOut(
83 particlePosition, particleDirection);
84 G4double detectorDepthInX0 = detectorDepthInMM / X0;
85 // check if detector depth is sufficient to create showers
86 if(detectorDepthInX0 < fLongMaxDepth)
87 {
88 return false;
89 }
90 return true;
91}
92
93//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
94
96 G4FastStep& aFastStep)
97{
98 // Remove particle from further processing by G4
99 aFastStep.KillPrimaryTrack();
100 aFastStep.ProposePrimaryTrackPathLength(0.0);
101 G4double energy = aFastTrack.GetPrimaryTrack()->GetKineticEnergy();
102 // No need to create any deposit, it will be handled by this model (and
103 // G4FastSimHitMaker that will call the sensitive detector)
104 aFastStep.ProposeTotalEnergyDeposited(0);
105 auto particlePosition = aFastTrack.GetPrimaryTrackLocalPosition();
106 auto particleDirection = aFastTrack.GetPrimaryTrackLocalDirection();
107
108 // Calculate how to create energy deposits
109 // Following PDG 33.5 chapter
110 // material calculation assumes homogeneous detector (true for Par03 example)
111 auto material = aFastTrack.GetPrimaryTrack()->GetMaterial();
112 G4double materialX0 = material->GetRadlen();
113 G4double materialZ = material->GetZ();
114 // EC estimation follows PDG fit to solids in Fig. 33.14 (rms 2.2%)
115 G4double materialEc = 610 * MeV / (materialZ + 1.24);
116 // RM estimation follows PDG Eq. (33.37) (rms 2.2%)
117 G4double materialRM = 21.2052 * MeV * materialX0 / materialEc;
118 G4double particleY = energy / materialEc;
119 // Estimate shower maximum and alpha parameter of Gamma distribution
120 // that describes the longitudinal profile (PDG Eq. (33.35))
121 // unless alpha is specified by UI command
122 if(fAlpha < 0)
123 {
124 // from PDG Eq. (33.36)
125 G4double particleTmax = std::log(particleY);
126 if(aFastTrack.GetPrimaryTrack()->GetParticleDefinition() ==
127 G4Gamma::GammaDefinition())
128 {
129 particleTmax += 0.5;
130 }
131 else
132 {
133 particleTmax -= 0.5;
134 }
135 fAlpha = particleTmax * fBeta + 1;
136 }
137 // Unless sigma of Gaussian distribution describing the transverse profile
138 // is specified by UI command, use value calculated from Moliere Radius
139 if(fSigma < 0)
140 {
141 // 90% of shower is contained within 1 * R_M
142 // 1.645 * std dev of Gaussian contains 90%
143 fSigma = materialRM / 1.645;
144 }
145
146 // Calculate rotation matrix along the particle momentum direction
147 // It will rotate the shower axes to match the incoming particle direction
148 G4RotationMatrix rotMatrix = G4RotationMatrix();
149 double particleTheta = particleDirection.theta();
150 double particlePhi = particleDirection.phi();
151 double epsilon = 1e-3;
152 rotMatrix.rotateY(particleTheta);
153 // do not use (random) phi if x==y==0
154 if(!(std::fabs(particleDirection.x()) < epsilon &&
155 std::fabs(particleDirection.y()) < epsilon))
156 rotMatrix.rotateZ(particlePhi);
157
158 // Create hits
159 // First use rejecton sampling to sample from Gamma distribution
160 // then get random numbers from uniform distribution for azimuthal angle, and
161 // from Gaussian for radius
162 G4ThreeVector position;
163 G4double gammaMax = Gamma((fAlpha - 1) / fBeta, fAlpha, fBeta);
164 G4int generatedHits = 0;
165 while(generatedHits < fNbOfHits)
166 {
167 G4double random1 = G4UniformRand() * fLongMaxDepth;
168 G4double random2 = G4UniformRand() * gammaMax;
169 if(Gamma(random1, fAlpha, fBeta) >= random2)
170 {
171 // Generate corresponding rho (phi) from Gaussian (flat) distribution
172 G4double phiPosition = G4UniformRand() * 2 * CLHEP::pi;
173 G4double rhoPosition = G4RandGauss::shoot(0, fSigma);
174 position = particlePosition +
175 rotMatrix * G4ThreeVector(rhoPosition * std::sin(phiPosition),
176 rhoPosition * std::cos(phiPosition),
177 random1 * materialX0);
178 // Create energy deposit in the detector
179 // This will call appropriate sensitive detector class
180 fHitMaker->make(G4FastHit(position, energy / fNbOfHits), aFastTrack);
181 generatedHits++;
182 }
183 }
184}
185
186//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
187
189{
190 G4cout << "Par03EMShowerModel: " << G4endl;
191 G4cout << "Gaussian distribution (transverse plane): \tmu = 0, sigma = "
192 << G4BestUnit(fSigma, "Length") << G4endl;
193 if(fSigma < 0)
194 G4cout << "Negative sigma value means that it will be recalculated "
195 "from the value of the Moliere radius of the detector material, "
196 "taking into account that 90% of the area below the Gaussian "
197 "distribution (from mu - 1.645 sigma to mu + 1.645 sigma) "
198 "corresponds to area within 1 Moliere radius."
199 << G4endl;
200 G4cout << "Gamma distribution (along shower axis): \talpha = " << fAlpha
201 << ", beta = " << fBeta << ", max depth = " << fLongMaxDepth << " X0"
202 << G4endl;
203 if(fAlpha < 0)
204 G4cout << "Negative alpha value means that it will be recalculated "
205 "from the critical energy of the detector material, particle "
206 "type, and beta parameter.\n alpha = beta * T_max, where T_max = "
207 "ln(E/E_C) + C\n where E is particle energy, E_C is critical "
208 "energy in the material, and constant C = -0.5 for electrons and "
209 "0.5 for photons (Eq. (33.36) from PDG)."
210 << G4endl;
211 G4cout << "Number of created energy deposits: " << fNbOfHits << G4endl;
212}
Messenger for the example fast simulation model.
void Print() const
Print current settings.
G4double fLongMaxDepth
Maximum depth of a shower created in fast simulation.
G4int fNbOfHits
Number of (same energy) hits created by the parametrisation.
virtual G4bool ModelTrigger(const G4FastTrack &) final
There are no kinematics constraints. True is returned.
G4double fBeta
Beta parameter of the Gamma distribution Can be changed with UI command /Par03/fastSim/longitudinalPr...
G4double fAlpha
Alpha parameter of the Gamma distribution Can be changed with UI command /Par03/fastSim/longitudunalP...
std::unique_ptr< G4FastSimHitMaker > fHitMaker
Helper class for creation of hits within the sensitive detector.
G4double fSigma
Standard deviation of the Gaussian distribution Can be changed with UI command /Par03/fastSim/transve...
G4double Gamma(G4double x, G4double alpha, G4double beta)
Gamma distribution.
virtual G4bool IsApplicable(const G4ParticleDefinition &) final
Model is applicable to electrons, positrons, and photons.
virtual void DoIt(const G4FastTrack &, G4FastStep &) final
Take particle out of the full simulation (kill it at the entrance depositing all the energy).
Par03EMShowerModel(G4String, G4Region *)

Applications | User Support | Publications | Collaboration