ATLAS Offline Software
Loading...
Searching...
No Matches
HistogramFiller1D.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_HistogramFiller1D_h
6#define AthenaMonitoringKernel_HistogramFiller_HistogramFiller1D_h
7
8#include "TH1.h"
9
10#include "HistogramFiller.h"
12
14#include "GaudiKernel/MsgStream.h"
15
16namespace Monitored {
17
22 public:
23 HistogramFiller1D(const HistogramDef& definition, std::shared_ptr<IHistogramProvider> provider)
24 : HistogramFiller(definition, std::move(provider)) {
25 }
26
27 virtual unsigned fill( const HistogramFiller::VariablesPack& vars ) const override {
28
29 if ( vars.cut ) {
30 const size_t maskSize = vars.cut->size();
31 // Abort if no cut entries or first (and only) entry is false
32 if (maskSize == 0 || (maskSize == 1 && !vars.cut->get(0))) { return 0; }
33 if (maskSize > 1 && maskSize != vars[0]->size()) [[unlikely]] {
34 MsgStream log(Athena::getMessageSvc(), "HistogramFiller1D");
35 log << MSG::ERROR << "CutMask does not match the size of plotted variable: "
36 << maskSize << " " << vars[0]->size() << endmsg;
37 }
38 }
39
40 // Accessor for cut mask in case one is defined
41 auto cutMaskAccessor = [&](size_t i) { return static_cast<bool>(vars.cut->get(i)); };
42
43 if (vars.weight) {
44 auto weightAccessor = [&](size_t i){ return vars.weight->get(i); };
45
46 if (vars.weight->size() != vars[0]->size()) [[unlikely]] {
47 MsgStream log(Athena::getMessageSvc(), "HistogramFiller1D");
48 log << MSG::ERROR << "Weight does not match the size of plotted variable: "
49 << vars.weight->size() << " " << vars[0]->size() << endmsg;
50 }
51 // Need to fill here while weightVector is still in scope
52 if (not vars.cut) return HistogramFiller::fill<TH1>(weightAccessor, detail::noCut, *vars[0]);
53 else return HistogramFiller::fill<TH1>(weightAccessor, cutMaskAccessor, *vars[0]);
54 }
55
56 if (not vars.cut) return HistogramFiller::fill<TH1>(detail::noWeight, detail::noCut, *vars[0]);
57 else return HistogramFiller::fill<TH1>(detail::noWeight, cutMaskAccessor, *vars[0]);
58 }
59 };
60}
61
62#endif /* AthenaMonitoringKernel_HistogramFiller_HistogramFiller1D_h */
#define endmsg
size_t size() const
Number of registered mappings.
HistogramFiller1D(const HistogramDef &definition, std::shared_ptr< IHistogramProvider > provider)
virtual unsigned fill(const HistogramFiller::VariablesPack &vars) const override
Method that actually fills the ROOT object.
HistogramFiller(const HistogramDef &histDef, std::shared_ptr< IHistogramProvider > histogramProvider)
Default constructor.
virtual unsigned fill(const VariablesPack &) const =0
Method that actually fills the ROOT object.
virtual double get(size_t) const =0
virtual size_t size() const =0
gives size of vector representation
singleton-like access to IMessageSvc via open function and helper
IMessageSvc * getMessageSvc(bool quiet=false)
auto noWeight
no weight for filling
auto noCut
no cut for filling
Generic monitoring tool for athena components.
STL namespace.
#define unlikely(x)
the internal class used to keep parsed Filler properties
helper class to pass variables to fillers
const Monitored::IMonitoredVariable * cut
pointer to cut mask variable, typically absent
size_t size() const
number of variables in the pack ( not counting the weight and mask )
const Monitored::IMonitoredVariable * weight
pointer to weight variable, typically absent