Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
G4Track.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 //
26 //
27 // $Id: G4Track.cc 110263 2018-05-17 14:28:14Z 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"
47 #include "G4PhysicsModelCatalog.hh"
48 
49 #include <iostream>
50 #include <iomanip>
51 
53 {
54  G4ThreadLocalStatic G4Allocator<G4Track>* _instance = nullptr;
55  return _instance;
56 }
57 
59 {
60  G4ThreadLocalStatic G4VelocityTable* _instance = nullptr;
61  return _instance;
62 }
63 
65 G4Track::G4Track(G4DynamicParticle* apValueDynamicParticle,
66  G4double aValueTime,
67  const G4ThreeVector& aValuePosition)
69  : fCurrentStepNumber(0), fPosition(aValuePosition),
70  fGlobalTime(aValueTime), fLocalTime(0.),
71  fTrackLength(0.),
72  fParentID(0), fTrackID(0),
73  fVelocity(c_light),
74  fpDynamicParticle(apValueDynamicParticle),
75  fTrackStatus(fAlive),
76  fBelowThreshold(false), fGoodForTracking(false),
77  fStepLength(0.0), fWeight(1.0),
78  fpStep(0),
79  fVtxKineticEnergy(0.0),
80  fpLVAtVertex(0), fpCreatorProcess(0),
81  fCreatorModelIndex(-1),
82  fpUserInformation(0),
83  prev_mat(0), groupvel(0),
84  prev_velocity(0.0), prev_momentum(0.0),
85  is_OpticalPhoton(false),
86  useGivenVelocity(false),
87  fpAuxiliaryTrackInformationMap(0)
88 {
89  static G4ThreadLocal G4bool isFirstTime = true;
90  static G4ThreadLocal G4ParticleDefinition* fOpticalPhoton =0;
91  if ( isFirstTime ) {
92  isFirstTime = false;
93  // set fOpticalPhoton
94  fOpticalPhoton = G4ParticleTable::GetParticleTable()->FindParticle("opticalphoton");
95  }
96  // check if the particle type is Optical Photon
97  is_OpticalPhoton = (fpDynamicParticle->GetDefinition() == fOpticalPhoton);
98 
100 
102 
103 }
104 
108  : fCurrentStepNumber(0),
109  fGlobalTime(0), fLocalTime(0.),
110  fTrackLength(0.),
111  fParentID(0), fTrackID(0),
112  fVelocity(c_light),
113  fpDynamicParticle(0),
114  fTrackStatus(fAlive),
115  fBelowThreshold(false), fGoodForTracking(false),
116  fStepLength(0.0), fWeight(1.0),
117  fpStep(0),
118  fVtxKineticEnergy(0.0),
119  fpLVAtVertex(0), fpCreatorProcess(0),
120  fCreatorModelIndex(-1),
121  fpUserInformation(0),
122  prev_mat(0), groupvel(0),
123  prev_velocity(0.0), prev_momentum(0.0),
124  is_OpticalPhoton(false),
125  useGivenVelocity(false),
126  fpAuxiliaryTrackInformationMap(0)
127 {
128 }
129 
133  : fCurrentStepNumber(0),
134  fGlobalTime(0), fLocalTime(0.),
135  fTrackLength(0.),
136  fParentID(0), fTrackID(0),
137  fVelocity(c_light),
138  fpDynamicParticle(0),
139  fTrackStatus(fAlive),
140  fBelowThreshold(false), fGoodForTracking(false),
141  fStepLength(0.0), fWeight(1.0),
142  fpStep(0),
143  fVtxKineticEnergy(0.0),
144  fpLVAtVertex(0), fpCreatorProcess(0),
145  fCreatorModelIndex(-1),
146  fpUserInformation(0),
147  prev_mat(0), groupvel(0),
148  prev_velocity(0.0), prev_momentum(0.0),
149  is_OpticalPhoton(false),
150  useGivenVelocity(false),
151  fpAuxiliaryTrackInformationMap(0)
152 {
153  *this = right;
154 }
155 
159 {
160  delete fpDynamicParticle;
161  delete fpUserInformation;
163 }
164 
168 {
169  if (this != &right) {
170  fPosition = right.fPosition;
171  fGlobalTime = right.fGlobalTime;
172  fLocalTime = right.fLocalTime;
173  fTrackLength = right.fTrackLength;
174  fWeight = right.fWeight;
175  fStepLength = right.fStepLength;
176 
177  // Track ID (and Parent ID) is not copied and set to zero for new track
178  fTrackID = 0;
179  fParentID =0;
180 
181  // CurrentStepNumber is set to be 0
182  fCurrentStepNumber = 0;
183 
184  // velocity information
185  fVelocity = right.fVelocity;
186 
187  // dynamic particle information
189 
190  // track status and flags for tracking
191  fTrackStatus = right.fTrackStatus;
194 
195  // Step information (Step Length, Step Number, pointer to the Step,)
196  // are not copied
197  fpStep=0;
198 
199  // vertex information
200  fVtxPosition = right.fVtxPosition;
201  fpLVAtVertex = right.fpLVAtVertex;
204 
205  // CreatorProcess and UserInformation are not copied
206  fpCreatorProcess = 0;
207  fpUserInformation = 0;
208 
209  prev_mat = right.prev_mat;
210  groupvel = right.groupvel;
213 
216 
218  }
219  return *this;
220 }
221 
225 {
226  *this = right;
227 }
228 
232 {
233  if (useGivenVelocity) return fVelocity;
234 
235  G4double velocity = c_light ;
236 
238 
239  // special case for photons
241 
242  // particles other than optical photon
243  if (mass<DBL_MIN) {
244  // Zero Mass
245  velocity = c_light;
246  } else {
248  if (T > GetMaxTOfVelocityTable()) {
249  velocity = c_light;
250  } else if (T<DBL_MIN) {
251  velocity =0.;
252  } else if (T<GetMinTOfVelocityTable()) {
253  velocity = c_light*std::sqrt(T*(T+2.))/(T+1.0);
254  } else {
255  velocity = velTable()->Value(T);
256  }
257 
258  }
259  return velocity ;
260 }
261 
265 {
266 
267  G4double velocity = c_light ;
268 
269 
270  G4Material* mat=0;
271  G4bool update_groupvel = false;
272  if ( fpStep !=0 ){
273  mat= this->GetMaterial(); // Fix for repeated volumes
274  }else{
275  if (fpTouchable!=0){
277  }
278  }
279  // check if previous step is in the same volume
280  // and get new GROUPVELOCITY table if necessary
281  if ((mat != 0) && ((mat != prev_mat)||(groupvel==0))) {
282  groupvel = 0;
283  if(mat->GetMaterialPropertiesTable() != 0)
284  groupvel = mat->GetMaterialPropertiesTable()->GetProperty("GROUPVEL");
285  update_groupvel = true;
286  }
287  prev_mat = mat;
288 
289  if (groupvel != 0 ) {
290  // light velocity = c/(rindex+d(rindex)/d(log(E_phot)))
291  // values stored in GROUPVEL material properties vector
292  velocity = prev_velocity;
293 
294  // check if momentum is same as in the previous step
295  // and calculate group velocity if necessary
296  G4double current_momentum = fpDynamicParticle->GetTotalMomentum();
297  if( update_groupvel || (current_momentum != prev_momentum) ) {
298  velocity =
299  groupvel->Value(current_momentum);
300  prev_velocity = velocity;
301  prev_momentum = current_momentum;
302  }
303  }
304 
305  return velocity ;
306 }
307 
311 {
314 }
315 
320 
325 
330 
334 {
335  if(!fpAuxiliaryTrackInformationMap)
336  { fpAuxiliaryTrackInformationMap = new std::map<G4int,G4VAuxiliaryTrackInformation*>; }
337  if(idx<0 || idx>=G4PhysicsModelCatalog::Entries())
338  {
340  ED << "Process/model index <" << idx << "> is invalid.";
341  G4Exception("G4VAuxiliaryTrackInformation::G4VAuxiliaryTrackInformation()","TRACK0982",
342  FatalException, ED);
343  }
344  (*fpAuxiliaryTrackInformationMap)[idx] = info;
345 }
346 
350 {
351  if(!fpAuxiliaryTrackInformationMap) return 0;
352  std::map<G4int,G4VAuxiliaryTrackInformation*>::iterator itr
353  = fpAuxiliaryTrackInformationMap->find(idx);
354  if(itr==fpAuxiliaryTrackInformationMap->end()) return 0;
355  else return (*itr).second;
356 }
357 
361 {
363  fpAuxiliaryTrackInformationMap->erase(idx);
364 }
365 
369 {
371  {
374  }
375 }
376 
380 {
381  if(!fpAuxiliaryTrackInformationMap) return;
382  for(std::map<G4int,G4VAuxiliaryTrackInformation*>::iterator itr=fpAuxiliaryTrackInformationMap->begin();
383  itr!=fpAuxiliaryTrackInformationMap->end(); itr++)
384  { delete (*itr).second; }
387 }
388 
389 
G4ParticleDefinition * FindParticle(G4int PDGEncoding)
static void SetVelocityTableProperties(G4double t_max, G4double t_min, G4int nbin)
const XML_Char XML_Encoding * info
Definition: expat.h:530
const XML_Char * name
Definition: expat.h:151
std::ostringstream G4ExceptionDescription
Definition: G4Exception.hh:45
G4double prev_momentum
Definition: G4Track.hh:321
static G4int GetNbinOfVelocityTable()
Definition: G4Track.cc:327
G4double Value(G4double theEnergy)
G4LogicalVolume * GetLogicalVolume() const
G4double fVtxKineticEnergy
Definition: G4Track.hh:310
static G4ParticleTable * GetParticleTable()
~G4Track()
Definition: G4Track.cc:157
static G4VelocityTable * GetVelocityTable()
static G4double GetMinTOfVelocityTable()
G4int fTrackID
Definition: G4Track.hh:279
G4ThreeVector fPosition
Definition: G4Track.hh:274
G4DynamicParticle * fpDynamicParticle
Definition: G4Track.hh:287
virtual G4VPhysicalVolume * GetVolume(G4int depth=0) const
Definition: G4VTouchable.cc:44
static G4double GetMaxTOfVelocityTable()
G4double Value(G4double theEnergy, size_t &lastidx) const
#define G4ThreadLocal
Definition: tls.hh:69
#define G4ThreadLocalStatic
Definition: tls.hh:68
G4double fVelocity
Definition: G4Track.hh:280
G4Material * GetMaterial() const
G4double fGlobalTime
Definition: G4Track.hh:275
void CopyTrackInfo(const G4Track &)
Definition: G4Track.cc:223
const G4Step * fpStep
Definition: G4Track.hh:306
const G4LogicalVolume * fpLVAtVertex
Definition: G4Track.hh:311
G4double CalculateVelocityForOpticalPhoton() const
Definition: G4Track.cc:263
G4double CalculateVelocity() const
Definition: G4Track.cc:230
static G4int GetIndex(const G4String &)
G4double fLocalTime
Definition: G4Track.hh:276
G4ThreeVector fVtxMomentumDirection
Definition: G4Track.hh:309
double G4double
Definition: G4Types.hh:76
bool G4bool
Definition: G4Types.hh:79
G4bool fGoodForTracking
Definition: G4Track.hh:293
G4ParticleDefinition * GetDefinition() const
G4double fStepLength
Definition: G4Track.hh:297
G4Track & operator=(const G4Track &)
Definition: G4Track.cc:166
std::map< G4int, G4VAuxiliaryTrackInformation * > * fpAuxiliaryTrackInformationMap
Definition: G4Track.hh:330
G4Allocator< G4Track > *& aTrackAllocator()
Definition: G4Track.cc:52
G4Material * prev_mat
Definition: G4Track.hh:318
static G4VelocityTable *& velTable()
Definition: G4Track.cc:58
G4double fTrackLength
Definition: G4Track.hh:277
G4bool fBelowThreshold
Definition: G4Track.hh:290
void RemoveAuxiliaryTrackInformation(G4int idx)
Definition: G4Track.cc:359
static void SetVelocityTableProperties(G4double t_max, G4double t_min, G4int nbin)
Definition: G4Track.cc:309
Float_t mat
G4Material * GetMaterial() const
const G4ThreeVector const G4double const
G4int fParentID
Definition: G4Track.hh:278
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.hh:65
G4TouchableHandle fpTouchable
Definition: G4Track.hh:282
G4VAuxiliaryTrackInformation * GetAuxiliaryTrackInformation(G4int idx) const
Definition: G4Track.cc:348
G4Track()
Definition: G4Track.cc:106
G4ThreeVector fVtxPosition
Definition: G4Track.hh:308
int G4int
Definition: G4Types.hh:78
static constexpr double c_light
G4double fWeight
Definition: G4Track.hh:303
G4bool is_OpticalPhoton
Definition: G4Track.hh:323
static G4double GetMinTOfVelocityTable()
Definition: G4Track.cc:322
G4int fCurrentStepNumber
Definition: G4Track.hh:273
G4double prev_velocity
Definition: G4Track.hh:320
#define DBL_MIN
Definition: templates.hh:75
G4double GetKineticEnergy() const
void SetAuxiliaryTrackInformation(G4int idx, G4VAuxiliaryTrackInformation *info) const
Definition: G4Track.cc:332
G4VUserTrackInformation * fpUserInformation
Definition: G4Track.hh:315
void ClearAuxiliaryTrackInformation()
Definition: G4Track.cc:378
G4MaterialPropertyVector * GetProperty(const char *key, G4bool warning=false)
static G4double GetMaxTOfVelocityTable()
Definition: G4Track.cc:317
G4bool useGivenVelocity
Definition: G4Track.hh:326
G4double GetMass() const
G4double GetTotalMomentum() const
static G4int GetNbinOfVelocityTable()
G4MaterialPropertiesTable * GetMaterialPropertiesTable() const
Definition: G4Material.hh:252
G4MaterialPropertyVector * groupvel
Definition: G4Track.hh:319
G4TrackStatus fTrackStatus
Definition: G4Track.hh:288
const G4VProcess * fpCreatorProcess
Definition: G4Track.hh:312