ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Par01PionShowerModel.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file Par01PionShowerModel.cc
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 //
31 #include "Par01PionShowerModel.hh"
32 #include "Par01EnergySpot.hh"
33 
34 #include "Randomize.hh"
35 
36 #include "G4PionMinus.hh"
37 #include "G4PionPlus.hh"
39 #include "G4VSensitiveDetector.hh"
40 #include "G4TouchableHistory.hh"
41 
42 #include "G4Colour.hh"
43 #include "G4PhysicalConstants.hh"
44 #include "G4SystemOfUnits.hh"
45 
46 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
47 
49 : G4VFastSimulationModel(modelName, envelope)
50 {
51  fFakeStep = new G4Step();
55  fpNavigator = new G4Navigator();
56  fNaviSetup = false;
57 }
58 
59 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
60 
62 : G4VFastSimulationModel(modelName)
63 {
64  fFakeStep = new G4Step();
68  fpNavigator = new G4Navigator();
69  fNaviSetup = false;
70 }
71 
72 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
73 
75 {
76  delete fFakeStep;
77  delete fpNavigator;
78 }
79 
80 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
81 
83 {
84  return
85  &particleType == G4PionMinus::PionMinusDefinition() ||
86  &particleType == G4PionPlus::PionPlusDefinition();
87 }
88 
89 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
90 
92 {
93  // Applies the parameterisation always:
94  // ie as soon as the pion enters the envelope
95  return true;
96 }
97 
98 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
99 
101  G4FastStep& fastStep)
102 {
103  // G4cout << "Par01PionShowerModel::DoIt" << G4endl;
104 
105  // Kill the parameterised particle:
106  fastStep.KillPrimaryTrack();
107  fastStep.ProposePrimaryTrackPathLength(0.0);
109 
110  // split into "energy spots" energy according to the shower shape:
111  Explode(fastTrack);
112 
113  // and put those energy spots into the crystals:
115 }
116 
117 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
118 
120 {
121  //-----------------------------------------------------
122  // Non-physical shower generated: exp along z and
123  // transverse.
124  //-----------------------------------------------------
125 
126  // center of the shower, we put at the middle of the ghost:
127  G4ThreeVector showerCenter;
128  G4double distOut;
129  distOut = fastTrack.GetEnvelopeSolid()->
130  DistanceToOut(fastTrack.GetPrimaryTrackLocalPosition(),
131  fastTrack.GetPrimaryTrackLocalDirection());
132  showerCenter = fastTrack.GetPrimaryTrackLocalPosition() +
133  (distOut/2.)*fastTrack.GetPrimaryTrackLocalDirection();
134 
135  showerCenter = fastTrack.GetInverseAffineTransformation()->
136  TransformPoint(showerCenter);
137 
138  // axis of the shower, in global reference frame:
139  G4ThreeVector xShower, yShower, zShower;
140  zShower = fastTrack.GetPrimaryTrack()->GetMomentumDirection();
141  xShower = zShower.orthogonal();
142  yShower = zShower.cross(xShower);
143 
144  // shoot the energy spots:
145  G4double Energy = fastTrack.GetPrimaryTrack()->GetKineticEnergy();
146  G4int nSpot = 50;
147  G4double deposit = Energy/double(nSpot);
148  Par01EnergySpot eSpot;
149  eSpot.SetEnergy(deposit);
150  G4ThreeVector ePoint;
151 
152  // clear the spot list before use
153  feSpotList.clear();
154 
155  G4double z, r, phi;
156  for (int i = 0; i < nSpot; i++)
157  {
158  z = G4RandGauss::shoot(0,20*cm);
159  r = G4RandGauss::shoot(0,10*cm);
160  phi = G4UniformRand()*twopi;
161  ePoint = showerCenter +
162  z*zShower +
163  r*std::cos(phi)*xShower + r*std::sin(phi)*yShower;
164  eSpot.SetPosition(ePoint);
165  feSpotList.push_back(eSpot);
166  }
167 }
168 
169 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
170 
172 {
173  // Does the assignation of the energy spots to the sensitive volumes:
174  for (size_t i = 0; i < feSpotList.size(); i++)
175  {
176  // Draw the energy spot:
177  // G4Colour red(1.,0.,0.);
178  // feSpotList[i].Draw(&red);
179  // feSpotList[i].Print();
180 
181  // "converts" the energy spot into the fake
182  // G4Step to pass to sensitive detector:
184  }
185 }
186 
187 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
188 
190 {
191  //
192  // "converts" the energy spot into the fake
193  // G4Step to pass to sensitive detector:
194  //
195  FillFakeStep(eSpot);
196 
197  //
198  // call sensitive part: taken/adapted from the stepping:
199  // Send G4Step information to Hit/Dig if the volume is sensitive
200  //
201  G4VPhysicalVolume* pCurrentVolume =
203  G4VSensitiveDetector* pSensitive;
204 
205  if( pCurrentVolume != 0 )
206  {
207  pSensitive = pCurrentVolume->GetLogicalVolume()->
208  GetSensitiveDetector();
209  if( pSensitive != 0 )
210  {
211  pSensitive->Hit(fFakeStep);
212  }
213  }
214 }
215 
216 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
217 
219 {
220  //-----------------------------------------------------------
221  // find in which volume the spot is.
222  //-----------------------------------------------------------
223  if (!fNaviSetup)
224  {
225  fpNavigator->
227  GetNavigatorForTracking()->GetWorldVolume());
228  fpNavigator->
229  LocateGlobalPointAndUpdateTouchableHandle(eSpot.GetPosition(),
230  G4ThreeVector(0.,0.,0.),
232  false);
233  fNaviSetup = true;
234  }
235  else
236  {
237  fpNavigator->
238  LocateGlobalPointAndUpdateTouchableHandle(eSpot.GetPosition(),
239  G4ThreeVector(0.,0.,0.),
241  }
242  //--------------------------------------
243  // Fills attribute of the G4Step needed
244  // by our sensitive detector:
245  //-------------------------------------
246  // set touchable volume at PreStepPoint:
248  // set total energy deposit:
250 }