27#include <G4AffineTransform.hh>
28#include <G4Navigator.hh>
29#include <G4OpticalPhoton.hh>
30#include <G4ProcessManager.hh>
31#include <G4ProcessVector.hh>
32#include <G4SteppingManager.hh>
33#include <G4TransportationManager.hh>
34#include <G4TransportationProcessType.hh>
35#include <G4UImanager.hh>
36#include <G4UserLimits.hh>
37#include <G4VProcess.hh>
38#include <G4VTouchable.hh>
40#include <TLorentzVector.h>
41#include <TMCParticleStatus.h>
53 fLimitsModifiedOnFly(0),
57 fDivisionCopyNoOffset(0),
59 fInitialVMCTrackStatus(0)
68 "Cannot create two instances of singleton.");
80 if (userGeometry ==
"RootToGeant4" || userGeometry ==
"Geant4")
103 "TG4StepManager",
"CheckTrack",
"Track is not defined.");
123 "TG4StepManager", method,
"Gflash spot is not defined.");
134 "Stepping manager is not defined.");
139 G4ThreeVector xyz, G4double t, TLorentzVector& lv)
const
159 G4ReferenceCountedHandle<G4VTouchable> touchableHandle =
161 return touchableHandle();
164 return fTrack->GetTouchable();
166 return fTrack->GetNextTouchable();
171 G4int off, G4bool warn)
const
182 if (touchable->GetHistoryDepth() < off) {
184 TString text =
"level=";
187 "Volume " + TString(touchable->GetVolume()->GetName()) +
188 " has not defined mother in " + text +
".");
193 return touchable->GetVolume(off);
218 fTrack->SetTrackStatus(fStopAndKill);
224 "There is no current track to be stopped.");
234 fTrack->SetTrackStatus(fStopAndKill);
239 "There is no current track to be interrupted.");
249 fTrack->SetTrackStatus(fKillTrackAndSecondaries);
253 G4UImanager::GetUIpointer()->ApplyCommand(
"/event/abort");
264 G4UImanager::GetUIpointer()->ApplyCommand(
"/run/abort");
276 if (!userLimits)
return;
295 "TG4StepManager",
"SetMaxStepBack",
"No limits modified on fly found.");
330 fTrack->GetDynamicParticle()->GetDefinition();
371 return fGflashSpot->GetTouchableHandle()->GetVolume();
373 return fTrack->GetVolume();
375 return fTrack->GetNextVolume();
393 "TG4StepManager",
"Get current limits",
"User limits not defined.");
409 "TG4StepManager",
"CurrentVolID",
"No current physical volume found");
414 if (physVolume->IsParameterised() || physVolume->IsReplicated())
437 if (mother->IsParameterised() || mother->IsReplicated())
471 mother->GetLogicalVolume()->GetName());
491 G4int depth = touchable->GetHistoryDepth();
496 for (G4int i = 0; i < depth; i++) {
497 G4VPhysicalVolume* physVolume = touchable->GetHistory()->GetVolume(i);
516 Double_t& x, Double_t& y, Double_t& z)
const
520 G4Navigator* theNavigator =
521 G4TransportationManager::GetTransportationManager()
522 ->GetNavigatorForTracking();
525 G4ThreeVector theLocalNormal = theNavigator->GetLocalExitNormal(&valid);
526 if (!valid)
return false;
528 G4ThreeVector theGlobalNormal =
529 theNavigator->GetLocalToGlobalTransform().TransformAxis(theLocalNormal);
531 x = theGlobalNormal.x();
532 y = theGlobalNormal.y();
533 z = theGlobalNormal.z();
540 Float_t& a, Float_t& z, Float_t& dens, Float_t& radl, Float_t& absl)
const
552 G4Material* material = physVolume->GetLogicalVolume()->GetMaterial();
554 G4int nofElements = material->GetNumberOfElements();
556 a = geometryServices->
GetEffA(material);
557 z = geometryServices->
GetEffZ(material);
560 dens = material->GetDensity();
564 radl = material->GetRadlen();
595 Gmtod(dxm, dxd, iflag);
598 for (G4int i = 0; i < 3; i++) {
619 if (iflag != 1 && iflag != 2) {
620 TString text =
"iflag=";
623 "TG4StepManager",
"Gmtod", text +
" is different from 1..2.");
628 const G4AffineTransform& affineTransform =
633 G4ThreeVector theLocalPoint;
635 theLocalPoint = affineTransform.TransformPoint(theGlobalPoint);
638 theLocalPoint = affineTransform.TransformAxis(theGlobalPoint);
660 Gdtom(dxd, dxm, iflag);
663 for (G4int i = 0; i < 3; i++) {
683 if (iflag != 1 && iflag != 2) {
684 TString text =
"iflag=";
687 "TG4StepManager",
"Gmtod", text +
" is different from 1..2.");
692 const G4AffineTransform& affineTransform =
697 G4ThreeVector theGlobalPoint;
699 theGlobalPoint = affineTransform.TransformPoint(theLocalPoint);
702 theGlobalPoint = affineTransform.TransformAxis(theLocalPoint);
716 G4LogicalVolume* curLogVolume =
720 G4UserLimits* userLimits = curLogVolume->GetUserLimits();
723 if (userLimits == 0) {
725 "User Limits are not defined for the current logical volume " +
726 TString(curLogVolume->GetName()) +
".");
730 const G4Track& trackRef = *(
fTrack);
731 maxStep = userLimits->GetMaxAllowedStep(trackRef);
756 G4ThreeVector positionVector;
758 positionVector =
fGflashSpot->GetEnergySpot()->GetPosition();
763 positionVector =
fTrack->GetPosition();
768 G4double time =
fTrack->GetGlobalTime();
784 G4ThreeVector positionVector;
786 positionVector =
fGflashSpot->GetEnergySpot()->GetPosition();
791 positionVector =
fTrack->GetPosition();
795 x = positionVector.x();
796 y = positionVector.y();
797 z = positionVector.z();
809 x =
static_cast<float>(dx);
810 y =
static_cast<float>(dy);
811 z =
static_cast<float>(dz);
824 G4ThreeVector momentumVector =
fTrack->GetMomentum();
827 G4double energy =
fTrack->GetDynamicParticle()->GetTotalEnergy();
835 Double_t& px, Double_t& py, Double_t& pz, Double_t& etot)
const
844 G4ThreeVector momentumVector =
fTrack->GetMomentum();
847 px = momentumVector.x();
848 py = momentumVector.y();
849 pz = momentumVector.z();
851 etot =
fTrack->GetDynamicParticle()->GetTotalEnergy();
857 Float_t& px, Float_t& py, Float_t& pz, Float_t& etot)
const
862 Double_t dpx, dpy, dpz, detot;
865 px =
static_cast<float>(dpx);
866 py =
static_cast<float>(dpy);
867 pz =
static_cast<float>(dpz);
868 etot =
static_cast<float>(detot);
936 if (proc && physicsManager->
GetMCProcess(proc) == kPLightScattering &&
978 return fTrack->GetCurrentStepNumber();
988 return fTrack->GetWeight();
993 Double_t& polX, Double_t& polY, Double_t& polZ)
const
997 const G4ThreeVector& pol =
fTrack->GetPolarization();
1008 const G4ThreeVector& polG4 =
fTrack->GetPolarization();
1024 fTrack->GetDynamicParticle()->GetDefinition();
1033 if (pdgEncoding == 50000050) {
1052 return fTrack->GetDynamicParticle()->GetDefinition()->GetPDGCharge() /
1065 return fTrack->GetDynamicParticle()->GetDefinition()->GetPDGMass() /
1122 if (
fStep->GetPostStepPoint()->GetStepStatus() == fGeomBoundary)
1141 if (
fStep->GetPostStepPoint()->GetStepStatus() == fWorldBoundary)
1170 G4TrackStatus status =
fTrack->GetTrackStatus();
1171 if ((status == fStopAndKill) || (status == fKillTrackAndSecondaries) ||
1172 (status == fSuspend) || (status == fPostponeToNextEvent)) {
1191 G4TrackStatus status =
fTrack->GetTrackStatus();
1192 if ((status == fStopAndKill) || (status == fKillTrackAndSecondaries) ||
1193 (status == fPostponeToNextEvent)) {
1209 G4TrackStatus status =
fTrack->GetTrackStatus();
1210 if ((status == fAlive) || (status == fStopButAlive))
1239 G4int nofSecondaries = 0;
1244 return nofSecondaries;
1249 TLorentzVector& position, TLorentzVector& momentum)
1263 if (!nofSecondaries)
return;
1267 if (!secondaryTracks) {
1269 "TG4StepManager",
"GetSecondary",
"Secondary tracks vector is empty");
1272 if (index >= nofSecondaries) {
1274 "TG4StepManager",
"GetSecondary",
"Wrong secondary track index.");
1279 G4int startIndex = secondaryTracks->size() - nofSecondaries;
1282 G4Track* track = (*secondaryTracks)[startIndex + index];
1285 particleId = track->GetDynamicParticle()->GetDefinition()->GetPDGEncoding();
1288 G4ThreeVector positionVector = track->GetPosition();
1290 G4double time = track->GetGlobalTime();
1295 G4ThreeVector momentumVector = track->GetMomentum();
1297 G4double energy = track->GetDynamicParticle()->GetTotalEnergy();
1323 if (!secondaryTracks) {
1325 "TG4StepManager",
"ProdProcess",
"Secondary tracks vector is empty.");
1330 if (isec >= nofSecondaries) {
1332 "TG4StepManager",
"ProdProcess",
"Wrong secondary track index.");
1339 G4int startIndex = secondaryTracks->size() - nofSecondaries;
1344 G4Track* track = (*secondaryTracks)[startIndex + isec];
1346 const G4VProcess* kpProcess = track->GetCreatorProcess();
1351 if (mcProcess == kPEnergyLoss) mcProcess = kPDeltaRay;
1366 G4int nofProcesses = 1;
1367 processes.Set(nofProcesses);
1368 processes[0] = kPNull;
1369 return nofProcesses;
1382 G4ProcessVector* processVector =
fStep->GetTrack()
1384 ->GetProcessManager()
1385 ->GetAlongStepProcessVector();
1386 G4int nofAlongStep = processVector->entries();
1390 fStep->GetPostStepPoint()->GetProcessDefinedStep();
1393 processes.Set(nofAlongStep + 2);
1402 for (G4int i = 0; i < nofAlongStep; i++) {
1405 if (g4Process && g4Process->GetProcessSubType() != TRANSPORTATION)
1406 processes[counter++] = physicsManager->
GetMCProcess(g4Process);
1410 if (
fStep->GetTrack()->GetDefinition() == G4OpticalPhoton::Definition() &&
1411 kpLastProcess->GetProcessSubType() == TRANSPORTATION &&
1415 processes[counter++] = kPLightScattering;
1420 processes[counter++] = physicsManager->
GetMCProcess(kpLastProcess);
Definition of the TG4G3Units class.
Definition of the TG4GeometryServices class.
Definition of the TG4Globals class and basic container types.
Definition of the TG4Limits class.
Definition of the TG4ParticlesManager class.
Definition of the TG4PhysicsManager class.
Definition of the TG4SDServices class.
Definition of the TG4StepManager class.
@ kGflashSpot
in post step point with Gflash
@ kBoundary
when crossing geometrical boundary
@ kNormalStep
in post step point
Definition of the TG4SteppingAction class.
Definition of the TG4TrackManager class.
static G4double InverseLength()
static G4double InverseTime()
static G4double InverseEnergy()
static G4double MassDensity()
Services for accessing to Geant4 geometry.
G4double * CreateG4doubleArray(Float_t *array, G4int size, G4bool copyValues=true) const
const G4String & UserVolumeName(const G4String &name) const
static TG4GeometryServices * Instance()
TG4Limits * GetLimits(G4UserLimits *limits) const
G4double GetEffA(G4Material *material) const
G4double GetEffZ(G4Material *material) const
static void AppendNumberToString(G4String &string, G4int number)
static void Warning(const TString &className, const TString &methodName, const TString &text)
static void Exception(const TString &className, const TString &methodName, const TString &text)
Extended G4UserLimits class.
void SetMaxAllowedStepBack()
void SetCurrentMaxAllowedStep(G4double step)
G4int GetPDGEncoding(G4ParticleDefinition *particle)
static TG4ParticlesManager * Instance()
Geant4 implementation of the TVirtualMC interface methods for building Geant4 physics and access to i...
static TG4PhysicsManager * Instance()
G4bool IsOpBoundaryProcess() const
TMCProcess GetMCProcess(const G4VProcess *process)
TMCProcess GetOpBoundaryStatus()
G4int GetMediumID(G4LogicalVolume *volume) const
void SetIsStopRun(G4bool stopRun)
G4int GetVolumeID(const G4String &volumeName) const
static TG4SDServices * Instance()
Geant4 implementation of the TVirtualMC interface methods for access to Geant4 at step level.
const char * CurrentVolPath()
G4Track * fTrack
current track
Int_t CurrentMaterial(Float_t &a, Float_t &z, Float_t &dens, Float_t &radl, Float_t &absl) const
Int_t StepProcesses(TArrayI &proc) const
TMCProcess ProdProcess(Int_t isec) const
G4int fDivisionCopyNoOffset
division copy number offset
Int_t CurrentVolOffID(Int_t off, Int_t ©No) const
void TrackMomentum(TLorentzVector &momentum) const
const char * CurrentVolOffName(Int_t off) const
Bool_t IsTrackStop() const
Bool_t IsTrackDisappeared() const
Bool_t IsTrackEntering() const
Double_t TrackStep() const
TG4StepManager(const TString &userGeometry)
Double_t TrackTime() const
void SetMaxNStep(Int_t maxNofSteps)
const char * CurrentVolName() const
G4String fNameBuffer
buffer for current volume name or path
void GetSecondary(Int_t index, Int_t &particleId, TLorentzVector &position, TLorentzVector &momentum)
G4SteppingManager * fSteppingManager
G4SteppingManager.
TG4Limits * GetCurrentLimits() const
Double_t TrackMass() const
Int_t NSecondaries() const
Double_t NIELEdep() const
void CheckGflashSpot(const G4String &method) const
Bool_t CurrentBoundaryNormal(Double_t &x, Double_t &y, Double_t &z) const
Double_t TrackWeight() const
G4GFlashSpot * fGflashSpot
current Gflash spot
TG4TrackManager * fTrackManager
Cached pointer to thread-local track manager.
TG4StepStatus fStepStatus
step status
const G4VTouchable * GetCurrentTouchable() const
Int_t CurrentVolID(Int_t ©No) const
Bool_t IsTrackAlive() const
void CheckSteppingManager() const
Double_t TrackCharge() const
Int_t CurrentMedium() const
Double_t TrackLength() const
Bool_t IsTrackInside() const
static G4ThreadLocal TG4StepManager * fgInstance
this instance
Bool_t IsCollectTracks() const
void Gdtom(Double_t *xd, Double_t *xm, Int_t iflag)
G4int fCopyNoOffset
volume copy number offset
Bool_t IsNewTrack() const
Bool_t IsTrackOut() const
void CheckStep(const G4String &method) const
G4VPhysicalVolume * GetCurrentPhysicalVolume() const
TG4Limits * fLimitsModifiedOnFly
limits which step limit was modified during tracking
void SetTLorentzVector(G4ThreeVector xyz, G4double t, TLorentzVector &lv) const
Bool_t IsTrackExiting() const
void Gmtod(Double_t *xm, Double_t *xd, Int_t iflag)
TMCParticleStatus * fInitialVMCTrackStatus
The initial status of a VMC track when it was popped from the VMC stack.
void SetCollectTracks(Bool_t collectTracks)
void ForceDecayTime(Float_t pdg)
G4Step * fStep
current step
void TrackPolarization(Double_t &polX, Double_t &polY, Double_t &polZ) const
Int_t GetMaxNStep() const
G4VPhysicalVolume * GetCurrentOffPhysicalVolume(G4int off, G4bool warn=false) const
void TrackPosition(TLorentzVector &position) const
void SetInitialVMCTrackStatus(TMCParticleStatus *status)
void SetMaxStep(Double_t step)
void SetMaxNofSteps(G4int number)
void SetCollectTracks(G4bool collectTracks)
void ProcessTrackIfGeneralProcess(const G4Step *step)
G4bool GetCollectTracks() const
static TG4SteppingAction * Instance()
G4int GetMaxNofSteps() const
static TG4TrackManager * Instance()
TG4TrackInformation * GetTrackInformation(const G4Track *track) const