Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
edep-sim
display
TRecurseGeoManager.hxx
Go to the documentation of this file.
1
#ifndef TRecurseGeoManager_hxx_seen
2
#define TRecurseGeoManager_hxx_seen
3
#include <iostream>
4
5
#include <TGeoManager.h>
6
#include <TGeoNode.h>
7
8
class
TRecurseGeoManager
{
9
public
:
10
TRecurseGeoManager
() {}
11
virtual
~TRecurseGeoManager
() {}
12
13
/// Apply the action recursively to every node starting with the current
14
/// node (depth first).
15
bool
Apply
(
int
depth=0) {
16
TGeoNode * node = gGeoManager->GetCurrentNode();
17
if
(!
Action
(depth)) {
18
gGeoManager->CdUp();
19
return
false
;
20
}
21
22
for
(
int
i=0; i< node->GetNdaughters(); ++i) {
23
gGeoManager->CdDown(i);
24
if
(!
Apply
(depth+1)) {
25
gGeoManager->CdUp();
26
return
false
;
27
}
28
}
29
30
gGeoManager->CdUp();
31
return
true
;
32
}
33
34
/// An action to override. Return false if the recursion should be
35
/// stopped. The action should act on the current node, and NOT change
36
/// the geometry. The input argument (depth) is the current depth in the
37
/// geometry (zero is the node where the recursion started).
38
virtual
bool
Action
(
int
depth) {
39
TGeoNode* node = gGeoManager->GetCurrentNode();
40
TGeoExtension* extension;
41
extension = node->GetUserExtension();
42
if
(extension) {
43
std::cout <<
"Have node user extension "
<< node->GetName()
44
<<
" depth "
<< depth
45
<<
std::endl
;
46
}
47
extension = node->GetFWExtension();
48
if
(extension) {
49
std::cout <<
"Have node FW extension "
<< node->GetName()
50
<<
" depth "
<< depth
51
<<
std::endl
;
52
}
53
TGeoVolume*
volume
= node->GetVolume();
54
extension = volume->GetUserExtension();
55
if
(extension) {
56
std::cout <<
"Have volume user extension "
<< volume->GetName()
57
<<
" depth "
<< depth
58
<<
std::endl
;
59
}
60
extension = volume->GetFWExtension();
61
if
(extension) {
62
std::cout <<
"Have volume FW extension "
<< volume->GetName()
63
<<
" depth "
<< depth
64
<<
std::endl
;
65
}
66
return
true
;
67
}
68
};
69
#endif
TRecurseGeoManager::TRecurseGeoManager
TRecurseGeoManager()
Definition:
TRecurseGeoManager.hxx:10
IMap::volume
static const std::string volume[nvol]
Definition:
CommonIMapIncludes.h:78
TRecurseGeoManager
Definition:
TRecurseGeoManager.hxx:8
TRecurseGeoManager::~TRecurseGeoManager
virtual ~TRecurseGeoManager()
Definition:
TRecurseGeoManager.hxx:11
TRecurseGeoManager::Action
virtual bool Action(int depth)
Definition:
TRecurseGeoManager.hxx:38
TRecurseGeoManager::Apply
bool Apply(int depth=0)
Definition:
TRecurseGeoManager.hxx:15
endl
QTextStream & endl(QTextStream &s)
Definition:
qtextstream.cpp:2030
Generated by
1.8.11