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