ATLAS Offline Software
HistogramFillerRebinable.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef AthenaMonitoringKernel_HistogramFiller_HistogramFillerRebinable1D_h
6 #define AthenaMonitoringKernel_HistogramFiller_HistogramFillerRebinable1D_h
7 
9 #include "HistogramFiller1D.h"
10 #include "HistogramFiller2D.h"
11 #include "HistogramFillerUtils.h"
12 
13 #include <cmath>
14 
15 namespace Monitored {
16 
23  template<typename BASE, Monitored::Axis AXIS>
24  class HistogramFillerRebinableAxis : public BASE {
25  public:
26 
27  HistogramFillerRebinableAxis(const HistogramDef& definition, std::shared_ptr<IHistogramProvider> provider)
28  : BASE(definition, provider) {
29  if (definition.kAddBinsDynamically) {
31  } else {
33  }
34  }
35 
36  virtual unsigned fill( const HistogramFiller::VariablesPack& vars ) const override {
37  if (AXIS >= vars.size() ) { return 0; }
38  if (vars.var[AXIS]->size()==0) { return 0; }
39 
42  const IMonitoredVariable& var = *vars.var[AXIS];
43  for (size_t i = 0; i < var.size(); i++) {
44  const double v = var.get(i);
45  if (v < min) min = v;
46  if (v > max) max = v;
47  }
48 
49  TH1* hist = this->template histogram<TH1>();
50  TAxis* axis = detail::getAxis<AXIS>(hist);
53  Monitored::detail::rebinHistogram<AXIS>(hist, max);
54  }
55  } else {
56  hist->SetCanExtend(detail::axis_bit[AXIS]);
57  // ExtendAxis is an extremely expensive operation; only call if necessary
58  // Rebinning requires a lock on the global ROOT directory state
59  std::scoped_lock<std::mutex> dirLock(HistogramFactory::globalROOTMutex());
60  if (max >= axis->GetXmax()) hist->ExtendAxis(max, axis);
61  if (min < axis->GetXmin()) hist->ExtendAxis(min, axis);
62  }
63  return BASE::fill( vars );
64  }
65 
66  private:
67  enum class RebinMode { AddBins, ExtendAxes };
69  };
70 
79 }
80 
81 #endif /* AthenaMonitoringKernel_HistogramFiller_HistogramFillerRebinable1D_h */
OHLockedHist.h
OH histogram lock header file.
beamspotnt.var
var
Definition: bin/beamspotnt.py:1394
HistogramFiller2D.h
max
#define max(a, b)
Definition: cfImp.cxx:41
Monitored::HistogramDef::kAddBinsDynamically
bool kAddBinsDynamically
add new bins outside the existing range
Definition: HistogramDef.h:45
plotmaker.hist
hist
Definition: plotmaker.py:148
Monitored::HistogramFillerRebinableAxis::RebinMode::AddBins
@ AddBins
yodamerge_tmp.axis
list axis
Definition: yodamerge_tmp.py:241
Monitored::HistogramFillerRebinableAxis::fill
virtual unsigned fill(const HistogramFiller::VariablesPack &vars) const override
Definition: HistogramFillerRebinable.h:36
Monitored::HistogramFillerRebinableAxis::RebinMode::ExtendAxes
@ ExtendAxes
Monitored::HistogramFillerRebinableAxis::RebinMode
RebinMode
Definition: HistogramFillerRebinable.h:67
Monitored::HistogramDef
the internal class used to keep parsed Filler properties
Definition: HistogramDef.h:15
Monitored::HistogramFillerRebinableAxis
Mixin class for rebinning of histogram axis.
Definition: HistogramFillerRebinable.h:24
Monitored::HistogramFiller::VariablesPack
helper class to pass variables to fillers
Definition: HistogramFiller.h:71
Monitored::IMonitoredVariable
Definition: IMonitoredVariable.h:14
lumiFormat.i
int i
Definition: lumiFormat.py:85
Monitored
Generic monitoring tool for athena components.
Definition: GenericMonitoringTool.h:30
Monitored::HistogramFiller::VariablesPack::size
size_t size() const
number of variables in the pack ( not counting the weight and mask )
Definition: HistogramFiller.h:79
Monitored::HistogramFillerRebinable2DX
HistogramFillerRebinableAxis< HistogramFiller2D, Axis::X > HistogramFillerRebinable2DX
Rebinable 2D histogram (x-axis only)
Definition: HistogramFillerRebinable.h:74
min
#define min(a, b)
Definition: cfImp.cxx:40
Monitored::HistogramFillerRebinable2DY
HistogramFillerRebinableAxis< HistogramFiller2D, Axis::Y > HistogramFillerRebinable2DY
Rebinable 2D histogram (y-axis only)
Definition: HistogramFillerRebinable.h:76
fill
void fill(H5::Group &out_file, size_t iterations)
Definition: test-hdf5-writer.cxx:95
HistogramFiller1D.h
Monitored::HistogramFactory::globalROOTMutex
static std::mutex & globalROOTMutex()
Definition: HistogramFactory.h:68
python.PyAthena.v
v
Definition: PyAthena.py:154
Monitored::HistogramFiller::VariablesPack::var
std::vector< const Monitored::IMonitoredVariable * > var
storage for variables, default size of 4, serves all histograming uses
Definition: HistogramFiller.h:113
Monitored::HistogramFillerRebinableAxis::m_rebinMode
RebinMode m_rebinMode
Definition: HistogramFillerRebinable.h:68
Monitored::detail::axis_bit
constexpr std::array axis_bit
Definition: HistogramFillerUtils.h:33
Monitored::HistogramFillerRebinable2D
HistogramFillerRebinableAxis< HistogramFillerRebinable2DX, Axis::Y > HistogramFillerRebinable2D
Rebinable 2D histogram (both axes)
Definition: HistogramFillerRebinable.h:78
Monitored::HistogramFillerRebinableAxis::HistogramFillerRebinableAxis
HistogramFillerRebinableAxis(const HistogramDef &definition, std::shared_ptr< IHistogramProvider > provider)
Definition: HistogramFillerRebinable.h:27
Monitored::detail::shouldRebinHistogram
bool shouldRebinHistogram(const TAxis *axis, const double value)
Method checks if histogram should be rebinned.
Definition: HistogramFillerUtils.h:70
HistogramFillerUtils.h
Monitored::HistogramFillerRebinable1D
HistogramFillerRebinableAxis< HistogramFiller1D, Axis::X > HistogramFillerRebinable1D
Rebinable 1D histogram.
Definition: HistogramFillerRebinable.h:72