Geant4  10.03
Par01EMShowerModel.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 //
28 //
29 //
30 // $Id: Par01EMShowerModel.cc 101151 2016-11-08 08:06:16Z gcosmo $
31 //
32 #include "Par01EMShowerModel.hh"
33 #include "Par01EnergySpot.hh"
34 
35 #include "Randomize.hh"
36 
37 #include "G4Electron.hh"
38 #include "G4Positron.hh"
39 #include "G4Gamma.hh"
41 #include "G4VSensitiveDetector.hh"
42 #include "G4TouchableHandle.hh"
43 #include "G4PhysicalConstants.hh"
44 #include "G4SystemOfUnits.hh"
45 #include "G4NistManager.hh"
46 
47 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
48 
50 : G4VFastSimulationModel(modelName, envelope)
51 {
52  fFakeStep = new G4Step();
56  fpNavigator = new G4Navigator();
57  fNaviSetup = false;
58  fCsI = 0;
59 }
60 
61 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
62 
64 : G4VFastSimulationModel(modelName)
65 {
66  fFakeStep = new G4Step();
70  fpNavigator = new G4Navigator();
71  fNaviSetup = false;
72  fCsI = 0;
73 }
74 
75 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
76 
78 {
79  delete fFakeStep;
80  delete fpNavigator;
81 }
82 
83 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
84 
86 {
87  return
88  &particleType == G4Electron::ElectronDefinition() ||
89  &particleType == G4Positron::PositronDefinition() ||
90  &particleType == G4Gamma::GammaDefinition();
91 }
92 
93 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
94 
96 {
97  // Applies the parameterisation above 100 MeV:
98  return fastTrack.GetPrimaryTrack()->GetKineticEnergy() > 100*MeV;
99 }
100 
101 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
102 
103 void Par01EMShowerModel::DoIt(const G4FastTrack& fastTrack,
104  G4FastStep& fastStep)
105 {
106  // Kill the parameterised particle:
107  fastStep.KillPrimaryTrack();
108  fastStep.ProposePrimaryTrackPathLength(0.0);
110 
111  // split into "energy spots" energy according to the shower shape:
112  Explode(fastTrack);
113 
114  // and put those energy spots into the crystals:
116 
117 }
118 
119 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
120 
122 {
123  //-----------------------------------------------------
124  //
125  //-----------------------------------------------------
126 
127  // Reduced quantities:
128  // -- critical energy in CsI:
129  G4double Ec = 800*MeV/(54. + 1.2); // 54 = mean Z of CsI
130  G4double Energy = fastTrack.GetPrimaryTrack()->GetKineticEnergy();
131  G4double y = Energy/Ec;
132 
133  // compute value of parameter "a" of longitudinal profile, b assumed = 0.5
134  G4double a, tmax, b(0.5), C;
135  if (fastTrack.GetPrimaryTrack()->GetDefinition() == G4Gamma::GammaDefinition()) C = 0.5;
136  else C = -0.5;
137  tmax = 1.0 * (std::log(y) + C);
138  a = 1.0 + b*tmax;
139 
140  // t : reduced quantity = z/X0:
141  G4double t, bt;
142  if ( fCsI == 0 ) fCsI = G4NistManager::Instance()->FindOrBuildMaterial("G4_CESIUM_IODIDE");
143  G4double X0 = fCsI->GetRadlen();
144  // Moliere radius:
145  G4double Es = 21*MeV;
146  G4double Rm = X0*Es/Ec;
147 
148  // axis of the shower, in global reference frame:
149  G4ThreeVector xShower, yShower, zShower;
150  zShower = fastTrack.GetPrimaryTrack()->GetMomentumDirection();
151  xShower = zShower.orthogonal();
152  yShower = zShower.cross(xShower);
153  // starting point of the shower:
154  G4ThreeVector sShower = fastTrack.GetPrimaryTrack()->GetPosition();
155 
156  // We shoot 100 spots of energy:
157  G4int nSpots = 100;
158  G4double deposit = Energy/double(nSpots);
159  Par01EnergySpot eSpot;
160  eSpot.SetEnergy(deposit);
161  G4ThreeVector ePoint;
162  G4double z, r, phi;
163 
164  feSpotList.clear();
165  for (int i = 0; i < nSpots; i++)
166  {
167  // Longitudinal profile:
168  // -- shoot z according to Gamma distribution:
169  bt = G4RandGamma::shoot(a,1.0);
170  t = bt/b;
171  z = t*X0;
172 
173  // transverse profile:
174  // we set 90% of energy in one Rm,
175  // the rest between 1 and 3.5 Rm:
176  G4double xr = G4UniformRand();
177  if (xr < 0.9) r = xr/0.9*Rm;
178  else r = ((xr - 0.9)/0.1*2.5 + 1.0)*Rm;
179  phi = G4UniformRand()*twopi;
180 
181  // build the position:
182  ePoint = sShower +
183  z*zShower +
184  r*std::cos(phi)*xShower + r*std::sin(phi)*yShower;
185 
186  // and the energy spot:
187  eSpot.SetPosition(ePoint);
188 
189  // Records the eSpot:
190  feSpotList.push_back(eSpot);
191  }
192 }
193 
194 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
195 
197 {
198  // Does the assignation of the energy spots to the sensitive volumes:
199  for (size_t i = 0; i < feSpotList.size(); i++)
200  {
201  // Draw the energy spot:
202  // feSpotList[i].Draw();
203  // feSpotList[i].Print();
204 
205  // "converts" the energy spot into the fake
206  // G4Step to pass to sensitive detector:
208  }
209 }
210 
211 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
212 
214 {
215  //
216  // "converts" the energy spot into the fake
217  // G4Step to pass to sensitive detector:
218  //
219  FillFakeStep(eSpot);
220 
221  //
222  // call sensitive part: taken/adapted from the stepping:
223  // Send G4Step information to Hit/Dig if the volume is sensitive
224  //
225  G4VPhysicalVolume* pCurrentVolume =
227  G4VSensitiveDetector* pSensitive;
228 
229  if( pCurrentVolume != 0 )
230  {
231  pSensitive = pCurrentVolume->GetLogicalVolume()->
232  GetSensitiveDetector();
233  if( pSensitive != 0 )
234  {
235  pSensitive->Hit(fFakeStep);
236  }
237  }
238 }
239 
240 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
241 
243 {
244  //-----------------------------------------------------------
245  // find in which volume the spot is.
246  //-----------------------------------------------------------
247  if (!fNaviSetup)
248  {
249  fpNavigator->
251  GetNavigatorForTracking()->GetWorldVolume());
252  fpNavigator->
253  LocateGlobalPointAndUpdateTouchableHandle(eSpot.GetPosition(),
254  G4ThreeVector(0.,0.,0.),
256  false);
257  fNaviSetup = true;
258  }
259  else
260  {
261  fpNavigator->
262  LocateGlobalPointAndUpdateTouchableHandle(eSpot.GetPosition(),
263  G4ThreeVector(0.,0.,0.),
265  }
266  //--------------------------------------
267  // Fills attribute of the G4Step needed
268  // by our sensitive detector:
269  //-------------------------------------
270  // set touchable volume at PreStepPoint:
272  // set total energy deposit:
274 }
void SetPosition(const G4ThreeVector &point)
G4ParticleDefinition * GetDefinition() const
static G4Electron * ElectronDefinition()
Definition: G4Electron.cc:89
virtual G4bool IsApplicable(const G4ParticleDefinition &)
ThreeVector shoot(const G4int Ap, const G4int Af)
G4double GetEnergy() const
G4Material * FindOrBuildMaterial(const G4String &name, G4bool isotopes=true, G4bool warning=false)
const G4Track * GetPrimaryTrack() const
Definition: G4FastTrack.hh:208
void Explode(const G4FastTrack &)
CLHEP::Hep3Vector G4ThreeVector
Definition of the Par01EMShowerModel class.
void FillFakeStep(const Par01EnergySpot &eSpot)
std::vector< ExP01TrackerHit * > a
Definition: ExP01Classes.hh:33
const G4ThreeVector & GetPosition() const
virtual G4bool ModelTrigger(const G4FastTrack &)
double C(double temp)
void AssignSpotAndCallHit(const Par01EnergySpot &eSpot)
int G4int
Definition: G4Types.hh:78
static G4NistManager * Instance()
Par01EMShowerModel(G4String, G4Region *)
static constexpr double twopi
Definition: G4SIunits.hh:76
G4StepPoint * GetPreStepPoint() const
G4double GetKineticEnergy() const
#define G4UniformRand()
Definition: Randomize.hh:97
G4VPhysicalVolume * GetPhysicalVolume() const
bool G4bool
Definition: G4Types.hh:79
void ProposePrimaryTrackPathLength(G4double)
G4StepPoint * fFakePostStepPoint
G4bool Hit(G4Step *aStep)
Definition: G4Step.hh:76
G4double GetRadlen() const
Definition: G4Material.hh:220
G4ThreeVector GetPosition() const
G4Navigator * fpNavigator
static G4TransportationManager * GetTransportationManager()
static G4Positron * PositronDefinition()
Definition: G4Positron.cc:89
const G4ThreeVector & GetMomentumDirection() const
G4LogicalVolume * GetLogicalVolume() const
G4StepPoint * GetPostStepPoint() const
void SetEnergy(const G4double &E)
Definition of the Par01EnergySpot class.
void ProposeTotalEnergyDeposited(G4double anEnergyPart)
static constexpr double MeV
Definition: G4SIunits.hh:214
void SetTotalEnergyDeposit(G4double value)
void KillPrimaryTrack()
Definition: G4FastStep.cc:88
double G4double
Definition: G4Types.hh:76
void SetTouchableHandle(const G4TouchableHandle &apValue)
virtual void DoIt(const G4FastTrack &, G4FastStep &)
G4TouchableHandle fTouchableHandle
std::vector< Par01EnergySpot > feSpotList
G4StepPoint * fFakePreStepPoint
static G4Gamma * GammaDefinition()
Definition: G4Gamma.cc:81