// // ******************************************************************** // * License and Disclaimer * // * * // * The Geant4 software is copyright of the Copyright Holders of * // * the Geant4 Collaboration. It is provided under the terms and * // * conditions of the Geant4 Software License, included in the file * // * LICENSE and available at http://cern.ch/geant4/license . These * // * include a list of copyright holders. * // * * // * Neither the authors of this software system, nor their employing * // * institutes,nor the agencies providing financial support for this * // * work make any representation or warranty, express or implied, * // * regarding this software system or assume any liability for its * // * use. Please see the license in the file LICENSE and URL above * // * for the full disclaimer and the limitation of liability. * // * * // * This code implementation is the result of the scientific and * // * technical work of the GEANT4 collaboration. * // * By using, copying, modifying or distributing the software (or * // * any work based on the software) you agree to acknowledge its * // * use in resulting scientific publications, and indicate your * // * acceptance of all terms of the Geant4 Software license. * // ******************************************************************** // // G4Step inline methods implementation // // Authors: // Katsuya Amako (e-mail: Katsuya.Amako@kek.jp) // Takashi Sasaki (e-mail: Takashi.Sasaki@kek.jp) // Revisions: // Hisaya Kurashige, 1998-2007 // -------------------------------------------------------------------- inline G4StepPoint* G4Step::GetPreStepPoint() const { return fpPreStepPoint; } inline void G4Step::SetPreStepPoint(G4StepPoint* value) { delete fpPreStepPoint; fpPreStepPoint = value; } inline G4StepPoint* G4Step::ResetPreStepPoint(G4StepPoint* value) { G4StepPoint* previousSP = fpPreStepPoint; fpPreStepPoint = value; return previousSP; } inline G4StepPoint* G4Step::GetPostStepPoint() const { return fpPostStepPoint; } inline void G4Step::SetPostStepPoint(G4StepPoint* value) { delete fpPostStepPoint; fpPostStepPoint = value; } inline G4StepPoint* G4Step::ResetPostStepPoint(G4StepPoint* value) { G4StepPoint* previousSP = fpPostStepPoint; fpPostStepPoint = value; return previousSP; } inline G4double G4Step::GetStepLength() const { return fStepLength; } inline void G4Step::SetStepLength(G4double value) { fStepLength = value; } inline G4ThreeVector G4Step::GetDeltaPosition() const { return fpPostStepPoint->GetPosition() - fpPreStepPoint->GetPosition(); } inline G4double G4Step::GetDeltaTime() const { return fpPostStepPoint->GetLocalTime() - fpPreStepPoint->GetLocalTime(); } inline G4double G4Step::GetTotalEnergyDeposit() const { return fTotalEnergyDeposit; } inline void G4Step::SetTotalEnergyDeposit(G4double value) { fTotalEnergyDeposit = value; } inline G4double G4Step::GetNonIonizingEnergyDeposit() const { return fNonIonizingEnergyDeposit; } inline void G4Step::SetNonIonizingEnergyDeposit(G4double value) { fNonIonizingEnergyDeposit = value; } inline void G4Step::AddTotalEnergyDeposit(G4double value) { fTotalEnergyDeposit += value; } inline void G4Step::ResetTotalEnergyDeposit() { fTotalEnergyDeposit = 0.; fNonIonizingEnergyDeposit = 0.; } inline void G4Step::AddNonIonizingEnergyDeposit(G4double value) { fNonIonizingEnergyDeposit += value; } inline void G4Step::ResetNonIonizingEnergyDeposit() { fNonIonizingEnergyDeposit = 0.; } inline G4double G4Step::GetDeltaEnergy() const { return fpPostStepPoint->GetKineticEnergy() - fpPreStepPoint->GetKineticEnergy(); } inline G4ThreeVector G4Step::GetDeltaMomentum() const { return fpPostStepPoint->GetMomentum() - fpPreStepPoint->GetMomentum(); } inline void G4Step::SetControlFlag(G4SteppingControl value) { fpSteppingControlFlag = value; } inline G4SteppingControl G4Step::GetControlFlag() const { return fpSteppingControlFlag; } inline void G4Step::CopyPostToPreStepPoint() { // This method is called at the beginning of each step *(fpPreStepPoint) = *(fpPostStepPoint); fpPostStepPoint->SetStepStatus(fUndefined); // store number of secondaries nSecondaryByLastStep = fSecondary->size(); } //------------------------------------------------------------- // To implement bi-directional association between G4Step and // and G4Track, a combined usage of 'forward declaration' and // 'include' is necessary. //------------------------------------------------------------- #include "G4Track.hh" inline G4Track* G4Step::GetTrack() const { return fpTrack; } inline void G4Step::SetTrack(G4Track* value) { fpTrack = value; } inline void G4Step::InitializeStep(G4Track* aValue) { fpTrack = aValue; fpTrack->SetStepLength(0.); // Initialize G4Step attributes fStepLength = 0.; fTotalEnergyDeposit = 0.; fNonIonizingEnergyDeposit = 0.; nSecondaryByLastStep = 0; // Initialize G4StepPoint attributes. // To avoid the circular dependency between G4Track, G4Step // and G4StepPoint, G4Step has to manage the copy actions. // fpPreStepPoint->SetSafety(0.0); fpPreStepPoint->SetProcessDefinedStep(nullptr); fpPreStepPoint->SetStepStatus(fUndefined); // G4Track properties fpPreStepPoint->SetWeight(fpTrack->GetWeight()); fpPreStepPoint->SetPosition(fpTrack->GetPosition()); fpPreStepPoint->SetLocalTime(fpTrack->GetLocalTime()); fpPreStepPoint->SetGlobalTime(fpTrack->GetGlobalTime()); // G4Track properties (via G4DynamicParticle) auto pParticle = fpTrack->GetDynamicParticle(); fpPreStepPoint->SetMass(pParticle->GetMass()); fpPreStepPoint->SetCharge(pParticle->GetCharge()); fpPreStepPoint->SetProperTime(pParticle->GetProperTime()); fpPreStepPoint->SetKineticEnergy(pParticle->GetKineticEnergy()); fpPreStepPoint->SetMomentumDirection(pParticle->GetMomentumDirection()); fpPreStepPoint->SetPolarization(pParticle->GetPolarization()); // G4Track properties (via G4LogicalVolume) auto lvol = fpTrack->GetTouchable()->GetVolume()->GetLogicalVolume(); fpPreStepPoint->SetTouchableHandle(fpTrack->GetTouchableHandle()); fpPreStepPoint->SetMaterial(lvol->GetMaterial()); fpPreStepPoint->SetMaterialCutsCouple(lvol->GetMaterialCutsCouple()); fpPreStepPoint->SetSensitiveDetector(lvol->GetSensitiveDetector()); // SetVelocity() must be called after SetMaterial() for fpPreStepPoint. fpPreStepPoint->SetVelocity(fpTrack->CalculateVelocity()); (*fpPostStepPoint) = (*fpPreStepPoint); } inline void G4Step::UpdateTrack() { // To avoid the circular dependency between G4Track, G4Step // and G4StepPoint, G4Step has to manage the update actions. // position, time fpTrack->SetPosition(fpPostStepPoint->GetPosition()); fpTrack->SetGlobalTime(fpPostStepPoint->GetGlobalTime()); fpTrack->SetLocalTime(fpPostStepPoint->GetLocalTime()); // mass, charge, proper time auto* pParticle = (G4DynamicParticle*) (fpTrack->GetDynamicParticle()); pParticle->SetMass(fpPostStepPoint->GetMass()); pParticle->SetCharge(fpPostStepPoint->GetCharge()); pParticle->SetProperTime(fpPostStepPoint->GetProperTime()); // energy, momentum, polarization pParticle->SetMomentumDirection(fpPostStepPoint->GetMomentumDirection()); pParticle->SetKineticEnergy(fpPostStepPoint->GetKineticEnergy()); pParticle->SetPolarization(fpPostStepPoint->GetPolarization()); // step length fpTrack->SetStepLength(fStepLength); // NextTouchable is updated // (G4Track::Touchable points touchable of Pre-StepPoint) fpTrack->SetNextTouchableHandle(fpPostStepPoint->GetTouchableHandle()); fpTrack->SetWeight(fpPostStepPoint->GetWeight()); // set velocity fpTrack->SetVelocity(fpPostStepPoint->GetVelocity()); } inline std::size_t G4Step::GetNumberOfSecondariesInCurrentStep() const { return fSecondary->size() - nSecondaryByLastStep; } inline const G4TrackVector* G4Step::GetSecondary() const { return fSecondary; } inline G4TrackVector* G4Step::GetfSecondary() { return fSecondary; } inline void G4Step::SetSecondary(G4TrackVector* value) { fSecondary = value; } inline G4TrackVector* G4Step::NewSecondaryVector() { fSecondary = new G4TrackVector(); return fSecondary; } inline void G4Step::DeleteSecondaryVector() { if(fSecondary != nullptr) { fSecondary->clear(); delete fSecondary; fSecondary = nullptr; } } inline G4bool G4Step::IsFirstStepInVolume() const { return fFirstStepInVolume; } inline G4bool G4Step::IsLastStepInVolume() const { return fLastStepInVolume; } inline void G4Step::SetFirstStepFlag() { fFirstStepInVolume = true; } inline void G4Step::ClearFirstStepFlag() { fFirstStepInVolume = false; } inline void G4Step::SetLastStepFlag() { fLastStepInVolume = true; } inline void G4Step::ClearLastStepFlag() { fLastStepInVolume = false; } inline void G4Step::SetPointerToVectorOfAuxiliaryPoints(std::vector* vec) { fpVectorOfAuxiliaryPointsPointer = vec; } inline std::vector* G4Step::GetPointerToVectorOfAuxiliaryPoints() const { return fpVectorOfAuxiliaryPointsPointer; }