ATLAS Offline Software
Trigger/TrigCost/TrigCostAnalysis/src/Variable.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef TRIGCOSTANALYSIS_VARIABLE_H
6 #define TRIGCOSTANALYSIS_VARIABLE_H 1
7 
8 #include "GaudiKernel/StatusCode.h"
10 
11 class TH1; //<! Forward declaration
12 
17 enum VariableType {
19  kPerEvent
20 };
21 
26 enum LogType {
28  kLog
29 };
30 
39 class Variable {
40  public:
44  Variable() = delete;
45 
52  Variable(const std::string& name, TH1* cacheHistoPtr, VariableType type = kPerCall);
53 
57  ~Variable() = default;
58 
62  Variable& operator=(const Variable&) = delete;
63 
67  Variable(const Variable&) = delete;
68 
73  const std::string& getName() const;
74 
79  size_t getCalls() const;
80 
85  float getAccumulator() const;
86 
92  StatusCode fill(float value, float weight = 1.0);
93 
100  StatusCode fill(float xvalue, float yvalue, float weight);
101 
107  StatusCode fill(const std::string& label, float weight = 1.0);
108 
113  StatusCode increment(float weight = 1.0);
114 
120  StatusCode setBinLabel(int bin, const std::string& label);
121 
127  StatusCode setYBinLabel(int bin, const std::string& label);
128 
133  void setDenominator(float value);
134 
139 
140  private:
141 
142  const std::string m_name; //<! Variable's name
143  const VariableType m_variableType; //<! Variable's type enumeration
144  TH1* m_cacheHistoPtr; //<! Mutable cached non-owning ptr to this Variable's histogram.
145  size_t m_calls; //<! Counter of how many times the Variable is Filled in an event.
146  float m_xaccumulator; //<! For per-Event quantities, the accumulator buffers until the final quantity is known.
147  float m_yaccumulator; //<! Buffer as xaccumulator, but for y axis, used of 2D histograms
148  float m_weight;
150 };
151 
152 #endif // TRIGCOSTANALYSIS_VARIABLE_H
Variable::m_calls
size_t m_calls
Definition: Trigger/TrigCost/TrigCostAnalysis/src/Variable.h:145
Variable::m_weight
float m_weight
Cache of the event weight.
Definition: Trigger/TrigCost/TrigCostAnalysis/src/Variable.h:148
AthCheckMacros.h
PlotCalibFromCool.label
label
Definition: PlotCalibFromCool.py:78
kPerEvent
@ kPerEvent
Variable should buffer fill calls in an accumulator and fill the underlying histogram once at the end...
Definition: Trigger/TrigCost/TrigCostAnalysis/src/Variable.h:19
bin
Definition: BinsDiffFromStripMedian.h:43
athena.value
value
Definition: athena.py:124
Variable::getCalls
size_t getCalls() const
Getter for how many times fill() has already been called on this Variable in this event.
Definition: Variable.cxx:29
Variable::endEvent
StatusCode endEvent()
Called by the framework.
Definition: Variable.cxx:120
Variable::m_cacheHistoPtr
TH1 * m_cacheHistoPtr
Definition: Trigger/TrigCost/TrigCostAnalysis/src/Variable.h:144
VariableType
VariableType
Behaviour of Variable.
Definition: Trigger/TrigCost/TrigCostAnalysis/src/Variable.h:17
Variable::m_yaccumulator
float m_yaccumulator
Definition: Trigger/TrigCost/TrigCostAnalysis/src/Variable.h:147
Variable::m_oneOverDenominator
float m_oneOverDenominator
Cache of the reciprocal of the denominator used to normalise when filling the histogram.
Definition: Trigger/TrigCost/TrigCostAnalysis/src/Variable.h:149
dqt_zlumi_pandas.weight
int weight
Definition: dqt_zlumi_pandas.py:189
Variable::operator=
Variable & operator=(const Variable &)=delete
Forbid copy.
Variable::m_variableType
const VariableType m_variableType
Definition: Trigger/TrigCost/TrigCostAnalysis/src/Variable.h:143
kLog
@ kLog
Logarithmic x-binning.
Definition: Trigger/TrigCost/TrigCostAnalysis/src/Variable.h:28
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
Variable::Variable
Variable(const Variable &)=delete
Forbid copy.
Variable::m_xaccumulator
float m_xaccumulator
Definition: Trigger/TrigCost/TrigCostAnalysis/src/Variable.h:146
Variable::increment
StatusCode increment(float weight=1.0)
Convenience function.
Definition: Variable.cxx:102
Variable::m_name
const std::string m_name
Definition: Trigger/TrigCost/TrigCostAnalysis/src/Variable.h:142
Variable::getAccumulator
float getAccumulator() const
Getter for accumulated value of a kPerEvent Variable.
Definition: Variable.cxx:34
Variable::setBinLabel
StatusCode setBinLabel(int bin, const std::string &label)
Set label on given bin in cached histogram.
Definition: Variable.cxx:108
kPerCall
@ kPerCall
Variable should fill underlying histogram on each fill.
Definition: Trigger/TrigCost/TrigCostAnalysis/src/Variable.h:18
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
Variable::setYBinLabel
StatusCode setYBinLabel(int bin, const std::string &label)
Set label on given bin in cached histogram on y axis.
Definition: Variable.cxx:114
Variable
Wrapper around a histogram which allows for some additional filling patterns and data manipulation.
Definition: Trigger/TrigCost/TrigCostAnalysis/src/Variable.h:39
kLinear
@ kLinear
Linear x-binning.
Definition: Trigger/TrigCost/TrigCostAnalysis/src/Variable.h:27
Variable::Variable
Variable()=delete
Forbid default constructor.
Variable::getName
const std::string & getName() const
Getter for Variable's name.
Definition: Variable.cxx:24
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
Variable::~Variable
~Variable()=default
Default destructor.
LogType
LogType
Histogram x-axis type flag.
Definition: Trigger/TrigCost/TrigCostAnalysis/src/Variable.h:26
Variable::fill
StatusCode fill(float value, float weight=1.0)
Fill histogram (per-Call Variable), or add value to internal accumulator (per-Event Variable) to be f...
Definition: Variable.cxx:49
Variable::setDenominator
void setDenominator(float value)
Sets, until the end of the event, a denominator which will be used to normalise every Fill.
Definition: Variable.cxx:39