ATLAS Offline Software
Loading...
Searching...
No Matches
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
11class TH1; //<! Forward declaration
12
21
30
39class 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
138 StatusCode endEvent();
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
VariableType
Behaviour of Variable.
@ kPerEvent
Variable should buffer fill calls in an accumulator and fill the underlying histogram once at the end...
@ kPerCall
Variable should fill underlying histogram on each fill.
LogType
Histogram x-axis type flag.
@ kLog
Logarithmic x-binning.
float m_weight
Cache of the event weight.
StatusCode endEvent()
Called by the framework.
Definition Variable.cxx:120
Variable()=delete
Forbid default constructor.
StatusCode increment(float weight=1.0)
Convenience function.
Definition Variable.cxx:102
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
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
StatusCode setYBinLabel(int bin, const std::string &label)
Set label on given bin in cached histogram on y axis.
Definition Variable.cxx:114
const std::string & getName() const
Getter for Variable's name.
Definition Variable.cxx:24
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()=default
Default destructor.
Variable(const Variable &)=delete
Forbid copy.
float getAccumulator() const
Getter for accumulated value of a kPerEvent Variable.
Definition Variable.cxx:34
StatusCode setBinLabel(int bin, const std::string &label)
Set label on given bin in cached histogram.
Definition Variable.cxx:108
float m_oneOverDenominator
Cache of the reciprocal of the denominator used to normalise when filling the histogram.
Variable & operator=(const Variable &)=delete
Forbid copy.
std::string label(const std::string &format, int i)
Definition label.h:19