ATLAS Offline Software
Loading...
Searching...
No Matches
Monitored::HistogramFillerEfficiency Class Reference

Filler for TEfficiency graphs. More...

#include <HistogramFillerEfficiency.h>

Inheritance diagram for Monitored::HistogramFillerEfficiency:
Collaboration diagram for Monitored::HistogramFillerEfficiency:

Public Member Functions

 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.
void touch () const
 Ensure histogram exists.
const std::vector< std::string > & histogramVariablesNames () const
const std::string & histogramWeightName () const
const std::string & histogramCutMaskName () const
const std::unique_lock< std::mutex > getLock () const

Protected Member Functions

template<class H, typename W, typename C, typename ... Ms>
unsigned fill (W weight, C cut, const Ms &... m) const
 Fill histogram from IMonitoredVariable.
template<class H>
Hhistogram () const

Protected Attributes

std::shared_ptr< HistogramDefm_histDef
std::shared_ptr< IHistogramProviderm_histogramProvider
std::mutex m_lock

Detailed Description

Filler for TEfficiency graphs.

Definition at line 17 of file HistogramFillerEfficiency.h.

Constructor & Destructor Documentation

◆ HistogramFillerEfficiency()

Monitored::HistogramFillerEfficiency::HistogramFillerEfficiency ( const HistogramDef & definition,
std::shared_ptr< IHistogramProvider > provider )
inline

Definition at line 19 of file HistogramFillerEfficiency.h.

20 : HistogramFiller(definition, std::move(provider)) {}
HistogramFiller(const HistogramDef &histDef, std::shared_ptr< IHistogramProvider > histogramProvider)
Default constructor.

Member Function Documentation

◆ fill() [1/2]

template<class H, typename W, typename C, typename ... Ms>
unsigned Monitored::HistogramFiller::fill ( W weight,
C cut,
const Ms &... m ) const
inlineprotectedinherited

Fill histogram from IMonitoredVariable.

Supports arbitrary dimensions and double/string representation.

Template Parameters
Hhistogram type (TH1, TH2, ...)
Parameters
weightweight accessor (use detail::noWeight if not needed)
cutcut mask accessor (use detail::noCut if not needed)
m...IMonitoredVariable list to fill from

Definition at line 168 of file HistogramFiller.h.

168 {
169 auto hist = this->histogram<H>();
170
171 size_t i = 0;
172 for (; i < std::max({m.size()...}); ++i ) {
173 if ( cut(i) ) {
174 detail::doFill(hist, weight, i, m...);
175 }
176 }
177 return i;
178 }
cut
This script demonstrates how to call a C++ class from Python Also how to use PyROOT is shown.
void doFill(H *hist, W weight, size_t i, const M &m1, const Ms &... m)
Perform (arbitrary dimension) histogram fill with weight.

◆ fill() [2/2]

virtual unsigned Monitored::HistogramFillerEfficiency::fill ( const HistogramFiller::VariablesPack & ) const
inlineoverridevirtual

Method that actually fills the ROOT object.

Returns
number of fills performed

Implements Monitored::HistogramFiller.

Definition at line 22 of file HistogramFillerEfficiency.h.

22 {
23
24 if ( ATH_UNLIKELY( vars[0] == nullptr or vars[1] == nullptr ) ) 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 (ATH_UNLIKELY(maskSize > 1 && maskSize != vars[0]->size())) {
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 }
#define endmsg
#define ATH_UNLIKELY(x)
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:130
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.
const uint32_t maskSize

◆ getLock()

const std::unique_lock< std::mutex > Monitored::HistogramFiller::getLock ( ) const
inlineinherited

Definition at line 147 of file HistogramFiller.h.

147 {
148 return std::unique_lock(m_lock);
149 }

◆ histogram()

template<class H>
H * Monitored::HistogramFiller::histogram ( ) const
inlineprotectedinherited

Definition at line 153 of file HistogramFiller.h.

153 {
154 return static_cast<H*>(m_histogramProvider->histogram());
155 }
#define H(x, y, z)
Definition MD5.cxx:114
std::shared_ptr< IHistogramProvider > m_histogramProvider

◆ histogramCutMaskName()

const std::string & Monitored::HistogramFiller::histogramCutMaskName ( ) const
inlineinherited

Definition at line 143 of file HistogramFiller.h.

143 {
144 return m_histDef->cutMask;
145 }
std::shared_ptr< HistogramDef > m_histDef

◆ histogramVariablesNames()

const std::vector< std::string > & Monitored::HistogramFiller::histogramVariablesNames ( ) const
inlineinherited

Definition at line 135 of file HistogramFiller.h.

135 {
136 return m_histDef->name;
137 }

◆ histogramWeightName()

const std::string & Monitored::HistogramFiller::histogramWeightName ( ) const
inlineinherited

Definition at line 139 of file HistogramFiller.h.

139 {
140 return m_histDef->weight;
141 }

◆ touch()

void Monitored::HistogramFiller::touch ( ) const
inlineinherited

Ensure histogram exists.

Definition at line 130 of file HistogramFiller.h.

130 {
132 }

Member Data Documentation

◆ m_histDef

std::shared_ptr<HistogramDef> Monitored::HistogramFiller::m_histDef
protectedinherited

Definition at line 180 of file HistogramFiller.h.

◆ m_histogramProvider

std::shared_ptr<IHistogramProvider> Monitored::HistogramFiller::m_histogramProvider
protectedinherited

Definition at line 181 of file HistogramFiller.h.

◆ m_lock

std::mutex Monitored::HistogramFiller::m_lock
mutableprotectedinherited

Definition at line 182 of file HistogramFiller.h.


The documentation for this class was generated from the following file: