Geant4  10.00.p01
G4Track.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: G4Track.cc 77080 2013-11-21 10:33:55Z gcosmo $
28 //
29 //
30 //---------------------------------------------------------------
31 //
32 // G4Track.cc
33 //
34 //---------------------------------------------------------------
35 // Add copy constructor Hisaya Feb. 07 01
36 // Fix GetVelocity Hisaya Feb. 17 01
37 // Modification for G4TouchableHandle 22 Oct. 2001 R.Chytracek//
38 // Fix GetVelocity (bug report #741) Horton-Smith Apr 14 2005
39 // Remove massless check in GetVelocity 02 Apr. 09 H.Kurashige
40 // Use G4VelocityTable 17 AUg. 2011 H.Kurashige
41 
42 #include "G4Track.hh"
43 #include "G4PhysicalConstants.hh"
44 #include "G4ParticleTable.hh"
45 #include "G4VelocityTable.hh"
46 
47 #include <iostream>
48 #include <iomanip>
49 
51 
53 
55 G4Track::G4Track(G4DynamicParticle* apValueDynamicParticle,
56  G4double aValueTime,
57  const G4ThreeVector& aValuePosition)
59  : fCurrentStepNumber(0), fPosition(aValuePosition),
60  fGlobalTime(aValueTime), fLocalTime(0.),
61  fTrackLength(0.),
62  fParentID(0), fTrackID(0),
63  fVelocity(c_light),
64  fpDynamicParticle(apValueDynamicParticle),
65  fTrackStatus(fAlive),
66  fBelowThreshold(false), fGoodForTracking(false),
67  fStepLength(0.0), fWeight(1.0),
68  fpStep(0),
69  fVtxKineticEnergy(0.0),
70  fpLVAtVertex(0), fpCreatorProcess(0),
71  fCreatorModelIndex(-1),
72  fpUserInformation(0),
73  prev_mat(0), groupvel(0),
74  prev_velocity(0.0), prev_momentum(0.0),
75  is_OpticalPhoton(false),
76  useGivenVelocity(false)
77 {
78  static G4ThreadLocal G4bool isFirstTime = true;
79  static G4ThreadLocal G4ParticleDefinition* fOpticalPhoton =0;
80  if ( isFirstTime ) {
81  isFirstTime = false;
82  // set fOpticalPhoton
83  fOpticalPhoton = G4ParticleTable::GetParticleTable()->FindParticle("opticalphoton");
84  }
85  // check if the particle type is Optical Photon
86  is_OpticalPhoton = (fpDynamicParticle->GetDefinition() == fOpticalPhoton);
87 
89 
91 
92 }
93 
97  : fCurrentStepNumber(0),
98  fGlobalTime(0), fLocalTime(0.),
99  fTrackLength(0.),
100  fParentID(0), fTrackID(0),
101  fVelocity(c_light),
102  fpDynamicParticle(0),
103  fTrackStatus(fAlive),
104  fBelowThreshold(false), fGoodForTracking(false),
105  fStepLength(0.0), fWeight(1.0),
106  fpStep(0),
107  fVtxKineticEnergy(0.0),
108  fpLVAtVertex(0), fpCreatorProcess(0),
109  fCreatorModelIndex(-1),
110  fpUserInformation(0),
111  prev_mat(0), groupvel(0),
112  prev_velocity(0.0), prev_momentum(0.0),
113  is_OpticalPhoton(false),
114  useGivenVelocity(false)
115 {
116 }
117 
121  : fCurrentStepNumber(0),
122  fGlobalTime(0), fLocalTime(0.),
123  fTrackLength(0.),
124  fParentID(0), fTrackID(0),
125  fVelocity(c_light),
126  fpDynamicParticle(0),
127  fTrackStatus(fAlive),
128  fBelowThreshold(false), fGoodForTracking(false),
129  fStepLength(0.0), fWeight(1.0),
130  fpStep(0),
131  fVtxKineticEnergy(0.0),
132  fpLVAtVertex(0), fpCreatorProcess(0),
133  fCreatorModelIndex(-1),
134  fpUserInformation(0),
135  prev_mat(0), groupvel(0),
136  prev_velocity(0.0), prev_momentum(0.0),
137  is_OpticalPhoton(false),
138  useGivenVelocity(false)
139 {
140  *this = right;
141 }
142 
146 {
147  delete fpDynamicParticle;
148  delete fpUserInformation;
149 }
150 
154 {
155  if (this != &right) {
156  fPosition = right.fPosition;
157  fGlobalTime = right.fGlobalTime;
158  fLocalTime = right.fLocalTime;
159  fTrackLength = right.fTrackLength;
160  fWeight = right.fWeight;
161  fStepLength = right.fStepLength;
162 
163  // Track ID (and Parent ID) is not copied and set to zero for new track
164  fTrackID = 0;
165  fParentID =0;
166 
167  // CurrentStepNumber is set to be 0
168  fCurrentStepNumber = 0;
169 
170  // velocity information
171  fVelocity = right.fVelocity;
172 
173  // dynamic particle information
175 
176  // track status and flags for tracking
177  fTrackStatus = right.fTrackStatus;
180 
181  // Step information (Step Length, Step Number, pointer to the Step,)
182  // are not copied
183  fpStep=0;
184 
185  // vertex information
186  fVtxPosition = right.fVtxPosition;
187  fpLVAtVertex = right.fpLVAtVertex;
190 
191  // CreatorProcess and UserInformation are not copied
192  fpCreatorProcess = 0;
193  fpUserInformation = 0;
194 
195  prev_mat = right.prev_mat;
196  groupvel = right.groupvel;
199 
202  }
203  return *this;
204 }
205 
209 {
210  *this = right;
211 }
212 
216 {
217  if (useGivenVelocity) return fVelocity;
218 
219  G4double velocity = c_light ;
220 
222 
223  // special case for photons
225 
226  // particles other than optical photon
227  if (mass<DBL_MIN) {
228  // Zero Mass
229  velocity = c_light;
230  } else {
232  if (T > GetMaxTOfVelocityTable()) {
233  velocity = c_light;
234  } else if (T<DBL_MIN) {
235  velocity =0.;
236  } else if (T<GetMinTOfVelocityTable()) {
237  velocity = c_light*std::sqrt(T*(T+2.))/(T+1.0);
238  } else {
239  velocity = velTable->Value(T);
240  }
241 
242  }
243  return velocity ;
244 }
245 
249 {
250 
251  G4double velocity = c_light ;
252 
253 
254  G4Material* mat=0;
255  G4bool update_groupvel = false;
256  if ( fpStep !=0 ){
257  mat= this->GetMaterial(); // Fix for repeated volumes
258  }else{
259  if (fpTouchable!=0){
261  }
262  }
263  // check if previous step is in the same volume
264  // and get new GROUPVELOCITY table if necessary
265  if ((mat != 0) && ((mat != prev_mat)||(groupvel==0))) {
266  groupvel = 0;
267  if(mat->GetMaterialPropertiesTable() != 0)
268  groupvel = mat->GetMaterialPropertiesTable()->GetProperty("GROUPVEL");
269  update_groupvel = true;
270  }
271  prev_mat = mat;
272 
273  if (groupvel != 0 ) {
274  // light velocity = c/(rindex+d(rindex)/d(log(E_phot)))
275  // values stored in GROUPVEL material properties vector
276  velocity = prev_velocity;
277 
278  // check if momentum is same as in the previous step
279  // and calculate group velocity if necessary
280  G4double current_momentum = fpDynamicParticle->GetTotalMomentum();
281  if( update_groupvel || (current_momentum != prev_momentum) ) {
282  velocity =
283  groupvel->Value(current_momentum);
284  prev_velocity = velocity;
285  prev_momentum = current_momentum;
286  }
287  }
288 
289  return velocity ;
290 }
291 
295 {
298 }
299 
304 
309 
static G4ThreadLocal G4VelocityTable * velTable
Definition: G4Track.hh:322
G4int fCurrentStepNumber
Definition: G4Track.hh:271
G4double fGlobalTime
Definition: G4Track.hh:273
static G4VelocityTable * GetVelocityTable()
G4ParticleDefinition * FindParticle(G4int PDGEncoding)
G4MaterialPropertyVector * GetProperty(const char *key)
G4ThreadLocal G4Allocator< G4Track > * aTrackAllocator
Definition: G4Track.cc:50
G4int fTrackID
Definition: G4Track.hh:277
G4double GetKineticEnergy() const
CLHEP::Hep3Vector G4ThreeVector
static G4double GetMinTOfVelocityTable()
G4DynamicParticle * fpDynamicParticle
Definition: G4Track.hh:285
G4Material * GetMaterial() const
G4MaterialPropertyVector * groupvel
Definition: G4Track.hh:317
G4bool is_OpticalPhoton
Definition: G4Track.hh:321
G4double fVtxKineticEnergy
Definition: G4Track.hh:308
G4ParticleDefinition * GetDefinition() const
#define G4ThreadLocal
Definition: tls.hh:52
int G4int
Definition: G4Types.hh:78
G4double fLocalTime
Definition: G4Track.hh:274
G4double prev_velocity
Definition: G4Track.hh:318
G4bool useGivenVelocity
Definition: G4Track.hh:324
G4double GetTotalMomentum() const
const G4VProcess * fpCreatorProcess
Definition: G4Track.hh:310
G4VUserTrackInformation * fpUserInformation
Definition: G4Track.hh:313
G4double CalculateVelocityForOpticalPhoton() const
Definition: G4Track.cc:247
G4bool fBelowThreshold
Definition: G4Track.hh:288
G4double fWeight
Definition: G4Track.hh:301
G4ThreeVector fVtxMomentumDirection
Definition: G4Track.hh:307
G4double fTrackLength
Definition: G4Track.hh:275
G4int fParentID
Definition: G4Track.hh:276
G4double GetMass() const
bool G4bool
Definition: G4Types.hh:79
G4Material * prev_mat
Definition: G4Track.hh:316
G4ThreeVector fPosition
Definition: G4Track.hh:272
static G4int GetNbinOfVelocityTable()
G4ThreeVector fVtxPosition
Definition: G4Track.hh:306
G4double Value(G4double theEnergy, size_t &lastidx) const
G4double CalculateVelocity() const
Definition: G4Track.cc:214
static void SetVelocityTableProperties(G4double t_max, G4double t_min, G4int nbin)
G4Material * GetMaterial() const
static G4int GetNbinOfVelocityTable()
Definition: G4Track.cc:311
G4TouchableHandle fpTouchable
Definition: G4Track.hh:280
G4double fStepLength
Definition: G4Track.hh:295
G4LogicalVolume * GetLogicalVolume() const
static G4ParticleTable * GetParticleTable()
G4Track & operator=(const G4Track &)
Definition: G4Track.cc:152
virtual G4VPhysicalVolume * GetVolume(G4int depth=0) const
Definition: G4VTouchable.cc:44
G4double fVelocity
Definition: G4Track.hh:278
G4MaterialPropertiesTable * GetMaterialPropertiesTable() const
Definition: G4Material.hh:250
static G4double GetMinTOfVelocityTable()
Definition: G4Track.cc:306
G4TrackStatus fTrackStatus
Definition: G4Track.hh:286
G4double prev_momentum
Definition: G4Track.hh:319
#define DBL_MIN
Definition: templates.hh:75
static void SetVelocityTableProperties(G4double t_max, G4double t_min, G4int nbin)
Definition: G4Track.cc:293
const G4LogicalVolume * fpLVAtVertex
Definition: G4Track.hh:309
static G4double GetMaxTOfVelocityTable()
Definition: G4Track.cc:301
double G4double
Definition: G4Types.hh:76
static G4double GetMaxTOfVelocityTable()
G4double Value(G4double theEnergy)
G4Track()
Definition: G4Track.cc:95
const G4Step * fpStep
Definition: G4Track.hh:304
void CopyTrackInfo(const G4Track &)
Definition: G4Track.cc:207
G4bool fGoodForTracking
Definition: G4Track.hh:291
~G4Track()
Definition: G4Track.cc:144