ATLAS Offline Software
Loading...
Searching...
No Matches
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
24class node : public std::vector<node*> {
25
26public:
27
29
30public:
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
74public:
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
92inline 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
Definition node.h:24
std::string stype() const
Definition node.h:54
void type(TYPE t)
Definition node.h:51
const std::string & name() const
Definition node.h:41
TObject * mobj
Definition node.h:84
TYPE mtype
Definition node.h:78
const std::pair< std::string, double > & rate() const
Definition node.h:71
virtual ~node()
Definition node.h:38
std::string mdepth
Definition node.h:82
std::string mname
Definition node.h:76
std::string mpath
Definition node.h:80
const std::string & path() const
Definition node.h:44
const node * parent() const
Definition node.h:47
TObject * object()
Definition node.h:61
const std::string & depth() const
Definition node.h:49
void addrate(const std::pair< std::string, double > &r)
Definition node.h:67
node * parent()
Definition node.h:46
std::pair< std::string, double > mhirate
Definition node.h:86
node(node *n=0, const std::string &d="", TObject *t=0)
Definition node.h:32
void addrate(const std::string &s, double r)
Definition node.h:63
virtual TYPE type() const
Definition node.h:52
TYPE
Definition node.h:28
@ DUFF
Definition node.h:28
@ DIRECTORY
Definition node.h:28
@ HISTOGRAM
Definition node.h:28
node * mparent
Definition node.h:77
void path(const std::string &p)
Definition node.h:43
void name(const std::string &n)
Definition node.h:40
const TObject * object() const
Definition node.h:60
int r
Definition globals.cxx:22
std::ostream & operator<<(std::ostream &s, const node &n)
Definition node.h:92