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> 
   37     template <
typename Arithmetic>
 
   47     template <
typename Arithmetic>
 
   49       return v.first * 
v.second;
 
   57     template <
typename Arithmetic>
 
   59       return v.first * 
v.first * 
v.second;
 
   69   template <atomicity Atomicity, 
typename Arithmetic>
 
   71       : 
GenericAccumulator<std::pair<Arithmetic, Arithmetic>, Arithmetic, Atomicity, ExtractWeight> {
 
   74     using Base::operator+=;
 
   77       *
this += {Arithmetic{}, weight};
 
   89   template <atomicity Atomicity, 
typename Arithmetic>
 
   91       : 
GenericAccumulator<std::pair<Arithmetic, Arithmetic>, Arithmetic, Atomicity, WeightedProduct> {
 
   94     Arithmetic 
sum()
 const { 
return this->
value(); }
 
  102   template <atomicity Atomicity, 
typename Arithmetic = 
double>
 
  104       : 
GenericAccumulator<std::pair<Arithmetic, Arithmetic>, Arithmetic, Atomicity, WeightedSquare> {
 
  115   template <atomicity Atomicity, 
typename Arithmetic>
 
  124   template <atomicity Atomicity, 
typename Arithmetic>
 
  131   template <
typename Arithmetic>
 
  133     Axis( 
unsigned int _nBins, Arithmetic _minValue, Arithmetic _maxValue, 
std::string _title = {},
 
  140         , 
ratio( _nBins / ( _maxValue - _minValue ) ){};
 
  156     unsigned int index( Arithmetic value )
 const {
 
  158       return idx < 0 ? 0 : ( (
unsigned int)idx > 
nBins ? 
nBins + 1 : (
unsigned int)idx );
 
  163   template <
typename Arithmetic>
 
  171   template <
typename Arithmetic, 
unsigned int ND, 
unsigned int NIndex = ND>
 
  174     template <
class... ARGS>
 
  180       unsigned int index = 0;
 
  181       for ( 
unsigned int dim = 0; dim < NIndex; dim++ ) {
 
  183         int localIndex = axis[dim].index( ( *
this )[dim] );
 
  185         index = ( dim > 0 ? ( axis[dim - 1].nBins + 2 ) : 0 ) * index + localIndex;
 
  194   template <
typename Arithmetic>
 
  202                  operator Arithmetic()
 const { 
return value; }
 
  210   template <
typename Arithmetic, 
unsigned int ND, 
unsigned int NIndex = ND>
 
  217       return this->first.computeIndex( axis );
 
  236   template <
atomicity Atomicity, 
typename InputType, 
typename Arithmetic, 
typename ND,
 
  237             template <atomicity Ato, 
typename Arith> 
typename BaseAccumulatorT>
 
  239     template <atomicity, 
typename, 
typename, 
typename, 
template <atomicity, 
typename> 
typename>
 
  252     template <atomicity ato>
 
  266     template <atomicity ato>
 
  269       for ( 
unsigned int index = 0; index < 
m_totNBins; index++ ) {
 
  292       unsigned int nTotBins = 1;
 
  293       for ( 
unsigned int i = 0; i < ND::value; i++ ) { nTotBins *= ( 
m_axis[i].nBins + 2 ); }
 
  309   template <atomicity Atomicity, 
typename Arithmetic, 
typename ND>
 
  318   template <atomicity Atomicity, 
typename Arithmetic, 
typename ND>
 
  328   template <atomicity Atomicity, 
typename Arithmetic, 
typename ND>
 
  338   template <atomicity Atomicity, 
typename Arithmetic, 
typename ND>
 
  396   template <
unsigned int ND, 
atomicity Atomicity, 
typename Arithmetic, 
const char* 
Type,
 
  397             template <atomicity, 
typename, 
typename> 
typename Accumulator>
 
  399       : 
public BufferableCounter<Atomicity, Accumulator, Arithmetic, std::integral_constant<int, ND>> {
 
  402     template <
typename OWNER>
 
  406                   std::make_index_sequence<ND>{} )
 
  408     template <
typename OWNER>
 
  412     template <
typename stream>
 
  414       o << ND << 
"D Histogram with config ";
 
  415       for ( 
unsigned int i = 0; i < ND; i++ ) {
 
  416         o << this->nBins( i ) << 
" " << this->minValue( i ) << 
" " << this->maxValue( i ) << 
" ";
 
  426       using Acc = Accumulator<Atomicity, Arithmetic, std::integral_constant<int, ND>>;
 
  428       bins.
reserve( this->totNBins() );
 
  429       unsigned long totNEntries{0};
 
  430       for ( 
unsigned int i = 0; i < this->totNBins(); i++ ) {
 
  438               {
"empty", totNEntries == 0},
 
  439               {
"nEntries", totNEntries},
 
  440               {
"axis", this->axis()},
 
  449     static const char histogramString[]                = 
"histogram:Histogram";
 
  450     static const char weightedHistogramString[]        = 
"histogram:WeightedHistogram";
 
  451     static const char profilehistogramString[]         = 
"histogram:ProfileHistogram";
 
  452     static const char weightedProfilehistogramString[] = 
"histogram:WeightedProfileHistogram";
 
  455   template <
unsigned int ND, atomicity Atomicity = atomicity::full, 
typename Arithmetic = 
double>
 
  459   template <
unsigned int ND, atomicity Atomicity = atomicity::full, 
typename Arithmetic = 
double>
 
  464   template <
unsigned int ND, atomicity Atomicity = atomicity::full, 
typename Arithmetic = 
double>
 
  469   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.
HistogramingCounterBase(OWNER *owner, std::string const &name, std::string const &title, std::initializer_list< Axis< Arithmetic >> 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
A base counter dealing with Histograms.
HistogramingAccumulatorInternal & operator+=(InputType v)
AveragingAccumulatorBase.
std::string const m_title
Definition of an Histogram Axis.
BaseAccumulatorT< Atomicity, Arithmetic > BaseAccumulator
nlohmann::json toJSON() const override
Basic JSON export for Gaudi::Monitoring::Hub support.
auto operator[](typename InputType::ValueType v)
stream & printImpl(stream &o, bool) const
friend class GenericAccumulator
auto maxValue(unsigned int i) const
std::ostream & print(std::ostream &o, bool tableFormat=false) const override
prints the counter to a stream
unsigned int index(Arithmetic value) const
returns the bin number for a given value, ranging from 0 (underflow) to nBins+1 (overflow)
auto nEntries(unsigned int i) const
HistogramingAccumulatorInternal(std::initializer_list< Axis< AxisArithmeticType >> axis, std::index_sequence< Is... >)
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
Buffer is a non atomic Accumulator which, when it goes out-of-scope, updates the underlying thread-sa...
atomicity
Defines atomicity of the accumulators.
HistogramingCounterBase(OWNER *owner, std::string const &name, std::string const &title, Axis< Arithmetic > axis)
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.
virtual std::ostream & print(std::ostream &, bool tableFormat=false) const =0
prints the counter to a stream
std::array< Axis< AxisArithmeticType >, ND::value > m_axis
set of Axis of this Histogram
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
MsgStream & print(MsgStream &o, bool tableFormat=false) const override