Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Classes | Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | List of all members
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. More...
 
 HistogramFiller (const HistogramFiller &hf)
 Copy constructor. More...
 
virtual ~HistogramFiller ()
 Virtual destructor. More...
 
virtual unsigned fill (const VariablesPack &) const =0
 Method that actually fills the ROOT object. More...
 
void touch () const
 Ensure histogram exists. More...
 
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 >
H * histogram () const
 
std::pair< size_t, std::function< bool(size_t)> > getCutMaskFunc (const Monitored::IMonitoredVariable *mask) const
 
template<class H , typename W , typename C , typename ... Ms>
unsigned fill (W weight, C cut, const Ms &... m) const
 Fill histogram from IMonitoredVariable. More...
 

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)) {}

◆ 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]

virtual unsigned Monitored::HistogramFiller::fill ( const VariablesPack ) const
pure virtual

◆ fill() [2/2]

template<class H , typename W , typename C , typename ... Ms>
unsigned Monitored::HistogramFiller::fill ( weight,
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 185 of file HistogramFiller.h.

185  {
186  auto hist = this->histogram<H>();
187 
188  size_t i = 0;
189  for (; i < std::max({m.size()...}); ++i ) {
190  if ( cut(i) ) {
191  detail::doFill(hist, weight, i, m...);
192  }
193  }
194  return i;
195  }

◆ getCutMaskFunc()

std::pair<size_t, std::function<bool(size_t)> > Monitored::HistogramFiller::getCutMaskFunc ( const Monitored::IMonitoredVariable mask) const
inlineprotected

Definition at line 156 of file HistogramFiller.h.

156  {
157  std::function<bool(size_t)> cutMaskValue = [] (size_t){ return true; }; // default is true
158  size_t maskSize = 1;
159  if ( mask != nullptr ) {
160  maskSize = mask->size();
161  if (maskSize == 1) {
162  if (!mask->get(0)) {
163  // globally fails cut; zero first argument is a signal that one can abort
164  return std::make_pair(0, [](size_t){ return false; });
165  // otherwise, default cutMaskValue is sufficient
166  }
167  } else {
168  return std::make_pair(maskSize, [mask](size_t i){ return static_cast<bool>(mask->get(i)); });
169  }
170  }
171  return std::make_pair(maskSize, cutMaskValue);
172  }

◆ getLock()

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

Definition at line 145 of file HistogramFiller.h.

145  {
146  return std::unique_lock(m_lock);
147  }

◆ histogram()

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

Definition at line 151 of file HistogramFiller.h.

151  {
152  return static_cast<H*>(m_histogramProvider->histogram());
153  }

◆ histogramCutMaskName()

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

Definition at line 141 of file HistogramFiller.h.

141  {
142  return m_histDef->cutMask;
143  }

◆ histogramVariablesNames()

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

Definition at line 133 of file HistogramFiller.h.

133  {
134  return m_histDef->name;
135  }

◆ histogramWeightName()

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

Definition at line 137 of file HistogramFiller.h.

137  {
138  return m_histDef->weight;
139  }

◆ operator=()

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

◆ touch()

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

Ensure histogram exists.

Definition at line 128 of file HistogramFiller.h.

128  {
129  histogram<void>();
130  }

Member Data Documentation

◆ m_histDef

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

Definition at line 197 of file HistogramFiller.h.

◆ m_histogramProvider

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

Definition at line 198 of file HistogramFiller.h.

◆ m_lock

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

Definition at line 199 of file HistogramFiller.h.


The documentation for this class was generated from the following file:
python.SystemOfUnits.m
int m
Definition: SystemOfUnits.py:91
Monitored::HistogramFiller::m_histDef
std::shared_ptr< HistogramDef > m_histDef
Definition: HistogramFiller.h:197
Monitored::HistogramFiller::m_histogramProvider
std::shared_ptr< IHistogramProvider > m_histogramProvider
Definition: HistogramFiller.h:198
max
constexpr double max()
Definition: ap_fixedTest.cxx:33
plotmaker.hist
hist
Definition: plotmaker.py:148
python.utils.AtlRunQueryLookup.mask
string mask
Definition: AtlRunQueryLookup.py:460
dqt_zlumi_pandas.weight
int weight
Definition: dqt_zlumi_pandas.py:189
Monitored::detail::doFill
void doFill(H *hist, W weight, size_t i, const M &m1, const Ms &... m)
Perform (arbitrary dimension) histogram fill with weight.
Definition: HistogramFillerUtils.h:164
H
#define H(x, y, z)
Definition: MD5.cxx:114
ROBbits::maskSize
const uint32_t maskSize
Definition: TrigMonROBData.cxx:17
lumiFormat.i
int i
Definition: lumiFormat.py:85
BindingsTest.cut
cut
This script demonstrates how to call a C++ class from Python Also how to use PyROOT is shown.
Definition: BindingsTest.py:13
Monitored::HistogramFiller::m_lock
std::mutex m_lock
Definition: HistogramFiller.h:199
xAOD::bool
setBGCode setTAP setLVL2ErrorBits bool
Definition: TrigDecision_v1.cxx:60