ATLAS Offline Software
TIDAHistogram.h
Go to the documentation of this file.
1 
12 #ifndef TIDA_HISTOGRAM_H
13 #define TIDA_HISTOGRAM_H
14 
15 #include "GaudiKernel/ToolHandle.h"
17 
19 
20 #include <string>
21 
22 namespace TIDA {
23 
24 template<typename T>
25 class Histogram {
26 
27 public:
28 
29  Histogram() : m_monTool(0), m_name("") { }
30 
31  Histogram( ToolHandle<GenericMonitoringTool>* m, const std::string& name ) : m_monTool(m), m_name(name) {
32  // std::cout << "book: " << m_name << " " << m_monTool->name() << std::endl;
33  }
34 
35  void Fill( T d ) const {
36  if ( m_monTool ) {
37  // std::cout << "Histogram::Fill() monTool " << m_monTool << "\tname: " << m_name << "\td: " << d << "\t" << monTool()->name() << std::endl;
38  auto s = Monitored::Scalar<T>( m_name, d );
40  }
41  else std::cerr << "Histogram " << m_name << "\tmonTool not defined" << std::endl;
42  }
43 
44  void Fill( T d, T w ) const {
45  if ( m_monTool ) {
46  // std::cout << "Histogram::Fill() monTool " << m_monTool << "\tname: " << m_name << "\td: " << d << "\tw:" << w << std::endl;
47  auto s = Monitored::Scalar<T>( m_name, d );
48  auto sw = Monitored::Scalar<T>( m_name+"_weight", w );
49  Monitored::Group( *m_monTool, s, sw );
50  }
51  else std::cerr << "Histogram " << m_name << "\tmonTool not defined" << std::endl;
52  }
53 
54  const std::string& name() const { return m_name; }
55 
56  ToolHandle<GenericMonitoringTool>* monTool() const { return m_monTool; };
57 
58  const Histogram* operator->() const { return this; }
59 
60 private:
61 
62  ToolHandle<GenericMonitoringTool>* m_monTool;
63 
64  std::string m_name;
65 
66 };
67 
68 
69 
70 }
71 
72 
73 #endif /* TIDA_HISTOGRAM_H */
74 
75 
76 
77 
78 
79 
80 
81 
82 
83 
TIDA::Histogram::m_monTool
ToolHandle< GenericMonitoringTool > * m_monTool
Definition: TIDAHistogram.h:62
TIDA
Test for xAOD.
Definition: Filter_AcceptAll.h:22
TrigDefs::Group
Group
Properties of a chain group.
Definition: GroupProperties.h:13
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
python.SystemOfUnits.m
int m
Definition: SystemOfUnits.py:91
TIDA::Histogram::monTool
ToolHandle< GenericMonitoringTool > * monTool() const
Definition: TIDAHistogram.h:56
TIDA::Histogram::Histogram
Histogram()
Definition: TIDAHistogram.h:29
hist_file_dump.d
d
Definition: hist_file_dump.py:137
TIDA::Histogram::m_name
std::string m_name
Definition: TIDAHistogram.h:64
TIDA::Histogram::Fill
void Fill(T d, T w) const
Definition: TIDAHistogram.h:44
TIDA::Histogram
Definition: TIDAHistogram.h:25
TIDA::Histogram::name
const std::string & name() const
Definition: TIDAHistogram.h:54
TIDA::Histogram::operator->
const Histogram * operator->() const
Definition: TIDAHistogram.h:58
TIDA::Histogram::Fill
void Fill(T d) const
Definition: TIDAHistogram.h:35
GenericMonitoringTool.h
TIDA::Histogram::Histogram
Histogram(ToolHandle< GenericMonitoringTool > *m, const std::string &name)
Definition: TIDAHistogram.h:31
Monitored.h
Header file to be included by clients of the Monitored infrastructure.
Monitored::Scalar
Declare a monitored scalar variable.
Definition: MonitoredScalar.h:34
python.IoTestsLib.w
def w
Definition: IoTestsLib.py:200