ATLAS Offline Software
Loading...
Searching...
No Matches
HistogramFiller2DProfile.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_HistogramFiller2DProfile_h
6#define AthenaMonitoringKernel_HistogramFiller_HistogramFiller2DProfile_h
7
8#include "TProfile2D.h"
9#include "boost/range/combine.hpp"
10
11#include "HistogramFiller.h"
12
13namespace Monitored {
18 public:
19 HistogramFiller2DProfile(const HistogramDef& definition, std::shared_ptr<IHistogramProvider> provider)
20 : HistogramFiller(definition, std::move(provider)) {}
21
22
23 virtual unsigned fill( const HistogramFiller::VariablesPack& vars ) const override {
24 if ( vars.size() != 3) {
25 return 0;
26 }
27
28 if (vars.cut) {
29 const size_t maskSize = vars.cut->size();
30 // Abort if no cut entries or first (and only) entry is false
31 if (maskSize == 0 || (maskSize == 1 && !vars.cut->get(0))) { return 0; }
32 }
33
34 // Accessor for cut mask in case one is defined
35 auto cutMaskAccessor = [&](size_t i) { return static_cast<bool>(vars.cut->get(i)); };
36
37 if (vars.weight) {
38 // Weighted fill
39 auto weightAccessor = [&](size_t i){ return vars.weight->get(i); };
40 const size_t size0 = vars[0]->size();
41 const size_t size1 = vars[1]->size();
42 const size_t size2 = vars[2]->size();
43 const size_t sizeWeight = vars.weight->size();
44 if (ATH_UNLIKELY(size0 > 1 && size1 > 1 && size2 > 1 &&
45 sizeWeight > 1 && size0 != sizeWeight)) {
46 MsgStream log(Athena::getMessageSvc(), "HistogramFiller2DProfile");
47 log << MSG::ERROR << "Weight does not match the size of plotted variable: "
48 << vars.weight->size() << " " << size0 << endmsg;
49 return 0;
50 }
51 // Need to fill here while weightVector is still in scope
52 if (not vars.cut) return HistogramFiller::fill<TProfile2D>(weightAccessor, detail::noCut, *vars[0], *vars[1], *vars[2]);
53 else return HistogramFiller::fill<TProfile2D>(weightAccessor, cutMaskAccessor, *vars[0], *vars[1], *vars[2]);
54 }
55 // Unweighted fill
56 if (not vars.cut) return HistogramFiller::fill<TProfile2D>(detail::noWeight, detail::noCut, *vars[0], *vars[1], *vars[2]);
57 else return HistogramFiller::fill<TProfile2D>(detail::noWeight, cutMaskAccessor, *vars[0], *vars[1], *vars[2]);
58 }
59 };
60
63
64}
65
66#endif /* AthenaMonitoringKernel_HistogramFiller_HistogramFiller2DProfile_h */
#define endmsg
#define ATH_UNLIKELY(x)
virtual unsigned fill(const HistogramFiller::VariablesPack &vars) const override
Method that actually fills the ROOT object.
HistogramFiller2DProfile(const HistogramDef &definition, std::shared_ptr< IHistogramProvider > provider)
Mixin class for rebinning of histogram axis.
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
IMessageSvc * getMessageSvc(bool quiet=false)
auto noWeight
no weight for filling
auto noCut
no cut for filling
Generic monitoring tool for athena components.
HistogramFillerRebinableAxis< HistogramFiller2DProfile, Axis::X > HistogramFiller2DProfileRebinable
TProfile2D filler with rebinable x-axis.
STL namespace.
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