ATLAS Offline Software
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Monitored::HistogramFiller1D Class Reference

Filler for plain 1D histograms. More...

#include <HistogramFiller1D.h>

Inheritance diagram for Monitored::HistogramFiller1D:
Collaboration diagram for Monitored::HistogramFiller1D:

Public Member Functions

 HistogramFiller1D (const HistogramDef &definition, std::shared_ptr< IHistogramProvider > provider)
 
virtual unsigned fill (const HistogramFiller::VariablesPack &vars) const override
 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 , typename W , typename C , typename ... Ms>
unsigned fill (W weight, C cut, const Ms &... m) const
 Fill histogram from IMonitoredVariable. More...
 
template<class H >
H * histogram () const
 

Protected Attributes

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

Detailed Description

Filler for plain 1D histograms.

Definition at line 22 of file HistogramFiller1D.h.

Constructor & Destructor Documentation

◆ HistogramFiller1D()

Monitored::HistogramFiller1D::HistogramFiller1D ( const HistogramDef definition,
std::shared_ptr< IHistogramProvider provider 
)
inline

Definition at line 24 of file HistogramFiller1D.h.

25  : HistogramFiller(definition, std::move(provider)) {
26  }

Member Function Documentation

◆ fill() [1/2]

virtual unsigned Monitored::HistogramFiller1D::fill ( const HistogramFiller::VariablesPack ) const
inlineoverridevirtual

Method that actually fills the ROOT object.

Returns
number of fills performed

Implements Monitored::HistogramFiller.

Reimplemented in Monitored::CumulativeHistogramFiller1D, and Monitored::VecHistogramFiller1D.

Definition at line 28 of file HistogramFiller1D.h.

28  {
29 
30  if ( vars.cut ) {
31  const size_t maskSize = vars.cut->size();
32  // Abort if no cut entries or first (and only) entry is false
33  if (maskSize == 0 || (maskSize == 1 && !vars.cut->get(0))) { return 0; }
34  if (ATH_UNLIKELY(maskSize > 1 && maskSize != vars[0]->size())) {
35  MsgStream log(Athena::getMessageSvc(), "HistogramFiller1D");
36  log << MSG::ERROR << "CutMask does not match the size of plotted variable: "
37  << maskSize << " " << vars[0]->size() << endmsg;
38  }
39  }
40 
41  // Accessor for cut mask in case one is defined
42  auto cutMaskAccessor = [&](size_t i) { return static_cast<bool>(vars.cut->get(i)); };
43 
44  if (vars.weight) {
45  auto weightAccessor = [&](size_t i){ return vars.weight->get(i); };
46 
47  if (ATH_UNLIKELY(vars.weight->size() != vars[0]->size())) {
48  MsgStream log(Athena::getMessageSvc(), "HistogramFiller1D");
49  log << MSG::ERROR << "Weight does not match the size of plotted variable: "
50  << vars.weight->size() << " " << vars[0]->size() << endmsg;
51  }
52  // Need to fill here while weightVector is still in scope
53  if (not vars.cut) return HistogramFiller::fill<TH1>(weightAccessor, detail::noCut, *vars[0]);
54  else return HistogramFiller::fill<TH1>(weightAccessor, cutMaskAccessor, *vars[0]);
55  }
56 
57  if (not vars.cut) return HistogramFiller::fill<TH1>(detail::noWeight, detail::noCut, *vars[0]);
58  else return HistogramFiller::fill<TH1>(detail::noWeight, cutMaskAccessor, *vars[0]);
59  }

◆ fill() [2/2]

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

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

◆ histogramCutMaskName()

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

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
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  {
131  histogram<void>();
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:
Monitored::HistogramFiller::m_histDef
std::shared_ptr< HistogramDef > m_histDef
Definition: HistogramFiller.h:180
Monitored::HistogramFiller::m_histogramProvider
std::shared_ptr< IHistogramProvider > m_histogramProvider
Definition: HistogramFiller.h:181
max
constexpr double max()
Definition: ap_fixedTest.cxx:33
plotmaker.hist
hist
Definition: plotmaker.py:148
ATH_UNLIKELY
#define ATH_UNLIKELY(x)
Definition: AthUnlikelyMacros.h:17
Athena::getMessageSvc
IMessageSvc * getMessageSvc(bool quiet=false)
Definition: getMessageSvc.cxx:20
dqt_zlumi_pandas.weight
int weight
Definition: dqt_zlumi_pandas.py:190
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
Monitored::detail::noCut
auto noCut
no cut for filling
Definition: HistogramFillerUtils.h:29
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
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
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:182
Monitored::detail::noWeight
auto noWeight
no weight for filling
Definition: HistogramFillerUtils.h:28
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
Monitored::HistogramFiller::HistogramFiller
HistogramFiller(const HistogramDef &histDef, std::shared_ptr< IHistogramProvider > histogramProvider)
Default constructor.
Definition: HistogramFiller.h:51
python.SystemOfUnits.m
float m
Definition: SystemOfUnits.py:106