2// ********************************************************************
3// * License and Disclaimer *
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. *
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. *
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// ********************************************************************
26// G4Track inline methods implementation
28// Author: Katsuya Amako, KEK - 1996
29// Revisions: Hisaya Kurashige, 1998-2011
30// --------------------------------------------------------------------
32extern G4TRACK_DLL G4Allocator<G4Track>*& aTrackAllocator();
34//-------------------------------------------------------------
35// To implement bi-directional association between G4Step and
36// and G4Track, a combined usage of 'forward declaration' and
37// 'include' is necessary.
38//-------------------------------------------------------------
41inline void* G4Track::operator new(std::size_t)
43 if(aTrackAllocator() == nullptr)
45 aTrackAllocator() = new G4Allocator<G4Track>;
47 return (void*) aTrackAllocator()->MallocSingle();
50inline void G4Track::operator delete(void* aTrack)
52 aTrackAllocator()->FreeSingle((G4Track*) aTrack);
55inline G4bool G4Track::operator==(const G4Track& trk)
57 return (this == &trk);
60inline G4bool G4Track::operator!=(const G4Track& trk)
62 return (this != &trk);
66inline const G4DynamicParticle* G4Track::GetDynamicParticle() const
68 return fpDynamicParticle;
72inline G4ParticleDefinition* G4Track::GetDefinition() const
74 return fpDynamicParticle->GetDefinition();
78inline const G4ParticleDefinition* G4Track::GetParticleDefinition() const
80 return fpDynamicParticle->GetParticleDefinition();
84inline G4int G4Track::GetParentID() const
89inline void G4Track::SetParentID(const G4int aValue)
95inline G4int G4Track::GetTrackID() const
100inline void G4Track::SetTrackID(const G4int aValue)
106inline const G4ThreeVector& G4Track::GetPosition() const
111inline void G4Track::SetPosition(const G4ThreeVector& aValue)
117inline G4double G4Track::GetGlobalTime() const
122inline void G4Track::SetGlobalTime(const G4double aValue)
124 fGlobalTime = aValue;
128inline G4double G4Track::GetLocalTime() const
133inline void G4Track::SetLocalTime(const G4double aValue)
139inline G4double G4Track::GetProperTime() const
141 return fpDynamicParticle->GetProperTime();
144inline void G4Track::SetProperTime(const G4double aValue)
146 fpDynamicParticle->SetProperTime(aValue);
150inline G4double G4Track::GetVelocity() const
152 return (useGivenVelocity) ? fVelocity
153 : ((!is_OpticalPhoton)
154 ? CLHEP::c_light * fpDynamicParticle->GetBeta()
155 : CalculateVelocityForOpticalPhoton());
158inline G4double G4Track::CalculateVelocity() const
160 return GetVelocity();
163inline void G4Track::SetVelocity(G4double val)
168inline G4bool G4Track::UseGivenVelocity() const
170 return useGivenVelocity;
173inline void G4Track::UseGivenVelocity(G4bool val)
175 useGivenVelocity = val;
179inline G4VPhysicalVolume* G4Track::GetVolume() const
181 return (fpTouchable) ? fpTouchable->GetVolume() : nullptr;
184inline G4VPhysicalVolume* G4Track::GetNextVolume() const
186 return (fpNextTouchable) ? fpNextTouchable->GetVolume() : nullptr;
189// material - assuming that the pointer to G4Step is defined
190inline const G4MaterialCutsCouple* G4Track::GetMaterialCutsCouple() const
192 return fpStep->GetPreStepPoint()->GetMaterialCutsCouple();
195inline const G4MaterialCutsCouple* G4Track::GetNextMaterialCutsCouple() const
197 return fpStep->GetPostStepPoint()->GetMaterialCutsCouple();
200inline G4Material* G4Track::GetMaterial() const
202 return fpStep->GetPreStepPoint()->GetMaterial();
205inline G4Material* G4Track::GetNextMaterial() const
207 return fpStep->GetPostStepPoint()->GetMaterial();
211inline const G4VTouchable* G4Track::GetTouchable() const
213 return fpTouchable();
216inline const G4TouchableHandle& G4Track::GetTouchableHandle() const
221inline void G4Track::SetTouchableHandle(const G4TouchableHandle& apValue)
223 fpTouchable = apValue;
226inline const G4VTouchable* G4Track::GetNextTouchable() const
228 return fpNextTouchable();
231inline const G4TouchableHandle& G4Track::GetNextTouchableHandle() const
233 return fpNextTouchable;
236inline void G4Track::SetNextTouchableHandle(const G4TouchableHandle& apValue)
238 fpNextTouchable = apValue;
241inline const G4VTouchable* G4Track::GetOriginTouchable() const
243 return fpOriginTouchable();
246inline const G4TouchableHandle& G4Track::GetOriginTouchableHandle() const
248 return fpOriginTouchable;
251inline void G4Track::SetOriginTouchableHandle(const G4TouchableHandle& apValue)
253 fpOriginTouchable = apValue;
257inline G4double G4Track::GetKineticEnergy() const
259 return fpDynamicParticle->GetKineticEnergy();
262inline void G4Track::SetKineticEnergy(const G4double aValue)
264 fpDynamicParticle->SetKineticEnergy(aValue);
268inline G4double G4Track::GetTotalEnergy() const
270 return fpDynamicParticle->GetTotalEnergy();
274inline G4ThreeVector G4Track::GetMomentum() const
276 return fpDynamicParticle->GetMomentum();
279// momentum (direction)
280inline const G4ThreeVector& G4Track::GetMomentumDirection() const
282 return fpDynamicParticle->GetMomentumDirection();
285inline void G4Track::SetMomentumDirection(const G4ThreeVector& aValue)
287 fpDynamicParticle->SetMomentumDirection(aValue);
291inline const G4ThreeVector& G4Track::GetPolarization() const
293 return fpDynamicParticle->GetPolarization();
296inline void G4Track::SetPolarization(const G4ThreeVector& aValue)
298 fpDynamicParticle->SetPolarization(aValue);
302inline G4TrackStatus G4Track::GetTrackStatus() const
307inline void G4Track::SetTrackStatus(const G4TrackStatus aTrackStatus)
309 fTrackStatus = aTrackStatus;
313inline G4double G4Track::GetTrackLength() const
318inline void G4Track::AddTrackLength(const G4double aValue)
320 fTrackLength += aValue;
322// Accumulated track length
325inline G4int G4Track::GetCurrentStepNumber() const
327 return fCurrentStepNumber;
330inline void G4Track::IncrementCurrentStepNumber()
332 ++fCurrentStepNumber;
336inline G4double G4Track::GetStepLength() const
341inline void G4Track::SetStepLength(G4double value)
346// vertex (where this track was created) information
347inline const G4ThreeVector& G4Track::GetVertexPosition() const
352inline void G4Track::SetVertexPosition(const G4ThreeVector& aValue)
354 fVtxPosition = aValue;
357inline const G4ThreeVector& G4Track::GetVertexMomentumDirection() const
359 return fVtxMomentumDirection;
362inline void G4Track::SetVertexMomentumDirection(const G4ThreeVector& aValue)
364 fVtxMomentumDirection = aValue;
367inline G4double G4Track::GetVertexKineticEnergy() const
369 return fVtxKineticEnergy;
372inline void G4Track::SetVertexKineticEnergy(const G4double aValue)
374 fVtxKineticEnergy = aValue;
377inline const G4LogicalVolume* G4Track::GetLogicalVolumeAtVertex() const
382inline void G4Track::SetLogicalVolumeAtVertex(const G4LogicalVolume* aValue)
384 fpLVAtVertex = aValue;
387inline const G4VProcess* G4Track::GetCreatorProcess() const
389 // If the pointer is null, this means the track is created
390 // by the event generator, i.e. the primary track. If it is not
391 // null, it points to the process which created this track.
393 return fpCreatorProcess;
396inline void G4Track::SetCreatorProcess(const G4VProcess* aValue)
398 fpCreatorProcess = aValue;
401inline void G4Track::SetCreatorModelID(const G4int id)
403 fCreatorModelID = id;
406inline G4int G4Track::GetCreatorModelID() const
408 return fCreatorModelID;
411inline G4int G4Track::GetCreatorModelIndex() const
413 return G4PhysicsModelCatalog::GetModelIndex(fCreatorModelID);
416inline const G4String G4Track::GetCreatorModelName() const
418 return G4PhysicsModelCatalog::GetModelNameFromID(fCreatorModelID);
421// flag for "Below Threshold"
422inline G4bool G4Track::IsBelowThreshold() const
424 return fBelowThreshold;
427inline void G4Track::SetBelowThresholdFlag(G4bool value)
429 fBelowThreshold = value;
432// flag for " Good for Tracking"
433inline G4bool G4Track::IsGoodForTracking() const
435 return fGoodForTracking;
438inline void G4Track::SetGoodForTrackingFlag(G4bool value)
440 fGoodForTracking = value;
444inline void G4Track::SetWeight(G4double aValue)
449inline G4double G4Track::GetWeight() const
455inline G4VUserTrackInformation* G4Track::GetUserInformation() const
457 return fpUserInformation;
460inline void G4Track::SetUserInformation(G4VUserTrackInformation* aValue) const
462 fpUserInformation = aValue;
465inline const G4Step* G4Track::GetStep() const
470inline void G4Track::SetStep(const G4Step* aValue)
475inline std::map<G4int, G4VAuxiliaryTrackInformation*>*
476 G4Track::GetAuxiliaryTrackInformationMap() const
478 return fpAuxiliaryTrackInformationMap;