Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:59:13

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 // G4Track inline methods implementation
0027 //
0028 // Author: Katsuya Amako, KEK - 1996
0029 // Revisions: Hisaya Kurashige, 1998-2011
0030 // --------------------------------------------------------------------
0031 
0032 extern G4TRACK_DLL G4Allocator<G4Track>*& aTrackAllocator();
0033 
0034 //-------------------------------------------------------------
0035 // To implement bi-directional association between G4Step and
0036 // and G4Track, a combined usage of 'forward declaration' and
0037 // 'include' is necessary.
0038 //-------------------------------------------------------------
0039 #include "G4Step.hh"
0040 
0041 inline void* G4Track::operator new(std::size_t)
0042 {
0043   if(aTrackAllocator() == nullptr)
0044   {
0045     aTrackAllocator() = new G4Allocator<G4Track>;
0046   }
0047   return (void*) aTrackAllocator()->MallocSingle();
0048 }
0049 
0050 inline void G4Track::operator delete(void* aTrack)
0051 {
0052   aTrackAllocator()->FreeSingle((G4Track*) aTrack);
0053 }
0054 
0055 inline G4bool G4Track::operator==(const G4Track& trk)
0056 {
0057   return (this == &trk);
0058 }
0059 
0060 inline G4bool G4Track::operator!=(const G4Track& trk)
0061 {
0062   return (this != &trk);
0063 }
0064 
0065 // dynamic particle
0066 inline const G4DynamicParticle* G4Track::GetDynamicParticle() const
0067 {
0068   return fpDynamicParticle;
0069 }
0070 
0071 // particle definition
0072 inline G4ParticleDefinition* G4Track::GetDefinition() const
0073 {
0074   return fpDynamicParticle->GetDefinition();
0075 }
0076 
0077 // particle definition
0078 inline const G4ParticleDefinition* G4Track::GetParticleDefinition() const
0079 {
0080   return fpDynamicParticle->GetParticleDefinition();
0081 }
0082 
0083 // parent track ID
0084 inline G4int G4Track::GetParentID() const
0085 {
0086   return fParentID;
0087 }
0088 
0089 inline void G4Track::SetParentID(const G4int aValue)
0090 {
0091   fParentID = aValue;
0092 }
0093 
0094 // current track ID
0095 inline G4int G4Track::GetTrackID() const
0096 {
0097   return fTrackID;
0098 }
0099 
0100 inline void G4Track::SetTrackID(const G4int aValue)
0101 {
0102   fTrackID = aValue;
0103 }
0104 
0105 // position
0106 inline const G4ThreeVector& G4Track::GetPosition() const
0107 {
0108   return fPosition;
0109 }
0110 
0111 inline void G4Track::SetPosition(const G4ThreeVector& aValue)
0112 {
0113   fPosition = aValue;
0114 }
0115 
0116 // global time
0117 inline G4double G4Track::GetGlobalTime() const
0118 {
0119   return fGlobalTime;
0120 }
0121 
0122 inline void G4Track::SetGlobalTime(const G4double aValue)
0123 {
0124   fGlobalTime = aValue;
0125 }
0126 
0127 // local time
0128 inline G4double G4Track::GetLocalTime() const
0129 {
0130   return fLocalTime;
0131 }
0132 
0133 inline void G4Track::SetLocalTime(const G4double aValue)
0134 {
0135   fLocalTime = aValue;
0136 }
0137 
0138 // proper time
0139 inline G4double G4Track::GetProperTime() const
0140 {
0141   return fpDynamicParticle->GetProperTime();
0142 }
0143 
0144 inline void G4Track::SetProperTime(const G4double aValue)
0145 {
0146   fpDynamicParticle->SetProperTime(aValue);
0147 }
0148 
0149 // velocity
0150 inline G4double G4Track::GetVelocity() const
0151 {
0152   return (useGivenVelocity) ? fVelocity
0153                             : ((!is_OpticalPhoton)
0154                                  ? CLHEP::c_light * fpDynamicParticle->GetBeta()
0155                                  : CalculateVelocityForOpticalPhoton());
0156 }
0157 
0158 inline G4double G4Track::CalculateVelocity() const
0159 {
0160   return GetVelocity();
0161 }
0162 
0163 inline void G4Track::SetVelocity(G4double val)
0164 {
0165   fVelocity = val;
0166 }
0167 
0168 inline G4bool G4Track::UseGivenVelocity() const
0169 {
0170   return useGivenVelocity;
0171 }
0172 
0173 inline void G4Track::UseGivenVelocity(G4bool val)
0174 {
0175   useGivenVelocity = val;
0176 }
0177 
0178 // volume
0179 inline G4VPhysicalVolume* G4Track::GetVolume() const
0180 {
0181   return (fpTouchable) ? fpTouchable->GetVolume() : nullptr;
0182 }
0183 
0184 inline G4VPhysicalVolume* G4Track::GetNextVolume() const
0185 {
0186   return (fpNextTouchable) ? fpNextTouchable->GetVolume() : nullptr;
0187 }
0188 
0189 // material - assuming that the pointer to G4Step is defined
0190 inline const G4MaterialCutsCouple* G4Track::GetMaterialCutsCouple() const
0191 {
0192   return fpStep->GetPreStepPoint()->GetMaterialCutsCouple();
0193 }
0194 
0195 inline const G4MaterialCutsCouple* G4Track::GetNextMaterialCutsCouple() const
0196 {
0197   return fpStep->GetPostStepPoint()->GetMaterialCutsCouple();
0198 }
0199 
0200 inline G4Material* G4Track::GetMaterial() const
0201 {
0202   return fpStep->GetPreStepPoint()->GetMaterial();
0203 }
0204 
0205 inline G4Material* G4Track::GetNextMaterial() const
0206 {
0207   return fpStep->GetPostStepPoint()->GetMaterial();
0208 }
0209 
0210 // touchable
0211 inline const G4VTouchable* G4Track::GetTouchable() const
0212 {
0213   return fpTouchable();
0214 }
0215 
0216 inline const G4TouchableHandle& G4Track::GetTouchableHandle() const
0217 {
0218   return fpTouchable;
0219 }
0220 
0221 inline void G4Track::SetTouchableHandle(const G4TouchableHandle& apValue)
0222 {
0223   fpTouchable = apValue;
0224 }
0225 
0226 inline const G4VTouchable* G4Track::GetNextTouchable() const
0227 {
0228   return fpNextTouchable();
0229 }
0230 
0231 inline const G4TouchableHandle& G4Track::GetNextTouchableHandle() const
0232 {
0233   return fpNextTouchable;
0234 }
0235 
0236 inline void G4Track::SetNextTouchableHandle(const G4TouchableHandle& apValue)
0237 {
0238   fpNextTouchable = apValue;
0239 }
0240 
0241 inline const G4VTouchable* G4Track::GetOriginTouchable() const
0242 {
0243   return fpOriginTouchable();
0244 }
0245 
0246 inline const G4TouchableHandle& G4Track::GetOriginTouchableHandle() const
0247 {
0248   return fpOriginTouchable;
0249 }
0250 
0251 inline void G4Track::SetOriginTouchableHandle(const G4TouchableHandle& apValue)
0252 {
0253   fpOriginTouchable = apValue;
0254 }
0255 
0256 // kinetic energy
0257 inline G4double G4Track::GetKineticEnergy() const
0258 {
0259   return fpDynamicParticle->GetKineticEnergy();
0260 }
0261 
0262 inline void G4Track::SetKineticEnergy(const G4double aValue)
0263 {
0264   fpDynamicParticle->SetKineticEnergy(aValue);
0265 }
0266 
0267 // total energy
0268 inline G4double G4Track::GetTotalEnergy() const
0269 {
0270   return fpDynamicParticle->GetTotalEnergy();
0271 }
0272 
0273 // momentum
0274 inline G4ThreeVector G4Track::GetMomentum() const
0275 {
0276   return fpDynamicParticle->GetMomentum();
0277 }
0278 
0279 // momentum (direction)
0280 inline const G4ThreeVector& G4Track::GetMomentumDirection() const
0281 {
0282   return fpDynamicParticle->GetMomentumDirection();
0283 }
0284 
0285 inline void G4Track::SetMomentumDirection(const G4ThreeVector& aValue)
0286 {
0287   fpDynamicParticle->SetMomentumDirection(aValue);
0288 }
0289 
0290 // polarization
0291 inline const G4ThreeVector& G4Track::GetPolarization() const
0292 {
0293   return fpDynamicParticle->GetPolarization();
0294 }
0295 
0296 inline void G4Track::SetPolarization(const G4ThreeVector& aValue)
0297 {
0298   fpDynamicParticle->SetPolarization(aValue);
0299 }
0300 
0301 // track status
0302 inline G4TrackStatus G4Track::GetTrackStatus() const
0303 {
0304   return fTrackStatus;
0305 }
0306 
0307 inline void G4Track::SetTrackStatus(const G4TrackStatus aTrackStatus)
0308 {
0309   fTrackStatus = aTrackStatus;
0310 }
0311 
0312 // track length
0313 inline G4double G4Track::GetTrackLength() const
0314 {
0315   return fTrackLength;
0316 }
0317 
0318 inline void G4Track::AddTrackLength(const G4double aValue)
0319 {
0320   fTrackLength += aValue;
0321 }
0322 // Accumulated track length
0323 
0324 // step number
0325 inline G4int G4Track::GetCurrentStepNumber() const
0326 {
0327   return fCurrentStepNumber;
0328 }
0329 
0330 inline void G4Track::IncrementCurrentStepNumber()
0331 {
0332   ++fCurrentStepNumber;
0333 }
0334 
0335 // step length
0336 inline G4double G4Track::GetStepLength() const
0337 {
0338   return fStepLength;
0339 }
0340 
0341 inline void G4Track::SetStepLength(G4double value)
0342 {
0343   fStepLength = value;
0344 }
0345 
0346 // vertex (where this track was created) information
0347 inline const G4ThreeVector& G4Track::GetVertexPosition() const
0348 {
0349   return fVtxPosition;
0350 }
0351 
0352 inline void G4Track::SetVertexPosition(const G4ThreeVector& aValue)
0353 {
0354   fVtxPosition = aValue;
0355 }
0356 
0357 inline const G4ThreeVector& G4Track::GetVertexMomentumDirection() const
0358 {
0359   return fVtxMomentumDirection;
0360 }
0361 
0362 inline void G4Track::SetVertexMomentumDirection(const G4ThreeVector& aValue)
0363 {
0364   fVtxMomentumDirection = aValue;
0365 }
0366 
0367 inline G4double G4Track::GetVertexKineticEnergy() const
0368 {
0369   return fVtxKineticEnergy;
0370 }
0371 
0372 inline void G4Track::SetVertexKineticEnergy(const G4double aValue)
0373 {
0374   fVtxKineticEnergy = aValue;
0375 }
0376 
0377 inline const G4LogicalVolume* G4Track::GetLogicalVolumeAtVertex() const
0378 {
0379   return fpLVAtVertex;
0380 }
0381 
0382 inline void G4Track::SetLogicalVolumeAtVertex(const G4LogicalVolume* aValue)
0383 {
0384   fpLVAtVertex = aValue;
0385 }
0386 
0387 inline const G4VProcess* G4Track::GetCreatorProcess() const
0388 {
0389  // If the pointer is null, this means the track is created
0390  // by the event generator, i.e. the primary track. If it is not
0391  // null, it points to the process which created this track.
0392 
0393   return fpCreatorProcess;
0394 }
0395 
0396 inline void G4Track::SetCreatorProcess(const G4VProcess* aValue)
0397 {
0398   fpCreatorProcess = aValue;
0399 }
0400 
0401 inline void G4Track::SetCreatorModelID(const G4int id)
0402 {
0403   fCreatorModelID = id;
0404 }
0405 
0406 inline G4int G4Track::GetCreatorModelID() const
0407 {
0408   return fCreatorModelID;
0409 }
0410 
0411 inline G4int G4Track::GetCreatorModelIndex() const 
0412 {
0413   return G4PhysicsModelCatalog::GetModelIndex(fCreatorModelID);
0414 }
0415 
0416 inline const G4String G4Track::GetCreatorModelName() const
0417 {
0418   return G4PhysicsModelCatalog::GetModelNameFromID(fCreatorModelID);
0419 }
0420 
0421 inline const G4ParticleDefinition* G4Track::GetParentResonanceDef() const
0422 {
0423   return fParentResonanceDef;
0424 }
0425 
0426 inline void G4Track::SetParentResonanceDef(const G4ParticleDefinition* parentDef)
0427 {
0428   fParentResonanceDef = parentDef;
0429 }
0430 
0431 inline G4int G4Track::GetParentResonanceID() const
0432 {
0433   return fParentResonanceID;
0434 }
0435 
0436 inline void G4Track::SetParentResonanceID(const G4int parentID)
0437 {
0438   fParentResonanceID = parentID;
0439 }
0440 
0441 inline G4bool G4Track::HasParentResonance() const {
0442   return ( fParentResonanceDef != nullptr );
0443 }
0444 
0445 inline G4int G4Track::GetParentResonancePDGEncoding() const {
0446   return ( fParentResonanceDef == nullptr ? 0 : fParentResonanceDef->GetPDGEncoding() );
0447 }
0448 
0449 inline G4String G4Track::GetParentResonanceName() const {
0450   return ( fParentResonanceDef == nullptr ? G4String() : fParentResonanceDef->GetParticleName() );
0451 }
0452 
0453 inline G4double G4Track::GetParentResonanceMass() const {
0454   return fParentResonanceID * CLHEP::keV;  // the ID is the mass of the resonance in eV
0455 }
0456 
0457 // flag for "Below Threshold"
0458 inline G4bool G4Track::IsBelowThreshold() const
0459 {
0460   return fBelowThreshold;
0461 }
0462 
0463 inline void G4Track::SetBelowThresholdFlag(G4bool value)
0464 {
0465   fBelowThreshold = value;
0466 }
0467 
0468 // flag for " Good for Tracking"
0469 inline G4bool G4Track::IsGoodForTracking() const
0470 {
0471   return fGoodForTracking;
0472 }
0473 
0474 inline void G4Track::SetGoodForTrackingFlag(G4bool value)
0475 {
0476   fGoodForTracking = value;
0477 }
0478 
0479 // track weight
0480 inline void G4Track::SetWeight(G4double aValue)
0481 {
0482   fWeight = aValue;
0483 }
0484 
0485 inline G4double G4Track::GetWeight() const
0486 {
0487   return fWeight;
0488 }
0489 
0490 // user information
0491 inline G4VUserTrackInformation* G4Track::GetUserInformation() const
0492 {
0493   return fpUserInformation;
0494 }
0495 
0496 inline void G4Track::SetUserInformation(G4VUserTrackInformation* aValue) const
0497 {
0498   fpUserInformation = aValue;
0499 }
0500 
0501 inline const G4Step* G4Track::GetStep() const
0502 {
0503   return fpStep;
0504 }
0505 
0506 inline void G4Track::SetStep(const G4Step* aValue)
0507 {
0508   fpStep = aValue;
0509 }
0510 
0511 inline std::map<G4int, G4VAuxiliaryTrackInformation*>*
0512            G4Track::GetAuxiliaryTrackInformationMap() const
0513 {
0514   return fpAuxiliaryTrackInformationMap;
0515 }