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 // ********************************************************************
 
   27 // $Id: G4Track.icc 83388 2014-08-21 14:29:33Z gcosmo $
 
   29 //-----------------------------------------------------------------
 
   30 // Definitions of inline functions
 
   31 //-----------------------------------------------------------------
 
   32 //   change GetMaterial        16 Feb. 2000  H.Kurashige
 
   34 extern G4TRACK_DLL G4ThreadLocal G4Allocator<G4Track> *aTrackAllocator;
 
   36 //-------------------------------------------------------------
 
   37 // To implement bi-directional association between G4Step and
 
   38 // and G4Track, a combined usage of 'forward declaration' and
 
   39 // 'include' is necessary.
 
   40 //-------------------------------------------------------------
 
   45    inline void* G4Track::operator new(size_t)
 
   47      if (!aTrackAllocator) aTrackAllocator = new G4Allocator<G4Track>;
 
   48      return (void *) aTrackAllocator->MallocSingle();
 
   50       // Override "new" for "G4Allocator".
 
   52    inline void G4Track::operator delete(void *aTrack)
 
   53    { aTrackAllocator->FreeSingle((G4Track *) aTrack); }
 
   54       // Override "delete" for "G4Allocator".
 
   56    inline G4bool G4Track::operator==( const G4Track& trk)
 
   57    { return (this==&trk); }
 
   58       // Define "==" operator because "G4TrackVector" uses 
 
   59       // "RWPtrOrderdVector" which requires this.
 
   63    inline const G4DynamicParticle* G4Track::GetDynamicParticle() const
 
   64    { return fpDynamicParticle; }
 
   66 // particle definition
 
   67    inline G4ParticleDefinition* G4Track::GetDefinition() const
 
   68    { return fpDynamicParticle->GetDefinition(); }
 
   70 // particle definition
 
   71    inline const G4ParticleDefinition* G4Track::GetParticleDefinition() const
 
   72    { return fpDynamicParticle->GetParticleDefinition(); }
 
   75    inline G4int G4Track::GetParentID() const
 
   78    inline void G4Track::SetParentID(const G4int aValue)
 
   79    { fParentID = aValue; }
 
   82    inline G4int G4Track::GetTrackID() const
 
   85    inline void G4Track::SetTrackID(const G4int aValue)
 
   86    { fTrackID = aValue; }
 
   89    inline const G4ThreeVector& G4Track::GetPosition() const
 
   92    inline void G4Track::SetPosition(const G4ThreeVector& aValue)
 
   93    { fPosition = aValue; }
 
   96    inline G4double G4Track::GetGlobalTime() const
 
   97    { return fGlobalTime; }
 
   99    inline void G4Track::SetGlobalTime(const G4double aValue)
 
  100    { fGlobalTime = aValue; }
 
  101      // Time since the event in which the track belongs is created.
 
  104    inline G4double G4Track::GetLocalTime() const
 
  105    { return fLocalTime; }
 
  107    inline void G4Track::SetLocalTime(const G4double aValue)
 
  108    { fLocalTime = aValue; }
 
  109       // Time since the current track is created.
 
  112    inline G4double G4Track::GetProperTime() const
 
  113    { return fpDynamicParticle->GetProperTime(); }
 
  115    inline void G4Track::SetProperTime(const G4double aValue)
 
  116    { fpDynamicParticle->SetProperTime(aValue); }
 
  117       // Proper time of the current track
 
  120    inline G4double G4Track::GetVelocity() const
 
  121    { return fVelocity; }
 
  123    inline void  G4Track::SetVelocity(G4double val)
 
  126    inline G4bool   G4Track::UseGivenVelocity() const
 
  127    { return  useGivenVelocity;}
 
  129    inline void     G4Track::UseGivenVelocity(G4bool val)
 
  130    { useGivenVelocity = val;}
 
  134    inline G4VPhysicalVolume* G4Track::GetVolume() const
 
  135    { if ( fpTouchable ==0 ) return 0; 
 
  136      return fpTouchable->GetVolume(); }
 
  138    inline G4VPhysicalVolume* G4Track::GetNextVolume() const
 
  139    {  if ( fpNextTouchable ==0 ) return 0; 
 
  140      return fpNextTouchable->GetVolume(); }
 
  144     const G4MaterialCutsCouple* G4Track::GetMaterialCutsCouple() const
 
  145    { return fpStep->GetPreStepPoint()->GetMaterialCutsCouple(); }
 
  148     const G4MaterialCutsCouple* G4Track::GetNextMaterialCutsCouple() const
 
  149    { return fpStep->GetPostStepPoint()->GetMaterialCutsCouple(); }
 
  152    inline G4Material* G4Track::GetMaterial() const
 
  153    { return fpStep->GetPreStepPoint()->GetMaterial(); }
 
  155    inline G4Material* G4Track::GetNextMaterial() const
 
  156    { return fpStep->GetPostStepPoint()->GetMaterial(); }
 
  160    inline const G4VTouchable* G4Track::GetTouchable() const 
 
  161    { return fpTouchable(); }
 
  163    inline const G4TouchableHandle& G4Track::GetTouchableHandle() const 
 
  164    { return fpTouchable; }
 
  166    inline void G4Track::SetTouchableHandle( const G4TouchableHandle& apValue) 
 
  167    { fpTouchable = apValue; }
 
  169    inline const  G4VTouchable* G4Track::GetNextTouchable() const 
 
  170    { return fpNextTouchable(); }
 
  172    inline const  G4TouchableHandle& G4Track::GetNextTouchableHandle() const 
 
  173    { return fpNextTouchable; }
 
  175    inline void G4Track::SetNextTouchableHandle( const G4TouchableHandle& apValue)
 
  176    { fpNextTouchable = apValue; }
 
  178    inline const  G4VTouchable* G4Track::GetOriginTouchable() const 
 
  179    { return fpOriginTouchable(); }
 
  181    inline const  G4TouchableHandle& G4Track::GetOriginTouchableHandle() const 
 
  182    { return fpOriginTouchable; }
 
  184    inline void G4Track::SetOriginTouchableHandle( const G4TouchableHandle& apValue)
 
  185    { fpOriginTouchable = apValue; }
 
  188    inline G4double G4Track::GetKineticEnergy() const
 
  189    { return fpDynamicParticle->GetKineticEnergy(); }
 
  191    inline void G4Track::SetKineticEnergy(const G4double aValue)
 
  192    { fpDynamicParticle->SetKineticEnergy(aValue); }
 
  195    inline G4double G4Track::GetTotalEnergy() const
 
  196    { return fpDynamicParticle->GetTotalEnergy(); }
 
  199    inline G4ThreeVector G4Track::GetMomentum() const
 
  200    { return fpDynamicParticle->GetMomentum(); }
 
  202 // momentum (direction)
 
  203   inline const G4ThreeVector& G4Track::GetMomentumDirection() const
 
  204    { return fpDynamicParticle->GetMomentumDirection(); }
 
  206    inline void G4Track::SetMomentumDirection(const G4ThreeVector& aValue)
 
  207    { fpDynamicParticle->SetMomentumDirection(aValue) ;}
 
  210    inline const G4ThreeVector& G4Track::GetPolarization() const
 
  211    { return fpDynamicParticle->GetPolarization(); }
 
  213    inline void G4Track::SetPolarization(const G4ThreeVector& aValue)
 
  214    { fpDynamicParticle->SetPolarization(aValue.x(),
 
  219    inline G4TrackStatus G4Track::GetTrackStatus() const
 
  220    { return fTrackStatus; }
 
  222    inline void G4Track::SetTrackStatus(const G4TrackStatus aTrackStatus)
 
  223    { fTrackStatus = aTrackStatus; }
 
  226    inline G4double G4Track::GetTrackLength() const
 
  227    { return fTrackLength; }
 
  229    inline void G4Track::AddTrackLength(const G4double aValue)
 
  230    { fTrackLength += aValue; }
 
  231       // Accumulated track length
 
  234    inline G4int G4Track::GetCurrentStepNumber() const
 
  235    { return fCurrentStepNumber; }
 
  237    inline void G4Track::IncrementCurrentStepNumber()
 
  238    { fCurrentStepNumber++; }
 
  241    inline G4double G4Track::GetStepLength() const
 
  242    { return fStepLength; }
 
  244    inline void G4Track::SetStepLength(G4double value)
 
  245    { fStepLength = value; }
 
  247 // vertex (where this track was created) information
 
  248    inline const G4ThreeVector& G4Track::GetVertexPosition() const
 
  249    { return fVtxPosition; }
 
  251    inline void G4Track::SetVertexPosition(const G4ThreeVector& aValue)
 
  252    { fVtxPosition = aValue; }
 
  254    inline const G4ThreeVector& G4Track::GetVertexMomentumDirection() const
 
  255    { return fVtxMomentumDirection; }
 
  256    inline void G4Track::SetVertexMomentumDirection(const G4ThreeVector& aValue)
 
  257    { fVtxMomentumDirection = aValue ;}
 
  259    inline G4double G4Track::GetVertexKineticEnergy() const
 
  260    { return fVtxKineticEnergy; }
 
  262    inline void G4Track::SetVertexKineticEnergy(const G4double aValue)
 
  263    { fVtxKineticEnergy = aValue; }
 
  265    inline  const G4LogicalVolume* G4Track::GetLogicalVolumeAtVertex() const
 
  266    { return fpLVAtVertex; } 
 
  268    inline void G4Track::SetLogicalVolumeAtVertex(const G4LogicalVolume* aValue)
 
  269    { fpLVAtVertex = aValue; }
 
  271    inline const G4VProcess* G4Track::GetCreatorProcess() const
 
  272    { return fpCreatorProcess; }
 
  273      // If the pointer is 0, this means the track is created
 
  274      // by the event generator, i.e. the primary track.If it is not
 
  275      // 0, it points to the process which created this track.
 
  277    inline void G4Track::SetCreatorProcess(const G4VProcess* aValue)
 
  278    { fpCreatorProcess = aValue; }
 
  280    inline void G4Track::SetCreatorModelIndex(G4int idx)
 
  281    { fCreatorModelIndex = idx; }
 
  283    inline const G4String & G4Track::GetCreatorModelName() const
 
  284    { return G4PhysicsModelCatalog::GetModelName(fCreatorModelIndex); }
 
  286    inline G4int G4Track::GetCreatorModelID() const
 
  287    { return fCreatorModelIndex; }
 
  289 // flag for "Below Threshold"
 
  290    inline G4bool G4Track::IsBelowThreshold() const
 
  291    { return fBelowThreshold; }
 
  293    inline void    G4Track::SetBelowThresholdFlag(G4bool value)
 
  294    { fBelowThreshold = value; }
 
  296 // flag for " Good for Tracking"
 
  297    inline G4bool  G4Track::IsGoodForTracking() const
 
  298    { return fGoodForTracking; }
 
  300    inline void    G4Track::SetGoodForTrackingFlag(G4bool value)
 
  301    { fGoodForTracking = value; }
 
  304    inline void  G4Track::SetWeight(G4double aValue)
 
  305    { fWeight = aValue; }
 
  307    inline G4double G4Track::GetWeight() const
 
  311    inline G4VUserTrackInformation* G4Track::GetUserInformation() const
 
  312    { return fpUserInformation; }
 
  313    inline void G4Track::SetUserInformation(G4VUserTrackInformation* aValue)
 
  314    { fpUserInformation = aValue; }
 
  316    inline const G4Step* G4Track::GetStep() const
 
  319    inline void G4Track::SetStep(const G4Step* aValue)