ATLAS Offline Software
Classes | Functions | Variables
Monitored::detail Namespace Reference

Classes

struct  get_value_type
 Get element type for containers. More...
 
struct  get_value_type< ActsTrk::TrackContainer >
 
struct  get_value_type< std::reference_wrapper< T > >
 Specializations for reference_wrappers which are hopefully never chosen. More...
 
struct  get_value_type< std::reference_wrapper< T[N]> >
 
struct  get_value_type< T[N]>
 Get element type for arrays. More...
 
struct  make_pointer_const
 
struct  make_pointer_const< T * >
 

Functions

template<typename H , typename W , typename M , typename ... Ms>
void doFill (H *hist, W weight, size_t i, const M &m1, const Ms &... m)
 Perform (arbitrary dimension) histogram fill with weight. More...
 
template<typename W >
void doFill (TProfile *, W, size_t, const double &, const char *const &)
 
template<typename W >
void doFill (TProfile *, W, size_t, const char *const &, const char *const &)
 
template<typename W >
void doFill (TProfile2D *, W, size_t, const double &, const double &, const char *const &)
 
template<typename W >
void doFill (TProfile2D *, W, size_t, const char *const &, const char *const &, const char *const &)
 
template<typename W >
void doFill (TProfile2D *, W, size_t, const char *const &, const double &, const char *const &)
 
template<typename W >
void doFill (TProfile2D *, W, size_t, const double &, const char *const &, const char *const &)
 
template<typename T = int>
int findToolIndex (const ToolHandleArray< GenericMonitoringTool > &toolArray, const std::string &name)
 Finds the index of an element in a tool handle array by its string name. More...
 
template<Axis AXIS, typename H >
constexpr auto getAxis (H *hist)
 Helper to get corresponding TAxis selected by Monitored::Axis. More...
 
template<Axis AXIS, typename H >
double getFillValue (const H *hist, const IMonitoredVariable *var, size_t i)
 Return value for filling i'th entry of var into AXIS for hist. More...
 
bool shouldRebinHistogram (const TAxis *axis, const double value)
 Method checks if histogram should be rebinned. More...
 
template<Axis AXIS, typename H >
void rebinHistogram (H *hist, const double value)
 Method that rebins a histogram. More...
 
template<typename T >
bool fillWillRebinHistogram (const TAxis *axis, T value)
 Check if Fill would result in rebinning. More...
 
template<>
bool fillWillRebinHistogram (const TAxis *axis, const char *value)
 Check if Fill would result in rebinning for alphanumeric axis. More...
 
template<typename H , typename T , T... a, typename ... Vs>
bool fillWillRebinHistogram (H *hist, std::integer_sequence< T, a... >, const Vs &... v)
 Check if any of the histogram axes will be rebinned. More...
 

Variables

auto noWeight = [](size_t){ return 1.0; }
 no weight for filling More...
 
auto noCut = [](size_t){ return true; }
 no cut for filling More...
 
constexpr std::array axis_name {"X", "Y", "Z"}
 Convert axis to ROOT-compatible character. More...
 
constexpr std::array axis_bit {TH1::kXaxis, TH1::kYaxis, TH1::kZaxis}
 

Function Documentation

◆ doFill() [1/7]

template<typename H , typename W , typename M , typename ... Ms>
void Monitored::detail::doFill ( H *  hist,
weight,
size_t  i,
const M &  m1,
const Ms &...  m 
)

Perform (arbitrary dimension) histogram fill with weight.

Parameters
histhistogram to fill
weightweight accessor
iIMonitoredVariable entry to fill
m1,m...IMonitoredVariable list to fill from

Definition at line 164 of file HistogramFillerUtils.h.

164  {
165 
166  // Template magic: Recursively convert all M to double or string
167  if constexpr(std::is_same_v<M, Monitored::IMonitoredVariable>) {
168  // For >=2D: If one variable has a single entry, do repeated fills with that value
169  const size_t j = m1.size()==1 ? 0 : i;
170  if (not m1.hasStringRepresentation())
171  doFill(hist, weight, i, m..., m1.get(j));
172  else
173  doFill(hist, weight, i, m..., m1.getString(j).c_str());
174  } else {
175  // In case re-binning occurs need to take the OH lock for online (no-op offline)
176  if ( ATH_UNLIKELY(fillWillRebinHistogram(hist, std::index_sequence_for<M, Ms...>{},
177  m1, m...)) ){
179  // Rebinning requires a lock on the global ROOT directory state
180  std::scoped_lock<std::mutex> dirLock(HistogramFactory::globalROOTMutex());
181  hist->Fill(m1, m..., weight(i));
182  }
183  else hist->Fill(m1, m..., weight(i));
184  }
185  }

◆ doFill() [2/7]

template<typename W >
void Monitored::detail::doFill ( TProfile ,
,
size_t  ,
const char *const ,
const char *const  
)

Definition at line 192 of file HistogramFillerUtils.h.

192 {}

◆ doFill() [3/7]

template<typename W >
void Monitored::detail::doFill ( TProfile ,
,
size_t  ,
const double &  ,
const char *const  
)

Definition at line 190 of file HistogramFillerUtils.h.

190 {}

◆ doFill() [4/7]

template<typename W >
void Monitored::detail::doFill ( TProfile2D ,
,
size_t  ,
const char *const ,
const char *const ,
const char *const  
)

Definition at line 196 of file HistogramFillerUtils.h.

196 {}

◆ doFill() [5/7]

template<typename W >
void Monitored::detail::doFill ( TProfile2D ,
,
size_t  ,
const char *const ,
const double &  ,
const char *const  
)

Definition at line 198 of file HistogramFillerUtils.h.

198 {}

◆ doFill() [6/7]

template<typename W >
void Monitored::detail::doFill ( TProfile2D ,
,
size_t  ,
const double &  ,
const char *const ,
const char *const  
)

Definition at line 200 of file HistogramFillerUtils.h.

200 {}

◆ doFill() [7/7]

template<typename W >
void Monitored::detail::doFill ( TProfile2D ,
,
size_t  ,
const double &  ,
const double &  ,
const char *const  
)

Definition at line 194 of file HistogramFillerUtils.h.

194 {}

◆ fillWillRebinHistogram() [1/3]

template<>
bool Monitored::detail::fillWillRebinHistogram ( const TAxis *  axis,
const char *  value 
)

Check if Fill would result in rebinning for alphanumeric axis.

Note that even adding a new label to an unlabeled bin is not thread-safe and needs to be treated as "rebinning" (ADHI-4881).

Definition at line 130 of file HistogramFillerUtils.h.

130  {
131  // valid bin found
132  if ( not axis or axis->FindFixBin(value)>0 ) return false;
133 
134  // If there are no labels yet at least one unlabeled bin is available
135  const THashList* labels = axis->GetLabels();
136  if ( not labels ) return false;
137 
138  return true;
139  }

◆ fillWillRebinHistogram() [2/3]

template<typename T >
bool Monitored::detail::fillWillRebinHistogram ( const TAxis *  axis,
value 
)

Check if Fill would result in rebinning.

Determine if Fill(value) would result in a rebinning of the histogram.

Definition at line 113 of file HistogramFillerUtils.h.

113  {
114  if (not axis) return false;
115  const int bin = axis->FindFixBin(value);
116  // if under/overflow
117  if ( bin==0 or bin==axis->GetNbins()+1 ) {
118  return true;
119  }
120  return false;
121  }

◆ fillWillRebinHistogram() [3/3]

template<typename H , typename T , T... a, typename ... Vs>
bool Monitored::detail::fillWillRebinHistogram ( H *  hist,
std::integer_sequence< T, a... >  ,
const Vs &...  v 
)

Check if any of the histogram axes will be rebinned.

Parameters
histhistogram to check
a...integer sequence of axes to check (0, 1, ...)
v...x, y, ... values to fill

Definition at line 149 of file HistogramFillerUtils.h.

149  {
150  // First check if axis is extensible, then if value would be outside of range
151  return (... || (getAxis<static_cast<Axis>(a)>(hist)->CanExtend() and
152  detail::fillWillRebinHistogram(getAxis<static_cast<Axis>(a)>(hist), v)));
153  }

◆ findToolIndex()

template<typename T = int>
int Monitored::detail::findToolIndex ( const ToolHandleArray< GenericMonitoringTool > &  toolArray,
const std::string &  name 
)

Finds the index of an element in a tool handle array by its string name.

Definition at line 132 of file MonitoredGroup.h.

132  {
133  auto it = std::find_if(toolArray.begin(),toolArray.end(),[&](const auto& r) {return r.name()==name;});
134  return it!=toolArray.end()
135  ? std::distance(toolArray.begin(),it)
136  : throw std::runtime_error("The tool "+name+" could not be found in the tool array.");
137  }

◆ getAxis()

template<Axis AXIS, typename H >
constexpr auto Monitored::detail::getAxis ( H *  hist)
constexpr

Helper to get corresponding TAxis selected by Monitored::Axis.

(works for const/non-const TAxis/TH1 thanks to auto return type)

Definition at line 40 of file HistogramFillerUtils.h.

40  {
41  if constexpr (AXIS==Axis::X) return hist->GetXaxis();
42  else if constexpr (AXIS==Axis::Y) return hist->GetYaxis();
43  else return hist->GetZaxis();
44  }

◆ getFillValue()

template<Axis AXIS, typename H >
double Monitored::detail::getFillValue ( const H *  hist,
const IMonitoredVariable var,
size_t  i 
)

Return value for filling i'th entry of var into AXIS for hist.

If var is string-valued performs a bin lookup first.

Template Parameters
AXISHistograms axis
Parameters
histHistogram
varMonitoredVariable for value lookup
iindex for IMonitoredVariable value lookup

Definition at line 56 of file HistogramFillerUtils.h.

56  {
57  if ( var->hasStringRepresentation() ) {
58  const TAxis* axis = getAxis<AXIS>(hist);
59  const int binNumber = axis->FindFixBin( var->getString(i).c_str() );
60  return axis->GetBinCenter(binNumber);
61  } else {
62  return var->get(i);
63  }
64  }

◆ rebinHistogram()

template<Axis AXIS, typename H >
void Monitored::detail::rebinHistogram ( H *  hist,
const double  value 
)

Method that rebins a histogram.

Algorithm will increase a size of the histogram until value can be included in new range of values. Examples for xMin=1.0, xMax=3.0; value=2.9, xMax will be unchanged value=3.0, xMax will be doubled value=4.9, xMax will be doubled value=5.0, xMax will be quadrupled value=5.1, xMax will be quadrupled value=8.9, xMax will be quadrupled value=9.0, xMax will be octupled value=9.1, xMax will be octupled

Definition at line 89 of file HistogramFillerUtils.h.

89  {
90  hist->SetCanExtend(axis_bit[AXIS]);
91  TAxis* a = getAxis<AXIS>(hist);
92 
93  // Rebinning requires to take OH lock in online (no-op offline)
95  // Rebinning requires a lock on the global ROOT directory state
96  std::scoped_lock<std::mutex> dirLock(HistogramFactory::globalROOTMutex());
97  do {
98  // need to unset cleanup bit of parent histogram during this operation
99  // since it gets copied to a hidden temporary (probably unintentionally)
100  bool curcleanup = hist->TestBit(TObject::kMustCleanup);
101  hist->ResetBit(TObject::kMustCleanup);
102  hist->LabelsInflate(axis_name[AXIS]);
103  hist->SetBit(TObject::kMustCleanup, curcleanup);
104  } while (shouldRebinHistogram(a, value));
105  }

◆ shouldRebinHistogram()

bool Monitored::detail::shouldRebinHistogram ( const TAxis *  axis,
const double  value 
)

Method checks if histogram should be rebinned.

It should happen when the new value is greater or equal to the greatest value of the histogram axis.

Definition at line 70 of file HistogramFillerUtils.h.

70  {
71  return axis ? axis->GetXmax() <= value : false;
72  }

Variable Documentation

◆ axis_bit

constexpr std::array Monitored::detail::axis_bit {TH1::kXaxis, TH1::kYaxis, TH1::kZaxis}
constexpr

Definition at line 33 of file HistogramFillerUtils.h.

◆ axis_name

constexpr std::array Monitored::detail::axis_name {"X", "Y", "Z"}
constexpr

Convert axis to ROOT-compatible character.

Definition at line 32 of file HistogramFillerUtils.h.

◆ noCut

auto Monitored::detail::noCut = [](size_t){ return true; }

no cut for filling

Definition at line 29 of file HistogramFillerUtils.h.

◆ noWeight

auto Monitored::detail::noWeight = [](size_t){ return 1.0; }

no weight for filling

Definition at line 28 of file HistogramFillerUtils.h.

beamspotman.r
def r
Definition: beamspotman.py:676
beamspotnt.var
var
Definition: bin/beamspotnt.py:1394
python.SystemOfUnits.m
int m
Definition: SystemOfUnits.py:91
plotmaker.hist
hist
Definition: plotmaker.py:148
beamspotCutsPlots.labels
list labels
Definition: beamspotCutsPlots.py:38
yodamerge_tmp.axis
list axis
Definition: yodamerge_tmp.py:241
Monitored::detail::axis_name
constexpr std::array axis_name
Convert axis to ROOT-compatible character.
Definition: HistogramFillerUtils.h:32
skel.it
it
Definition: skel.GENtoEVGEN.py:424
bin
Definition: BinsDiffFromStripMedian.h:43
athena.value
value
Definition: athena.py:122
ATH_UNLIKELY
#define ATH_UNLIKELY(x)
Definition: AthUnlikelyMacros.h:17
Monitored::X
@ X
Definition: HistogramFillerUtils.h:24
oh_scoped_lock_histogram
Scoped lock to be used for threaded histogram operations.
Definition: OHLockedHist.h:108
dqt_zlumi_pandas.weight
int weight
Definition: dqt_zlumi_pandas.py:200
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
python.changerun.m1
m1
Definition: changerun.py:32
Monitored::detail::getAxis
constexpr auto getAxis(H *hist)
Helper to get corresponding TAxis selected by Monitored::Axis.
Definition: HistogramFillerUtils.h:40
lumiFormat.i
int i
Definition: lumiFormat.py:92
Monitored::Y
@ Y
Definition: HistogramFillerUtils.h:24
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:192
python.PyAthena.v
v
Definition: PyAthena.py:157
a
TList * a
Definition: liststreamerinfos.cxx:10
Monitored::Axis
Axis
Helper type for histogram axis selection.
Definition: HistogramFillerUtils.h:24
Monitored::detail::fillWillRebinHistogram
bool fillWillRebinHistogram(H *hist, std::integer_sequence< T, a... >, const Vs &... v)
Check if any of the histogram axes will be rebinned.
Definition: HistogramFillerUtils.h:149
Monitored::detail::axis_bit
constexpr std::array axis_bit
Definition: HistogramFillerUtils.h:33
Monitored::detail::shouldRebinHistogram
bool shouldRebinHistogram(const TAxis *axis, const double value)
Method checks if histogram should be rebinned.
Definition: HistogramFillerUtils.h:70
Amg::distance
float distance(const Amg::Vector3D &p1, const Amg::Vector3D &p2)
calculates the distance between two point in 3D space
Definition: GeoPrimitivesHelpers.h:54