ATLAS Offline Software
Loading...
Searching...
No Matches
CounterBase.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 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
16#include <cstdint>
17#include <string>
18#include <string_view>
19#include <unordered_map>
20
21
22class MonitorBase;
23class TH1;
24
33 public:
37 CounterBase() = delete;
38
44 CounterBase(const std::string& name, const MonitorBase* parent);
45
49 virtual ~CounterBase() = default;
50
55
59 CounterBase(const CounterBase&) = delete;
60
65 const std::string& getName() const;
66
71 const MonitorBase* getParent() const;
72
78 bool variableExists(const std::string& name) const;
79
86 Variable& getVariable(std::string_view name);
87
94 StatusCode fill(std::string_view name, float value, float weight = 1.0);
95
103 StatusCode fill(std::string_view name, float xvalue, float yvalue, float weight);
104
110 StatusCode increment(std::string_view name, float weight = 1.0);
111
117 StatusCode setDenominator(const std::string& name, float value);
118
122 virtual StatusCode endEvent(float weight = 1.0);
123
130 virtual StatusCode newEvent(const CostData& data, size_t index, float weight = 1.0) = 0;
131
132 protected:
133
143 void regHistogram(const std::string& name,
144 const std::string& title,
146 const LogType xaxis = kLog,
147 const float min = 0.1,
148 const float max = 1000000.,
149 const size_t bins = 70);
150
160 void regTProfile(const std::string& name,
161 const std::string& title,
163 const LogType xaxis = kLog,
164 const float min = 0.1,
165 const float max = 1000000.,
166 const size_t bins = 70);
167
181 void regHistogram(const std::string& name,
182 const std::string& title,
183 const VariableType type,
184 const LogType xaxis,
185 const float xmin,
186 const float xmax,
187 const size_t xbins,
188 const LogType yaxis,
189 const float ymin,
190 const float ymax,
191 const size_t ybins);
192
193
200 TH1* bookGetPointer(TH1* hist, const std::string& tDir = "") const;
201
206 float timeToMilliSec(const uint64_t start, const uint64_t stop) const;
207
208 private:
209
210 const std::string m_name;
212 std::unordered_map< std::string, Variable, CxxUtils::TransparentStringHash, std::equal_to<> > m_variables;
213};
214
215#endif // TRIGCOSTANALYSIS_COUNTERBASE_H
static const std::vector< std::string > bins
VariableType
Behaviour of Variable.
Definition Variable.h:19
@ kPerCall
Variable should fill underlying histogram on each fill.
Definition Variable.h:20
LogType
Histogram x-axis type flag.
Definition Variable.h:28
@ kLog
Logarithmic x-binning.
Definition Variable.h:30
#define min(a, b)
Definition cfImp.cxx:40
#define max(a, b)
Definition cfImp.cxx:41
Caches and propagates event data to be used by monitoring algorithms.
Definition CostData.h:26
float timeToMilliSec(const uint64_t start, const uint64_t stop) const
Helper function.
CounterBase()=delete
Forbid default constructor.
TH1 * bookGetPointer(TH1 *hist, const std::string &tDir="") const
Appends Counter name (to histogram path) and forwards histogram book request to parent Monitor.
StatusCode increment(std::string_view name, float weight=1.0)
Convenience function.
const MonitorBase * getParent() const
Return cached non-owning const ptr to this Counter's parent Monitor.
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.
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.
const std::string & getName() const
Getter for Counter's name.
virtual StatusCode endEvent(float weight=1.0)
Called by the framework.
bool variableExists(const std::string &name) const
Check if a variable of a given name exists.
const MonitorBase * m_parent
Counter's parent Monitor.
Variable & getVariable(std::string_view name)
Returns a mutable reference to a named Variable.
StatusCode fill(std::string_view 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...
std::unordered_map< std::string, Variable, CxxUtils::TransparentStringHash, std::equal_to<> > m_variables
Store of Counter's Variables.
const std::string m_name
Counter's name.
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.
StatusCode setDenominator(const std::string &name, float value)
Optional for per-Event Variables.
CounterBase(const CounterBase &)=delete
Forbid copy.
CounterBase & operator=(const CounterBase &)=delete
Forbid assignment.
virtual ~CounterBase()=default
Default destructor.
Wrapper around a histogram which allows for some additional filling patterns and data manipulation.
Definition Variable.h:41
double xmax
Definition listroot.cxx:61
double ymin
Definition listroot.cxx:63
double xmin
Definition listroot.cxx:60
double ymax
Definition listroot.cxx:64
Definition index.py:1