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 if (not m_preHistory){
46 ATH_MSG_ERROR("Dynamic cast failed in VolumeTreeNavigator::VolumeTreeNavigator");
47 return;
48 }
49 m_preDepth = m_preHistory->GetHistoryDepth();
50 m_stepNo = m_track->GetCurrentStepNumber();
51
52 if (!m_history.empty()) m_history.clear();
53
54 // consolidate volume data into a vector
55 for (G4int c = m_preDepth; c + 1 != 0; c--) {
56 G4VPhysicalVolume* thPV = m_preHistory->GetVolume(c);
57 int thPVRep = (int)(thPV->GetCopyNo());
58 pair<G4VPhysicalVolume*, int> thPVID = make_pair(thPV, thPVRep);
59 m_history.push_back(thPVID);
60 }
61 ATH_MSG_DEBUG("history size: "<< m_history.size());
62
63 // Set h_end to specify full history unless otherwise chosen by DepthCut functions, and
64 // set h_nav to start at the lowest accessible level, h_end - 1.
65 m_h_end = m_history.end();
66 m_h_nav = m_h_end-1;
67}
#define ATH_MSG_ERROR(x)
#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 137 of file VolumeTreeNavigator.cxx.

137 {
138 // Move up # of levels given in the navigable history, stop at Atlas::Atlas
139 if ( !m_history.empty() )
140 {
141 if ( distance( m_history.begin(), m_h_nav ) == 0 || levels == 0 ) return 0;
142 else if ( abs(levels) > abs(distance( m_history.begin(), m_h_nav )) )
143 levels = abs(distance( m_history.begin(), m_h_nav ));
144 advance(m_h_nav, -abs(levels));
145 return 1;
146 }
147 else return 0;
148}
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 150 of file VolumeTreeNavigator.cxx.

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

◆ Extract()

VolTree VolumeTreeNavigator::Extract ( )

Definition at line 126 of file VolumeTreeNavigator.cxx.

127{
128 // Derive a permanent VolTree object from the current volume and its history
129 VolTree ret;
130 for (VolNav t = m_history.begin(); t != m_h_nav+1; ++t) {
131 ret.push_back(*t);
132 }
133 ATH_MSG_DEBUG("VolumeTreeNavigator::Extract succeeded for "<< m_h_nav->first->GetName() <<".");
134 return ret;
135}
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 164 of file VolumeTreeNavigator.cxx.

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

168{
169 MsgStream* ms = m_msg_tls.get();
170 if (!ms) {
171 if (!m_initialized.test_and_set()) initMessaging();
172 ms = new MsgStream(m_imsg,m_nm);
173 m_msg_tls.reset( ms );
174 }
175
176 ms->setLevel (m_lvl);
177 return *ms;
178}
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 182 of file AthMessaging.h.

183{ 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 user did not set explicit message level we have to initialize
154 // the messaging and retrieve the default via the MessageSvc.
155 if (m_lvl==MSG::NIL && !m_initialized.test_and_set()) initMessaging();
156
157 if (m_lvl <= lvl) {
158 msg() << lvl;
159 return true;
160 } else {
161 return false;
162 }
163}

◆ SetDepthCutDetail()

void VolumeTreeNavigator::SetDepthCutDetail ( const char * cpath)

Definition at line 92 of file VolumeTreeNavigator.cxx.

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

◆ SetDepthCutSimple()

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

Definition at line 69 of file VolumeTreeNavigator.cxx.

70{
71 unsigned int cut = m_history.size();
72 if ( m_history.size() > 1 ) {
73 const string name = stringify(m_history[1].first->GetName());
74 if (name == "CALO::CALO") cut = CALO+1;
75 else if (name == "BeamPipe::BeamPipe") cut = BeamPipe+1;
76 else if (name == "IDET::IDET" || name == "ITK::ITK") cut = IDET+1;
77 else if (name == "MUONQ02::MUONQ02") cut = MUONQ02+1;
78 else { ATH_MSG_INFO("Level 1 volume not found, output default depth"); }
79 }
80 else if ( m_history.empty() ) {
81 ATH_MSG_FATAL("No volumes in history, run will terminate!");
82 }
83
84 if ( cut > m_history.size() ) cut = m_history.size();
85 m_h_end = m_history.begin();
86 advance(m_h_end, cut);
87 m_h_nav = m_h_end-1;
88 ATH_MSG_DEBUG("VolumeTreeNavigator::SetDepthCutSimple at "<< m_h_nav->first->GetName());
89 return;
90}
#define ATH_MSG_FATAL(x)
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: