ATLAS Offline Software
Loading...
Searching...
No Matches
TIDAHistogram.h
Go to the documentation of this file.
1
10
11
12#ifndef TIDA_HISTOGRAM_H
13#define TIDA_HISTOGRAM_H
14
15#include "GaudiKernel/ToolHandle.h"
17
19
20#include <string>
21#include <stdexcept>
22
23namespace TIDA {
24
25template<typename T>
26class Histogram {
27
28public:
29
30 Histogram() : m_monTool(0), m_name("UNINITIALISED"), m_initialised(false) { }
31
32 Histogram( ToolHandle<GenericMonitoringTool>* m, const std::string& name ) :
33 m_monTool(m), m_name(name), m_initialised(false) {
34 if ( !m_name.empty() && m_monTool ) m_initialised = true;
35 }
36
37 void Fill( T d ) const {
38 if ( !m_initialised ) throw std::runtime_error("TIDA::Histogram not initialised: "+name());
39 auto s = Monitored::Scalar<T>( m_name, d );
41 }
42
43 void Fill( T d, T w ) const {
44 if ( !m_initialised ) throw std::runtime_error("TIDA::Histogram not initialised: "+name());
45 auto s = Monitored::Scalar<T>( m_name, d );
46 auto sw = Monitored::Scalar<T>( m_name+"_weight", w );
47 Monitored::Group( *m_monTool, s, sw );
48 }
49
50 const std::string& name() const { return m_name; }
51
52 ToolHandle<GenericMonitoringTool>* monTool() const { return m_monTool; };
53
54 const Histogram* operator->() const { return this; }
55
56private:
57
58 ToolHandle<GenericMonitoringTool>* m_monTool;
59
60 std::string m_name;
61
63
64};
65
66
67
68}
69
70
71#endif /* TIDA_HISTOGRAM_H */
72
73
74
75
76
77
78
79
80
81
Header file to be included by clients of the Monitored infrastructure.
Group of local monitoring quantities and retain correlation when filling histograms
Declare a monitored scalar variable.
const Histogram * operator->() const
void Fill(T d) const
Histogram(ToolHandle< GenericMonitoringTool > *m, const std::string &name)
ToolHandle< GenericMonitoringTool > * m_monTool
ToolHandle< GenericMonitoringTool > * monTool() const
const std::string & name() const
void Fill(T d, T w) const
std::string m_name
Test for xAOD.