ATLAS Offline Software
CounterBase.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef TRIGCOSTANALYSIS_COUNTERBASE_H
6 #define TRIGCOSTANALYSIS_COUNTERBASE_H 1
7 
8 #include "GaudiKernel/StatusCode.h"
11 
12 #include "CostData.h"
13 #include "Variable.h"
14 
15 class MonitorBase;
16 class TH1;
17 
25 class CounterBase {
26  public:
30  CounterBase() = delete;
31 
37  CounterBase(const std::string& name, const MonitorBase* parent);
38 
42  virtual ~CounterBase() = default;
43 
47  CounterBase& operator=(const CounterBase&) = delete;
48 
52  CounterBase(const CounterBase&) = delete;
53 
58  const std::string& getName() const;
59 
64  const MonitorBase* getParent() const;
65 
71  bool variableExists(const std::string& name) const;
72 
79  Variable& getVariable(const std::string& name);
80 
87  StatusCode fill(const std::string& name, float value, float weight = 1.0);
88 
96  StatusCode fill(const std::string& name, float xvalue, float yvalue, float weight);
97 
103  StatusCode increment(const std::string& name, float weight = 1.0);
104 
110  StatusCode setDenominator(const std::string& name, float value);
111 
115  virtual StatusCode endEvent(float weight = 1.0);
116 
123  virtual StatusCode newEvent(const CostData& data, size_t index, float weight = 1.0) = 0;
124 
125  protected:
126 
136  void regHistogram(const std::string& name,
137  const std::string& title,
139  const LogType xaxis = kLog,
140  const float min = 0.1,
141  const float max = 1000000.,
142  const size_t bins = 70);
143 
153  void regTProfile(const std::string& name,
154  const std::string& title,
156  const LogType xaxis = kLog,
157  const float min = 0.1,
158  const float max = 1000000.,
159  const size_t bins = 70);
160 
174  void regHistogram(const std::string& name,
175  const std::string& title,
176  const VariableType type,
177  const LogType xaxis,
178  const float xmin,
179  const float xmax,
180  const size_t xbins,
181  const LogType yaxis,
182  const float ymin,
183  const float ymax,
184  const size_t ybins);
185 
186 
193  TH1* bookGetPointer(TH1* hist, const std::string& tDir = "") const;
194 
199  float timeToMilliSec(const uint64_t start, const uint64_t stop) const;
200 
201  private:
202 
203  const std::string m_name;
205  std::unordered_map< std::string, Variable > m_variables;
206 };
207 
208 #endif // TRIGCOSTANALYSIS_COUNTERBASE_H
data
char data[hepevt_bytes_allocation_ATLAS]
Definition: HepEvt.cxx:11
CounterBase::newEvent
virtual StatusCode newEvent(const CostData &data, size_t index, float weight=1.0)=0
Pure virtual interface called by Monitor to instruct this Counter to perform its analysis.
ymin
double ymin
Definition: listroot.cxx:63
CounterBase::setDenominator
StatusCode setDenominator(const std::string &name, float value)
Optional for per-Event Variables.
Definition: CounterBase.cxx:210
CounterBase
Forward declare.
Definition: CounterBase.h:25
CounterBase::regHistogram
void regHistogram(const std::string &name, const std::string &title, const VariableType type=VariableType::kPerCall, const LogType xaxis=kLog, const float min=0.1, const float max=1000000., const size_t bins=70)
Book a histogram for this Counter, to be filled in per-event monitoring.
Definition: CounterBase.cxx:27
max
#define max(a, b)
Definition: cfImp.cxx:41
AthCheckMacros.h
index
Definition: index.py:1
CounterBase::fill
StatusCode fill(const std::string &name, float value, float weight=1.0)
Fill (for per-Call) or accumulate in a buffer (for per-Event) a quantity histogrammed by a named Vari...
Definition: CounterBase.cxx:191
plotmaker.hist
hist
Definition: plotmaker.py:148
mergePhysValFiles.start
start
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:14
CounterBase::endEvent
virtual StatusCode endEvent(float weight=1.0)
Called by the framework.
Definition: CounterBase.cxx:225
PixelAthClusterMonAlgCfg.ybins
ybins
Definition: PixelAthClusterMonAlgCfg.py:169
athena.value
value
Definition: athena.py:124
PixelModuleFeMask_create_db.stop
int stop
Definition: PixelModuleFeMask_create_db.py:76
CounterBase::CounterBase
CounterBase()=delete
Forbid default constructor.
CounterBase::CounterBase
CounterBase(const CounterBase &)=delete
Forbid copy.
CounterBase::getName
const std::string & getName() const
Getter for Counter's name.
Definition: CounterBase.cxx:17
VariableType
VariableType
Behaviour of Variable.
Definition: Trigger/TrigCost/TrigCostAnalysis/src/Variable.h:17
dqt_zlumi_pandas.weight
int weight
Definition: dqt_zlumi_pandas.py:189
Variable.h
kLog
@ kLog
Logarithmic x-binning.
Definition: Trigger/TrigCost/TrigCostAnalysis/src/Variable.h:28
HLTUtils.h
CounterBase::bookGetPointer
TH1 * bookGetPointer(TH1 *hist, const std::string &tDir="") const
Appends Counter name (to histogram path) and forwards histogram book request to parent Monitor.
Definition: CounterBase.cxx:233
xmin
double xmin
Definition: listroot.cxx:60
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
covarianceTool.title
title
Definition: covarianceTool.py:542
CounterBase::operator=
CounterBase & operator=(const CounterBase &)=delete
Forbid assignment.
test_pyathena.parent
parent
Definition: test_pyathena.py:15
xAOD::uint64_t
uint64_t
Definition: EventInfo_v1.cxx:123
plotting.yearwise_luminosity_vs_mu.bins
bins
Definition: yearwise_luminosity_vs_mu.py:30
CounterBase::m_parent
const MonitorBase * m_parent
Counter's parent Monitor.
Definition: CounterBase.h:204
CounterBase::variableExists
bool variableExists(const std::string &name) const
Check if a variable of a given name exists.
Definition: CounterBase.cxx:178
min
#define min(a, b)
Definition: cfImp.cxx:40
kPerCall
@ kPerCall
Variable should fill underlying histogram on each fill.
Definition: Trigger/TrigCost/TrigCostAnalysis/src/Variable.h:18
CounterBase::getVariable
Variable & getVariable(const std::string &name)
Returns a mutable reference to a named Variable.
Definition: CounterBase.cxx:182
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
CounterBase::regTProfile
void regTProfile(const std::string &name, const std::string &title, const VariableType type=VariableType::kPerCall, const LogType xaxis=kLog, const float min=0.1, const float max=1000000., const size_t bins=70)
Book a TProfile for this Counter, to be filled in per-event monitoring.
Definition: CounterBase.cxx:68
CounterBase::getParent
const MonitorBase * getParent() const
Return cached non-owning const ptr to this Counter's parent Monitor.
Definition: CounterBase.cxx:22
CounterBase::~CounterBase
virtual ~CounterBase()=default
Default destructor.
Variable
Wrapper around a histogram which allows for some additional filling patterns and data manipulation.
Definition: Trigger/TrigCost/TrigCostAnalysis/src/Variable.h:39
CostData.h
LArCellBinning.xbins
int xbins
Definition: LArCellBinning.py:163
MonitorBase
Forward declare.
Definition: Trigger/TrigCost/TrigCostAnalysis/src/MonitorBase.h:33
CounterBase::increment
StatusCode increment(const std::string &name, float weight=1.0)
Convenience function.
Definition: CounterBase.cxx:220
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
xmax
double xmax
Definition: listroot.cxx:61
LogType
LogType
Histogram x-axis type flag.
Definition: Trigger/TrigCost/TrigCostAnalysis/src/Variable.h:26
CounterBase::m_variables
std::unordered_map< std::string, Variable > m_variables
Store of Counter's Variables.
Definition: CounterBase.h:205
CounterBase::timeToMilliSec
float timeToMilliSec(const uint64_t start, const uint64_t stop) const
Helper function.
Definition: CounterBase.cxx:243
CostData
Caches and propagates event data to be used by monitoring algorithms.
Definition: CostData.h:26
CounterBase::m_name
const std::string m_name
Counter's name.
Definition: CounterBase.h:203
ymax
double ymax
Definition: listroot.cxx:64