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