Loading [MathJax]/extensions/tex2jax.js
Go to the documentation of this file.
19 #include <fmt/format.h>
20 #include <nlohmann/json.hpp>
22 #include <type_traits>
29 template <std::
size_t,
typename T>
32 template <
typename Type,
unsigned int ND>
34 template <
typename Type,
unsigned int ND>
36 template <
typename Type,
unsigned int ND>
41 template <
typename Type>
49 fmt::format(
"Histogram title \'{}\' has whitespace at front or back -- please remove", sv ),
59 template <
typename Arithmetic>
69 template <
typename Arithmetic>
71 return v.first *
v.second;
79 template <
typename Arithmetic>
81 return v.first *
v.first *
v.second;
91 template <atomicity Atomicity,
typename Arithmetic>
93 :
GenericAccumulator<std::pair<Arithmetic, Arithmetic>, Arithmetic, Atomicity, ExtractWeight> {
96 using Base::operator+=;
99 *
this += { Arithmetic{}, weight };
111 template <atomicity Atomicity,
typename Arithmetic>
113 :
GenericAccumulator<std::pair<Arithmetic, Arithmetic>, Arithmetic, Atomicity, WeightedProduct> {
124 template <atomicity Atomicity,
typename Arithmetic =
double>
126 :
GenericAccumulator<std::pair<Arithmetic, Arithmetic>, Arithmetic, Atomicity, WeightedSquare> {
137 template <atomicity Atomicity,
typename Arithmetic>
146 template <atomicity Atomicity,
typename Arithmetic>
153 template <
typename Arithmetic>
155 Axis(
unsigned int _nBins, Arithmetic _minValue, Arithmetic _maxValue,
std::string _title = {},
162 ,
ratio( _nBins / ( _maxValue - _minValue ) ) {
167 :
Axis( (unsigned int)def.bins(), def.lowEdge(), def.highEdge(), def.
title() ){};
183 unsigned int index( Arithmetic value )
const {
187 if constexpr ( std::is_integral_v<Arithmetic> ) {
192 return idx < 0 ? 0 : ( (
unsigned int)idx >
nBins ?
nBins + 1 : (
unsigned int)idx );
197 template <
typename Arithmetic>
202 {
"title", axis.
title } };
207 template <
typename Arithmetic,
unsigned int ND,
unsigned int NIndex = ND>
210 template <
class... ARGS,
typename =
typename std::enable_if_t<(
sizeof...( ARGS ) == NIndex )>>
216 unsigned int index = 0;
217 for (
unsigned int j = 0;
j < NIndex;
j++ ) {
218 unsigned int dim = NIndex -
j - 1;
220 int localIndex = axis[dim].index( ( *
this )[dim] );
222 index *= ( axis[dim].nBins + 2 );
228 template <
typename AxisType,
long unsigned NAxis>
230 unsigned int nTotBins = 1;
231 for (
unsigned int i = 0; i < NAxis; i++ ) { nTotBins *= ( axis[i].nBins + 2 ); }
238 template <
typename Arithmetic>
246 operator Arithmetic()
const {
return value; }
248 template <
typename AxisType>
250 return axis[0].nBins + 2;
258 template <
typename Arithmetic,
unsigned int ND,
unsigned int NIndex = ND>
265 return this->first.computeIndex( axis );
268 template <
typename AxisType,
long unsigned NAxis>
288 template <
atomicity Atomicity,
typename InputType,
typename Arithmetic,
typename ND,
289 template <atomicity Ato,
typename Arith>
typename BaseAccumulatorT>
291 template <atomicity,
typename,
typename,
typename,
template <atomicity,
typename>
typename>
305 template <atomicity ato>
322 template <atomicity ato>
325 for (
unsigned int index = 0; index <
m_totNBins; index++ ) {
329 [[nodiscard]]
auto operator[](
typename InputType::ValueType
v ) {
359 template <atomicity Atomicity,
typename Arithmetic,
typename ND>
368 template <atomicity Atomicity,
typename Arithmetic,
typename ND>
378 template <atomicity Atomicity,
typename Arithmetic,
typename ND>
388 template <atomicity Atomicity,
typename Arithmetic,
typename ND>
448 template <
unsigned int ND,
atomicity Atomicity,
typename Arithmetic,
const char*
Type,
449 template <atomicity,
typename,
typename>
typename Accumulator,
typename Seq>
451 template <
unsigned int ND,
atomicity Atomicity,
typename Arithmetic,
const char*
Type,
452 template <atomicity,
typename,
typename>
typename Accumulator,
std::size_t... NDs>
454 :
public BufferableCounter<Atomicity, Accumulator, Arithmetic, std::integral_constant<int, ND>> {
457 using AccumulatorType = Accumulator<Atomicity, Arithmetic, std::integral_constant<int, ND>>;
460 template <
typename OWNER>
463 :
Parent( owner,
name, *this, axis,
std::make_index_sequence<ND>{} ), m_title( title ) {
466 template <
typename OWNER>
471 template <
typename stream>
473 o << ND <<
"D Histogram with config ";
474 for (
unsigned int i = 0; i < ND; i++ ) {
475 o << this->nBins( i ) <<
" " << this->minValue( i ) <<
" " << this->maxValue( i ) <<
" ";
480 return printImpl( o, tableFormat );
486 bins.
reserve( this->totNBins() );
487 unsigned long totNEntries{ 0 };
488 for (
unsigned int i = 0; i < this->totNBins(); i++ ) {
494 {
"title", m_title },
496 {
"empty", totNEntries == 0 },
497 {
"nEntries", totNEntries },
498 {
"axis", this->axis() },
505 template <
unsigned int ND,
atomicity Atomicity,
typename Arithmetic,
const char*
Type,
506 template <atomicity,
typename,
typename>
typename Accumulator>
517 template <
unsigned int ND, atomicity Atomicity = atomicity::full,
typename Arithmetic =
double>
522 template <
unsigned int ND, atomicity Atomicity = atomicity::full,
typename Arithmetic =
double>
527 template <
unsigned int ND, atomicity Atomicity = atomicity::full,
typename Arithmetic =
double>
532 template <
unsigned int ND, atomicity Atomicity = atomicity::full,
typename Arithmetic =
double>
Arithmetic minValue
min and max values on this axis
auto nBins(unsigned int i) const
WeightedSquareAccumulator.
void requireValidTitle(std::string_view sv)
HistogramingCounterBaseInternal(OWNER *owner, std::string const &name, std::string const &title, details::GetTuple_t< typename AccumulatorType::AxisType, ND > axis)
BaseAccumulator & accumulator(unsigned int index) const
Arithmetic nEntries() const
void mergeAndReset(HistogramingAccumulatorInternal< ato, InputType, Arithmetic, ND, BaseAccumulatorT > &&other)
typename InputType::AxisArithmeticType AxisArithmeticType
unsigned int nBins
number of bins for this Axis
long
(c) Copyright 1998-2020 CERN for the benefit of the LHCb and ATLAS collaborations # # This software i...
auto binValue(unsigned int i) const
constexpr char weightedHistogramString[]
nlohmann::json toJSON() const override
Basic JSON export for Gaudi::Monitoring::Hub support.
HistogramingCounterBaseInternal(OWNER *owner, std::string const &name, std::string const &title, details::alwaysT< NDs, typename AccumulatorType::AxisType >... allAxis)
HistogramingAccumulatorInternal & operator+=(InputType v)
constexpr char weightedProfilehistogramString[]
AveragingAccumulatorBase.
constexpr char profilehistogramString[]
HistogramingAccumulatorInternal(details::GetTuple_t< AxisType, ND::value > axis, std::index_sequence< Is... >)
Definition of an Histogram Axis.
Accumulator< Atomicity, Arithmetic, std::integral_constant< int, ND > > AccumulatorType
stream & printImpl(stream &o, bool) const
std::ostream & print(std::ostream &o, bool tableFormat=false) const override
prints the counter to a stream
BaseAccumulatorT< Atomicity, Arithmetic > BaseAccumulator
auto operator[](typename InputType::ValueType v)
MsgStream & print(MsgStream &o, bool tableFormat=false) const override
decltype(std::tuple_cat(std::declval< std::tuple< Type > >(), std::declval< GetTuple_t< Type, ND - 1 > >())) type
friend class GenericAccumulator
auto maxValue(unsigned int i) const
unsigned int index(Arithmetic value) const
returns the bin number for a given value, ranging from 0 (underflow) to nBins+1 (overflow)
std::string const m_title
auto nEntries(unsigned int i) const
GAUDI_API std::string format(const char *,...)
MsgStream format utility "a la sprintf(...)".
Generic Accumulator, templated by.
auto minValue(unsigned int i) const
HistogramingAccumulatorInternal(construct_empty_t, const HistogramingAccumulatorInternal< ato, InputType, Arithmetic, ND, BaseAccumulatorT > &other)
void to_json(nlohmann::json &j, const Axis< Arithmetic > &axis)
automatic conversion of the Axis type to json
Axis(unsigned int _nBins, Arithmetic _minValue, Arithmetic _maxValue, std::string _title={}, std::vector< std::string > _labels={})
A Product functor, take a pair (value, weight) as input.
An empty ancester of all counters that provides a buffer method that returns a buffer on itself Also ...
Internal Accumulator class dealing with Histograming.
Axis(Gaudi::Histo1DDef const &def)
struct GAUDI_API array
Parametrisation class for redirection array - like implementation.
std::unique_ptr< BaseAccumulator[]> m_value
Histogram content.
A WeightedSquare functor, take a pair (value, weight) as input.
unsigned int m_totNBins
total number of bins in this histogram, under and overflow included
friend class HistogramingAccumulatorInternal
Buffer is a non atomic Accumulator which, when it goes out-of-scope, updates the underlying thread-sa...
atomicity
Defines atomicity of the accumulators.
Arithmetic ratio
precomputed ratio to convert a value into bin number equal to nBins/(maxValue-minValue).
constant used to disambiguate construction of an empty Accumulator versus the copy constructor.
WeightedCountAccumulator.
std::array< AxisType, ND::value > m_axis
set of Axis of this Histogram
constexpr static const auto FAILURE
typename GetTuple< Type, ND >::type GetTuple_t
constexpr char histogramString[]
A base counter dealing with Histograms.
WeightedCountAccumulator operator+=(const Arithmetic weight)
std::string title
title of this axis
std::vector< std::string > labels
labels for the bins