|
ATLAS Offline Software
|
Go to the documentation of this file.
28 const std::string&
title,
36 std::unique_ptr<TH1F>
hist;
39 throw std::runtime_error(
"CounterBase::regHistogram: Cannot have max <= min or bins == 0");
44 }
else if (xaxis ==
kLog) {
46 throw std::runtime_error(
"CounterBase::regHistogram: Cannot have min <= 0 with log binning");
48 std::unique_ptr<double[]>
xbins = std::make_unique<double[]>(
bins+1);
49 const double xlogmin = log10(
min);
50 const double xlogmax = log10(
max);
51 const double dlogx = (xlogmax-xlogmin)/((
double)
bins);
52 for (
size_t i = 0;
i <=
bins; ++
i) {
53 const double xlog = xlogmin +
i*dlogx;
58 throw std::runtime_error(
"CounterBase::regHistogram: Unknown logarithm flag");
62 std::forward_as_tuple(
name),
69 const std::string&
title,
77 std::unique_ptr<TProfile>
hist;
80 throw std::runtime_error(
"CounterBase::regTProfile: Cannot have max <= min or bins == 0");
85 }
else if (xaxis ==
kLog) {
87 throw std::runtime_error(
"CounterBase::regTProfile: Cannot have min <= 0 with log binning");
89 std::unique_ptr<double[]>
xbins = std::make_unique<double[]>(
bins+1);
90 const double xlogmin = log10(
min);
91 const double xlogmax = log10(
max);
92 const double dlogx = (xlogmax-xlogmin)/((
double)
bins);
93 for (
size_t i = 0;
i <=
bins; ++
i) {
94 const double xlog = xlogmin +
i*dlogx;
97 hist = std::make_unique<TProfile>(hisSvcName.c_str(),
title.c_str(),
bins,
xbins.get());
99 throw std::runtime_error(
"CounterBase::regTProfile: Unknown logarithm flag");
103 std::forward_as_tuple(
name),
110 const std::string&
title,
122 std::unique_ptr<TH2F>
hist;
125 throw std::runtime_error(
"CounterBase::regHistogram: Cannot have max <= min or bins == 0");
130 }
else if (xaxis ==
kLog || yaxis ==
kLog) {
132 throw std::runtime_error(
"CounterBase::regHistogram: Cannot have min <= 0 with log binning");
134 std::unique_ptr<double[]> xlogbins = std::make_unique<double[]>(
xbins+1);
135 std::unique_ptr<double[]> ylogbins = std::make_unique<double[]>(
ybins+1);
137 const double xlogmin = log10(
xmin);
138 const double xlogmax = log10(
xmax);
139 const double dlogx = (xlogmax-xlogmin)/((
double)
xbins);
140 for (
size_t i = 0;
i <=
xbins; ++
i) {
141 const double xlog = xlogmin +
i*dlogx;
142 xlogbins[
i] =
exp(
log(10) * xlog );
146 for (
size_t i = 0;
i <=
xbins; ++
i) {
152 const double ylogmin = log10(
ymin);
153 const double ylogmax = log10(
ymax);
154 const double dlogy = (ylogmax-ylogmin)/((
double)
ybins);
155 for (
size_t i = 0;
i <=
ybins; ++
i) {
156 const double ylog = ylogmin +
i*dlogy;
157 ylogbins[
i] =
exp(
log(10) * ylog );
161 for (
size_t i = 0;
i <=
ybins; ++
i) {
166 hist = std::make_unique<TH2F>(hisSvcName.c_str(),
title.c_str(),
xbins, xlogbins.get(),
ybins, ylogbins.get());
168 throw std::runtime_error(
"CounterBase::regHistogram: Unknown logarithm flag");
172 std::forward_as_tuple(
name),
185 throw std::runtime_error(
"CounterBase::getVariable: No varialbe with name " +
name );
194 return StatusCode::FAILURE;
197 return StatusCode::SUCCESS;
203 return StatusCode::FAILURE;
206 return StatusCode::SUCCESS;
213 return StatusCode::FAILURE;
215 it->second.setDenominator(
value);
216 return StatusCode::SUCCESS;
227 ATH_CHECK( nameVariablePair.second.endEvent() );
229 return StatusCode::SUCCESS;
248 return (difference * 1
e-3);
StatusCode setDenominator(const std::string &name, float value)
Optional for per-Event Variables.
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.
TH1 * bookGetPointer(TH1 *hist, const std::string &tDir="") const
Appends Monitor name (to histogram path) and forwards histogram book request to parent Range.
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...
virtual StatusCode endEvent(float weight=1.0)
Called by the framework.
CounterBase()=delete
Forbid default constructor.
const std::string & getName() const
Getter for Counter's name.
const std::string & getName() const
Getter for Range's name.
VariableType
Behaviour of Variable.
const MonitoredRange * getParent() const
Return cached non-owning const ptr to this Monitor's parent Range.
@ kLog
Logarithmic x-binning.
TH1 * bookGetPointer(TH1 *hist, const std::string &tDir="") const
Appends Counter name (to histogram path) and forwards histogram book request to parent Monitor.
::StatusCode StatusCode
StatusCode definition for legacy code.
const std::string & getName() const
Getter for Monitor's name.
const MonitorBase * m_parent
Counter's parent Monitor.
bool variableExists(const std::string &name) const
Check if a variable of a given name exists.
Variable & getVariable(const std::string &name)
Returns a mutable reference to a named Variable.
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.
std::string to_string(const DetectorType &type)
const MonitorBase * getParent() const
Return cached non-owning const ptr to this Counter's parent Monitor.
Wrapper around a histogram which allows for some additional filling patterns and data manipulation.
@ kLinear
Linear x-binning.
StatusCode increment(const std::string &name, float weight=1.0)
Convenience function.
LogType
Histogram x-axis type flag.
std::unordered_map< std::string, Variable > m_variables
Store of Counter's Variables.
float timeToMilliSec(const uint64_t start, const uint64_t stop) const
Helper function.
const std::string m_name
Counter's name.