Go to the documentation of this file.
15 #include <ROOT/RHist.hxx>
17 #include <boost/format.hpp>
18 #include <boost/histogram/algorithm/sum.hpp>
19 #include <boost/histogram/fwd.hpp>
22 #include <nlohmann/json.hpp>
27 #include <type_traits>
32 template <std::
size_t,
typename T>
35 template <
typename Type,
unsigned int ND>
37 template <
typename Type,
unsigned int ND>
38 using GetTuple_t =
typename GetTuple<Type, ND>::type;
39 template <
typename Type,
unsigned int ND>
44 template <
typename Type>
45 struct GetTuple<
Type, 1> {
56 template <
typename Arithmetic>
66 template <
typename Arithmetic>
68 return v.first *
v.second;
76 template <
typename Arithmetic>
78 return v.first *
v.first *
v.second;
88 template <atomicity Atomicity,
typename Arithmetic>
90 :
GenericAccumulator<std::pair<Arithmetic, Arithmetic>, Arithmetic, Atomicity, ExtractWeight> {
93 using Base::operator+=;
96 *
this += { Arithmetic{}, weight };
108 template <atomicity Atomicity,
typename Arithmetic>
110 :
GenericAccumulator<std::pair<Arithmetic, Arithmetic>, Arithmetic, Atomicity, WeightedProduct> {
121 template <atomicity Atomicity,
typename Arithmetic =
double>
123 :
GenericAccumulator<std::pair<Arithmetic, Arithmetic>, Arithmetic, Atomicity, WeightedSquare> {
134 template <atomicity Atomicity,
typename Arithmetic>
143 template <atomicity Atomicity,
typename Arithmetic>
150 template <
typename Arithmetic>
152 Axis(
unsigned int _nBins, Arithmetic _minValue, Arithmetic _maxValue,
std::string _title = {},
159 ,
ratio( _nBins / ( _maxValue - _minValue ) ){};
175 unsigned int index( Arithmetic value )
const {
177 return idx < 0 ? 0 : ( (
unsigned int)idx >
nBins ?
nBins + 1 : (
unsigned int)idx );
182 template <
typename Arithmetic>
187 {
"title", axis.
title } };
192 template <
typename Arithmetic,
unsigned int ND,
unsigned int NIndex = ND>
195 template <
class... ARGS>
201 unsigned int index = 0;
202 for (
unsigned int j = 0; j < NIndex; j++ ) {
203 unsigned int dim = NIndex - j - 1;
205 int localIndex = axis[dim].index( ( *
this )[dim] );
207 index *= ( axis[dim].nBins + 2 );
217 template <
typename Arithmetic>
225 operator Arithmetic()
const {
return value; }
233 template <
typename Arithmetic,
unsigned int ND,
unsigned int NIndex = ND>
240 return this->first.computeIndex( axis );
259 template <
atomicity Atomicity,
typename InputType,
typename Arithmetic,
typename ND,
260 template <atomicity Ato,
typename Arith>
typename BaseAccumulatorT>
262 template <atomicity,
typename,
typename,
typename,
template <atomicity,
typename>
typename>
275 template <atomicity ato>
289 template <atomicity ato>
292 for (
unsigned int index = 0; index <
m_totNBins; index++ ) {
315 unsigned int nTotBins = 1;
316 for (
unsigned int i = 0; i < ND::value; i++ ) { nTotBins *= (
m_axis[i].nBins + 2 ); }
332 template <atomicity Atomicity,
typename Arithmetic,
typename ND>
341 template <atomicity Atomicity,
typename Arithmetic,
typename ND>
351 template <atomicity Atomicity,
typename Arithmetic,
typename ND>
361 template <atomicity Atomicity,
typename Arithmetic,
typename ND>
419 template <
unsigned int ND,
atomicity Atomicity,
typename Arithmetic,
const char*
Type,
420 template <atomicity,
typename,
typename>
typename Accumulator,
typename Seq>
422 template <
unsigned int ND,
atomicity Atomicity,
typename Arithmetic,
const char*
Type,
423 template <atomicity,
typename,
typename>
typename Accumulator,
std::size_t... NDs>
425 :
public BufferableCounter<Atomicity, Accumulator, Arithmetic, std::integral_constant<int, ND>> {
428 template <
typename OWNER>
432 std::make_index_sequence<ND>{} )
433 , m_title( title ) {}
434 template <
typename OWNER>
439 template <
typename stream>
441 o << ND <<
"D Histogram with config ";
442 for (
unsigned int i = 0; i < ND; i++ ) {
443 o << this->nBins( i ) <<
" " << this->minValue( i ) <<
" " << this->maxValue( i ) <<
" ";
448 return printImpl( o, tableFormat );
453 using Acc = Accumulator<Atomicity, Arithmetic, std::integral_constant<int, ND>>;
455 bins.
reserve( this->totNBins() );
456 unsigned long totNEntries{ 0 };
457 for (
unsigned int i = 0; i < this->totNBins(); i++ ) {
463 {
"title", m_title },
465 {
"empty", totNEntries == 0 },
466 {
"nEntries", totNEntries },
467 {
"axis", this->axis() },
474 template <
unsigned int ND,
atomicity Atomicity,
typename Arithmetic,
const char*
Type,
475 template <atomicity,
typename,
typename>
typename Accumulator>
480 static const char histogramString[] =
"histogram:Histogram";
481 static const char weightedHistogramString[] =
"histogram:WeightedHistogram";
482 static const char profilehistogramString[] =
"histogram:ProfileHistogram";
483 static const char weightedProfilehistogramString[] =
"histogram:WeightedProfileHistogram";
486 template <
unsigned int ND, atomicity Atomicity = atomicity::full,
typename Arithmetic =
double>
490 template <
unsigned int ND, atomicity Atomicity = atomicity::full,
typename Arithmetic =
double>
495 template <
unsigned int ND, atomicity Atomicity = atomicity::full,
typename Arithmetic =
double>
500 template <
unsigned int ND, atomicity Atomicity = atomicity::full,
typename Arithmetic =
double>
Arithmetic minValue
min and max values on this axis
HistogramingAccumulatorInternal(GetTuple_t< Axis< AxisArithmeticType >, ND::value > axis, std::index_sequence< Is... >)
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
long
(c) Copyright 1998-2020 CERN for the benefit of the LHCb and ATLAS collaborations # # This software i...
auto binValue(unsigned int i) const
nlohmann::json toJSON() const override
Basic JSON export for Gaudi::Monitoring::Hub support.
HistogramingAccumulatorInternal & operator+=(InputType v)
HistogramingCounterBaseInternal(OWNER *owner, std::string const &name, std::string const &title, alwaysT< NDs, Axis< Arithmetic >>... allAxis)
AveragingAccumulatorBase.
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
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.
HistogramingCounterBaseInternal(OWNER *owner, std::string const &name, std::string const &title, GetTuple_t< Axis< Arithmetic >, ND > axis)
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
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< Axis< AxisArithmeticType >, ND::value > m_axis
set of Axis of this Histogram
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
Arithmetic operator[](Arithmetic ... args)
unsigned int computeTotNBins() const