ATLAS Offline Software
node.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 */
4 // emacs: this is -*- c++ -*-
5 //
6 // @file node.h
7 //
8 //
9 //
10 //
11 //
12 
13 
14 #ifndef NODE_H
15 #define NODE_H
16 
17 #include <iostream>
18 #include <string>
19 #include <vector>
20 
21 
22 #include "TObject.h"
23 
24 class node : public std::vector<node*> {
25 
26 public:
27 
29 
30 public:
31 
32  node( node* n=0, const std::string &d="", TObject* t=0 ) :
33  mname("duff"), mparent(n), mtype(DUFF), mpath(""), mdepth(d), mobj(t) {
34  if ( t!=0 ) mname = t->GetName();
35  mhirate = std::pair<std::string, double>( "", 0);
36  }
37 
38  virtual ~node() { }
39 
40  void name( const std::string& n) { mname=n; }
41  const std::string& name() const { return mname; }
42 
43  void path(const std::string& p) { mpath=p; }
44  const std::string& path() const { return mpath; }
45 
46  node* parent() { return mparent; }
47  const node* parent() const { return mparent; }
48 
49  const std::string& depth() const { return mdepth; }
50 
51  void type(TYPE t) { mtype=t; }
52  virtual TYPE type() const { return mtype; }
53 
54  std::string stype() const {
55  if ( type()==DIRECTORY ) return "DIRECTORY";
56  if ( type()==HISTOGRAM ) return "HISTOGRAM";
57  return "DUFF";
58  };
59 
60  const TObject* object() const { return mobj; }
61  TObject* object() { return mobj; }
62 
63  void addrate( const std::string& s, double r ) {
64  addrate( std::pair<std::string, double>( s, r ) );
65  }
66 
67  void addrate( const std::pair<std::string, double>& r ) {
68  if ( r.second > mhirate.second ) mhirate = r;
69  }
70 
71  const std::pair<std::string, double>& rate() const { return mhirate; }
72 
73 
74 public:
75 
76  std::string mname;
79 
80  std::string mpath;
81 
82  std::string mdepth;
83 
84  TObject* mobj;
85 
86  std::pair<std::string, double> mhirate;
87 
88 };
89 
90 
91 
92 inline std::ostream& operator<<( std::ostream& s, const node& n ) {
93  s << n.depth() << n.name() << "::" << n.stype() << " : obj " << n.object() << " : size " << n.size() << "\tpath " << n.path();
94  if ( n.type()==node::HISTOGRAM ) return s;
95  else if ( n.size() ) {
96  if ( n.parent() ) s << "\t( parent " << n.parent()->name() << " )";
97  if ( n.rate().first!="" )s << "\t\t:::(max rate chain " << n.rate().first << " " << n.rate().second << " ):::";
98  for ( unsigned i=0 ; i<n.size() ; i++ ) {
99  // if ( n[i]->type()!=node::HISTOGRAM )
100  s << "\n" << i << " " << n.depth() << " " << *n[i];
101  }
102  }
103  return s;
104 }
105 
106 
107 
108 
109 #endif // NODE_H
110 
111 
112 
113 
114 
115 
116 
117 
118 
119 
node::type
void type(TYPE t)
Definition: node.h:51
beamspotman.r
def r
Definition: beamspotman.py:672
node::mparent
node * mparent
Definition: node.h:77
operator<<
std::ostream & operator<<(std::ostream &s, const node &n)
Definition: node.h:92
node::path
void path(const std::string &p)
Definition: node.h:43
node::depth
const std::string & depth() const
Definition: node.h:49
hist_file_dump.d
d
Definition: hist_file_dump.py:142
node::mhirate
std::pair< std::string, double > mhirate
Definition: node.h:86
node::type
virtual TYPE type() const
Definition: node.h:52
node::addrate
void addrate(const std::pair< std::string, double > &r)
Definition: node.h:67
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
node::mtype
TYPE mtype
Definition: node.h:78
node::rate
const std::pair< std::string, double > & rate() const
Definition: node.h:71
node::DUFF
@ DUFF
Definition: node.h:28
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:209
node::parent
node * parent()
Definition: node.h:46
lumiFormat.i
int i
Definition: lumiFormat.py:85
beamspotman.n
n
Definition: beamspotman.py:727
node::parent
const node * parent() const
Definition: node.h:47
node::mname
std::string mname
Definition: node.h:76
node::object
const TObject * object() const
Definition: node.h:60
node::mpath
std::string mpath
Definition: node.h:80
node::HISTOGRAM
@ HISTOGRAM
Definition: node.h:28
node::name
void name(const std::string &n)
Definition: node.h:40
node::addrate
void addrate(const std::string &s, double r)
Definition: node.h:63
node::DIRECTORY
@ DIRECTORY
Definition: node.h:28
node::stype
std::string stype() const
Definition: node.h:54
node::path
const std::string & path() const
Definition: node.h:44
node::mobj
TObject * mobj
Definition: node.h:84
node::TYPE
TYPE
Definition: node.h:28
node::object
TObject * object()
Definition: node.h:61
node::mdepth
std::string mdepth
Definition: node.h:82
python.SystemOfUnits.s
float s
Definition: SystemOfUnits.py:147
node::node
node(node *n=0, const std::string &d="", TObject *t=0)
Definition: node.h:32
node::~node
virtual ~node()
Definition: node.h:38
node::name
const std::string & name() const
Definition: node.h:41
node
Definition: node.h:24