Geant4  10.01.p03
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 //
26 //
27 // $Id: Par01PionShowerModel.cc 66241 2012-12-13 18:34:42Z gunter $
28 //
29 #include "Par01PionShowerModel.hh"
30 #include "Par01EnergySpot.hh"
31 
32 #include "Randomize.hh"
33 
34 #include "G4PionMinus.hh"
35 #include "G4PionPlus.hh"
37 #include "G4VSensitiveDetector.hh"
38 #include "G4TouchableHistory.hh"
39 
40 #include "G4Colour.hh"
41 #include "G4PhysicalConstants.hh"
42 #include "G4SystemOfUnits.hh"
43 
45 : G4VFastSimulationModel(modelName, envelope)
46 {
47  fFakeStep = new G4Step();
51  fpNavigator = new G4Navigator();
52  fNaviSetup = false;
53 }
54 
56 : G4VFastSimulationModel(modelName)
57 {
58  fFakeStep = new G4Step();
62  fpNavigator = new G4Navigator();
63  fNaviSetup = false;
64 }
65 
67 {
68  delete fFakeStep;
69  delete fpNavigator;
70 }
71 
73 {
74  return
75  &particleType == G4PionMinus::PionMinusDefinition() ||
76  &particleType == G4PionPlus::PionPlusDefinition();
77 }
78 
80 {
81  // Applies the parameterisation always:
82  // ie as soon as the pion enters the envelope
83  return true;
84 }
85 
86 void Par01PionShowerModel::DoIt(const G4FastTrack& fastTrack,
87  G4FastStep& fastStep)
88 {
89  // G4cout << "Par01PionShowerModel::DoIt" << G4endl;
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 
104 {
105  //-----------------------------------------------------
106  // Non-physical shower generated: exp along z and
107  // transverse.
108  //-----------------------------------------------------
109 
110  // center of the shower, we put at the middle of the ghost:
111  G4ThreeVector showerCenter;
112  G4double distOut;
113  distOut = fastTrack.GetEnvelopeSolid()->
114  DistanceToOut(fastTrack.GetPrimaryTrackLocalPosition(),
115  fastTrack.GetPrimaryTrackLocalDirection());
116  showerCenter = fastTrack.GetPrimaryTrackLocalPosition() +
117  (distOut/2.)*fastTrack.GetPrimaryTrackLocalDirection();
118 
119  showerCenter = fastTrack.GetInverseAffineTransformation()->
120  TransformPoint(showerCenter);
121 
122  // axis of the shower, in global reference frame:
123  G4ThreeVector xShower, yShower, zShower;
124  zShower = fastTrack.GetPrimaryTrack()->GetMomentumDirection();
125  xShower = zShower.orthogonal();
126  yShower = zShower.cross(xShower);
127 
128  // shoot the energy spots:
129  G4double Energy = fastTrack.GetPrimaryTrack()->GetKineticEnergy();
130  G4int nSpot = 50;
131  G4double deposit = Energy/double(nSpot);
132  Par01EnergySpot eSpot;
133  eSpot.SetEnergy(deposit);
134  G4ThreeVector ePoint;
135 
136  // clear the spot list before use
137  feSpotList.clear();
138 
139  G4double z, r, phi;
140  for (int i = 0; i < nSpot; i++)
141  {
142  z = G4RandGauss::shoot(0,20*cm);
143  r = G4RandGauss::shoot(0,10*cm);
144  phi = G4UniformRand()*twopi;
145  ePoint = showerCenter +
146  z*zShower +
147  r*std::cos(phi)*xShower + r*std::sin(phi)*yShower;
148  eSpot.SetPosition(ePoint);
149  feSpotList.push_back(eSpot);
150  }
151 }
152 
153 
155 {
156  // Does the assignation of the energy spots to the sensitive volumes:
157  for (size_t i = 0; i < feSpotList.size(); i++)
158  {
159  // Draw the energy spot:
160  G4Colour red(1.,0.,0.);
161  feSpotList[i].Draw(&red);
162  // feSpotList[i].Print();
163 
164  // "converts" the energy spot into the fake
165  // G4Step to pass to sensitive detector:
167  }
168 }
169 
170 
172 {
173  //
174  // "converts" the energy spot into the fake
175  // G4Step to pass to sensitive detector:
176  //
177  FillFakeStep(eSpot);
178 
179  //
180  // call sensitive part: taken/adapted from the stepping:
181  // Send G4Step information to Hit/Dig if the volume is sensitive
182  //
183  G4VPhysicalVolume* pCurrentVolume =
185  G4VSensitiveDetector* pSensitive;
186 
187  if( pCurrentVolume != 0 )
188  {
189  pSensitive = pCurrentVolume->GetLogicalVolume()->
190  GetSensitiveDetector();
191  if( pSensitive != 0 )
192  {
193  pSensitive->Hit(fFakeStep);
194  }
195  }
196 }
197 
198 
200 {
201  //-----------------------------------------------------------
202  // find in which volume the spot is.
203  //-----------------------------------------------------------
204  if (!fNaviSetup)
205  {
206  fpNavigator->
208  GetNavigatorForTracking()->GetWorldVolume());
209  fpNavigator->
210  LocateGlobalPointAndUpdateTouchableHandle(eSpot.GetPosition(),
211  G4ThreeVector(0.,0.,0.),
213  false);
214  fNaviSetup = true;
215  }
216  else
217  {
218  fpNavigator->
219  LocateGlobalPointAndUpdateTouchableHandle(eSpot.GetPosition(),
220  G4ThreeVector(0.,0.,0.),
222  }
223  //--------------------------------------
224  // Fills attribute of the G4Step needed
225  // by our sensitive detector:
226  //-------------------------------------
227  // set touchable volume at PreStepPoint:
229  // set total energy deposit:
231 }
void SetPosition(const G4ThreeVector &point)
static const double cm
Definition: G4SIunits.hh:106
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
G4TouchableHandle fTouchableHandle
std::vector< Par01EnergySpot > feSpotList
G4ThreeVector GetPrimaryTrackLocalDirection() const
Definition: G4FastTrack.hh:223
Definition: test07.cc:36
CLHEP::Hep3Vector G4ThreeVector
G4double z
Definition: TRTMaterials.hh:39
const G4AffineTransform * GetInverseAffineTransformation() const
Definition: G4FastTrack.hh:238
Par01PionShowerModel(G4String, G4Region *)
int G4int
Definition: G4Types.hh:78
G4StepPoint * GetPreStepPoint() const
virtual void DoIt(const G4FastTrack &, G4FastStep &)
G4double GetKineticEnergy() const
#define G4UniformRand()
Definition: Randomize.hh:93
G4VPhysicalVolume * GetPhysicalVolume() const
void Explode(const G4FastTrack &)
static G4PionMinus * PionMinusDefinition()
Definition: G4PionMinus.cc:93
bool G4bool
Definition: G4Types.hh:79
void ProposePrimaryTrackPathLength(G4double)
void FillFakeStep(const Par01EnergySpot &eSpot)
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()
void AssignSpotAndCallHit(const Par01EnergySpot &eSpot)
const G4ThreeVector & GetMomentumDirection() const
G4LogicalVolume * GetLogicalVolume() const
virtual G4bool ModelTrigger(const G4FastTrack &)
G4StepPoint * GetPostStepPoint() const
void SetEnergy(const G4double &E)
void ProposeTotalEnergyDeposited(G4double anEnergyPart)
void SetTotalEnergyDeposit(G4double value)
G4StepPoint * fFakePostStepPoint
void KillPrimaryTrack()
Definition: G4FastStep.cc:87
virtual G4bool IsApplicable(const G4ParticleDefinition &)
double G4double
Definition: G4Types.hh:76
void SetTouchableHandle(const G4TouchableHandle &apValue)