ATLAS Offline Software
Public Member Functions | Private Member Functions | Private Attributes | List of all members
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. More...
 
MsgStream & msg () const
 The standard message stream. More...
 
MsgStream & msg (const MSG::Level lvl) const
 The standard message stream. More...
 
void setLevel (MSG::Level lvl)
 Change the current logging level. More...
 

Private Member Functions

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

Private Attributes

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

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 }

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 }

◆ 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 }

◆ 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  m_lvl = m_imsg ?
43  static_cast<MSG::Level>( m_imsg.load()->outputLevel(m_nm) ) :
44  MSG::INFO;
45 }

◆ 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 }

◆ 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 164 of file AthMessaging.h.

165 {
166  MsgStream* ms = m_msg_tls.get();
167  if (!ms) {
168  if (!m_initialized.test_and_set()) initMessaging();
169  ms = new MsgStream(m_imsg,m_nm);
170  m_msg_tls.reset( ms );
171  }
172 
173  ms->setLevel (m_lvl);
174  return *ms;
175 }

◆ 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 179 of file AthMessaging.h.

180 { return msg() << lvl; }

◆ 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_initialized.test_and_set()) initMessaging();
154  if (m_lvl <= lvl) {
155  msg() << lvl;
156  return true;
157  } else {
158  return false;
159  }
160 }

◆ SetDepthCutDetail()

void VolumeTreeNavigator::SetDepthCutDetail ( const char *  cpath)

Definition at line 88 of file VolumeTreeNavigator.cxx.

89 {
90  static const vector<string> volumes = [&]() {
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 
106  m_h_nav = m_h_end;
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  }
116  m_h_end = m_h_nav;
117  m_h_nav = m_h_end-1;
118  ATH_MSG_INFO("VolumeTreeNavigator::SetDepthCutDetail at "<< m_h_nav->first->GetName());
119  return;
120 }

◆ 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 }

◆ 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.

◆ m_lvl

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

Current logging level.

Definition at line 138 of file AthMessaging.h.

◆ 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:
AthMessaging::m_lvl
std::atomic< MSG::Level > m_lvl
Current logging level.
Definition: AthMessaging.h:138
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
athena.path
path
python interpreter configuration --------------------------------------—
Definition: athena.py:128
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
VolumeTreeNavigator::m_stepNo
int m_stepNo
depth of volume tree, step number
Definition: VolumeTreeNavigator.h:65
mergePhysValFiles.start
start
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:14
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
AthMessaging::m_imsg
std::atomic< IMessageSvc * > m_imsg
MessageSvc pointer.
Definition: AthMessaging.h:135
python.SystemOfUnits.ms
int ms
Definition: SystemOfUnits.py:132
VolumeTreeNavigator::m_preHistory
const G4TouchableHistory * m_preHistory
touchable history containing current volume's history
Definition: VolumeTreeNavigator.h:64
Athena::getMessageSvc
IMessageSvc * getMessageSvc(bool quiet=false)
Definition: getMessageSvc.cxx:20
Trk::BeamPipe
@ BeamPipe
Definition: GeometrySignature.h:27
TBElementID::IDET
@ IDET
Definition: TBElementID.h:22
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
AthMessaging::AthMessaging
AthMessaging()
Default constructor:
TrigConf::MSGTC::Level
Level
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStream.h:21
stringify
std::string stringify(T obj)
Definition: VolumeTreeNavigator.h:73
lumiFormat.i
int i
Definition: lumiFormat.py:85
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
vector< string >
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
COOLRates.numProc
numProc
Definition: COOLRates.py:1138
BindingsTest.cut
cut
This script demonstrates how to call a C++ class from Python Also how to use PyROOT is shown.
Definition: BindingsTest.py:13
VolumeTreeNavigator::m_postStepPoint
G4StepPoint * m_postStepPoint
volume/process/etc.
Definition: VolumeTreeNavigator.h:63
egammaPIDObs::CALO
const unsigned int CALO
all cuts in calorimeter (including isolation)
Definition: egammaPIDdefsObs.h:919
AthMessaging::msg
MsgStream & msg() const
The standard message stream.
Definition: AthMessaging.h:164
VolumeTreeNavigator::m_h_end
VolNav m_h_end
specifies cut termination in history
Definition: VolumeTreeNavigator.h:68
VolTree
std::vector< VolID > VolTree
Definition: VolumeTreeNavigator.h:36
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
python.PyAthena.v
v
Definition: PyAthena.py:154
VolumeTreeNavigator::m_history
VolTree m_history
full volume history, cast as const after preparation
Definition: VolumeTreeNavigator.h:67
AthMessaging::m_nm
std::string m_nm
Message source name.
Definition: AthMessaging.h:129
DeMoScan.first
bool first
Definition: DeMoScan.py:536
AthMessaging::initMessaging
void initMessaging() const
Initialize our message level and MessageSvc.
Definition: AthMessaging.cxx:39
VolumeTreeNavigator::m_h_nav
VolNav m_h_nav
VolTree iterator with no access below cut.
Definition: VolumeTreeNavigator.h:69
AthMessaging::m_msg_tls
boost::thread_specific_ptr< MsgStream > m_msg_tls
MsgStream instance (a std::cout like with print-out levels)
Definition: AthMessaging.h:132
Amg::distance
float distance(const Amg::Vector3D &p1, const Amg::Vector3D &p2)
calculates the distance between two point in 3D space
Definition: GeoPrimitivesHelpers.h:54
python.compressB64.c
def c
Definition: compressB64.py:93
VolumeTreeNavigator::m_track
G4Track * m_track
current track
Definition: VolumeTreeNavigator.h:61