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