Loading [MathJax]/extensions/tex2jax.js
Go to the documentation of this file.
17 #include <nlohmann/json.hpp>
19 #include <type_traits>
26 template <std::
size_t,
typename T>
29 template <
typename Type,
unsigned int ND>
31 template <
typename Type,
unsigned int ND>
33 template <
typename Type,
unsigned int ND>
38 template <
typename Type>
48 template <
typename Arithmetic>
58 template <
typename Arithmetic>
60 return v.first *
v.second;
68 template <
typename Arithmetic>
70 return v.first *
v.first *
v.second;
80 template <atomicity Atomicity,
typename Arithmetic>
82 :
GenericAccumulator<std::pair<Arithmetic, Arithmetic>, Arithmetic, Atomicity, ExtractWeight> {
85 using Base::operator+=;
88 *
this += { Arithmetic{}, weight };
100 template <atomicity Atomicity,
typename Arithmetic>
102 :
GenericAccumulator<std::pair<Arithmetic, Arithmetic>, Arithmetic, Atomicity, WeightedProduct> {
113 template <atomicity Atomicity,
typename Arithmetic =
double>
115 :
GenericAccumulator<std::pair<Arithmetic, Arithmetic>, Arithmetic, Atomicity, WeightedSquare> {
126 template <atomicity Atomicity,
typename Arithmetic>
135 template <atomicity Atomicity,
typename Arithmetic>
142 template <
typename Arithmetic>
144 Axis(
unsigned int _nBins, Arithmetic _minValue, Arithmetic _maxValue,
std::string _title = {},
151 ,
ratio( _nBins / ( _maxValue - _minValue ) ){};
167 unsigned int index( Arithmetic value )
const {
169 return idx < 0 ? 0 : ( (
unsigned int)idx >
nBins ?
nBins + 1 : (
unsigned int)idx );
174 template <
typename Arithmetic>
179 {
"title", axis.
title } };
184 template <
typename Arithmetic,
unsigned int ND,
unsigned int NIndex = ND>
187 template <
class... ARGS,
typename =
typename std::enable_if_t<(
sizeof...( ARGS ) == NIndex )>>
193 unsigned int index = 0;
194 for (
unsigned int j = 0; j < NIndex; j++ ) {
195 unsigned int dim = NIndex - j - 1;
197 int localIndex = axis[dim].index( ( *
this )[dim] );
199 index *= ( axis[dim].nBins + 2 );
205 template <
typename AxisType,
long unsigned NAxis>
207 unsigned int nTotBins = 1;
208 for (
unsigned int i = 0; i < NAxis; i++ ) { nTotBins *= ( axis[i].nBins + 2 ); }
215 template <
typename Arithmetic>
223 operator Arithmetic()
const {
return value; }
225 template <
typename AxisType>
227 return axis[0].nBins + 2;
235 template <
typename Arithmetic,
unsigned int ND,
unsigned int NIndex = ND>
242 return this->first.computeIndex( axis );
245 template <
typename AxisType,
long unsigned NAxis>
265 template <
atomicity Atomicity,
typename InputType,
typename Arithmetic,
typename ND,
266 template <atomicity Ato,
typename Arith>
typename BaseAccumulatorT>
268 template <atomicity,
typename,
typename,
typename,
template <atomicity,
typename>
typename>
276 std::index_sequence<Is...> )
282 template <atomicity ato>
299 template <atomicity ato>
302 for (
unsigned int index = 0; index <
m_totNBins; index++ ) {
306 [[nodiscard]]
auto operator[](
typename InputType::ValueType
v ) {
337 template <atomicity Atomicity,
typename Arithmetic,
typename ND>
346 template <atomicity Atomicity,
typename Arithmetic,
typename ND>
356 template <atomicity Atomicity,
typename Arithmetic,
typename ND>
366 template <atomicity Atomicity,
typename Arithmetic,
typename ND>
424 template <
unsigned int ND,
atomicity Atomicity,
typename Arithmetic,
const char*
Type,
425 template <atomicity,
typename,
typename>
typename Accumulator,
typename Seq>
427 template <
unsigned int ND,
atomicity Atomicity,
typename Arithmetic,
const char*
Type,
428 template <atomicity,
typename,
typename>
typename Accumulator,
std::size_t... NDs>
430 :
public BufferableCounter<Atomicity, Accumulator, Arithmetic, std::integral_constant<int, ND>> {
433 template <
typename OWNER>
437 std::make_index_sequence<ND>{} )
438 , m_title( title ) {}
439 template <
typename OWNER>
444 template <
typename stream>
446 o << ND <<
"D Histogram with config ";
447 for (
unsigned int i = 0; i < ND; i++ ) {
448 o << this->nBins( i ) <<
" " << this->minValue( i ) <<
" " << this->maxValue( i ) <<
" ";
453 return printImpl( o, tableFormat );
458 using Acc = Accumulator<Atomicity, Arithmetic, std::integral_constant<int, ND>>;
460 bins.
reserve( this->totNBins() );
461 unsigned long totNEntries{ 0 };
462 for (
unsigned int i = 0; i < this->totNBins(); i++ ) {
468 {
"title", m_title },
470 {
"empty", totNEntries == 0 },
471 {
"nEntries", totNEntries },
472 {
"axis", this->axis() },
479 template <
unsigned int ND,
atomicity Atomicity,
typename Arithmetic,
const char*
Type,
480 template <atomicity,
typename,
typename>
typename Accumulator>
491 template <
unsigned int ND, atomicity Atomicity = atomicity::full,
typename Arithmetic =
double>
496 template <
unsigned int ND, atomicity Atomicity = atomicity::full,
typename Arithmetic =
double>
501 template <
unsigned int ND, atomicity Atomicity = atomicity::full,
typename Arithmetic =
double>
506 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.
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
HistogramingCounterBaseInternal(OWNER *owner, std::string const &name, std::string const &title, details::GetTuple_t< Axis< Arithmetic >, ND > 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.
HistogramingAccumulatorInternal & operator+=(InputType v)
constexpr char weightedProfilehistogramString[]
HistogramingAccumulatorInternal(details::GetTuple_t< Axis< AxisArithmeticType >, ND::value > axis, std::index_sequence< Is... >)
AveragingAccumulatorBase.
constexpr char profilehistogramString[]
Definition of an Histogram Axis.
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
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.
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...
HistogramingCounterBaseInternal(OWNER *owner, std::string const &name, std::string const &title, details::alwaysT< NDs, Axis< Arithmetic >>... allAxis)
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< Axis< AxisArithmeticType >, ND::value > m_axis
set of Axis of this Histogram
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