ATLAS Offline Software
HistogramFillerEfficiency.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef AthenaMonitoringKernel_HistogramFiller_HistogramFillerEfficiency_h
6 #define AthenaMonitoringKernel_HistogramFiller_HistogramFillerEfficiency_h
7 
8 #include "TEfficiency.h"
9 
11 #include "HistogramFillerUtils.h"
12 
13 namespace Monitored {
18  public:
19  HistogramFillerEfficiency(const HistogramDef& definition, std::shared_ptr<IHistogramProvider> provider)
20  : HistogramFiller(definition, provider) {}
21 
22  virtual unsigned fill( const HistogramFiller::VariablesPack& vars ) const override {
23 
24  if ( ATH_UNLIKELY( vars.var[0] == nullptr or vars.var[1] == nullptr ) ) return 0;
25 
26 
27 
28  auto cutMaskValuePair = getCutMaskFunc(vars.cut);
29  if (cutMaskValuePair.first == 0) { return 0; }
30  if (ATH_UNLIKELY(cutMaskValuePair.first > 1 && cutMaskValuePair.first != vars.var[0]->size())) {
31  MsgStream log(Athena::getMessageSvc(), "HistogramFillerEfficiency");
32  log << MSG::ERROR << "CutMask does not match the size of plotted variable: "
33  << cutMaskValuePair.first << " " << vars.var[0]->size() << endmsg;
34  }
35  auto cutMaskAccessor = cutMaskValuePair.second;
36 
37  TEfficiency* efficiency = this->histogram<TEfficiency>();
38  const TH1* efftot = efficiency->GetTotalHistogram();
39 
40  const unsigned nMonVar = vars.size();
41  const size_t var0Size = vars.var[0]->size();
42  if ( nMonVar==2 ) { // Single observable (1D TEfficiency)
43  for (unsigned i = 0; i < var0Size; ++i) {
44  if (cutMaskAccessor(i)) {
45  efficiency->Fill(vars.var[0]->get(i),
46  detail::getFillValue<Axis::X>(efftot, vars.var[1], i));
47  }
48  }
49  return var0Size;
50  } else if ( nMonVar==3 ) { // Two observables (2D TEfficiency)
51  for (unsigned i = 0; i < var0Size; ++i) {
52  if (cutMaskAccessor(i)) {
53  efficiency->Fill(vars.var[0]->get(i),
54  detail::getFillValue<Axis::X>(efftot, vars.var[1], i),
55  detail::getFillValue<Axis::Y>(efftot, vars.var[2], i));
56  }
57  }
58  return var0Size;
59  } else if ( nMonVar==4 ) { // Three observables (3D Efficiency)
60  for (unsigned i = 0; i < var0Size; ++i) {
61  if (cutMaskAccessor(i)) {
62  efficiency->Fill(vars.var[0]->get(i),
63  detail::getFillValue<Axis::X>(efftot, vars.var[1], i),
64  detail::getFillValue<Axis::Y>(efftot, vars.var[2], i),
65  detail::getFillValue<Axis::Z>(efftot, vars.var[3], i));
66  }
67  }
68  return var0Size;
69  } else {
70  return 0;
71  }
72  return var0Size;
73  }
74  };
75 }
76 
77 #endif /* AthenaMonitoringKernel_HistogramFiller_HistogramFillerEfficiency_h */
Monitored::HistogramFillerEfficiency::fill
virtual unsigned fill(const HistogramFiller::VariablesPack &vars) const override
Method that actually fills the ROOT object.
Definition: HistogramFillerEfficiency.h:22
Monitored::HistogramFiller::VariablesPack::cut
const Monitored::IMonitoredVariable * cut
pointer to cut mask variable, typically absent
Definition: HistogramFiller.h:115
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::HistogramFillerEfficiency
Filler for TEfficiency graphs.
Definition: HistogramFillerEfficiency.h:17
Monitored::HistogramFiller::VariablesPack
helper class to pass variables to fillers
Definition: HistogramFiller.h:71
Monitored::HistogramFillerEfficiency::HistogramFillerEfficiency
HistogramFillerEfficiency(const HistogramDef &definition, std::shared_ptr< IHistogramProvider > provider)
Definition: HistogramFillerEfficiency.h:19
efficiency
void efficiency(std::vector< double > &bins, std::vector< double > &values, const std::vector< std::string > &files, const std::string &histname, const std::string &tplotname, const std::string &label="")
Definition: dependence.cxx:128
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::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::HistogramFiller::getCutMaskFunc
std::pair< size_t, std::function< bool(size_t)> > getCutMaskFunc(const Monitored::IMonitoredVariable *mask) const
Definition: HistogramFiller.h:155
HistogramFillerUtils.h