ATLAS Offline Software
Loading...
Searching...
No Matches
VolumeTreeNavigator Class Reference

#include <VolumeTreeNavigator.h>

Inheritance diagram for VolumeTreeNavigator:
Collaboration diagram for VolumeTreeNavigator:

Public Member Functions

 VolumeTreeNavigator (const G4Step *)
void SetDepthCutSimple (const int, const int, const int, const int)
void SetDepthCutDetail (const char *)
VolTree Extract ()
bool Ascend (int levels=1)
bool Descend (int levels=1)
bool KillProcesses (const int, const char *,...)
int GetCurrentDepth ()
G4VPhysicalVolume * GetVolume (int rel=0) const
int GetCopyNumber (int rel=0) const
const G4Track * GetTrack () const
const G4StepPoint * GetPreStepPoint () const
const G4StepPoint * GetPostStepPoint () const
int GetStepNumber () const
const VolTreeGetHistory () const
int GetFullDepth () const
bool msgLvl (const MSG::Level lvl) const
 Test the output level.
MsgStream & msg () const
 The standard message stream.
MsgStream & msg (const MSG::Level lvl) const
 The standard message stream.
void setLevel (MSG::Level lvl)
 Change the current logging level.

Private Member Functions

void initMessaging () const
 Initialize our message level and MessageSvc.

Private Attributes

G4Track * m_track
 current track
G4StepPoint * m_preStepPoint
 volume/process/etc.
G4StepPoint * m_postStepPoint
 volume/process/etc.
const G4TouchableHistory * m_preHistory
 touchable history containing current volume's history
int m_preDepth
int m_stepNo
 depth of volume tree, step number
VolTree m_history
 full volume history, cast as const after preparation
VolNav m_h_end
 specifies cut termination in history
VolNav m_h_nav
 VolTree iterator with no access below cut.
std::string m_nm
 Message source name.
boost::thread_specific_ptr< MsgStream > m_msg_tls
 MsgStream instance (a std::cout like with print-out levels)
std::atomic< IMessageSvc * > m_imsg { nullptr }
 MessageSvc pointer.
std::atomic< MSG::Level > m_lvl { MSG::NIL }
 Current logging level.
std::atomic_flag m_initialized ATLAS_THREAD_SAFE = ATOMIC_FLAG_INIT
 Messaging initialized (initMessaging)

Detailed Description

Definition at line 39 of file VolumeTreeNavigator.h.

Constructor & Destructor Documentation

◆ VolumeTreeNavigator()

VolumeTreeNavigator::VolumeTreeNavigator ( const G4Step * aStep)

Definition at line 35 of file VolumeTreeNavigator.cxx.

35 :
36 AthMessaging("VolumeTreeNavigator"),
38
39{
40 // collect full set of volume tree data
41 m_track = aStep->GetTrack();
42 m_preStepPoint = aStep->GetPreStepPoint();
43 m_postStepPoint = aStep->GetPostStepPoint();
44 m_preHistory = dynamic_cast<const G4TouchableHistory*>(m_preStepPoint->GetTouchable());
45 m_preDepth = m_preHistory->GetHistoryDepth();
46 m_stepNo = m_track->GetCurrentStepNumber();
47
48 if (!m_history.empty()) m_history.clear();
49
50 // consolidate volume data into a vector
51 for (G4int c = m_preDepth; c + 1 != 0; c--) {
52 G4VPhysicalVolume* thPV = m_preHistory->GetVolume(c);
53 int thPVRep = (int)(thPV->GetCopyNo());
54 pair<G4VPhysicalVolume*, int> thPVID = make_pair(thPV, thPVRep);
55 m_history.push_back(thPVID);
56 }
57 ATH_MSG_DEBUG("history size: "<< m_history.size());
58
59 // Set h_end to specify full history unless otherwise chosen by DepthCut functions, and
60 // set h_nav to start at the lowest accessible level, h_end - 1.
61 m_h_end = m_history.end();
62 m_h_nav = m_h_end-1;
63}
#define ATH_MSG_DEBUG(x)
AthMessaging()
Default constructor:
int m_stepNo
depth of volume tree, step number
VolNav m_h_end
specifies cut termination in history
VolTree m_history
full volume history, cast as const after preparation
G4Track * m_track
current track
const G4TouchableHistory * m_preHistory
touchable history containing current volume's history
G4StepPoint * m_preStepPoint
volume/process/etc.
G4StepPoint * m_postStepPoint
volume/process/etc.
VolNav m_h_nav
VolTree iterator with no access below cut.

Member Function Documentation

◆ Ascend()

bool VolumeTreeNavigator::Ascend ( int levels = 1)

Definition at line 133 of file VolumeTreeNavigator.cxx.

133 {
134 // Move up # of levels given in the navigable history, stop at Atlas::Atlas
135 if ( !m_history.empty() )
136 {
137 if ( distance( m_history.begin(), m_h_nav ) == 0 || levels == 0 ) return 0;
138 else if ( abs(levels) > abs(distance( m_history.begin(), m_h_nav )) )
139 levels = abs(distance( m_history.begin(), m_h_nav ));
140 advance(m_h_nav, -abs(levels));
141 return 1;
142 }
143 else return 0;
144}
float distance(const Amg::Vector3D &p1, const Amg::Vector3D &p2)
calculates the distance between two point in 3D space

◆ Descend()

bool VolumeTreeNavigator::Descend ( int levels = 1)

Definition at line 146 of file VolumeTreeNavigator.cxx.

147{
148 // Move down # of levels given in the navigable history
149 if ( !m_history.empty() )
150 {
151 if ( distance(m_h_nav, m_h_end) == 1 || levels == 0 ) return 0;
152 else if ( abs(levels) > abs(distance( m_h_nav, m_h_end-1 )) )
153 levels = abs(distance( m_h_nav, m_h_end-1 ));
154 advance(m_h_nav, abs(levels));
155 return 1;
156 }
157 else return 0;
158}

◆ Extract()

VolTree VolumeTreeNavigator::Extract ( )

Definition at line 122 of file VolumeTreeNavigator.cxx.

123{
124 // Derive a permanent VolTree object from the current volume and its history
125 VolTree ret;
126 for (VolNav t = m_history.begin(); t != m_h_nav+1; ++t) {
127 ret.push_back(*t);
128 }
129 ATH_MSG_DEBUG("VolumeTreeNavigator::Extract succeeded for "<< m_h_nav->first->GetName() <<".");
130 return ret;
131}
std::vector< VolID > VolTree
VolTree::iterator VolNav

◆ GetCopyNumber()

int VolumeTreeNavigator::GetCopyNumber ( int rel = 0) const

◆ GetCurrentDepth()

int VolumeTreeNavigator::GetCurrentDepth ( )

◆ GetFullDepth()

int VolumeTreeNavigator::GetFullDepth ( ) const

◆ GetHistory()

const VolTree & VolumeTreeNavigator::GetHistory ( ) const

◆ GetPostStepPoint()

const G4StepPoint * VolumeTreeNavigator::GetPostStepPoint ( ) const

◆ GetPreStepPoint()

const G4StepPoint * VolumeTreeNavigator::GetPreStepPoint ( ) const

◆ GetStepNumber()

int VolumeTreeNavigator::GetStepNumber ( ) const

◆ GetTrack()

const G4Track * VolumeTreeNavigator::GetTrack ( ) const

◆ GetVolume()

G4VPhysicalVolume * VolumeTreeNavigator::GetVolume ( int rel = 0) const

◆ initMessaging()

void AthMessaging::initMessaging ( ) const
privateinherited

Initialize our message level and MessageSvc.

This method should only be called once.

Definition at line 39 of file AthMessaging.cxx.

40{
42 // If user did not set an explicit level, set a default
43 if (m_lvl == MSG::NIL) {
44 m_lvl = m_imsg ?
45 static_cast<MSG::Level>( m_imsg.load()->outputLevel(m_nm) ) :
46 MSG::INFO;
47 }
48}
std::string m_nm
Message source name.
std::atomic< IMessageSvc * > m_imsg
MessageSvc pointer.
std::atomic< MSG::Level > m_lvl
Current logging level.
IMessageSvc * getMessageSvc(bool quiet=false)

◆ KillProcesses()

bool VolumeTreeNavigator::KillProcesses ( const int numProc,
const char * pr1,
... )

Definition at line 160 of file VolumeTreeNavigator.cxx.

161{
162 // Checks for disallowed processes, and if found returns true; accepts arbitrary number
163 // of process names.
164 const G4VProcess* pds = m_postStepPoint->GetProcessDefinedStep();
165 va_list procs;
166
167 if ( pds ) {
168 std::string name_string = stringify( pds->GetProcessName() );
169 const char* name = name_string.c_str();
170 va_start(procs, pr1);
171 for ( int i = 0; i != numProc; i++ ) {
172 if ( name == va_arg(procs, const char*) ) {
173 ATH_MSG_DEBUG(name <<" process triggered - return");
174 va_end(procs);
175 return 1;
176 }
177 }
178 va_end(procs);
179 }
180 return 0;
181}
std::string stringify(T obj)

◆ msg() [1/2]

MsgStream & AthMessaging::msg ( ) const
inlineinherited

The standard message stream.

Returns a reference to the default message stream May not be invoked before sysInitialize() has been invoked.

Definition at line 163 of file AthMessaging.h.

164{
165 MsgStream* ms = m_msg_tls.get();
166 if (!ms) {
167 if (!m_initialized.test_and_set()) initMessaging();
168 ms = new MsgStream(m_imsg,m_nm);
169 m_msg_tls.reset( ms );
170 }
171
172 ms->setLevel (m_lvl);
173 return *ms;
174}
boost::thread_specific_ptr< MsgStream > m_msg_tls
MsgStream instance (a std::cout like with print-out levels)
void initMessaging() const
Initialize our message level and MessageSvc.

◆ msg() [2/2]

MsgStream & AthMessaging::msg ( const MSG::Level lvl) const
inlineinherited

The standard message stream.

Returns a reference to the default message stream May not be invoked before sysInitialize() has been invoked.

Definition at line 178 of file AthMessaging.h.

179{ return msg() << lvl; }
MsgStream & msg() const
The standard message stream.

◆ msgLvl()

bool AthMessaging::msgLvl ( const MSG::Level lvl) const
inlineinherited

Test the output level.

Parameters
lvlThe message level to test against
Returns
boolean Indicating if messages at given level will be printed
Return values
trueMessages at level "lvl" will be printed

Definition at line 151 of file AthMessaging.h.

152{
153 if (m_lvl <= lvl) {
154 msg() << lvl;
155 return true;
156 } else {
157 return false;
158 }
159}

◆ SetDepthCutDetail()

void VolumeTreeNavigator::SetDepthCutDetail ( const char * cpath)

Definition at line 88 of file VolumeTreeNavigator.cxx.

89{
90 static const vector<string> volumes = [&]() {
91 vector<string> v;
92 msg() << MSG::INFO <<"SetDepthCutDetail path parsed as ";
93 string path = stringify(cpath);
94 string::size_type slash = 0;
95 string::size_type start = path.find_first_not_of( '/' );
96 while ( slash != string::npos ) {
97 start = slash+1;
98 slash = path.find_first_of( '/', start );
99 v.push_back( path.substr(start, slash-start) );
100 msg() << MSG::INFO <<"/"<<volumes.back();
101 }
102 msg() << endmsg;
103 return v;
104 }();
105
107 vector<string>::const_iterator v_nav = volumes.begin();
108 advance( v_nav, distance( m_history.begin(), m_h_nav ) );
109 while ( v_nav != volumes.end() && m_h_nav != m_history.end() ) {
110 if ( *v_nav == stringify( m_h_nav->first->GetName() ) ) {
111 ++m_h_nav;
112 ++v_nav; }
113 else {
114 break; }
115 }
117 m_h_nav = m_h_end-1;
118 ATH_MSG_INFO("VolumeTreeNavigator::SetDepthCutDetail at "<< m_h_nav->first->GetName());
119 return;
120}
#define endmsg
#define ATH_MSG_INFO(x)
path
python interpreter configuration --------------------------------------—
Definition athena.py:128

◆ SetDepthCutSimple()

void VolumeTreeNavigator::SetDepthCutSimple ( const int CALO,
const int BeamPipe,
const int IDET,
const int MUONQ02 )

Definition at line 65 of file VolumeTreeNavigator.cxx.

66{
67 unsigned int cut = m_history.size();
68 if ( m_history.size() > 1 ) {
69 const string name = stringify(m_history[1].first->GetName());
70 if (name == "CALO::CALO") cut = CALO+1;
71 else if (name == "BeamPipe::BeamPipe") cut = BeamPipe+1;
72 else if (name == "IDET::IDET" || name == "ITK::ITK") cut = IDET+1;
73 else if (name == "MUONQ02::MUONQ02") cut = MUONQ02+1;
74 else { ATH_MSG_INFO("Level 1 volume not found, output default depth"); }
75 }
76 else if ( m_history.empty() ) {
77 ATH_MSG_FATAL("No volumes in history, run will terminate!");
78 }
79
80 if ( cut > m_history.size() ) cut = m_history.size();
81 m_h_end = m_history.begin();
82 advance(m_h_end, cut);
83 m_h_nav = m_h_end-1;
84 ATH_MSG_DEBUG("VolumeTreeNavigator::SetDepthCutSimple at "<< m_h_nav->first->GetName());
85 return;
86}
#define ATH_MSG_FATAL(x)
cut
This script demonstrates how to call a C++ class from Python Also how to use PyROOT is shown.
bool first
Definition DeMoScan.py:534
const unsigned int CALO
all cuts in calorimeter (including isolation)

◆ setLevel()

void AthMessaging::setLevel ( MSG::Level lvl)
inherited

Change the current logging level.

Use this rather than msg().setLevel() for proper operation with MT.

Definition at line 28 of file AthMessaging.cxx.

29{
30 m_lvl = lvl;
31}

Member Data Documentation

◆ ATLAS_THREAD_SAFE

std::atomic_flag m_initialized AthMessaging::ATLAS_THREAD_SAFE = ATOMIC_FLAG_INIT
mutableprivateinherited

Messaging initialized (initMessaging)

Definition at line 141 of file AthMessaging.h.

◆ m_h_end

VolNav VolumeTreeNavigator::m_h_end
private

specifies cut termination in history

Definition at line 68 of file VolumeTreeNavigator.h.

◆ m_h_nav

VolNav VolumeTreeNavigator::m_h_nav
private

VolTree iterator with no access below cut.

Definition at line 69 of file VolumeTreeNavigator.h.

◆ m_history

VolTree VolumeTreeNavigator::m_history
private

full volume history, cast as const after preparation

Definition at line 67 of file VolumeTreeNavigator.h.

◆ m_imsg

std::atomic<IMessageSvc*> AthMessaging::m_imsg { nullptr }
mutableprivateinherited

MessageSvc pointer.

Definition at line 135 of file AthMessaging.h.

135{ nullptr };

◆ m_lvl

std::atomic<MSG::Level> AthMessaging::m_lvl { MSG::NIL }
mutableprivateinherited

Current logging level.

Definition at line 138 of file AthMessaging.h.

138{ MSG::NIL };

◆ m_msg_tls

boost::thread_specific_ptr<MsgStream> AthMessaging::m_msg_tls
mutableprivateinherited

MsgStream instance (a std::cout like with print-out levels)

Definition at line 132 of file AthMessaging.h.

◆ m_nm

std::string AthMessaging::m_nm
privateinherited

Message source name.

Definition at line 129 of file AthMessaging.h.

◆ m_postStepPoint

G4StepPoint* VolumeTreeNavigator::m_postStepPoint
private

volume/process/etc.

info after the current step

Definition at line 63 of file VolumeTreeNavigator.h.

◆ m_preDepth

int VolumeTreeNavigator::m_preDepth
private

Definition at line 65 of file VolumeTreeNavigator.h.

◆ m_preHistory

const G4TouchableHistory* VolumeTreeNavigator::m_preHistory
private

touchable history containing current volume's history

Definition at line 64 of file VolumeTreeNavigator.h.

◆ m_preStepPoint

G4StepPoint* VolumeTreeNavigator::m_preStepPoint
private

volume/process/etc.

info before the current step

Definition at line 62 of file VolumeTreeNavigator.h.

◆ m_stepNo

int VolumeTreeNavigator::m_stepNo
private

depth of volume tree, step number

Definition at line 65 of file VolumeTreeNavigator.h.

◆ m_track

G4Track* VolumeTreeNavigator::m_track
private

current track

Definition at line 61 of file VolumeTreeNavigator.h.


The documentation for this class was generated from the following files: