The Gaudi Framework  v41r0 (bdbe7744)
Loading...
Searching...
No Matches
Gaudi::Accumulators::HistogramingAccumulatorInternal< Atomicity, InputType, Arithmetic, BaseAccumulatorT, AxisTupleType > Class Template Reference

Internal Accumulator class dealing with Histograming. More...

#include </builds/gaudi/Gaudi/GaudiKernel/include/Gaudi/Accumulators/StaticHistogram.h>

Collaboration diagram for Gaudi::Accumulators::HistogramingAccumulatorInternal< Atomicity, InputType, Arithmetic, BaseAccumulatorT, AxisTupleType >:

Public Types

using ND = std::integral_constant<unsigned int, std::tuple_size_v<AxisTupleType>>
using BaseAccumulator = BaseAccumulatorT<Atomicity, Arithmetic>
using AxisTupleArithmeticType = typename InputType::ValueType

Public Member Functions

 HistogramingAccumulatorInternal (AxisTupleType axis)
template<atomicity ato>
 HistogramingAccumulatorInternal (construct_empty_t, const HistogramingAccumulatorInternal< ato, InputType, Arithmetic, BaseAccumulatorT, AxisTupleType > &other)
HistogramingAccumulatorInternal & operator+= (InputType v)
void reset ()
template<atomicity ato>
void mergeAndReset (HistogramingAccumulatorInternal< ato, InputType, Arithmetic, BaseAccumulatorT, AxisTupleType > &other)
auto operator[] (typename InputType::ValueType v)
template<unsigned int N>
auto & axis () const
auto & axis () const
auto binValue (unsigned int i) const
auto nEntries (unsigned int i) const
auto totNBins () const
auto nBins (unsigned int i) const
auto minValue (unsigned int i) const
auto maxValue (unsigned int i) const

Private Member Functions

BaseAccumulator & accumulator (unsigned int index) const
std::tuple_element_t< 0, AxisTupleType > const & _getAxis (size_t i, typename std::tuple_size< AxisTupleType >::type) const
template<size_t N>
requires ( std::tuple_size_v<AxisTupleType> != N )
auto & _getAxis (size_t i, std::integral_constant< size_t, N >) const

Private Attributes

AxisTupleType m_axis
 set of Axis of this Histogram
unsigned int m_totNBins {}
 total number of bins in this histogram, under and overflow included
std::unique_ptr< BaseAccumulator[]> m_value
 Histogram content.

Friends

template<atomicity, typename, typename, template< atomicity, typename > typename, typename>
class HistogramingAccumulatorInternal

Detailed Description

template<atomicity Atomicity, typename InputType, typename Arithmetic, template< atomicity Ato, typename Arith > typename BaseAccumulatorT, typename AxisTupleType>
class Gaudi::Accumulators::HistogramingAccumulatorInternal< Atomicity, InputType, Arithmetic, BaseAccumulatorT, AxisTupleType >

Internal Accumulator class dealing with Histograming.

Templates parameters are :

  • Atomicity : none or full
  • InputType : a class holding a value given as input of the Histogram, and able to answer questions on this value given a number of axis matching the type of value. e.g. it would hold a pair of double for a non weighted 2D histogram or a pair of triplet of doubles and double for the weighted 3D histogram. Example implementations are (Weighted)HistoInputType. This class must define :
    • a constructor taking a set of value to build the InputType
    • a static method unsigned int computeTotNBins( std::tuple<AxisType...> const& ) able to compute the total number of bins needed with this input type and these axis. It will typically be the product of the number of bins for each dimension, potentially increased by 2 for each if underflow and overflow is supported
    • a type ValueType alias defining the type of the input values to give to InputType This type needs to implement :
      • a method unsigned int computeIndex( std::tuple<AxisType...> const& ) const able to compute the bin corresponding to a given value
      • a method auto forInternalCounter() const returning the value to be used to inscrease the accumulator dealing with the bin associated with the current value. In most simple cases, it return Arithmetic{} or even 1 but for weighted histograms, it returns a pair with the weight as second item
      • in case of usage within a RootHistogram, it should also define a method bool inAcceptance( std::tuple<AxisType...> const& ) checking whether a given value in within the range of the accumulator
  • Arithmetic : the arithmetic type used for values stored inside the histogram e.g. unsigned int for regular histogram as we only count entries, or float/double for weighted histograms, as we store actual sums of original values
  • BaseAccumulator : the underlying accumulator used in each bin
  • AxisTupleType : the types of the axis as a tuple. Its length defines the dimension of the Histogram this accumulator handles. The constraints on the AxisType are : FIXME use concepts when available
    • that they can be copied
    • that they have a ArithmeticType type alias
    • that they have a unsigned int numBins() const method
    • that they have a friend operator<< using std::ostream for printing
    • that they have a friend to_json method using nlohmann library
    • that they implement whatever is needed by the computeIndex and computeTotNBins methods of the InputType used. Plus the inAcceptance one if Roothistograms are used A default Axis class is provided for most cases This accumulator is simply an array of BaseAccumulator, one per bin.

Definition at line 483 of file StaticHistogram.h.

Member Typedef Documentation

◆ AxisTupleArithmeticType

template<atomicity Atomicity, typename InputType, typename Arithmetic, template< atomicity Ato, typename Arith > typename BaseAccumulatorT, typename AxisTupleType>
using Gaudi::Accumulators::HistogramingAccumulatorInternal< Atomicity, InputType, Arithmetic, BaseAccumulatorT, AxisTupleType >::AxisTupleArithmeticType = typename InputType::ValueType

Definition at line 490 of file StaticHistogram.h.

◆ BaseAccumulator

template<atomicity Atomicity, typename InputType, typename Arithmetic, template< atomicity Ato, typename Arith > typename BaseAccumulatorT, typename AxisTupleType>
using Gaudi::Accumulators::HistogramingAccumulatorInternal< Atomicity, InputType, Arithmetic, BaseAccumulatorT, AxisTupleType >::BaseAccumulator = BaseAccumulatorT<Atomicity, Arithmetic>

Definition at line 489 of file StaticHistogram.h.

◆ ND

template<atomicity Atomicity, typename InputType, typename Arithmetic, template< atomicity Ato, typename Arith > typename BaseAccumulatorT, typename AxisTupleType>
using Gaudi::Accumulators::HistogramingAccumulatorInternal< Atomicity, InputType, Arithmetic, BaseAccumulatorT, AxisTupleType >::ND = std::integral_constant<unsigned int, std::tuple_size_v<AxisTupleType>>

Definition at line 488 of file StaticHistogram.h.

Constructor & Destructor Documentation

◆ HistogramingAccumulatorInternal() [1/2]

template<atomicity Atomicity, typename InputType, typename Arithmetic, template< atomicity Ato, typename Arith > typename BaseAccumulatorT, typename AxisTupleType>
Gaudi::Accumulators::HistogramingAccumulatorInternal< Atomicity, InputType, Arithmetic, BaseAccumulatorT, AxisTupleType >::HistogramingAccumulatorInternal ( AxisTupleType axis)
inline

Definition at line 491 of file StaticHistogram.h.

492 : m_axis{ axis }
495 reset();
496 }
Internal Accumulator class dealing with Histograming.
AxisTupleType m_axis
set of Axis of this Histogram
unsigned int m_totNBins
total number of bins in this histogram, under and overflow included
BaseAccumulatorT< Atomicity, Arithmetic > BaseAccumulator
std::unique_ptr< BaseAccumulator[]> m_value
Histogram content.

◆ HistogramingAccumulatorInternal() [2/2]

template<atomicity Atomicity, typename InputType, typename Arithmetic, template< atomicity Ato, typename Arith > typename BaseAccumulatorT, typename AxisTupleType>
template<atomicity ato>
Gaudi::Accumulators::HistogramingAccumulatorInternal< Atomicity, InputType, Arithmetic, BaseAccumulatorT, AxisTupleType >::HistogramingAccumulatorInternal ( construct_empty_t ,
const HistogramingAccumulatorInternal< ato, InputType, Arithmetic, BaseAccumulatorT, AxisTupleType > & other )
inline

Definition at line 498 of file StaticHistogram.h.

Member Function Documentation

◆ _getAxis() [1/2]

template<atomicity Atomicity, typename InputType, typename Arithmetic, template< atomicity Ato, typename Arith > typename BaseAccumulatorT, typename AxisTupleType>
template<size_t N>
requires ( std::tuple_size_v<AxisTupleType> != N )
auto & Gaudi::Accumulators::HistogramingAccumulatorInternal< Atomicity, InputType, Arithmetic, BaseAccumulatorT, AxisTupleType >::_getAxis ( size_t i,
std::integral_constant< size_t, N >  ) const
inlineprivate

Definition at line 556 of file StaticHistogram.h.

556 {
557 if ( i == N ) return std::get<N>( m_axis );
559 }
std::tuple_element_t< 0, AxisTupleType > const & _getAxis(size_t i, typename std::tuple_size< AxisTupleType >::type) const

◆ _getAxis() [2/2]

template<atomicity Atomicity, typename InputType, typename Arithmetic, template< atomicity Ato, typename Arith > typename BaseAccumulatorT, typename AxisTupleType>
std::tuple_element_t< 0, AxisTupleType > const & Gaudi::Accumulators::HistogramingAccumulatorInternal< Atomicity, InputType, Arithmetic, BaseAccumulatorT, AxisTupleType >::_getAxis ( size_t i,
typename std::tuple_size< AxisTupleType >::type  ) const
inlineprivate

Definition at line 549 of file StaticHistogram.h.

550 {
551 throw std::logic_error(
552 std::format( "Retrieving axis {} in Histogram of dimension {}", i, std::tuple_size_v<AxisTupleType> ) );
553 }

◆ accumulator()

template<atomicity Atomicity, typename InputType, typename Arithmetic, template< atomicity Ato, typename Arith > typename BaseAccumulatorT, typename AxisTupleType>
BaseAccumulator & Gaudi::Accumulators::HistogramingAccumulatorInternal< Atomicity, InputType, Arithmetic, BaseAccumulatorT, AxisTupleType >::accumulator ( unsigned int index) const
inlineprivate

Definition at line 541 of file StaticHistogram.h.

541 {
543 assert( m_value.get() );
544 return m_value[index];
545 }

◆ axis() [1/2]

template<atomicity Atomicity, typename InputType, typename Arithmetic, template< atomicity Ato, typename Arith > typename BaseAccumulatorT, typename AxisTupleType>
auto & Gaudi::Accumulators::HistogramingAccumulatorInternal< Atomicity, InputType, Arithmetic, BaseAccumulatorT, AxisTupleType >::axis ( ) const
inline

Definition at line 528 of file StaticHistogram.h.

528{ return m_axis; }

◆ axis() [2/2]

template<atomicity Atomicity, typename InputType, typename Arithmetic, template< atomicity Ato, typename Arith > typename BaseAccumulatorT, typename AxisTupleType>
template<unsigned int N>
auto & Gaudi::Accumulators::HistogramingAccumulatorInternal< Atomicity, InputType, Arithmetic, BaseAccumulatorT, AxisTupleType >::axis ( ) const
inline

Definition at line 525 of file StaticHistogram.h.

525 {
526 return std::get<N>( m_axis );
527 }

◆ binValue()

template<atomicity Atomicity, typename InputType, typename Arithmetic, template< atomicity Ato, typename Arith > typename BaseAccumulatorT, typename AxisTupleType>
auto Gaudi::Accumulators::HistogramingAccumulatorInternal< Atomicity, InputType, Arithmetic, BaseAccumulatorT, AxisTupleType >::binValue ( unsigned int i) const
inline

Definition at line 529 of file StaticHistogram.h.

529{ return accumulator( i ).value(); }
BaseAccumulator & accumulator(unsigned int index) const

◆ maxValue()

template<atomicity Atomicity, typename InputType, typename Arithmetic, template< atomicity Ato, typename Arith > typename BaseAccumulatorT, typename AxisTupleType>
auto Gaudi::Accumulators::HistogramingAccumulatorInternal< Atomicity, InputType, Arithmetic, BaseAccumulatorT, AxisTupleType >::maxValue ( unsigned int i) const
inline

Definition at line 538 of file StaticHistogram.h.

538{ return _getAxis( i, std::integral_constant<size_t, 0>() ).maxValue(); }

◆ mergeAndReset()

template<atomicity Atomicity, typename InputType, typename Arithmetic, template< atomicity Ato, typename Arith > typename BaseAccumulatorT, typename AxisTupleType>
template<atomicity ato>
void Gaudi::Accumulators::HistogramingAccumulatorInternal< Atomicity, InputType, Arithmetic, BaseAccumulatorT, AxisTupleType >::mergeAndReset ( HistogramingAccumulatorInternal< ato, InputType, Arithmetic, BaseAccumulatorT, AxisTupleType > & other)
inline

Definition at line 513 of file StaticHistogram.h.

514 {
516 for ( unsigned int index = 0; index < m_totNBins; index++ ) {
517 accumulator( index ).mergeAndReset( other.accumulator( index ) );
518 }
519 }

◆ minValue()

template<atomicity Atomicity, typename InputType, typename Arithmetic, template< atomicity Ato, typename Arith > typename BaseAccumulatorT, typename AxisTupleType>
auto Gaudi::Accumulators::HistogramingAccumulatorInternal< Atomicity, InputType, Arithmetic, BaseAccumulatorT, AxisTupleType >::minValue ( unsigned int i) const
inline

Definition at line 537 of file StaticHistogram.h.

537{ return _getAxis( i, std::integral_constant<size_t, 0>() ).minValue(); }

◆ nBins()

template<atomicity Atomicity, typename InputType, typename Arithmetic, template< atomicity Ato, typename Arith > typename BaseAccumulatorT, typename AxisTupleType>
auto Gaudi::Accumulators::HistogramingAccumulatorInternal< Atomicity, InputType, Arithmetic, BaseAccumulatorT, AxisTupleType >::nBins ( unsigned int i) const
inline

Definition at line 536 of file StaticHistogram.h.

536{ return _getAxis( i, std::integral_constant<size_t, 0>() ).numBins(); }

◆ nEntries()

template<atomicity Atomicity, typename InputType, typename Arithmetic, template< atomicity Ato, typename Arith > typename BaseAccumulatorT, typename AxisTupleType>
auto Gaudi::Accumulators::HistogramingAccumulatorInternal< Atomicity, InputType, Arithmetic, BaseAccumulatorT, AxisTupleType >::nEntries ( unsigned int i) const
inline

Definition at line 530 of file StaticHistogram.h.

530{ return accumulator( i ).nEntries(); }

◆ operator+=()

template<atomicity Atomicity, typename InputType, typename Arithmetic, template< atomicity Ato, typename Arith > typename BaseAccumulatorT, typename AxisTupleType>
HistogramingAccumulatorInternal & Gaudi::Accumulators::HistogramingAccumulatorInternal< Atomicity, InputType, Arithmetic, BaseAccumulatorT, AxisTupleType >::operator+= ( InputType v)
inline

Definition at line 505 of file StaticHistogram.h.

505 {
506 accumulator( v.computeIndex( m_axis ) ) += v.forInternalCounter();
507 return *this;
508 }

◆ operator[]()

template<atomicity Atomicity, typename InputType, typename Arithmetic, template< atomicity Ato, typename Arith > typename BaseAccumulatorT, typename AxisTupleType>
auto Gaudi::Accumulators::HistogramingAccumulatorInternal< Atomicity, InputType, Arithmetic, BaseAccumulatorT, AxisTupleType >::operator[] ( typename InputType::ValueType v)
inlinenodiscard

Definition at line 520 of file StaticHistogram.h.

520 {
522 }

◆ reset()

template<atomicity Atomicity, typename InputType, typename Arithmetic, template< atomicity Ato, typename Arith > typename BaseAccumulatorT, typename AxisTupleType>
void Gaudi::Accumulators::HistogramingAccumulatorInternal< Atomicity, InputType, Arithmetic, BaseAccumulatorT, AxisTupleType >::reset ( )
inline

Definition at line 509 of file StaticHistogram.h.

509 {
510 for ( unsigned int index = 0; index < m_totNBins; index++ ) { accumulator( index ).reset(); }
511 }

◆ totNBins()

template<atomicity Atomicity, typename InputType, typename Arithmetic, template< atomicity Ato, typename Arith > typename BaseAccumulatorT, typename AxisTupleType>
auto Gaudi::Accumulators::HistogramingAccumulatorInternal< Atomicity, InputType, Arithmetic, BaseAccumulatorT, AxisTupleType >::totNBins ( ) const
inline

Definition at line 531 of file StaticHistogram.h.

531{ return m_totNBins; }

◆ HistogramingAccumulatorInternal

template<atomicity Atomicity, typename InputType, typename Arithmetic, template< atomicity Ato, typename Arith > typename BaseAccumulatorT, typename AxisTupleType>
template<atomicity, typename, typename, template< atomicity, typename > typename, typename>
friend class HistogramingAccumulatorInternal
friend

Definition at line 485 of file StaticHistogram.h.

Member Data Documentation

◆ m_axis

template<atomicity Atomicity, typename InputType, typename Arithmetic, template< atomicity Ato, typename Arith > typename BaseAccumulatorT, typename AxisTupleType>
AxisTupleType Gaudi::Accumulators::HistogramingAccumulatorInternal< Atomicity, InputType, Arithmetic, BaseAccumulatorT, AxisTupleType >::m_axis
private

set of Axis of this Histogram

Definition at line 562 of file StaticHistogram.h.

◆ m_totNBins

template<atomicity Atomicity, typename InputType, typename Arithmetic, template< atomicity Ato, typename Arith > typename BaseAccumulatorT, typename AxisTupleType>
unsigned int Gaudi::Accumulators::HistogramingAccumulatorInternal< Atomicity, InputType, Arithmetic, BaseAccumulatorT, AxisTupleType >::m_totNBins {}
private

total number of bins in this histogram, under and overflow included

Definition at line 564 of file StaticHistogram.h.

564{};

◆ m_value

template<atomicity Atomicity, typename InputType, typename Arithmetic, template< atomicity Ato, typename Arith > typename BaseAccumulatorT, typename AxisTupleType>
std::unique_ptr<BaseAccumulator[]> Gaudi::Accumulators::HistogramingAccumulatorInternal< Atomicity, InputType, Arithmetic, BaseAccumulatorT, AxisTupleType >::m_value
private

Histogram content.

Definition at line 566 of file StaticHistogram.h.


The documentation for this class was generated from the following file: