ATLAS Offline Software
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 
13 namespace G4StepHelper {
14 G4ThreeVector preStepPosition(const G4Step* theStep)
15 {
16  assert (theStep!=nullptr);
17  return theStep->GetPreStepPoint()->GetPosition();
18 }
19 G4ThreeVector postStepPosition(const G4Step* theStep)
20 {
21  assert (theStep!=nullptr);
22  return theStep->GetPostStepPoint()->GetPosition();
23 }
24 std::string particleName(const G4Step* theStep)
25 {
26  assert (theStep!=nullptr);
27  return theStep->GetTrack()->GetDefinition()->GetParticleName();
28 }
29 int particlePDGCode(const G4Step* theStep)
30 {
31  assert (theStep!=nullptr);
32  return theStep->GetTrack()->GetDefinition()->GetPDGEncoding();
33 }
34 double depositedEnergy(const G4Step* theStep)
35 {
36  assert (theStep!=nullptr);
37  return theStep->GetTotalEnergyDeposit();
38 }
39 G4LogicalVolume* getPreStepLogicalVolume(const G4Step* theStep, int iLevel)
40 {
41  return getPreStepPhysicalVolume(theStep, iLevel)->GetLogicalVolume();
42 }
43 std::string getPreStepLogicalVolumeName(const G4Step* theStep, int iLevel)
44 {
45  return getPreStepLogicalVolume(theStep, iLevel)->GetName();
46 }
47 G4VPhysicalVolume* 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 }
58 G4LogicalVolume* getPostStepLogicalVolume(const G4Step* theStep, int iLevel)
59 {
60  return getPostStepPhysicalVolume(theStep, iLevel)->GetLogicalVolume();
61 }
62 std::string getPostStepLogicalVolumeName(const G4Step* theStep, int iLevel)
63 {
64  return getPostStepLogicalVolume(theStep, iLevel)->GetName();
65 }
66 G4VPhysicalVolume* 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 }
77 int preStepBranchDepth(const G4Step* theStep)
78 {
79  return static_cast<const G4TouchableHistory*>(theStep->GetPreStepPoint()->
80  GetTouchable())->GetHistoryDepth();
81 }
82 int postStepBranchDepth(const G4Step* theStep)
83 {
84  return static_cast<const G4TouchableHistory*>(theStep->GetPostStepPoint()->
85  GetTouchable())->GetHistoryDepth();
86 }
87 const G4VProcess* getProcess(const G4Step* theStep)
88 {
89  return theStep->GetPostStepPoint()->GetProcessDefinedStep();
90 }
91 
92 std::string getProcessName(const G4Step* theStep)
93 {
94  return getProcess(theStep)->GetProcessName();
95 }
96 
97 G4int getProcessSubType(const G4Step* theStep)
98 {
99  return getProcess(theStep)->GetProcessSubType();
100 }
101 }
G4StepHelper::getProcess
const G4VProcess * getProcess(const G4Step *theStep)
TODO.
Definition: StepHelper.cxx:87
G4StepHelper::getPreStepLogicalVolume
G4LogicalVolume * getPreStepLogicalVolume(const G4Step *theStep, int iLevel=0)
TODO.
Definition: StepHelper.cxx:39
G4StepHelper::getPreStepPhysicalVolume
G4VPhysicalVolume * getPreStepPhysicalVolume(const G4Step *theStep, int iLevel=0)
TODO.
Definition: StepHelper.cxx:47
G4StepHelper::preStepBranchDepth
int preStepBranchDepth(const G4Step *theStep)
TODO.
Definition: StepHelper.cxx:77
G4StepHelper::postStepBranchDepth
int postStepBranchDepth(const G4Step *theStep)
TODO.
Definition: StepHelper.cxx:82
StepHelper.h
G4StepHelper::particleName
std::string particleName(const G4Step *theStep)
TODO.
Definition: StepHelper.cxx:24
G4StepHelper::getPreStepLogicalVolumeName
std::string getPreStepLogicalVolumeName(const G4Step *theStep, int iLevel=0)
TODO.
Definition: StepHelper.cxx:43
G4StepHelper::getProcessName
std::string getProcessName(const G4Step *theStep)
TODO.
Definition: StepHelper.cxx:92
G4StepHelper::getProcessSubType
G4int getProcessSubType(const G4Step *theStep)
TODO.
Definition: StepHelper.cxx:97
G4StepHelper::getPostStepLogicalVolume
G4LogicalVolume * getPostStepLogicalVolume(const G4Step *theStep, int iLevel=0)
TODO.
Definition: StepHelper.cxx:58
G4StepHelper::getPostStepPhysicalVolume
G4VPhysicalVolume * getPostStepPhysicalVolume(const G4Step *theStep, int iLevel=0)
TODO.
Definition: StepHelper.cxx:66
G4StepHelper
helper functions to avoid having to play with the G4Step to retrieve relevant quantities.
Definition: StepHelper.h:24
G4StepHelper::getPostStepLogicalVolumeName
std::string getPostStepLogicalVolumeName(const G4Step *theStep, int iLevel=0)
TODO.
Definition: StepHelper.cxx:62
G4StepHelper::particlePDGCode
int particlePDGCode(const G4Step *theStep)
TODO.
Definition: StepHelper.cxx:29
G4StepHelper::preStepPosition
G4ThreeVector preStepPosition(const G4Step *theStep)
TODO.
Definition: StepHelper.cxx:14
G4StepHelper::postStepPosition
G4ThreeVector postStepPosition(const G4Step *theStep)
TODO.
Definition: StepHelper.cxx:19
G4StepHelper::depositedEnergy
double depositedEnergy(const G4Step *theStep)
TODO.
Definition: StepHelper.cxx:34