ATLAS Offline Software
Loading...
Searching...
No Matches
HistogramFillerEfficiency.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_HistogramFillerEfficiency_h
6#define AthenaMonitoringKernel_HistogramFiller_HistogramFillerEfficiency_h
7
8#include "TEfficiency.h"
9
10#include "HistogramFiller.h"
12
13namespace Monitored {
18 public:
19 HistogramFillerEfficiency(const HistogramDef& definition, std::shared_ptr<IHistogramProvider> provider)
20 : HistogramFiller(definition, std::move(provider)) {}
21
22 virtual unsigned fill( const HistogramFiller::VariablesPack& vars ) const override {
23
24 if ( vars[0] == nullptr or vars[1] == nullptr ) [[unlikely]] return 0;
25
26 if (vars.cut) {
27 const size_t maskSize = vars.cut->size();
28 // Abort if no cut entries or first (and only) entry is false
29 if (maskSize == 0 || (maskSize == 1 && !vars.cut->get(0))) { return 0; }
30 if (maskSize > 1 && maskSize != vars[0]->size()) [[unlikely]] {
31 MsgStream log(Athena::getMessageSvc(), "HistogramFillerEfficiency");
32 log << MSG::ERROR << "CutMask does not match the size of plotted variable: "
33 << maskSize << " " << vars[0]->size() << endmsg;
34 }
35 }
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[0]->size();
42 if ( nMonVar==2 ) { // Single observable (1D TEfficiency)
43 for (unsigned i = 0; i < var0Size; ++i) {
44 if (vars.cut==nullptr || vars.cut->get(i)) {
45 efficiency->Fill(vars[0]->get(i),
46 detail::getFillValue<Axis::X>(efftot, vars[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 (vars.cut==nullptr || vars.cut->get(i)) {
53 efficiency->Fill(vars[0]->get(i),
54 detail::getFillValue<Axis::X>(efftot, vars[1], i),
55 detail::getFillValue<Axis::Y>(efftot, vars[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 (vars.cut==nullptr || vars.cut->get(i)) {
62 efficiency->Fill(vars[0]->get(i),
63 detail::getFillValue<Axis::X>(efftot, vars[1], i),
64 detail::getFillValue<Axis::Y>(efftot, vars[2], i),
65 detail::getFillValue<Axis::Z>(efftot, vars[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 */
#define endmsg
size_t size() const
Number of registered mappings.
HistogramFillerEfficiency(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 double get(size_t) const =0
virtual size_t size() const =0
gives size of vector representation
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="")
T * get(TKey *tobj)
get a TObject* from a TKey* (why can't a TObject be a TKey?)
Definition hcg.cxx:132
IMessageSvc * getMessageSvc(bool quiet=false)
double getFillValue(const H *hist, const IMonitoredVariable *var, size_t i)
Return value for filling i'th entry of var into AXIS for hist.
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 )