ATLAS Offline Software
Loading...
Searching...
No Matches
Variable.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_VARIABLE_H
6#define TRIGCOSTANALYSIS_VARIABLE_H 1
7
8#include "GaudiKernel/StatusCode.h"
10#include <string>
11
12
13class TH1; //<! Forward declaration
14
23
32
41class Variable {
42 public:
46 Variable() = delete;
47
54 Variable(const std::string& name, TH1* cacheHistoPtr, VariableType type = kPerCall);
55
59 ~Variable() = default;
60
64 Variable& operator=(const Variable&) = delete;
65
69 Variable(const Variable&) = delete;
70
75 const std::string& getName() const;
76
81 size_t getCalls() const;
82
87 float getAccumulator() const;
88
94 StatusCode fill(float value, float weight = 1.0);
95
102 StatusCode fill(float xvalue, float yvalue, float weight);
103
109 StatusCode fill(const std::string& label, float weight = 1.0);
110
115 StatusCode increment(float weight = 1.0);
116
122 StatusCode setBinLabel(int bin, const std::string& label);
123
129 StatusCode setYBinLabel(int bin, const std::string& label);
130
135 void setDenominator(float value);
136
140 StatusCode endEvent();
141
142 private:
143
144 const std::string m_name; //<! Variable's name
145 const VariableType m_variableType; //<! Variable's type enumeration
146 TH1* m_cacheHistoPtr; //<! Mutable cached non-owning ptr to this Variable's histogram.
147 size_t m_calls; //<! Counter of how many times the Variable is Filled in an event.
148 float m_xaccumulator; //<! For per-Event quantities, the accumulator buffers until the final quantity is known.
149 float m_yaccumulator; //<! Buffer as xaccumulator, but for y axis, used of 2D histograms
150 float m_weight;
152};
153
154#endif // TRIGCOSTANALYSIS_VARIABLE_H
VariableType
Behaviour of Variable.
Definition Variable.h:19
@ kPerEvent
Variable should buffer fill calls in an accumulator and fill the underlying histogram once at the end...
Definition Variable.h:21
@ kPerCall
Variable should fill underlying histogram on each fill.
Definition Variable.h:20
LogType
Histogram x-axis type flag.
Definition Variable.h:28
@ kLinear
Linear x-binning.
Definition Variable.h:29
@ kLog
Logarithmic x-binning.
Definition Variable.h:30
float m_xaccumulator
Definition Variable.h:148
float m_weight
Cache of the event weight.
Definition Variable.h:150
StatusCode endEvent()
Called by the framework.
Definition Variable.cxx:126
Variable()=delete
Forbid default constructor.
StatusCode increment(float weight=1.0)
Convenience function.
Definition Variable.cxx:108
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:50
void setDenominator(float value)
Sets, until the end of the event, a denominator which will be used to normalise every Fill.
Definition Variable.cxx:40
StatusCode setYBinLabel(int bin, const std::string &label)
Set label on given bin in cached histogram on y axis.
Definition Variable.cxx:120
const std::string & getName() const
Getter for Variable's name.
Definition Variable.cxx:25
size_t getCalls() const
Getter for how many times fill() has already been called on this Variable in this event.
Definition Variable.cxx:30
const VariableType m_variableType
Definition Variable.h:145
~Variable()=default
Default destructor.
float m_yaccumulator
Definition Variable.h:149
Variable(const Variable &)=delete
Forbid copy.
float getAccumulator() const
Getter for accumulated value of a kPerEvent Variable.
Definition Variable.cxx:35
StatusCode setBinLabel(int bin, const std::string &label)
Set label on given bin in cached histogram.
Definition Variable.cxx:114
size_t m_calls
Definition Variable.h:147
const std::string m_name
Definition Variable.h:144
TH1 * m_cacheHistoPtr
Definition Variable.h:146
float m_oneOverDenominator
Cache of the reciprocal of the denominator used to normalise when filling the histogram.
Definition Variable.h:151
Variable & operator=(const Variable &)=delete
Forbid copy.
std::string label(const std::string &format, int i)
Definition label.h:19