ATLAS Offline Software
Loading...
Searching...
No Matches
StepHelper.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3*/
4
5
7
8#include "G4LogicalVolume.hh"
9#include "G4VPhysicalVolume.hh"
10#include "G4TouchableHistory.hh"
11#include "G4VProcess.hh"
12
13namespace G4StepHelper {
14G4ThreeVector preStepPosition(const G4Step* theStep)
15{
16 assert (theStep!=nullptr);
17 return theStep->GetPreStepPoint()->GetPosition();
18}
19G4ThreeVector postStepPosition(const G4Step* theStep)
20{
21 assert (theStep!=nullptr);
22 return theStep->GetPostStepPoint()->GetPosition();
23}
24std::string particleName(const G4Step* theStep)
25{
26 assert (theStep!=nullptr);
27 return theStep->GetTrack()->GetDefinition()->GetParticleName();
28}
29int particlePDGCode(const G4Step* theStep)
30{
31 assert (theStep!=nullptr);
32 return theStep->GetTrack()->GetDefinition()->GetPDGEncoding();
33}
34double depositedEnergy(const G4Step* theStep)
35{
36 assert (theStep!=nullptr);
37 return theStep->GetTotalEnergyDeposit();
38}
39G4LogicalVolume* getPreStepLogicalVolume(const G4Step* theStep, int iLevel)
40{
41 return getPreStepPhysicalVolume(theStep, iLevel)->GetLogicalVolume();
42}
43std::string getPreStepLogicalVolumeName(const G4Step* theStep, int iLevel)
44{
45 return getPreStepLogicalVolume(theStep, iLevel)->GetName();
46}
47G4VPhysicalVolume* getPreStepPhysicalVolume(const G4Step* theStep, int iLevel)
48{
49 const G4TouchableHistory *history
50 = static_cast<const G4TouchableHistory*>(theStep->GetPreStepPoint()->GetTouchable());
51 if (iLevel<=0)
52 {
53 return history->GetVolume(std::abs(iLevel));
54 }
55 const int nLev=history->GetHistoryDepth();
56 return history->GetVolume(nLev-iLevel);
57}
58G4LogicalVolume* getPostStepLogicalVolume(const G4Step* theStep, int iLevel)
59{
60 return getPostStepPhysicalVolume(theStep, iLevel)->GetLogicalVolume();
61}
62std::string getPostStepLogicalVolumeName(const G4Step* theStep, int iLevel)
63{
64 return getPostStepLogicalVolume(theStep, iLevel)->GetName();
65}
66G4VPhysicalVolume* getPostStepPhysicalVolume(const G4Step* theStep, int iLevel)
67{
68 const G4TouchableHistory *history
69 = static_cast<const G4TouchableHistory*>(theStep->GetPostStepPoint()->GetTouchable());
70 if (iLevel<=0)
71 {
72 return history->GetVolume(std::abs(iLevel));
73 }
74 const int nLev=history->GetHistoryDepth();
75 return history->GetVolume(nLev-iLevel);
76}
77int preStepBranchDepth(const G4Step* theStep)
78{
79 return static_cast<const G4TouchableHistory*>(theStep->GetPreStepPoint()->
80 GetTouchable())->GetHistoryDepth();
81}
82int postStepBranchDepth(const G4Step* theStep)
83{
84 return static_cast<const G4TouchableHistory*>(theStep->GetPostStepPoint()->
85 GetTouchable())->GetHistoryDepth();
86}
87const G4VProcess* getProcess(const G4Step* theStep)
88{
89 return theStep->GetPostStepPoint()->GetProcessDefinedStep();
90}
91
92std::string getProcessName(const G4Step* theStep)
93{
94 return getProcess(theStep)->GetProcessName();
95}
96
97G4int getProcessSubType(const G4Step* theStep)
98{
99 return getProcess(theStep)->GetProcessSubType();
100}
101}
helper functions to avoid having to play with the G4Step to retrieve relevant quantities.
Definition StepHelper.h:24
std::string getPreStepLogicalVolumeName(const G4Step *theStep, int iLevel=0)
TODO.
int particlePDGCode(const G4Step *theStep)
TODO.
double depositedEnergy(const G4Step *theStep)
TODO.
int postStepBranchDepth(const G4Step *theStep)
TODO.
G4VPhysicalVolume * getPreStepPhysicalVolume(const G4Step *theStep, int iLevel=0)
TODO.
G4ThreeVector preStepPosition(const G4Step *theStep)
TODO.
int preStepBranchDepth(const G4Step *theStep)
TODO.
const G4VProcess * getProcess(const G4Step *theStep)
TODO.
std::string particleName(const G4Step *theStep)
TODO.
G4ThreeVector postStepPosition(const G4Step *theStep)
TODO.
std::string getPostStepLogicalVolumeName(const G4Step *theStep, int iLevel=0)
TODO.
G4int getProcessSubType(const G4Step *theStep)
TODO.
G4LogicalVolume * getPreStepLogicalVolume(const G4Step *theStep, int iLevel=0)
TODO.
G4LogicalVolume * getPostStepLogicalVolume(const G4Step *theStep, int iLevel=0)
TODO.
std::string getProcessName(const G4Step *theStep)
TODO.
G4VPhysicalVolume * getPostStepPhysicalVolume(const G4Step *theStep, int iLevel=0)
TODO.