ATLAS Offline Software
Loading...
Searching...
No Matches
Monitored::HistogramFiller Class Referenceabstract

Base class for all histogram fillers. More...

#include <HistogramFiller.h>

Inheritance diagram for Monitored::HistogramFiller:
Collaboration diagram for Monitored::HistogramFiller:

Classes

struct  VariablesPack
 helper class to pass variables to fillers More...

Public Member Functions

 HistogramFiller (const HistogramDef &histDef, std::shared_ptr< IHistogramProvider > histogramProvider)
 Default constructor.
 HistogramFiller (const HistogramFiller &hf)
 Copy constructor.
virtual ~HistogramFiller ()
 Virtual destructor.
virtual unsigned fill (const VariablesPack &) const =0
 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>
Hhistogram () const
template<class H, typename W, typename C, typename ... Ms>
unsigned fill (W weight, C cut, const Ms &... m) const
 Fill histogram from IMonitoredVariable.

Protected Attributes

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

Private Member Functions

HistogramFilleroperator= (HistogramFiller const &)=delete

Detailed Description

Base class for all histogram fillers.

Definition at line 44 of file HistogramFiller.h.

Constructor & Destructor Documentation

◆ HistogramFiller() [1/2]

Monitored::HistogramFiller::HistogramFiller ( const HistogramDef & histDef,
std::shared_ptr< IHistogramProvider > histogramProvider )
inline

Default constructor.

Parameters
histDefHistogram definition of ROOT object

Definition at line 51 of file HistogramFiller.h.

52 : m_histDef(new HistogramDef(histDef)),
53 m_histogramProvider(std::move(histogramProvider)) {}
std::shared_ptr< HistogramDef > m_histDef
std::shared_ptr< IHistogramProvider > m_histogramProvider

◆ HistogramFiller() [2/2]

Monitored::HistogramFiller::HistogramFiller ( const HistogramFiller & hf)
inline

Copy constructor.

Parameters
hfOther HistogramFiller

Definition at line 59 of file HistogramFiller.h.

60 : m_histDef(hf.m_histDef),
61 m_histogramProvider(hf.m_histogramProvider) {}

◆ ~HistogramFiller()

virtual Monitored::HistogramFiller::~HistogramFiller ( )
inlinevirtual

Virtual destructor.

Definition at line 66 of file HistogramFiller.h.

66{}

Member Function Documentation

◆ fill() [1/2]

◆ fill() [2/2]

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

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.

◆ getLock()

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

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
inlineprotected

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

◆ histogramCutMaskName()

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

Definition at line 143 of file HistogramFiller.h.

143 {
144 return m_histDef->cutMask;
145 }

◆ histogramVariablesNames()

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

Definition at line 135 of file HistogramFiller.h.

135 {
136 return m_histDef->name;
137 }

◆ histogramWeightName()

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

Definition at line 139 of file HistogramFiller.h.

139 {
140 return m_histDef->weight;
141 }

◆ operator=()

HistogramFiller & Monitored::HistogramFiller::operator= ( HistogramFiller const & )
privatedelete

◆ touch()

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

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
protected

Definition at line 180 of file HistogramFiller.h.

◆ m_histogramProvider

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

Definition at line 181 of file HistogramFiller.h.

◆ m_lock

std::mutex Monitored::HistogramFiller::m_lock
mutableprotected

Definition at line 182 of file HistogramFiller.h.


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