ATLAS Offline Software
HistogramFiller2DProfile.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 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 
12 
13 namespace Monitored {
18  public:
19  HistogramFiller2DProfile(const HistogramDef& definition, std::shared_ptr<IHistogramProvider> provider)
20  : HistogramFiller(definition, provider) {}
21 
22 
23  virtual unsigned fill( const HistogramFiller::VariablesPack& vars ) const override {
24  if ( vars.size() != 3) {
25  return 0;
26  }
27 
28  // handling of the cutmask
29  auto cutMaskValuePair = getCutMaskFunc(vars.cut);
30  if (cutMaskValuePair.first == 0) { return 0; }
31  auto cutMaskAccessor = cutMaskValuePair.second;
32 
33  if (vars.weight) {
34  // Weighted fill
35  auto weightAccessor = [&](size_t i){ return vars.weight->get(i); };
36  const size_t size0 = vars.var[0]->size();
37  const size_t size1 = vars.var[1]->size();
38  const size_t size2 = vars.var[2]->size();
39  const size_t sizeWeight = vars.weight->size();
40  if (ATH_UNLIKELY(size0 > 1 && size1 > 1 && size2 > 1 &&
41  sizeWeight > 1 && size0 != sizeWeight)) {
42  MsgStream log(Athena::getMessageSvc(), "HistogramFiller2DProfile");
43  log << MSG::ERROR << "Weight does not match the size of plotted variable: "
44  << vars.weight->size() << " " << size0 << endmsg;
45  return 0;
46  }
47  // Need to fill here while weightVector is still in scope
48  if (not vars.cut) return HistogramFiller::fill<TProfile2D>(weightAccessor, detail::noCut, *vars.var[0], *vars.var[1], *vars.var[2]);
49  else return HistogramFiller::fill<TProfile2D>(weightAccessor, cutMaskAccessor, *vars.var[0], *vars.var[1], *vars.var[2]);
50  }
51  // Unweighted fill
52  if (not vars.cut) return HistogramFiller::fill<TProfile2D>(detail::noWeight, detail::noCut, *vars.var[0], *vars.var[1], *vars.var[2]);
53  else return HistogramFiller::fill<TProfile2D>(detail::noWeight, cutMaskAccessor, *vars.var[0], *vars.var[1], *vars.var[2]);
54  }
55  };
56 
59 
60 }
61 
62 #endif /* AthenaMonitoringKernel_HistogramFiller_HistogramFiller2DProfile_h */
Monitored::HistogramFiller2DProfile::fill
virtual unsigned fill(const HistogramFiller::VariablesPack &vars) const override
Method that actually fills the ROOT object.
Definition: HistogramFiller2DProfile.h:23
Monitored::IMonitoredVariable::size
virtual size_t size() const =0
gives size of vector representation
Monitored::HistogramFiller::VariablesPack::cut
const Monitored::IMonitoredVariable * cut
pointer to cut mask variable, typically absent
Definition: HistogramFiller.h:115
Monitored::HistogramFiller2DProfile
Filler for profile 2D histogram.
Definition: HistogramFiller2DProfile.h:17
Monitored::HistogramFiller2DProfile::HistogramFiller2DProfile
HistogramFiller2DProfile(const HistogramDef &definition, std::shared_ptr< IHistogramProvider > provider)
Definition: HistogramFiller2DProfile.h:19
ATH_UNLIKELY
#define ATH_UNLIKELY(x)
Definition: AthUnlikelyMacros.h:17
Monitored::HistogramDef
the internal class used to keep parsed Filler properties
Definition: HistogramDef.h:15
Athena::getMessageSvc
IMessageSvc * getMessageSvc(bool quiet=false)
Definition: getMessageSvc.cxx:20
Monitored::HistogramFillerRebinableAxis
Mixin class for rebinning of histogram axis.
Definition: HistogramFillerRebinable.h:24
Monitored::HistogramFiller::VariablesPack::weight
const Monitored::IMonitoredVariable * weight
pointer to weight variable, typically absent
Definition: HistogramFiller.h:114
Monitored::HistogramFiller::VariablesPack
helper class to pass variables to fillers
Definition: HistogramFiller.h:71
Monitored::detail::noCut
auto noCut
no cut for filling
Definition: HistogramFillerUtils.h:29
Monitored::IMonitoredVariable::get
virtual double get(size_t) const =0
lumiFormat.i
int i
Definition: lumiFormat.py:85
Monitored
Generic monitoring tool for athena components.
Definition: GenericMonitoringTool.h:30
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
Monitored::HistogramFiller::VariablesPack::size
size_t size() const
number of variables in the pack ( not counting the weight and mask )
Definition: HistogramFiller.h:79
HistogramFiller.h
Monitored::HistogramFiller
Base class for all histogram fillers.
Definition: HistogramFiller.h:43
Monitored::detail::noWeight
auto noWeight
no weight for filling
Definition: HistogramFillerUtils.h:28
Monitored::HistogramFiller::VariablesPack::var
std::vector< const Monitored::IMonitoredVariable * > var
storage for variables, default size of 4, serves all histograming uses
Definition: HistogramFiller.h:113
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
Monitored::HistogramFiller2DProfileRebinable
HistogramFillerRebinableAxis< HistogramFiller2DProfile, Axis::X > HistogramFiller2DProfileRebinable
TProfile2D filler with rebinable x-axis.
Definition: HistogramFiller2DProfile.h:58
Monitored::HistogramFiller::getCutMaskFunc
std::pair< size_t, std::function< bool(size_t)> > getCutMaskFunc(const Monitored::IMonitoredVariable *mask) const
Definition: HistogramFiller.h:155