5#ifndef AthenaMonitoringKernel_HistogramFillerUtils_h
6#define AthenaMonitoringKernel_HistogramFillerUtils_h
19#include "TProfile2D.h"
29 auto noCut = [](size_t){
return true; };
33 constexpr std::array
axis_bit{TH1::kXaxis, TH1::kYaxis, TH1::kZaxis};
39 template<Axis AXIS,
typename H>
41 if constexpr (AXIS==
Axis::X)
return hist->GetXaxis();
42 else if constexpr (AXIS==
Axis::Y)
return hist->GetYaxis();
43 else return hist->GetZaxis();
55 template<Axis AXIS,
typename H>
57 if ( var->hasStringRepresentation() ) {
59 const int binNumber = axis->FindFixBin( var->getString(i).c_str() );
60 return axis->GetBinCenter(binNumber);
71 return axis ? axis->GetXmax() <= value :
false;
88 template<Axis AXIS,
typename H>
100 bool curcleanup = hist->TestBit(TObject::kMustCleanup);
101 hist->ResetBit(TObject::kMustCleanup);
103 hist->SetBit(TObject::kMustCleanup, curcleanup);
114 if (not axis)
return false;
115 const int bin = axis->FindFixBin(value);
117 if (
bin==0 or
bin==axis->GetNbins()+1 ) {
132 if ( not axis or axis->FindFixBin(value)>0 )
return false;
135 const THashList* labels = axis->GetLabels();
136 if ( not labels )
return false;
148 template<
typename H,
typename T, T...
a,
typename ...Vs>
151 return (... || (
getAxis<
static_cast<Axis>(
a)>(hist)->CanExtend() and
163 template<
typename H,
typename W,
typename M,
typename ...Ms>
164 void doFill(
H* hist, W weight,
size_t i,
const M& m1,
const Ms&... m) {
167 if constexpr(std::is_same_v<M, Monitored::IMonitoredVariable>) {
169 const size_t j = m1.size()==1 ? 0 : i;
170 if (not m1.hasStringRepresentation())
171 doFill(hist, weight, i, m..., m1.get(j));
173 doFill(hist, weight, i, m..., m1.getString(j).c_str());
181 hist->Fill(m1, m..., weight(i));
183 else hist->Fill(m1, m..., weight(i));
190 void doFill(TProfile*, W,
size_t,
const double&,
const char*
const&) {}
192 void doFill(TProfile*, W,
size_t,
const char*
const&,
const char*
const&) {}
194 void doFill(TProfile2D*, W,
size_t,
const double&,
const double&,
const char*
const&) {}
196 void doFill(TProfile2D*, W,
size_t,
const char*
const&,
const char*
const&,
const char*
const&) {}
198 void doFill(TProfile2D*, W,
size_t,
const char*
const&,
const double&,
const char*
const&) {}
200 void doFill(TProfile2D*, W,
size_t,
const double&,
const char*
const&,
const char*
const&) {}
OH histogram lock header file.
static std::mutex & globalROOTMutex()
Scoped lock to be used for threaded histogram operations.
bool fillWillRebinHistogram(const TAxis *axis, T value)
Check if Fill would result in rebinning.
constexpr auto getAxis(H *hist)
Helper to get corresponding TAxis selected by Monitored::Axis.
auto noWeight
no weight for filling
void doFill(H *hist, W weight, size_t i, const M &m1, const Ms &... m)
Perform (arbitrary dimension) histogram fill with weight.
constexpr std::array axis_bit
constexpr std::array axis_name
Convert axis to ROOT-compatible character.
bool shouldRebinHistogram(const TAxis *axis, const double value)
Method checks if histogram should be rebinned.
auto noCut
no cut for filling
double getFillValue(const H *hist, const IMonitoredVariable *var, size_t i)
Return value for filling i'th entry of var into AXIS for hist.
void rebinHistogram(H *hist, const double value)
Method that rebins a histogram.
Generic monitoring tool for athena components.
Axis
Helper type for histogram axis selection.