1//------------------------------------------------
2// The Geant4 Virtual Monte Carlo package
3// Copyright (C) 2007 - 2014 Ivana Hrivnacova
6// For the licensing terms see geant4_vmc/LICENSE.
7// Contact: root-vmc@cern.ch
8//-------------------------------------------------
11/// \brief Implementation of the inline functions for the TGeant4
14/// \author I. Hrivnacova; IPN Orsay
16#include "TG4Globals.h"
17#include "TG4StepManager.h"
19#include <G4Threading.hh>
22// methods for step management
25//_____________________________________________________________________________
26inline TGeant4* TGeant4::MasterInstance() { return fgMasterInstance; }
28//_____________________________________________________________________________
29inline TVirtualMCApplication* TGeant4::MasterApplicationInstance()
31 return fgMasterApplicationInstance;
34//_____________________________________________________________________________
35inline void TGeant4::StopTrack()
39 fStepManager->StopTrack();
42//_____________________________________________________________________________
43inline void TGeant4::InterruptTrack()
47 fStepManager->InterruptTrack();
50//_____________________________________________________________________________
51inline void TGeant4::StopEvent()
53 /// Aborts the current event processing.
55 fStepManager->StopEvent();
58//_____________________________________________________________________________
59inline void TGeant4::StopRun()
61 /// Aborts the current run processing.
63 fStepManager->StopRun();
66//_____________________________________________________________________________
67inline void TGeant4::SetMaxStep(Double_t step)
69 /// Sets the maximum step allowed in the current logical volume.
71 fStepManager->SetMaxStep(step);
74//_____________________________________________________________________________
75inline void TGeant4::SetMaxNStep(Int_t number)
77 /// Sets the maximum number of steps.
79 fStepManager->SetMaxNStep(number);
82//_____________________________________________________________________________
83inline void TGeant4::ForceDecayTime(Float_t time)
85 /// Force decay time. \n Not yet implemented.
87 fStepManager->ForceDecayTime(time);
90//_____________________________________________________________________________
91inline Int_t TGeant4::CurrentVolID(Int_t& copyNo) const
93 /// Return the current sensitive detector ID
94 /// and the copy number of the current physical volume.
96 return fStepManager->CurrentVolID(copyNo);
99//_____________________________________________________________________________
100inline Int_t TGeant4::CurrentVolOffID(Int_t off, Int_t& copyNo) const
102 /// Returns the off-th mother's of the current volume
103 /// the sensitive detector ID and the copy number.
105 return fStepManager->CurrentVolOffID(off, copyNo);
108//_____________________________________________________________________________
109inline const char* TGeant4::CurrentVolName() const
111 /// Returns the current physical volume name.
113 return fStepManager->CurrentVolName();
116//_____________________________________________________________________________
117inline const char* TGeant4::CurrentVolOffName(Int_t off) const
119 /// Returns the off-th mother's physical volume name.
121 return fStepManager->CurrentVolOffName(off);
124//_____________________________________________________________________________
125inline const char* TGeant4::CurrentVolPath()
127 /// Returns the current volume path.
129 return fStepManager->CurrentVolPath();
132//_____________________________________________________________________________
133inline Bool_t TGeant4::CurrentBoundaryNormal(
134 Double_t& x, Double_t& y, Double_t& z) const
136 /// Returns the normal vector of the surface of the last volume exited
138 return fStepManager->CurrentBoundaryNormal(x, y, z);
141//_____________________________________________________________________________
142inline Int_t TGeant4::CurrentMaterial(
143 Float_t& a, Float_t& z, Float_t& dens, Float_t& radl, Float_t& absl) const
145 /// Returns the parameters of the current material during transport;
146 /// the return value is the number of elements in the mixture.
148 return fStepManager->CurrentMaterial(a, z, dens, radl, absl);
151//_____________________________________________________________________________
152inline Int_t TGeant4::CurrentMedium() const
154 /// Returns the second index of the current material (corresponding to
155 /// G3 tracking medium index).
157 return fStepManager->CurrentMedium();
160//_____________________________________________________________________________
161inline Int_t TGeant4::GetMedium() const
163 /// Returns the second index of the current material (corresponding to
164 /// G3 tracking medium index).
166 TG4Globals::Warning("TGeant4", "GetMedium",
167 "Deprecated function - use CurrentMedium() instead");
169 return CurrentMedium();
172//_____________________________________________________________________________
173inline void TGeant4::Gmtod(Float_t* xm, Float_t* xd, Int_t iflag)
175 /// Transforms a position from the world reference frame
176 /// to the current volume reference frame.
178 fStepManager->Gmtod(xm, xd, iflag);
181//_____________________________________________________________________________
182inline void TGeant4::Gmtod(Double_t* xm, Double_t* xd, Int_t iflag)
184 /// Transforms a position from the world reference frame
185 /// to the current volume reference frame.
187 fStepManager->Gmtod(xm, xd, iflag);
190//_____________________________________________________________________________
191inline void TGeant4::Gdtom(Float_t* xd, Float_t* xm, Int_t iflag)
193 /// Transforms a position from the current volume reference frame
194 /// to the world reference frame.
196 fStepManager->Gdtom(xd, xm, iflag);
199//_____________________________________________________________________________
200inline void TGeant4::Gdtom(Double_t* xd, Double_t* xm, Int_t iflag)
202 /// Transforms a position from the current volume reference frame
203 /// to the world reference frame.
205 fStepManager->Gdtom(xd, xm, iflag);
208//_____________________________________________________________________________
209inline Double_t TGeant4::MaxStep() const
211 /// Returns the maximum step allowed in the current logical volume
214 return fStepManager->MaxStep();
217//_____________________________________________________________________________
218inline Int_t TGeant4::GetMaxNStep() const
220 /// Returns the maximum number of steps.
222 return fStepManager->GetMaxNStep();
225//_____________________________________________________________________________
226inline void TGeant4::TrackPosition(TLorentzVector& position) const
228 /// The current particle position (in the world reference frame)
229 /// and the local time since the current track is created
230 /// (position of the PostStepPoint).
232 fStepManager->TrackPosition(position);
235//_____________________________________________________________________________
236inline void TGeant4::TrackPosition(Double_t& x, Double_t& y, Double_t& z) const
238 /// The current particle position (in the world reference frame)
239 /// and the local time since the current track is created
240 /// (position of the PostStepPoint).
242 fStepManager->TrackPosition(x, y, z);
245//_____________________________________________________________________________
246inline void TGeant4::TrackPosition(Float_t& x, Float_t& y, Float_t& z) const
248 /// The current particle position (in the world reference frame)
249 /// and the local time since the current track is created
250 /// (position of the PostStepPoint) as float.
252 fStepManager->TrackPosition(x, y, z);
255//_____________________________________________________________________________
256inline void TGeant4::TrackMomentum(TLorentzVector& momentum) const
258 /// The current particle "momentum" (px, py, pz, Etot).
260 fStepManager->TrackMomentum(momentum);
263//_____________________________________________________________________________
264inline void TGeant4::TrackMomentum(
265 Double_t& px, Double_t& py, Double_t& pz, Double_t& etot) const
267 /// The current particle "momentum" (px, py, pz, Etot).
269 fStepManager->TrackMomentum(px, py, pz, etot);
272//_____________________________________________________________________________
273inline void TGeant4::TrackMomentum(
274 Float_t& px, Float_t& py, Float_t& pz, Float_t& etot) const
276 /// The current particle "momentum" (px, py, pz, Etot) as float.
278 fStepManager->TrackMomentum(px, py, pz, etot);
281//_____________________________________________________________________________
282inline Double_t TGeant4::TrackStep() const
284 /// Returns the current step length.
286 return fStepManager->TrackStep();
289//_____________________________________________________________________________
290inline Double_t TGeant4::TrackLength() const
292 /// Returns the length of the current track from its origin.
294 return fStepManager->TrackLength();
297//_____________________________________________________________________________
298inline Double_t TGeant4::TrackTime() const
300 /// Returns the local time since the current track is created. \n Comment: in
301 /// Geant4: there is also defined proper time as the proper time of the
302 /// dynamical particle of the current track.
304 return fStepManager->TrackTime();
307//_____________________________________________________________________________
308inline Double_t TGeant4::Edep() const
310 /// Returns the total energy deposit in this step.
312 return fStepManager->Edep();
315//_____________________________________________________________________________
316inline Double_t TGeant4::NIELEdep() const
318 /// Returns the total energy deposit in this step.
320 return fStepManager->NIELEdep();
323//_____________________________________________________________________________
324inline Int_t TGeant4::StepNumber() const
326 /// Returns the current step number.
328 return fStepManager->StepNumber();
331//_____________________________________________________________________________
332inline Double_t TGeant4::TrackWeight() const
334 /// Returns the current weight.
336 return fStepManager->TrackWeight();
339//_____________________________________________________________________________
340inline void TGeant4::TrackPolarization(
341 Double_t& polX, Double_t& polY, Double_t& polZ) const
343 /// Returns the current polarization.
345 fStepManager->TrackPolarization(polX, polY, polZ);
348//_____________________________________________________________________________
349inline void TGeant4::TrackPolarization(TVector3& pol) const
351 /// Returns the current polarization.
353 fStepManager->TrackPolarization(pol);
356//_____________________________________________________________________________
357inline Int_t TGeant4::TrackPid() const
359 /// Returns the current particle PDG encoding.
361 return fStepManager->TrackPid();
364//_____________________________________________________________________________
365inline Double_t TGeant4::TrackCharge() const
367 /// Returns the current particle charge.
369 return fStepManager->TrackCharge();
372//_____________________________________________________________________________
373inline Double_t TGeant4::TrackMass() const
375 /// Returns the current particle mass at rest.
377 return fStepManager->TrackMass();
380//_____________________________________________________________________________
381inline Double_t TGeant4::Etot() const
383 /// Returns the total energy of the current particle.
385 return fStepManager->Etot();
388//_____________________________________________________________________________
389inline Bool_t TGeant4::IsTrackInside() const
391 /// Returns true if the particle does not cross a geometrical boundary
392 /// and is not in the vertex.
394 return fStepManager->IsTrackInside();
397//_____________________________________________________________________________
398inline Bool_t TGeant4::IsTrackEntering() const
400 /// Returns true if the particle crosses a geometrical boundary
401 /// or is in the vertex.
403 return fStepManager->IsTrackEntering();
406//_____________________________________________________________________________
407inline Bool_t TGeant4::IsTrackExiting() const
409 /// Returns true if the particle crosses a geometrical boundary.
411 return fStepManager->IsTrackExiting();
414//_____________________________________________________________________________
415inline Bool_t TGeant4::IsTrackOut() const
417 /// Returns true if the particle crosses the world boundary
418 /// at the post-step point.
420 return fStepManager->IsTrackOut();
423//_____________________________________________________________________________
424inline Bool_t TGeant4::IsTrackDisappeared() const
426 /// Returns true if particle has disappeared
427 /// (due to any physical process)
428 /// or has been killed, suspended or postponed to next event.
430 return fStepManager->IsTrackDisappeared();
433//_____________________________________________________________________________
434inline Bool_t TGeant4::IsTrackStop() const
436 /// Returns true if the particle has stopped
437 /// or has been killed, suspended or postponed to the next event.
439 return fStepManager->IsTrackStop();
442//_____________________________________________________________________________
443inline Bool_t TGeant4::IsTrackAlive() const
445 /// Returns true if particle continues tracking.
447 return fStepManager->IsTrackAlive();
450//_____________________________________________________________________________
451inline Bool_t TGeant4::IsNewTrack() const
453 /// Returns true when the track performs the first step.
455 return fStepManager->IsNewTrack();
458//_____________________________________________________________________________
459inline Int_t TGeant4::NSecondaries() const
461 /// Returns the number of secondary particles generated
462 /// in the current step.
464 return fStepManager->NSecondaries();
467//_____________________________________________________________________________
468inline void TGeant4::GetSecondary(Int_t isec, Int_t& particleId,
469 TLorentzVector& position, TLorentzVector& momentum)
471 /// Fills the parameters (particle encoding, position, momentum)
472 /// of the generated secondary particle which is specified by index.
474 fStepManager->GetSecondary(isec, particleId, position, momentum);
477//_____________________________________________________________________________
478inline TMCProcess TGeant4::ProdProcess(Int_t isec) const
480 /// Returns the process that has produced the secondary particles specified
481 /// with isec index in the current step.
483 return fStepManager->ProdProcess(isec);
486//_____________________________________________________________________________
487inline Int_t TGeant4::StepProcesses(TArrayI& proc) const
489 /// Fills the array of processes that were active in the current step
490 /// and returns the number of them.
492 return fStepManager->StepProcesses(proc);
495//_____________________________________________________________________________
496inline Bool_t TGeant4::IsMT() const
498 /// Returns true if Geant4 is built in multi-threading mode and
499 /// MT mode is not inactivated in runConfiguration.