ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Control
AthenaMonitoringKernel
src
HistogramFiller
HistogramFillerRebinable.h
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#ifndef AthenaMonitoringKernel_HistogramFiller_HistogramFillerRebinable1D_h
6
#define AthenaMonitoringKernel_HistogramFiller_HistogramFillerRebinable1D_h
7
8
#include "
AthenaMonitoringKernel/OHLockedHist.h
"
9
#include "
HistogramFiller1D.h
"
10
#include "
HistogramFiller2D.h
"
11
#include "
HistogramFillerUtils.h
"
12
13
#include <cmath>
14
15
namespace
Monitored
{
16
23
template
<
typename
BASE, Monitored::Axis AXIS>
24
class
HistogramFillerRebinableAxis
:
public
BASE {
25
public
:
26
27
HistogramFillerRebinableAxis
(
const
HistogramDef
& definition, std::shared_ptr<IHistogramProvider> provider)
28
: BASE(definition,
std
::move(provider)) {
29
if
(definition.
kAddBinsDynamically
) {
30
m_rebinMode = RebinMode::AddBins;
31
}
else
{
32
m_rebinMode = RebinMode::ExtendAxes;
33
}
34
}
35
36
virtual
unsigned
fill
(
const
HistogramFiller::VariablesPack
& vars )
const override
{
37
if
(AXIS >= vars.
size
() ) {
return
0; }
38
if
(vars[AXIS]->
size
()==0) {
return
0; }
39
40
// check if any of the cutmasks are non-zero before attempting any rebinning
41
if
(vars.
cut
) {
42
bool
anyTrue =
false
;
43
for
(
size_t
i=0; i<vars.
cut
->
size
(); i++) {
44
anyTrue |=
static_cast<
bool
>
(vars.
cut
->
get
(i));
45
}
46
if
(!anyTrue) {
return
0; }
47
}
48
49
double
min
= std::numeric_limits<double>::max();
50
double
max
= std::numeric_limits<double>::min();
51
const
IMonitoredVariable
& var = *vars[AXIS];
52
for
(
size_t
i = 0; i < var.size(); i++) {
53
const
double
v = var.get(i);
54
if
(v <
min
)
min
= v;
55
if
(v >
max
)
max
= v;
56
}
57
58
TH1* hist = this->
template
histogram<TH1>
();
59
TAxis* axis =
detail::getAxis<AXIS>
(hist);
60
if
(
m_rebinMode
==
RebinMode::AddBins
) {
61
if
(
Monitored::detail::shouldRebinHistogram
(axis,
max
)) {
62
Monitored::detail::rebinHistogram<AXIS>
(hist,
max
);
63
}
64
}
else
{
65
hist->SetCanExtend(
detail::axis_bit
[AXIS]);
66
// ExtendAxis is an extremely expensive operation; only call if necessary
67
// Rebinning requires a lock on the global ROOT directory state
68
std::scoped_lock<std::mutex> dirLock(
HistogramFactory::globalROOTMutex
());
69
if
(
max
>= axis->GetXmax()) hist->ExtendAxis(
max
, axis);
70
if
(
min < axis->
GetXmin()) hist->ExtendAxis(
min
, axis);
71
}
72
return
BASE::fill( vars );
73
}
74
75
private
:
76
enum class
RebinMode
{
AddBins
,
ExtendAxes
};
77
RebinMode
m_rebinMode
;
78
};
79
81
typedef
HistogramFillerRebinableAxis<HistogramFiller1D, Axis::X>
HistogramFillerRebinable1D
;
83
typedef
HistogramFillerRebinableAxis<HistogramFiller2D, Axis::X>
HistogramFillerRebinable2DX
;
85
typedef
HistogramFillerRebinableAxis<HistogramFiller2D, Axis::Y>
HistogramFillerRebinable2DY
;
87
typedef
HistogramFillerRebinableAxis<HistogramFillerRebinable2DX, Axis::Y>
HistogramFillerRebinable2D
;
88
}
89
90
#endif
/* AthenaMonitoringKernel_HistogramFiller_HistogramFillerRebinable1D_h */
HistogramFiller1D.h
HistogramFiller2D.h
HistogramFillerUtils.h
OHLockedHist.h
OH histogram lock header file.
size
size_t size() const
Number of registered mappings.
min
#define min(a, b)
Definition
cfImp.cxx:40
max
#define max(a, b)
Definition
cfImp.cxx:41
histogram
std::string histogram
Definition
chains.cxx:52
Monitored::HistogramFactory::globalROOTMutex
static std::mutex & globalROOTMutex()
Definition
HistogramFactory.h:68
Monitored::HistogramFillerRebinableAxis
Mixin class for rebinning of histogram axis.
Definition
HistogramFillerRebinable.h:24
Monitored::HistogramFillerRebinableAxis::RebinMode
RebinMode
Definition
HistogramFillerRebinable.h:76
Monitored::HistogramFillerRebinableAxis::RebinMode::AddBins
@ AddBins
Definition
HistogramFillerRebinable.h:76
Monitored::HistogramFillerRebinableAxis::RebinMode::ExtendAxes
@ ExtendAxes
Definition
HistogramFillerRebinable.h:76
Monitored::HistogramFillerRebinableAxis< HistogramFiller2DProfile, Axis::X >::m_rebinMode
RebinMode m_rebinMode
Definition
HistogramFillerRebinable.h:77
Monitored::HistogramFillerRebinableAxis::HistogramFillerRebinableAxis
HistogramFillerRebinableAxis(const HistogramDef &definition, std::shared_ptr< IHistogramProvider > provider)
Definition
HistogramFillerRebinable.h:27
Monitored::HistogramFillerRebinableAxis::fill
virtual unsigned fill(const HistogramFiller::VariablesPack &vars) const override
Definition
HistogramFillerRebinable.h:36
Monitored::IMonitoredVariable
Definition
IMonitoredVariable.h:14
Monitored::IMonitoredVariable::get
virtual double get(size_t) const =0
Monitored::IMonitoredVariable::size
virtual size_t size() const =0
gives size of vector representation
Monitored::detail::getAxis
constexpr auto getAxis(H *hist)
Helper to get corresponding TAxis selected by Monitored::Axis.
Definition
HistogramFillerUtils.h:40
Monitored::detail::axis_bit
constexpr std::array axis_bit
Definition
HistogramFillerUtils.h:33
Monitored::detail::shouldRebinHistogram
bool shouldRebinHistogram(const TAxis *axis, const double value)
Method checks if histogram should be rebinned.
Definition
HistogramFillerUtils.h:70
Monitored::detail::rebinHistogram
void rebinHistogram(H *hist, const double value)
Method that rebins a histogram.
Definition
HistogramFillerUtils.h:89
Monitored
Generic monitoring tool for athena components.
Definition
GenericMonitoringTool.h:28
Monitored::HistogramFillerRebinable2D
HistogramFillerRebinableAxis< HistogramFillerRebinable2DX, Axis::Y > HistogramFillerRebinable2D
Rebinable 2D histogram (both axes).
Definition
HistogramFillerRebinable.h:87
Monitored::HistogramFillerRebinable2DY
HistogramFillerRebinableAxis< HistogramFiller2D, Axis::Y > HistogramFillerRebinable2DY
Rebinable 2D histogram (y-axis only).
Definition
HistogramFillerRebinable.h:85
Monitored::HistogramFillerRebinable2DX
HistogramFillerRebinableAxis< HistogramFiller2D, Axis::X > HistogramFillerRebinable2DX
Rebinable 2D histogram (x-axis only).
Definition
HistogramFillerRebinable.h:83
Monitored::HistogramFillerRebinable1D
HistogramFillerRebinableAxis< HistogramFiller1D, Axis::X > HistogramFillerRebinable1D
Rebinable 1D histogram.
Definition
HistogramFillerRebinable.h:81
std
STL namespace.
Monitored::HistogramDef
the internal class used to keep parsed Filler properties
Definition
HistogramDef.h:15
Monitored::HistogramDef::kAddBinsDynamically
bool kAddBinsDynamically
add new bins outside the existing range
Definition
HistogramDef.h:45
Monitored::HistogramFiller::VariablesPack
helper class to pass variables to fillers
Definition
HistogramFiller.h:72
Monitored::HistogramFiller::VariablesPack::cut
const Monitored::IMonitoredVariable * cut
pointer to cut mask variable, typically absent
Definition
HistogramFiller.h:113
Monitored::HistogramFiller::VariablesPack::size
size_t size() const
number of variables in the pack ( not counting the weight and mask )
Definition
HistogramFiller.h:87
Generated on
for ATLAS Offline Software by
1.17.0