Geant4  10.03.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Par01PionShowerModel.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: Par01PionShowerModel.cc 101151 2016-11-08 08:06:16Z gcosmo $
31 //
32 #include "Par01PionShowerModel.hh"
33 #include "Par01EnergySpot.hh"
34 
35 #include "Randomize.hh"
36 
37 #include "G4PionMinus.hh"
38 #include "G4PionPlus.hh"
40 #include "G4VSensitiveDetector.hh"
41 #include "G4TouchableHistory.hh"
42 
43 #include "G4Colour.hh"
44 #include "G4PhysicalConstants.hh"
45 #include "G4SystemOfUnits.hh"
46 
47 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
48 
50 : G4VFastSimulationModel(modelName, envelope)
51 {
52  fFakeStep = new G4Step();
53  fFakePreStepPoint = fFakeStep->GetPreStepPoint();
54  fFakePostStepPoint = fFakeStep->GetPostStepPoint();
55  fTouchableHandle = new G4TouchableHistory();
56  fpNavigator = new G4Navigator();
57  fNaviSetup = false;
58 }
59 
60 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
61 
63 : G4VFastSimulationModel(modelName)
64 {
65  fFakeStep = new G4Step();
66  fFakePreStepPoint = fFakeStep->GetPreStepPoint();
67  fFakePostStepPoint = fFakeStep->GetPostStepPoint();
68  fTouchableHandle = new G4TouchableHistory();
69  fpNavigator = new G4Navigator();
70  fNaviSetup = false;
71 }
72 
73 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
74 
76 {
77  delete fFakeStep;
78  delete fpNavigator;
79 }
80 
81 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
82 
84 {
85  return
86  &particleType == G4PionMinus::PionMinusDefinition() ||
87  &particleType == G4PionPlus::PionPlusDefinition();
88 }
89 
90 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
91 
93 {
94  // Applies the parameterisation always:
95  // ie as soon as the pion enters the envelope
96  return true;
97 }
98 
99 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
100 
102  G4FastStep& fastStep)
103 {
104  // G4cout << "Par01PionShowerModel::DoIt" << G4endl;
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:
115  BuildDetectorResponse();
116 }
117 
118 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
119 
120 void Par01PionShowerModel::Explode(const G4FastTrack& fastTrack)
121 {
122  //-----------------------------------------------------
123  // Non-physical shower generated: exp along z and
124  // transverse.
125  //-----------------------------------------------------
126 
127  // center of the shower, we put at the middle of the ghost:
128  G4ThreeVector showerCenter;
129  G4double distOut;
130  distOut = fastTrack.GetEnvelopeSolid()->
131  DistanceToOut(fastTrack.GetPrimaryTrackLocalPosition(),
132  fastTrack.GetPrimaryTrackLocalDirection());
133  showerCenter = fastTrack.GetPrimaryTrackLocalPosition() +
134  (distOut/2.)*fastTrack.GetPrimaryTrackLocalDirection();
135 
136  showerCenter = fastTrack.GetInverseAffineTransformation()->
137  TransformPoint(showerCenter);
138 
139  // axis of the shower, in global reference frame:
140  G4ThreeVector xShower, yShower, zShower;
141  zShower = fastTrack.GetPrimaryTrack()->GetMomentumDirection();
142  xShower = zShower.orthogonal();
143  yShower = zShower.cross(xShower);
144 
145  // shoot the energy spots:
146  G4double Energy = fastTrack.GetPrimaryTrack()->GetKineticEnergy();
147  G4int nSpot = 50;
148  G4double deposit = Energy/double(nSpot);
149  Par01EnergySpot eSpot;
150  eSpot.SetEnergy(deposit);
151  G4ThreeVector ePoint;
152 
153  // clear the spot list before use
154  feSpotList.clear();
155 
156  G4double z, r, phi;
157  for (int i = 0; i < nSpot; i++)
158  {
159  z = G4RandGauss::shoot(0,20*cm);
160  r = G4RandGauss::shoot(0,10*cm);
161  phi = G4UniformRand()*twopi;
162  ePoint = showerCenter +
163  z*zShower +
164  r*std::cos(phi)*xShower + r*std::sin(phi)*yShower;
165  eSpot.SetPosition(ePoint);
166  feSpotList.push_back(eSpot);
167  }
168 }
169 
170 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
171 
172 void Par01PionShowerModel::BuildDetectorResponse()
173 {
174  // Does the assignation of the energy spots to the sensitive volumes:
175  for (size_t i = 0; i < feSpotList.size(); i++)
176  {
177  // Draw the energy spot:
178  // G4Colour red(1.,0.,0.);
179  // feSpotList[i].Draw(&red);
180  // feSpotList[i].Print();
181 
182  // "converts" the energy spot into the fake
183  // G4Step to pass to sensitive detector:
184  AssignSpotAndCallHit(feSpotList[i]);
185  }
186 }
187 
188 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
189 
190 void Par01PionShowerModel::AssignSpotAndCallHit(const Par01EnergySpot &eSpot)
191 {
192  //
193  // "converts" the energy spot into the fake
194  // G4Step to pass to sensitive detector:
195  //
196  FillFakeStep(eSpot);
197 
198  //
199  // call sensitive part: taken/adapted from the stepping:
200  // Send G4Step information to Hit/Dig if the volume is sensitive
201  //
202  G4VPhysicalVolume* pCurrentVolume =
203  fFakeStep->GetPreStepPoint()->GetPhysicalVolume();
204  G4VSensitiveDetector* pSensitive;
205 
206  if( pCurrentVolume != 0 )
207  {
208  pSensitive = pCurrentVolume->GetLogicalVolume()->
209  GetSensitiveDetector();
210  if( pSensitive != 0 )
211  {
212  pSensitive->Hit(fFakeStep);
213  }
214  }
215 }
216 
217 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
218 
219 void Par01PionShowerModel::FillFakeStep(const Par01EnergySpot &eSpot)
220 {
221  //-----------------------------------------------------------
222  // find in which volume the spot is.
223  //-----------------------------------------------------------
224  if (!fNaviSetup)
225  {
226  fpNavigator->
228  GetNavigatorForTracking()->GetWorldVolume());
229  fpNavigator->
230  LocateGlobalPointAndUpdateTouchableHandle(eSpot.GetPosition(),
231  G4ThreeVector(0.,0.,0.),
232  fTouchableHandle,
233  false);
234  fNaviSetup = true;
235  }
236  else
237  {
238  fpNavigator->
239  LocateGlobalPointAndUpdateTouchableHandle(eSpot.GetPosition(),
240  G4ThreeVector(0.,0.,0.),
241  fTouchableHandle);
242  }
243  //--------------------------------------
244  // Fills attribute of the G4Step needed
245  // by our sensitive detector:
246  //-------------------------------------
247  // set touchable volume at PreStepPoint:
248  fFakePreStepPoint->SetTouchableHandle(fTouchableHandle);
249  // set total energy deposit:
250  fFakeStep->SetTotalEnergyDeposit(eSpot.GetEnergy());
251 }
void SetPosition(const G4ThreeVector &point)
G4ThreeVector GetPrimaryTrackLocalPosition() const
Definition: G4FastTrack.hh:213
ThreeVector shoot(const G4int Ap, const G4int Af)
G4double GetEnergy() const
const G4Track * GetPrimaryTrack() const
Definition: G4FastTrack.hh:208
G4ThreeVector GetPrimaryTrackLocalDirection() const
Definition: G4FastTrack.hh:223
CLHEP::Hep3Vector G4ThreeVector
Definition of the Par01PionShowerModel class.
const G4AffineTransform * GetInverseAffineTransformation() const
Definition: G4FastTrack.hh:238
Par01PionShowerModel(G4String, G4Region *)
int G4int
Definition: G4Types.hh:78
static constexpr double twopi
Definition: G4SIunits.hh:76
G4StepPoint * GetPreStepPoint() const
virtual void DoIt(const G4FastTrack &, G4FastStep &)
G4double GetKineticEnergy() const
#define G4UniformRand()
Definition: Randomize.hh:97
G4VPhysicalVolume * GetPhysicalVolume() const
static G4PionMinus * PionMinusDefinition()
Definition: G4PionMinus.cc:93
bool G4bool
Definition: G4Types.hh:79
void ProposePrimaryTrackPathLength(G4double)
static constexpr double cm
Definition: G4SIunits.hh:119
static G4PionPlus * PionPlusDefinition()
Definition: G4PionPlus.cc:93
G4bool Hit(G4Step *aStep)
Definition: G4Step.hh:76
G4ThreeVector GetPosition() const
G4VSolid * GetEnvelopeSolid() const
Definition: G4FastTrack.hh:203
static G4TransportationManager * GetTransportationManager()
const G4ThreeVector & GetMomentumDirection() const
G4LogicalVolume * GetLogicalVolume() const
virtual G4bool ModelTrigger(const G4FastTrack &)
G4StepPoint * GetPostStepPoint() const
Hep3Vector orthogonal() const
void SetEnergy(const G4double &E)
Definition of the Par01EnergySpot class.
tuple z
Definition: test.py:28
void ProposeTotalEnergyDeposited(G4double anEnergyPart)
void SetTotalEnergyDeposit(G4double value)
Hep3Vector cross(const Hep3Vector &) const
void KillPrimaryTrack()
Definition: G4FastStep.cc:88
virtual G4bool IsApplicable(const G4ParticleDefinition &)
double G4double
Definition: G4Types.hh:76
void SetTouchableHandle(const G4TouchableHandle &apValue)