ATLAS Offline Software
VolumeTreeNavigator.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 // //
7 // VolumeTreeNavigator.h //
8 // Class containing functions to allow a general //
9 // navigation of uniquely specified GEANT4 volumes //
10 // and collection of their tree patterns and locations. //
11 // //
12 // Written by Kevin Sapp //
13 // University of Pittsburgh //
14 // kcs34@pitt.edu //
15 // Last update 02.02.10 //
16 // //
17 // //
19 
20 #ifndef VolumeTreeNavigator_H
21 #define VolumeTreeNavigator_H
22 
23 #include <string>
24 #include <vector>
25 #include <stdarg.h>
26 
28 
29 class G4Step;
30 class G4Track;
31 class G4StepPoint;
32 class G4TouchableHistory;
33 class G4VPhysicalVolume;
34 
35 typedef std::pair<G4VPhysicalVolume*,int> VolID;
36 typedef std::vector<VolID> VolTree;
38 
40  public:
41  VolumeTreeNavigator(const G4Step*);
42 
43  void SetDepthCutSimple(const int, const int, const int, const int);
44  void SetDepthCutDetail(const char*);
45  VolTree Extract();
46  bool Ascend(int levels = 1);
47  bool Descend(int levels = 1);
48  bool KillProcesses(const int, const char*, ...);
49 
51  G4VPhysicalVolume* GetVolume(int rel = 0) const;
52  int GetCopyNumber(int rel = 0) const;
53  const G4Track* GetTrack() const;
54  const G4StepPoint* GetPreStepPoint() const;
55  const G4StepPoint* GetPostStepPoint() const;
56  int GetStepNumber() const;
57  const VolTree& GetHistory() const;
58  int GetFullDepth() const;
59 
60  private:
61  G4Track* m_track;
62  G4StepPoint* m_preStepPoint;
63  G4StepPoint* m_postStepPoint;
64  const G4TouchableHistory* m_preHistory;
66 
70 };
71 
72 template <class T>
73 inline std::string stringify(T obj)
74 {
75  std::ostringstream ss;
76  ss << obj;
77  return ss.str();
78 }
79 
80 template<class T>
81 inline std::string cleanstr(T obj)
82 {
83  std::string s = stringify(obj);
84  std::string::size_type col = s.find_first_of(":");
85  while (col != std::string::npos) {
86  (s.substr(col,2) == "::") ? s.replace(col,2,"_") : s.replace(col,1,"-");
87  col = s.find_first_of(":");
88  }
89  std::string::size_type sp = s.find_first_of(" ");
90  while (sp != std::string::npos) {
91  s.erase(sp,1);
92  sp = s.find_first_of(" ");
93  }
94  return s;
95 }
96 
97 #include "VolumeTreeNavigator.icc"
98 #endif
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
VolumeTreeNavigator::GetStepNumber
int GetStepNumber() const
VolID
std::pair< G4VPhysicalVolume *, int > VolID
Definition: VolumeTreeNavigator.h:33
skel.rel
rel
Announce start of JO checkingrelease nimber checking.
Definition: skel.GENtoEVGEN.py:182
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
VolumeTreeNavigator::SetDepthCutSimple
void SetDepthCutSimple(const int, const int, const int, const int)
Definition: VolumeTreeNavigator.cxx:65
PowhegControl_ttHplus_NLO.ss
ss
Definition: PowhegControl_ttHplus_NLO.py:83
VolumeTreeNavigator::GetHistory
const VolTree & GetHistory() const
VolumeTreeNavigator::m_stepNo
int m_stepNo
depth of volume tree, step number
Definition: VolumeTreeNavigator.h:65
VolumeTreeNavigator::GetVolume
G4VPhysicalVolume * GetVolume(int rel=0) const
VolumeTreeNavigator
Definition: VolumeTreeNavigator.h:39
cleanstr
std::string cleanstr(T obj)
Definition: VolumeTreeNavigator.h:81
VolumeTreeNavigator::m_preHistory
const G4TouchableHistory * m_preHistory
touchable history containing current volume's history
Definition: VolumeTreeNavigator.h:64
VolumeTreeNavigator::m_preDepth
int m_preDepth
Definition: VolumeTreeNavigator.h:65
VolNav
VolTree::iterator VolNav
Definition: VolumeTreeNavigator.h:37
VolumeTreeNavigator::m_preStepPoint
G4StepPoint * m_preStepPoint
volume/process/etc.
Definition: VolumeTreeNavigator.h:62
VolumeTreeNavigator.icc
stringify
std::string stringify(T obj)
Definition: VolumeTreeNavigator.h:73
VolumeTreeNavigator::GetPostStepPoint
const G4StepPoint * GetPostStepPoint() const
AthMessaging
Class to provide easy MsgStream access and capabilities.
Definition: AthMessaging.h:55
VolumeTreeNavigator::m_postStepPoint
G4StepPoint * m_postStepPoint
volume/process/etc.
Definition: VolumeTreeNavigator.h:63
VolumeTreeNavigator::GetFullDepth
int GetFullDepth() const
VolumeTreeNavigator::m_h_end
VolNav m_h_end
specifies cut termination in history
Definition: VolumeTreeNavigator.h:68
VolumeTreeNavigator::SetDepthCutDetail
void SetDepthCutDetail(const char *)
Definition: VolumeTreeNavigator.cxx:88
VolumeTreeNavigator::GetTrack
const G4Track * GetTrack() const
VolumeTreeNavigator::GetCopyNumber
int GetCopyNumber(int rel=0) const
VolumeTreeNavigator::KillProcesses
bool KillProcesses(const int, const char *,...)
Definition: VolumeTreeNavigator.cxx:160
VolTree
std::vector< VolID > VolTree
Definition: VolumeTreeNavigator.h:36
VolumeTreeNavigator::Descend
bool Descend(int levels=1)
Definition: VolumeTreeNavigator.cxx:146
query_example.col
col
Definition: query_example.py:7
VolumeTreeNavigator::VolumeTreeNavigator
VolumeTreeNavigator(const G4Step *)
Definition: VolumeTreeNavigator.cxx:35
VolumeTreeNavigator::m_history
VolTree m_history
full volume history, cast as const after preparation
Definition: VolumeTreeNavigator.h:67
AthMessaging.h
VolumeTreeNavigator::Ascend
bool Ascend(int levels=1)
Definition: VolumeTreeNavigator.cxx:133
VolumeTreeNavigator::Extract
VolTree Extract()
Definition: VolumeTreeNavigator.cxx:122
VolumeTreeNavigator::GetCurrentDepth
int GetCurrentDepth()
VolumeTreeNavigator::GetPreStepPoint
const G4StepPoint * GetPreStepPoint() const
VolumeTreeNavigator::m_h_nav
VolNav m_h_nav
VolTree iterator with no access below cut.
Definition: VolumeTreeNavigator.h:69
python.PyAthena.obj
obj
Definition: PyAthena.py:135
TSU::T
unsigned long long T
Definition: L1TopoDataTypes.h:35
VolumeTreeNavigator::m_track
G4Track * m_track
current track
Definition: VolumeTreeNavigator.h:61