ATLAS Offline Software
Public Types | Public Member Functions | Static Private Member Functions | Private Attributes | List of all members
CBTree Class Reference

#include <CBTree.h>

Collaboration diagram for CBTree:

Public Types

typedef std::set< CBNode *, CBNode::nodeOrdernodeSet
 
typedef IOVSvcCallBackFcn BFCN
 

Public Member Functions

 CBTree ()
 
 ~CBTree ()
 
 CBTree (const CBTree &)=delete
 
CBTreeoperator= (const CBTree &)=delete
 
CBNodeaddNode (const std::string &name, CBNode *parent)
 
CBNodeaddNode (const SG::DataProxy *proxy, const std::string &name)
 
CBNodeaddNode (BFCN *fcn, const CallBackID &cb, const SG::DataProxy *parent_proxy)
 
CBNodeaddNode (BFCN *fcn, const CallBackID &cb, BFCN *parent_fcn)
 
CBNodereplaceProxy (const SG::DataProxy *pOld, const SG::DataProxy *pNew)
 
void connectNode (CBNode *node, CBNode *parent)
 
void connectNode (const std::string &name, CBNode *parent)
 
CBNodefindNode (const std::string &name)
 
CBNodefindNode (const std::string &name, CBNode *start)
 
CBNodefindNode (const SG::DataProxy *proxy)
 
CBNodefindNode (const SG::DataProxy *proxy, CBNode *start)
 
CBNodefindNode (BFCN *fcn)
 
CBNodefindNode (BFCN *fcn, CBNode *start)
 
bool delNode (const SG::DataProxy *prx)
 
void printTree () const
 
void printTree (const CBNode *start) const
 
int maxLevel () const
 
void adjustLevels (CBNode *start)
 
void listNodes () const
 
void listNodes (const int &level, nodeSet::const_iterator &start, nodeSet::const_iterator &end) const
 
void cascadeTrigger (const bool b, CBNode *start)
 
void cascadeTrigger (const bool b, BFCN *fcn)
 
void cascadeTrigger (const bool b, const SG::DataProxy *proxy)
 
void clearTrigger () const
 
void cascadeFlag (const bool b, CBNode *node) const
 
void clearFlag () const
 
void traverse (void(*pF)(const CBNode *)) const
 
void traverse (const CBNode *, void(*pF)(const CBNode *)) const
 
void traverseR (const CBNode *, void(*pF)(const CBNode *)) const
 
const CBNodetraverse (const CBNode *(*pF)(const CBNode *)) const
 
const CBNodetraverse (const CBNode *, const CBNode *(*pF)(const CBNode *)) const
 
const CBNodetraverseR (const CBNode *, const CBNode *(*pF)(const CBNode *)) const
 
void traverse (void(*pF)(const CBNode *, const CBNode *)) const
 
void traverse (const CBNode *, const CBNode *, void(*pF)(const CBNode *, const CBNode *)) const
 
void traverseR (const CBNode *, const CBNode *, void(*pF)(const CBNode *, const CBNode *)) const
 

Static Private Member Functions

static void _printTree (const CBNode *, const CBNode *)
 

Private Attributes

CBNodem_root
 
nodeSet m_allNodes
 

Detailed Description

Definition at line 30 of file CBTree.h.

Member Typedef Documentation

◆ BFCN

Definition at line 34 of file CBTree.h.

◆ nodeSet

Definition at line 33 of file CBTree.h.

Constructor & Destructor Documentation

◆ CBTree() [1/2]

CBTree::CBTree ( )

Definition at line 28 of file CBTree.cxx.

28  {
29  m_root = new CBNode("root",0);
30  m_allNodes.insert( m_root );
31 }

◆ ~CBTree()

CBTree::~CBTree ( )

Definition at line 35 of file CBTree.cxx.

35  {
37  itr != m_allNodes.end(); ++itr) {
38  delete *itr;
39  }
40 }

◆ CBTree() [2/2]

CBTree::CBTree ( const CBTree )
delete

Member Function Documentation

◆ _printTree()

void CBTree::_printTree ( const CBNode current,
const CBNode parent 
)
staticprivate

Definition at line 294 of file CBTree.cxx.

294  {
295  std::string np;
296  int lp;
297  if (parent == 0) {
298  np = "";
299  lp = 0;
300  } else {
301  np = parent->name();
302  lp = parent->level();
303  }
304 
305  for (int i=0; i<lp; ++i) {
306  cout << " ";
307  }
308 
309  for (int i=0; i<(current->level()-lp); ++i) {
310  if ( i == 0 ) {
311  // cout << "";
312  cout << "+-";
313  } else {
314  // cout << "";
315  cout << "--";
316  }
317  }
318 
319  if (current->trigger()) {
320  cout << "" << current->name() << "";
321  } else {
322  cout << current->name();
323  }
324  cout << endl;
325 
326 }

◆ addNode() [1/4]

CBNode * CBTree::addNode ( BFCN fcn,
const CallBackID cb,
BFCN parent_fcn 
)

Definition at line 96 of file CBTree.cxx.

96  {
97 
98  CBNode* parent = findNode(parent_fcn);
99 
100  if (parent == 0) {
101  cout << "ERROR: no parent function found in tree for " << parent_fcn
102  << endl;
103  return 0;
104  }
105 
106  CBNode* n = new CBNode(fcn, cb, parent);
107 
108  m_allNodes.insert( n );
109 
110  return n;
111 }

◆ addNode() [2/4]

CBNode * CBTree::addNode ( BFCN fcn,
const CallBackID cb,
const SG::DataProxy parent_proxy 
)

Definition at line 77 of file CBTree.cxx.

78  {
79 
81 
82  if (parent == 0) {
83  cout << "ERROR: no parent proxy found in tree for " << proxy->name()
84  << endl;
85  return 0;
86  }
87 
88  CBNode* n = new CBNode(fcn, cb, parent);
89 
90  m_allNodes.insert( n );
91 
92  return n;
93 }

◆ addNode() [3/4]

CBNode * CBTree::addNode ( const SG::DataProxy proxy,
const std::string &  name 
)

Definition at line 44 of file CBTree.cxx.

44  {
45 
46  CBNode* n = new CBNode(proxy, name, m_root);
47 
48  m_allNodes.insert( n );
49 
50  return n;
51 }

◆ addNode() [4/4]

CBNode * CBTree::addNode ( const std::string &  name,
CBNode parent 
)

Definition at line 65 of file CBTree.cxx.

65  {
66  if (parent == 0) {
67  parent = m_root;
68  }
69  CBNode* n = new CBNode(name, parent);
70 
71  m_allNodes.insert( n );
72 
73  return n;
74 }

◆ adjustLevels()

void CBTree::adjustLevels ( CBNode start)

Definition at line 452 of file CBTree.cxx.

452  {
453 
454  int level = start->level();
455 
456  std::set<CBNode*>::iterator citr = start->children().begin();
457  for (;citr != start->children().end(); ++citr) {
458  m_allNodes.erase( m_allNodes.find( *citr ) );
459  (*citr)->setLevel( level+1 );
460  m_allNodes.insert( *citr );
461  adjustLevels( *citr );
462  }
463 }

◆ cascadeFlag()

void CBTree::cascadeFlag ( const bool  b,
CBNode node 
) const

Definition at line 428 of file CBTree.cxx.

428  {
429  if (start == 0) {
430  start = m_root;
431  }
432 
433  start->setFlag(b);
434 
435  for (CBNode* child : start->children()) {
436  cascadeFlag(b, child);
437  }
438 }

◆ cascadeTrigger() [1/3]

void CBTree::cascadeTrigger ( const bool  b,
BFCN fcn 
)

Definition at line 389 of file CBTree.cxx.

389  {
390 
391  CBNode* start = findNode(fcn);
392  if (start == 0) {
393  cout << "ERROR cascading trigger from fcn: " << fcn << endl;
394  return;
395  }
396 
398 
399 }

◆ cascadeTrigger() [2/3]

void CBTree::cascadeTrigger ( const bool  b,
CBNode start 
)

Definition at line 374 of file CBTree.cxx.

374  {
375  if (start == 0) {
376  start = m_root;
377  }
378 
379  start->setTrigger(b);
380 
381  std::set<CBNode*>::iterator citr = start->children().begin();
382  for (;citr!=start->children().end(); ++citr) {
383  cascadeTrigger(b, *citr);
384  }
385 }

◆ cascadeTrigger() [3/3]

void CBTree::cascadeTrigger ( const bool  b,
const SG::DataProxy proxy 
)

Definition at line 403 of file CBTree.cxx.

403  {
404 
406  if (start == 0) {
407  cout << "ERROR cascading trigger from proxy: " << proxy->name() << endl;
408  return;
409  }
410 
412 
413 }

◆ clearFlag()

void CBTree::clearFlag ( ) const

Definition at line 442 of file CBTree.cxx.

442  {
443  nodeSet::const_iterator itr;
444  for (itr=m_allNodes.begin(); itr != m_allNodes.end(); ++itr) {
445  (*itr)->setFlag(false);
446  }
447 }

◆ clearTrigger()

void CBTree::clearTrigger ( ) const

Definition at line 417 of file CBTree.cxx.

417  {
418 
419  nodeSet::const_iterator itr;
420  for (itr=m_allNodes.begin(); itr != m_allNodes.end(); ++itr) {
421  (*itr)->setTrigger(false);
422  }
423 
424 }

◆ connectNode() [1/2]

void CBTree::connectNode ( CBNode node,
CBNode parent 
)

Definition at line 144 of file CBTree.cxx.

144  {
145 
146  // check to see if we're creating a loop
147  cascadeFlag(true, node);
148  if (parent->flag()) {
149  cout << "ERROR: cannot connect " << node->name() << " to "
150  << parent->name() << " as a loop would be formed"
151  << endl;
152  return;
153  }
154  clearFlag();
155 
156  node->addParent( parent );
157  parent->addChild( node );
158  if (node->level() < (parent->level() + 1)) {
159  // we need to erase it first and then reinsert it as the ordering
160  // critereon has changed. Do this for all children too.
161  m_allNodes.erase( m_allNodes.find( node ) );
162  node->setLevel( parent->level() + 1);
163  m_allNodes.insert( node );
164 
165  adjustLevels( node );
166 
167  }
168 }

◆ connectNode() [2/2]

void CBTree::connectNode ( const std::string &  name,
CBNode parent 
)

Definition at line 172 of file CBTree.cxx.

172  {
173  CBNode* n = findNode(name);
174  if (n == 0) {
176  } else {
177  connectNode(n, parent);
178  }
179 }

◆ delNode()

bool CBTree::delNode ( const SG::DataProxy prx)

Definition at line 114 of file CBTree.cxx.

114  {
115  CBNode *n = findNode(prx);
116  if (n == 0) {
117  cout << "ERROR: no node with DataProxy " << prx->name() << " found in tree"
118  << endl;
119  return false;
120  }
121 
122  bool b(true);
123  for ( auto p : n->parents() ) {
124  if (!p->delChild( n )) {
125  cout << "ERROR: CBTree::delNode : unable to delete child "
126  << n->name() << " from parent " << p->name() << endl;
127  b = false;
128  }
129  }
130 
131  for (auto c : n->children()) {
132  if (!c->delParent( n )) {
133  cout << "ERROR: CBTree::delNode : unable to delete parent "
134  << n->name() << " from child " << c->name() << endl;
135  b = false;
136  }
137  }
138 
139  return b;
140 }

◆ findNode() [1/6]

CBNode * CBTree::findNode ( BFCN fcn)

Definition at line 211 of file CBTree.cxx.

211  {
212  return findNode(fcn, m_root);
213 }

◆ findNode() [2/6]

CBNode * CBTree::findNode ( BFCN fcn,
CBNode start 
)

Definition at line 217 of file CBTree.cxx.

217  {
218 
219  if (start->fcn() == fcn) {
220  return start;
221  } else {
222 
223  CBNode *c;
224  std::set<CBNode*>::const_iterator citr = start->children().begin();
225  for (; citr != start->children().end(); ++citr) {
226  c = findNode(fcn,*citr);
227  if (c != 0) {
228  return c;
229  }
230  }
231  }
232 
233  return 0;
234 }

◆ findNode() [3/6]

CBNode * CBTree::findNode ( const SG::DataProxy proxy)

Definition at line 183 of file CBTree.cxx.

183  {
184 
185  return findNode(proxy, m_root);
186 
187 }

◆ findNode() [4/6]

CBNode * CBTree::findNode ( const SG::DataProxy proxy,
CBNode start 
)

Definition at line 191 of file CBTree.cxx.

191  {
192 
193  if ( start->proxy() == proxy ) {
194  return start;
195  } else {
196 
197  for ( auto c : start->children() ) {
198  c = findNode(proxy, c);
199  if (c != 0) {
200  return c;
201  }
202  }
203  }
204 
205  return 0;
206 
207 }

◆ findNode() [5/6]

CBNode * CBTree::findNode ( const std::string &  name)

Definition at line 238 of file CBTree.cxx.

238  {
239  return findNode(name, m_root);
240 }

◆ findNode() [6/6]

CBNode * CBTree::findNode ( const std::string &  name,
CBNode start 
)

Definition at line 244 of file CBTree.cxx.

244  {
245 
246  if (start->name() == name) {
247  return start;
248  } else {
249 
250  CBNode *c;
251  std::set<CBNode*>::const_iterator citr = start->children().begin();
252  for (; citr != start->children().end(); ++citr) {
253  c = findNode(name,*citr);
254  if (c != 0) {
255  return c;
256  }
257  }
258  }
259 
260  return 0;
261 }

◆ listNodes() [1/2]

void CBTree::listNodes ( ) const

Definition at line 337 of file CBTree.cxx.

337  {
338  nodeSet::const_iterator citr = m_allNodes.begin();
339  for (; citr != m_allNodes.end(); ++citr) {
340  cout << (*citr)->name() << " " << *citr << " " << (*citr)->level()
341  << " " << (*citr)->trigger() << endl;
342  }
343 }

◆ listNodes() [2/2]

void CBTree::listNodes ( const int &  level,
nodeSet::const_iterator &  start,
nodeSet::const_iterator &  end 
) const

Definition at line 347 of file CBTree.cxx.

349  {
350 
351  bool s = false;
352 
353  start = m_allNodes.end();
354  end = m_allNodes.end();
355 
356  nodeSet::const_iterator citr = m_allNodes.begin();
357  for (; citr != m_allNodes.end(); ++citr) {
358  if (!s && (*citr)->level() == level) {
359  s = true;
360  start = citr;
361  }
362 
363  if (s && (*citr)->level() != level) {
364  end = citr;
365  break;
366  }
367  }
368 
369  return;
370 }

◆ maxLevel()

int CBTree::maxLevel ( ) const

Definition at line 329 of file CBTree.cxx.

329  {
330  nodeSet::const_iterator itr = m_allNodes.end();
331  --itr;
332  return (*itr)->level();
333 }

◆ operator=()

CBTree& CBTree::operator= ( const CBTree )
delete

◆ printTree() [1/2]

void CBTree::printTree ( ) const

Definition at line 265 of file CBTree.cxx.

265  {
266  cout << "total entries: " << m_allNodes.size() << " max levels: "
267  << maxLevel() << endl;
269 }

◆ printTree() [2/2]

void CBTree::printTree ( const CBNode start) const

Definition at line 273 of file CBTree.cxx.

273  {
274 
275  for (int i=0; i<start->level(); ++i) {
276  cout << " ";
277  }
278 
279  if (start->trigger()) {
280  cout << "";
281  }
282  cout << start->name();
283  if (start->trigger()) {
284  cout << "";
285  }
286  cout << endl;
287 
288  for (const CBNode* child : start->children()) {
289  printTree( child );
290  }
291 
292 }

◆ replaceProxy()

CBNode * CBTree::replaceProxy ( const SG::DataProxy pOld,
const SG::DataProxy pNew 
)

Definition at line 55 of file CBTree.cxx.

55  {
56  assert (0 != pOld);
57  assert (0 != pNew);
58  CBNode* n(findNode(pOld));
59  if (0 != n) n->setProxy(pNew);
60  return n;
61 }

◆ traverse() [1/6]

const CBNode * CBTree::traverse ( const CBNode *(*)(const CBNode *)  pF) const

Definition at line 546 of file CBTree.cxx.

546  {
547 
548  return traverse(m_root, pf);
549 
550 }

◆ traverse() [2/6]

const CBNode * CBTree::traverse ( const CBNode current,
const CBNode *(*)(const CBNode *)  pF 
) const

Definition at line 552 of file CBTree.cxx.

552  {
553 
554  const CBNode *n = (*pf)(current);
555 
556  if ( n != 0 ) {
557  return n;
558  } else {
559 
560  for (const CBNode* child : current->children()) {
561  const CBNode* c = traverse(child, pf );
562  if (c != 0) {
563  return c;
564  }
565  }
566  }
567 
568  return 0;
569 
570 }

◆ traverse() [3/6]

void CBTree::traverse ( const CBNode current,
const CBNode parent,
void(*)(const CBNode *, const CBNode *)  pF 
) const

Definition at line 515 of file CBTree.cxx.

516  {
517 
518  if (current == 0) { return; }
519 
520  (*pf)(current,parent);
521 
522  for (const CBNode* child : current->children()) {
523  traverse( child, current, pf);
524  }
525 
526 }

◆ traverse() [4/6]

void CBTree::traverse ( const CBNode current,
void(*)(const CBNode *)  pF 
) const

Definition at line 477 of file CBTree.cxx.

477  {
478 
479  if (current == 0) { return; }
480 
481  (*pf)(current);
482 
483  for (const CBNode* child : current->children()) {
484  traverse( child, pf);
485  }
486 
487 }

◆ traverse() [5/6]

void CBTree::traverse ( void(*)(const CBNode *)  pF) const

Definition at line 469 of file CBTree.cxx.

469  {
470 
471  const CBNode* current = m_root;
472 
473  traverse(current, pf);
474 
475 }

◆ traverse() [6/6]

void CBTree::traverse ( void(*)(const CBNode *, const CBNode *)  pF) const

Definition at line 507 of file CBTree.cxx.

507  {
508 
509  const CBNode* current = m_root;
510 
511  traverse(current,0, pf);
512 
513 }

◆ traverseR() [1/3]

const CBNode * CBTree::traverseR ( const CBNode current,
const CBNode *(*)(const CBNode *)  pF 
) const

Definition at line 572 of file CBTree.cxx.

572  {
573 
574  const CBNode *n = (*pf)(current);
575 
576  if ( n != 0 ) {
577  return n;
578  } else {
579 
580  for (const CBNode* parent : current->parents()) {
581  const CBNode* c = traverseR(parent, pf );
582  if (c != 0) {
583  return c;
584  }
585  }
586  }
587 
588  return 0;
589 
590 }

◆ traverseR() [2/3]

void CBTree::traverseR ( const CBNode current,
const CBNode child,
void(*)(const CBNode *, const CBNode *)  pF 
) const

Definition at line 528 of file CBTree.cxx.

529  {
530 
531  if (current == 0) { return; }
532 
533  (*pf)(current,child);
534 
535  for (const CBNode* parent : current->parents()) {
537  }
538 
539 }

◆ traverseR() [3/3]

void CBTree::traverseR ( const CBNode current,
void(*)(const CBNode *)  pF 
) const

Definition at line 489 of file CBTree.cxx.

489  {
490  // traverse tree in reverse
491 
492  if (current == 0) { return; }
493 
494  (*pf)(current);
495 
496  for (const CBNode* parent : current->parents()) {
497  traverseR( parent, pf);
498  }
499 
500 }

Member Data Documentation

◆ m_allNodes

nodeSet CBTree::m_allNodes
private

Definition at line 101 of file CBTree.h.

◆ m_root

CBNode* CBTree::m_root
private

Definition at line 100 of file CBTree.h.


The documentation for this class was generated from the following files:
CBTree::addNode
CBNode * addNode(const std::string &name, CBNode *parent)
Definition: CBTree.cxx:65
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
fillPileUpNoiseLumi.current
current
Definition: fillPileUpNoiseLumi.py:52
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
CBTree::m_root
CBNode * m_root
Definition: CBTree.h:100
StateLessPT_NewConfig.proxy
proxy
Definition: StateLessPT_NewConfig.py:392
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
mergePhysValFiles.start
start
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:14
CBTree::traverseR
void traverseR(const CBNode *, void(*pF)(const CBNode *)) const
Definition: CBTree.cxx:489
CBTree::connectNode
void connectNode(CBNode *node, CBNode *parent)
Definition: CBTree.cxx:144
CBTree::cascadeTrigger
void cascadeTrigger(const bool b, CBNode *start)
Definition: CBTree.cxx:374
PlotPulseshapeFromCool.np
np
Definition: PlotPulseshapeFromCool.py:64
CBTree::findNode
CBNode * findNode(const std::string &name)
Definition: CBTree.cxx:238
mergePhysValFiles.end
end
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:93
python.iconfTool.models.loaders.level
level
Definition: loaders.py:20
CBNode
Definition: CBNode.h:30
CBTree::adjustLevels
void adjustLevels(CBNode *start)
Definition: CBTree.cxx:452
lumiFormat.i
int i
Definition: lumiFormat.py:92
CBTree::maxLevel
int maxLevel() const
Definition: CBTree.cxx:329
beamspotman.n
n
Definition: beamspotman.py:731
CBTree::clearFlag
void clearFlag() const
Definition: CBTree.cxx:442
test_pyathena.parent
parent
Definition: test_pyathena.py:15
fcn
void fcn(int &, double *, double &result, double par[], int)
this is where we write out chi2
Definition: Chi2LJets.cxx:183
CBTree::printTree
void printTree() const
Definition: CBTree.cxx:265
node::name
void name(const std::string &n)
Definition: node.h:38
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
SG::DataProxy::name
virtual const name_type & name() const override final
Retrieve data object key == string.
CBTree::traverse
void traverse(void(*pF)(const CBNode *)) const
Definition: CBTree.cxx:469
python.output.AtlRunQueryRoot.pf
pf
Definition: AtlRunQueryRoot.py:988
CBTree::_printTree
static void _printTree(const CBNode *, const CBNode *)
Definition: CBTree.cxx:294
CBTree::cascadeFlag
void cascadeFlag(const bool b, CBNode *node) const
Definition: CBTree.cxx:428
CBTree::m_allNodes
nodeSet m_allNodes
Definition: CBTree.h:101
python.compressB64.c
def c
Definition: compressB64.py:93
node
Definition: memory_hooks-stdcmalloc.h:74