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// G4Step inline methods implementation
29// Katsuya Amako (e-mail: Katsuya.Amako@kek.jp)
30// Takashi Sasaki (e-mail: Takashi.Sasaki@kek.jp)
32// Hisaya Kurashige, 1998-2007
33// --------------------------------------------------------------------
35inline G4StepPoint* G4Step::GetPreStepPoint() const
37 return fpPreStepPoint;
40inline void G4Step::SetPreStepPoint(G4StepPoint* value)
42 delete fpPreStepPoint;
43 fpPreStepPoint = value;
46inline G4StepPoint* G4Step::GetPostStepPoint() const
48 return fpPostStepPoint;
51inline void G4Step::SetPostStepPoint(G4StepPoint* value)
53 delete fpPostStepPoint;
54 fpPostStepPoint = value;
57inline G4double G4Step::GetStepLength() const
62inline void G4Step::SetStepLength(G4double value)
67inline G4ThreeVector G4Step::GetDeltaPosition() const
69 return fpPostStepPoint->GetPosition() - fpPreStepPoint->GetPosition();
72inline G4double G4Step::GetDeltaTime() const
74 return fpPostStepPoint->GetLocalTime() - fpPreStepPoint->GetLocalTime();
77inline G4double G4Step::GetTotalEnergyDeposit() const
79 return fTotalEnergyDeposit;
82inline void G4Step::SetTotalEnergyDeposit(G4double value)
84 fTotalEnergyDeposit = value;
87inline G4double G4Step::GetNonIonizingEnergyDeposit() const
89 return fNonIonizingEnergyDeposit;
92inline void G4Step::SetNonIonizingEnergyDeposit(G4double value)
94 fNonIonizingEnergyDeposit = value;
97inline void G4Step::AddTotalEnergyDeposit(G4double value)
99 fTotalEnergyDeposit += value;
102inline void G4Step::ResetTotalEnergyDeposit()
104 fTotalEnergyDeposit = 0.;
105 fNonIonizingEnergyDeposit = 0.;
108inline void G4Step::AddNonIonizingEnergyDeposit(G4double value)
110 fNonIonizingEnergyDeposit += value;
113inline void G4Step::ResetNonIonizingEnergyDeposit()
115 fNonIonizingEnergyDeposit = 0.;
118inline void G4Step::SetControlFlag(G4SteppingControl value)
120 fpSteppingControlFlag = value;
123inline G4SteppingControl G4Step::GetControlFlag() const
125 return fpSteppingControlFlag;
128inline void G4Step::CopyPostToPreStepPoint()
130 // This method is called at the beginning of each step
131 *(fpPreStepPoint) = *(fpPostStepPoint);
132 fpPostStepPoint->SetStepStatus(fUndefined);
134 // store number of secondaries
135 nSecondaryByLastStep = fSecondary->size();
138//-------------------------------------------------------------
139// To implement bi-directional association between G4Step and
140// and G4Track, a combined usage of 'forward declaration' and
141// 'include' is necessary.
142//-------------------------------------------------------------
145inline G4Track* G4Step::GetTrack() const
150inline void G4Step::SetTrack(G4Track* value)
155inline void G4Step::InitializeStep(G4Track* aValue)
158 fpTrack->SetStepLength(0.);
160 // Initialize G4Step attributes
162 fTotalEnergyDeposit = 0.;
163 fNonIonizingEnergyDeposit = 0.;
165 nSecondaryByLastStep = 0;
167 // Initialize G4StepPoint attributes.
168 // To avoid the circular dependency between G4Track, G4Step
169 // and G4StepPoint, G4Step has to manage the copy actions.
171 fpPreStepPoint->SetSafety(0.0);
172 fpPreStepPoint->SetProcessDefinedStep(0);
173 fpPreStepPoint->SetStepStatus(fUndefined);
175 // G4Track properties
177 fpPreStepPoint->SetWeight(fpTrack->GetWeight());
178 fpPreStepPoint->SetPosition(fpTrack->GetPosition());
179 fpPreStepPoint->SetLocalTime(fpTrack->GetLocalTime());
180 fpPreStepPoint->SetGlobalTime(fpTrack->GetGlobalTime());
182 // G4Track properties (via G4DynamicParticle)
184 auto pParticle = fpTrack->GetDynamicParticle();
186 fpPreStepPoint->SetMass(pParticle->GetMass());
187 fpPreStepPoint->SetCharge(pParticle->GetCharge());
188 fpPreStepPoint->SetProperTime(pParticle->GetProperTime());
189 fpPreStepPoint->SetKineticEnergy(pParticle->GetKineticEnergy());
190 fpPreStepPoint->SetMomentumDirection(pParticle->GetMomentumDirection());
191 fpPreStepPoint->SetPolarization(pParticle->GetPolarization());
193 // G4Track properties (via G4LogicalVolume)
195 auto lvol = fpTrack->GetTouchable()->GetVolume()->GetLogicalVolume();
197 fpPreStepPoint->SetTouchableHandle(fpTrack->GetTouchableHandle());
199 fpPreStepPoint->SetMaterial(lvol->GetMaterial());
200 fpPreStepPoint->SetMaterialCutsCouple(lvol->GetMaterialCutsCouple());
201 fpPreStepPoint->SetSensitiveDetector(lvol->GetSensitiveDetector());
203 // SetVelocity() must be called after SetMaterial() for fpPreStepPoint.
204 fpPreStepPoint->SetVelocity(fpTrack->CalculateVelocity());
206 (*fpPostStepPoint) = (*fpPreStepPoint);
209inline void G4Step::UpdateTrack()
211 // To avoid the circular dependency between G4Track, G4Step
212 // and G4StepPoint, G4Step has to manage the update actions.
214 fpTrack->SetPosition(fpPostStepPoint->GetPosition());
215 fpTrack->SetGlobalTime(fpPostStepPoint->GetGlobalTime());
216 fpTrack->SetLocalTime(fpPostStepPoint->GetLocalTime());
217 // mass, charge, proper time
218 G4DynamicParticle* pParticle =
219 (G4DynamicParticle*) (fpTrack->GetDynamicParticle());
220 pParticle->SetMass(fpPostStepPoint->GetMass());
221 pParticle->SetCharge(fpPostStepPoint->GetCharge());
222 pParticle->SetProperTime(fpPostStepPoint->GetProperTime());
223 // energy, momentum, polarization
224 pParticle->SetMomentumDirection(fpPostStepPoint->GetMomentumDirection());
225 pParticle->SetKineticEnergy(fpPostStepPoint->GetKineticEnergy());
226 pParticle->SetPolarization(fpPostStepPoint->GetPolarization());
228 fpTrack->SetStepLength(fStepLength);
229 // NextTouchable is updated
230 // (G4Track::Touchable points touchable of Pre-StepPoint)
231 fpTrack->SetNextTouchableHandle(fpPostStepPoint->GetTouchableHandle());
232 fpTrack->SetWeight(fpPostStepPoint->GetWeight());
235 fpTrack->SetVelocity(fpPostStepPoint->GetVelocity());
238inline std::size_t G4Step::GetNumberOfSecondariesInCurrentStep() const
240 return fSecondary->size() - nSecondaryByLastStep;
243inline const G4TrackVector* G4Step::GetSecondary() const
248inline G4TrackVector* G4Step::GetfSecondary()
253inline void G4Step::SetSecondary(G4TrackVector* value)
258inline G4TrackVector* G4Step::NewSecondaryVector()
260 fSecondary = new G4TrackVector();
264inline void G4Step::DeleteSecondaryVector()
266 if(fSecondary != nullptr)
270 fSecondary = nullptr;
274inline G4bool G4Step::IsFirstStepInVolume() const
276 return fFirstStepInVolume;
279inline G4bool G4Step::IsLastStepInVolume() const
281 return fLastStepInVolume;
284inline void G4Step::SetFirstStepFlag()
286 fFirstStepInVolume = true;
289inline void G4Step::ClearFirstStepFlag()
291 fFirstStepInVolume = false;
294inline void G4Step::SetLastStepFlag()
296 fLastStepInVolume = true;
299inline void G4Step::ClearLastStepFlag()
301 fLastStepInVolume = false;
305G4Step::SetPointerToVectorOfAuxiliaryPoints(std::vector<G4ThreeVector>* vec)
307 fpVectorOfAuxiliaryPointsPointer = vec;
310inline std::vector<G4ThreeVector>*
311G4Step::GetPointerToVectorOfAuxiliaryPoints() const
313 return fpVectorOfAuxiliaryPointsPointer;