ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Control
AthenaMonitoringKernel
src
HistogramFiller
HistogramFiller2D.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 AthenaMonitoringKernel_HistogramFiller_HistogramFiller2D_h
6
#define AthenaMonitoringKernel_HistogramFiller_HistogramFiller2D_h
7
8
#include "TH2.h"
9
10
#include "
HistogramFiller.h
"
11
#include "
HistogramFillerUtils.h
"
12
#include "GaudiKernel/MsgStream.h"
13
14
namespace
Monitored
{
15
21
template
<
typename
H>
22
class
HistogramFiller2DGeneric
:
public
HistogramFiller
{
23
public
:
24
HistogramFiller2DGeneric
(
const
HistogramDef
& definition, std::shared_ptr<IHistogramProvider> provider)
25
:
HistogramFiller
(definition,
std
::move(provider)) {}
26
27
virtual
unsigned
fill
(
const
HistogramFiller::VariablesPack
& vars)
const override
{
28
if
(vars.
size
()!=2 or vars[0] ==
nullptr
or vars[1] ==
nullptr
) [[
unlikely
]]
return
0;
29
30
const
size_t
size0 = vars[0]->
size
();
31
const
size_t
size1 = vars[1]->
size
();
32
33
if
(size0 == 0 || size1 == 0) [[
unlikely
]] {
34
// nothing to do
35
return
0;
36
}
37
38
if
(size0 > 1 && size1 > 1 && size0 != size1) [[
unlikely
]] {
39
MsgStream log(
Athena::getMessageSvc
(),
"HistogramFiller2D"
);
40
log << MSG::ERROR <<
"Mismatch of provided vector sizes "
41
<< size0 <<
","
<< size1 <<
" for "
<<
m_histDef
->alias <<
endmsg
;
42
return
0;
43
}
44
45
if
(vars.
cut
) {
46
const
size_t
maskSize = vars.
cut
->
size
();
47
// Abort if no cut entries or first (and only) entry is false
48
if
(maskSize == 0 || (maskSize == 1 && !vars.
cut
->
get
(0))) {
return
0; }
49
if
(size0 > 1 && size1 > 1 &&
50
maskSize > 1 && size0 != maskSize) [[
unlikely
]] {
51
MsgStream log(
Athena::getMessageSvc
(),
"HistogramFiller2D"
);
52
log << MSG::ERROR <<
"CutMask does not match the size of plotted variable: "
53
<< maskSize <<
" "
<< size0 <<
endmsg
;
54
return
0;
55
}
56
}
57
58
// Accessor for cut mask in case one is defined
59
auto
cutMaskAccessor = [&](
size_t
i) {
return
static_cast<
bool
>
(vars.
cut
->
get
(i)); };
60
61
if
(vars.
weight
) {
62
auto
weightAccessor = [&](
size_t
i){
return
vars.
weight
->
get
(i); };
63
if
(size0 > 1 && size1 > 1 &&
64
vars.
weight
->
size
() > 1 && size0 != vars.
weight
->
size
()) [[
unlikely
]] {
65
MsgStream log(
Athena::getMessageSvc
(),
"HistogramFiller2D"
);
66
log << MSG::ERROR <<
"Weight does not match the size of plotted variable: "
67
<< vars.
weight
->
size
() <<
" "
<< size0 <<
endmsg
;
68
return
0;
69
}
70
// Need to fill here while weightVector is still in scope
71
if
(not vars.
cut
)
return
HistogramFiller::fill<H>
(weightAccessor,
detail::noCut
, *vars[0], *vars[1]);
72
else
return
HistogramFiller::fill<H>
(weightAccessor, cutMaskAccessor, *vars[0], *vars[1]);
73
}
74
75
if
(not vars.
cut
)
return
HistogramFiller::fill<H>
(
detail::noWeight
,
detail::noCut
, *vars[0], *vars[1]);
76
else
return
HistogramFiller::fill<H>
(
detail::noWeight
, cutMaskAccessor, *vars[0], *vars[1]);
77
}
78
};
79
80
typedef
HistogramFiller2DGeneric<TH2>
HistogramFiller2D
;
81
}
82
83
#endif
/* AthenaMonitoringKernel_HistogramFiller_HistogramFiller2D_h */
84
endmsg
#define endmsg
Definition
AnalysisConfig_Ntuple.cxx:54
HistogramFillerUtils.h
HistogramFiller.h
Monitored::HistogramFiller2DGeneric
Generic filler for 2D histogram.
Definition
HistogramFiller2D.h:22
Monitored::HistogramFiller2DGeneric::HistogramFiller2DGeneric
HistogramFiller2DGeneric(const HistogramDef &definition, std::shared_ptr< IHistogramProvider > provider)
Definition
HistogramFiller2D.h:24
Monitored::HistogramFiller2DGeneric::fill
virtual unsigned fill(const HistogramFiller::VariablesPack &vars) const override
Method that actually fills the ROOT object.
Definition
HistogramFiller2D.h:27
Monitored::HistogramFiller::HistogramFiller
HistogramFiller(const HistogramDef &histDef, std::shared_ptr< IHistogramProvider > histogramProvider)
Default constructor.
Definition
HistogramFiller.h:51
Monitored::HistogramFiller2DGeneric< TH2 >::m_histDef
std::shared_ptr< HistogramDef > m_histDef
Definition
HistogramFiller.h:180
Monitored::HistogramFiller::fill
virtual unsigned fill(const VariablesPack &) const =0
Method that actually fills the ROOT object.
Monitored::IMonitoredVariable::get
virtual double get(size_t) const =0
Monitored::IMonitoredVariable::size
virtual size_t size() const =0
gives size of vector representation
Athena::getMessageSvc
IMessageSvc * getMessageSvc(bool quiet=false)
Definition
getMessageSvc.cxx:20
Monitored::detail::noWeight
auto noWeight
no weight for filling
Definition
HistogramFillerUtils.h:27
Monitored::detail::noCut
auto noCut
no cut for filling
Definition
HistogramFillerUtils.h:28
Monitored
Generic monitoring tool for athena components.
Definition
GenericMonitoringTool.h:28
Monitored::HistogramFiller2D
HistogramFiller2DGeneric< TH2 > HistogramFiller2D
Definition
HistogramFiller2D.h:80
std
STL namespace.
unlikely
#define unlikely(x)
Definition
pythonic_coracool.cxx:9
Monitored::HistogramDef
the internal class used to keep parsed Filler properties
Definition
HistogramDef.h:15
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
Monitored::HistogramFiller::VariablesPack::weight
const Monitored::IMonitoredVariable * weight
pointer to weight variable, typically absent
Definition
HistogramFiller.h:112
Generated on
for ATLAS Offline Software by
1.17.0