Loading [MathJax]/extensions/tex2jax.js
The Gaudi Framework  v38r0 (2143aa4c)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Histogram.h
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2022 CERN for the benefit of the LHCb and ATLAS collaborations *
3 * *
4 * This software is distributed under the terms of the Apache version 2 licence, *
5 * copied verbatim in the file "LICENSE". *
6 * *
7 * In applying this licence, CERN does not waive the privileges and immunities *
8 * granted to it by virtue of its status as an Intergovernmental Organization *
9 * or submit itself to any jurisdiction. *
10 \***********************************************************************************/
11 #pragma once
12 
13 #include <Gaudi/Accumulators.h>
14 #include <Gaudi/MonitoringHub.h>
15 #include <GaudiKernel/HistoDef.h>
16 
17 #include <array>
18 #include <cmath>
19 #include <fmt/format.h>
20 #include <nlohmann/json.hpp>
21 #include <string>
22 #include <type_traits>
23 #include <utility>
24 #include <vector>
25 
26 namespace Gaudi::Accumulators {
27 
28  namespace details {
29  template <std::size_t, typename T>
30  using alwaysT = T;
31  // get a tuple of n types the given Type, or directly the type for n = 1
32  template <typename Type, unsigned int ND>
33  struct GetTuple;
34  template <typename Type, unsigned int ND>
36  template <typename Type, unsigned int ND>
37  struct GetTuple {
38  using type =
40  };
41  template <typename Type>
42  struct GetTuple<Type, 1> {
44  };
45 
46  inline void requireValidTitle( std::string_view sv ) {
47  if ( !sv.empty() && ( std::isspace( sv.back() ) || std::isspace( sv.front() ) ) ) {
48  throw GaudiException(
49  fmt::format( "Histogram title \'{}\' has whitespace at front or back -- please remove", sv ),
50  "Gaudi::Accumulators", StatusCode::FAILURE );
51  }
52  }
53  } // namespace details
54 
58  struct ExtractWeight {
59  template <typename Arithmetic>
60  constexpr decltype( auto ) operator()( const std::pair<Arithmetic, Arithmetic>& v ) const noexcept {
61  return v.second;
62  }
63  };
64 
68  struct WeightedProduct {
69  template <typename Arithmetic>
70  constexpr decltype( auto ) operator()( const std::pair<Arithmetic, Arithmetic>& v ) const noexcept {
71  return v.first * v.second;
72  }
73  };
74 
78  struct WeightedSquare {
79  template <typename Arithmetic>
80  constexpr decltype( auto ) operator()( const std::pair<Arithmetic, Arithmetic>& v ) const noexcept {
81  return v.first * v.first * v.second;
82  }
83  };
84 
91  template <atomicity Atomicity, typename Arithmetic>
93  : GenericAccumulator<std::pair<Arithmetic, Arithmetic>, Arithmetic, Atomicity, ExtractWeight> {
95  using Base::Base;
96  using Base::operator+=;
98  WeightedCountAccumulator operator+=( const Arithmetic weight ) {
99  *this += { Arithmetic{}, weight };
100  return *this;
101  }
102  Arithmetic nEntries() const { return this->value(); }
103  };
104 
111  template <atomicity Atomicity, typename Arithmetic>
113  : GenericAccumulator<std::pair<Arithmetic, Arithmetic>, Arithmetic, Atomicity, WeightedProduct> {
114  using GenericAccumulator<std::pair<Arithmetic, Arithmetic>, Arithmetic, Atomicity,
116  Arithmetic sum() const { return this->value(); }
117  };
118 
124  template <atomicity Atomicity, typename Arithmetic = double>
126  : GenericAccumulator<std::pair<Arithmetic, Arithmetic>, Arithmetic, Atomicity, WeightedSquare> {
127  using GenericAccumulator<std::pair<Arithmetic, Arithmetic>, Arithmetic, Atomicity,
129  Arithmetic sum2() const { return this->value(); };
130  };
131 
137  template <atomicity Atomicity, typename Arithmetic>
140 
146  template <atomicity Atomicity, typename Arithmetic>
149 
153  template <typename Arithmetic>
154  struct Axis {
155  Axis( unsigned int _nBins, Arithmetic _minValue, Arithmetic _maxValue, std::string _title = {},
156  std::vector<std::string> _labels = {} )
157  : nBins( _nBins )
158  , minValue( _minValue )
159  , maxValue( _maxValue )
160  , title( std::move( _title ) )
161  , labels( std::move( _labels ) )
162  , ratio( _nBins / ( _maxValue - _minValue ) ) {
164  for ( const auto& s : labels ) details::requireValidTitle( s );
165  };
166  explicit Axis( Gaudi::Histo1DDef const& def )
167  : Axis( (unsigned int)def.bins(), def.lowEdge(), def.highEdge(), def.title() ){};
169  unsigned int nBins;
171  Arithmetic minValue, maxValue;
180  Arithmetic ratio;
181 
183  unsigned int index( Arithmetic value ) const {
184  // In case we use integer as Arithmetic type, we cannot use ratio for computing indices,
185  // as ratios < 1.0 will simply be 0, so we have to pay the division in such a case
186  int idx;
187  if constexpr ( std::is_integral_v<Arithmetic> ) {
188  idx = ( ( value - minValue ) * nBins / ( maxValue - minValue ) ) + 1;
189  } else {
190  idx = std::floor( ( value - minValue ) * ratio ) + 1;
191  }
192  return idx < 0 ? 0 : ( (unsigned int)idx > nBins ? nBins + 1 : (unsigned int)idx );
193  }
195  bool inAcceptance( Arithmetic value ) const { return value >= minValue && value <= maxValue; }
196  };
197 
199  template <typename Arithmetic>
200  void to_json( nlohmann::json& j, const Axis<Arithmetic>& axis ) {
201  j = nlohmann::json{ { "nBins", axis.nBins },
202  { "minValue", axis.minValue },
203  { "maxValue", axis.maxValue },
204  { "title", axis.title } };
205  if ( !axis.labels.empty() ) { j["labels"] = axis.labels; }
206  }
207 
209  template <typename Arithmetic, unsigned int ND, unsigned int NIndex = ND>
210  struct HistoInputType : std::array<Arithmetic, ND> {
211  // allow construction from set of values
212  template <class... ARGS, typename = typename std::enable_if_t<( sizeof...( ARGS ) == NIndex )>>
213  HistoInputType( ARGS... args ) : std::array<Arithmetic, ND>{ static_cast<Arithmetic>( args )... } {}
214  // The change on NIndex == 1 allow to have simpler syntax in that case, that is no tuple of one item
216  using AxisArithmeticType = Arithmetic;
218  unsigned int computeIndex( const std::array<Axis<Arithmetic>, NIndex>& axis ) const {
219  unsigned int index = 0;
220  for ( unsigned int j = 0; j < NIndex; j++ ) {
221  unsigned int dim = NIndex - j - 1;
222  // compute local index for a given dimension
223  int localIndex = axis[dim].index( ( *this )[dim] );
224  // compute global index. Bins are stored in a column first manner
225  index *= ( axis[dim].nBins + 2 );
226  index += localIndex;
227  }
228  return index;
229  }
230  bool inAcceptance( const std::array<Axis<Arithmetic>, NIndex>& axis ) const {
231  for ( unsigned int dim = 0; dim < NIndex; dim++ ) {
232  if ( !axis[dim].inAcceptance( ( *this )[dim] ) ) return false;
233  }
234  return true;
235  }
236  auto forInternalCounter() { return 1ul; }
237  template <typename AxisType, long unsigned NAxis>
238  static unsigned int computeTotNBins( std::array<AxisType, NAxis> axis ) {
239  unsigned int nTotBins = 1;
240  for ( unsigned int i = 0; i < NAxis; i++ ) { nTotBins *= ( axis[i].nBins + 2 ); }
241  return nTotBins;
242  }
243  };
244 
247  template <typename Arithmetic>
248  class HistoInputType<Arithmetic, 1> {
249  public:
251  using AxisArithmeticType = Arithmetic;
252  using InternalType = Arithmetic;
253  HistoInputType( Arithmetic a ) : value( a ) {}
254  unsigned int computeIndex( const std::array<Axis<Arithmetic>, 1>& axis ) const { return axis[0].index( value ); }
255  bool inAcceptance( const std::array<Axis<Arithmetic>, 1>& axis ) const { return axis[0].inAcceptance( value ); }
256  Arithmetic& operator[]( int ) { return value; }
257  operator Arithmetic() const { return value; }
258  auto forInternalCounter() { return 1ul; }
259  template <typename AxisType>
260  static unsigned int computeTotNBins( std::array<AxisType, 1> axis ) {
261  return axis[0].nBins + 2;
262  }
263 
264  private:
265  Arithmetic value;
266  };
267 
269  template <typename Arithmetic, unsigned int ND, unsigned int NIndex = ND>
270  struct WeightedHistoInputType : std::pair<HistoInputType<Arithmetic, ND, NIndex>, Arithmetic> {
271  // The change on NIndex == 1 allow to have simpler syntax in that case, that is no tuple of one item
273  using AxisArithmeticType = Arithmetic;
275  unsigned int computeIndex( const std::array<Axis<Arithmetic>, NIndex>& axis ) const {
276  return this->first.computeIndex( axis );
277  }
278  unsigned int inAcceptance( const std::array<Axis<Arithmetic>, NIndex>& axis ) const {
279  return this->first.inAcceptance( axis );
280  }
281  auto forInternalCounter() { return std::pair( this->first.forInternalCounter(), this->second ); }
282  template <typename AxisType, long unsigned NAxis>
283  static unsigned int computeTotNBins( std::array<AxisType, NAxis> axis ) {
285  }
286  };
287 
302  template <atomicity Atomicity, typename InputType, typename Arithmetic, typename ND,
303  template <atomicity Ato, typename Arith> typename BaseAccumulatorT>
305  template <atomicity, typename, typename, typename, template <atomicity, typename> typename>
307 
308  public:
309  using BaseAccumulator = BaseAccumulatorT<Atomicity, Arithmetic>;
310  using AxisArithmeticType = typename InputType::AxisArithmeticType;
312  template <std::size_t... Is>
314  : m_axis{ std::get<Is>( axis )... }
315  , m_totNBins{ InputType::computeTotNBins( m_axis ) }
317  reset();
318  }
319  template <atomicity ato>
323  : m_axis( other.m_axis )
324  , m_totNBins{ InputType::computeTotNBins( m_axis ) }
326  reset();
327  }
328  [[deprecated( "Use `++h1[x]`, `++h2[{x,y}]`, etc. instead." )]] HistogramingAccumulatorInternal&
329  operator+=( InputType v ) {
330  accumulator( v.computeIndex( m_axis ) ) += v.forInternalCounter();
331  return *this;
332  }
333  void reset() {
334  for ( unsigned int index = 0; index < m_totNBins; index++ ) accumulator( index ).reset();
335  }
336  template <atomicity ato>
338  assert( m_totNBins == other.m_totNBins );
339  for ( unsigned int index = 0; index < m_totNBins; index++ ) {
340  accumulator( index ).mergeAndReset( other.accumulator( index ) );
341  }
342  }
343  [[nodiscard]] auto operator[]( typename InputType::ValueType v ) {
345  }
346 
347  auto& axis() const { return m_axis; }
348  auto nBins( unsigned int i ) const { return m_axis[i].nBins; }
349  auto minValue( unsigned int i ) const { return m_axis[i].minValue; }
350  auto maxValue( unsigned int i ) const { return m_axis[i].maxValue; }
351  auto binValue( unsigned int i ) const { return accumulator( i ).value(); }
352  auto nEntries( unsigned int i ) const { return accumulator( i ).nEntries(); }
353  auto totNBins() const { return m_totNBins; }
354 
355  private:
356  BaseAccumulator& accumulator( unsigned int index ) const {
357  assert( index < m_totNBins );
358  return m_value[index];
359  }
363  unsigned int m_totNBins;
366  };
367 
373  template <atomicity Atomicity, typename Arithmetic, typename ND>
375  unsigned long, ND, IntegralAccumulator>;
376 
382  template <atomicity Atomicity, typename Arithmetic, typename ND>
386 
392  template <atomicity Atomicity, typename Arithmetic, typename ND>
396 
402  template <atomicity Atomicity, typename Arithmetic, typename ND>
405  Arithmetic, ND, WeightedSigmaAccumulator>;
406 
462  template <unsigned int ND, atomicity Atomicity, typename Arithmetic, const char* Type,
463  template <atomicity, typename, typename> typename Accumulator, typename Seq>
465  template <unsigned int ND, atomicity Atomicity, typename Arithmetic, const char* Type,
466  template <atomicity, typename, typename> typename Accumulator, std::size_t... NDs>
467  class HistogramingCounterBaseInternal<ND, Atomicity, Arithmetic, Type, Accumulator, std::index_sequence<NDs...>>
468  : public BufferableCounter<Atomicity, Accumulator, Arithmetic, std::integral_constant<int, ND>> {
469  public:
471  using AccumulatorType = Accumulator<Atomicity, Arithmetic, std::integral_constant<int, ND>>;
473  inline static const std::string typeString{ std::string{ Type } + ':' + typeid( Arithmetic ).name() };
474  template <typename OWNER>
475  HistogramingCounterBaseInternal( OWNER* owner, std::string const& name, std::string const& title,
477  : Parent( owner, name, *this, axis, std::make_index_sequence<ND>{} ), m_title( title ) {
478  details::requireValidTitle( m_title );
479  }
480  template <typename OWNER>
481  HistogramingCounterBaseInternal( OWNER* owner, std::string const& name, std::string const& title,
483  : HistogramingCounterBaseInternal( owner, name, title, std::make_tuple( allAxis... ) ) {}
484  using Parent::print;
485  template <typename stream>
486  stream& printImpl( stream& o, bool /*tableFormat*/ ) const {
487  o << ND << "D Histogram with config ";
488  for ( unsigned int i = 0; i < ND; i++ ) {
489  o << this->nBins( i ) << " " << this->minValue( i ) << " " << this->maxValue( i ) << " ";
490  }
491  return o;
492  }
493  std::ostream& print( std::ostream& o, bool tableFormat = false ) const override {
494  return printImpl( o, tableFormat );
495  }
496  MsgStream& print( MsgStream& o, bool tableFormat = false ) const override { return printImpl( o, tableFormat ); }
497  friend void reset( HistogramingCounterBaseInternal& c ) { c.reset(); }
499  h.mergeAndReset( o );
500  }
502  // get all bin values and compute total nbEntries
504  bins.reserve( h.totNBins() );
505  unsigned long totNEntries{ 0 };
506  for ( unsigned int i = 0; i < h.totNBins(); i++ ) {
507  bins.push_back( h.binValue( i ) );
508  totNEntries += h.nEntries( i );
509  }
510  // build json
511  j = { { "type", std::string( Type ) + ":" + typeid( Arithmetic ).name() },
512  { "title", h.m_title },
513  { "dimension", ND },
514  { "empty", totNEntries == 0 },
515  { "nEntries", totNEntries },
516  { "axis", h.axis() },
517  { "bins", bins } };
518  }
519 
520  private:
522  };
523  template <unsigned int ND, atomicity Atomicity, typename Arithmetic, const char* Type,
524  template <atomicity, typename, typename> typename Accumulator>
527 
528  namespace naming {
529  inline constexpr char histogramString[] = "histogram:Histogram";
530  inline constexpr char weightedHistogramString[] = "histogram:WeightedHistogram";
531  inline constexpr char profilehistogramString[] = "histogram:ProfileHistogram";
532  inline constexpr char weightedProfilehistogramString[] = "histogram:WeightedProfileHistogram";
533  } // namespace naming
535  template <unsigned int ND, atomicity Atomicity = atomicity::full, typename Arithmetic = double>
536  using Histogram =
538 
540  template <unsigned int ND, atomicity Atomicity = atomicity::full, typename Arithmetic = double>
543 
545  template <unsigned int ND, atomicity Atomicity = atomicity::full, typename Arithmetic = double>
548 
550  template <unsigned int ND, atomicity Atomicity = atomicity::full, typename Arithmetic = double>
554 
555 } // namespace Gaudi::Accumulators
Gaudi::Accumulators::Axis::minValue
Arithmetic minValue
min and max values on this axis
Definition: Histogram.h:171
Gaudi::Accumulators::ExtractWeight
A functor to extract weight, take a pair (valueTuple, weight) as input.
Definition: Histogram.h:58
std::floor
T floor(T... args)
Gaudi::Accumulators::HistogramingAccumulatorInternal::nBins
auto nBins(unsigned int i) const
Definition: Histogram.h:348
std::integral_constant
Gaudi::Accumulators::WeightedSquareAccumulator
WeightedSquareAccumulator.
Definition: Histogram.h:126
Write.stream
stream
Definition: Write.py:32
std::string
STL class.
Gaudi::Accumulators::details::requireValidTitle
void requireValidTitle(std::string_view sv)
Definition: Histogram.h:46
Gaudi::Accumulators::WeightedHistoInputType::forInternalCounter
auto forInternalCounter()
Definition: Histogram.h:281
Gaudi::Accumulators::HistogramingCounterBaseInternal< ND, Atomicity, Arithmetic, Type, Accumulator, std::index_sequence< NDs... > >::HistogramingCounterBaseInternal
HistogramingCounterBaseInternal(OWNER *owner, std::string const &name, std::string const &title, details::GetTuple_t< typename AccumulatorType::AxisType, ND > axis)
Definition: Histogram.h:475
std::move
T move(T... args)
Gaudi::Accumulators::HistogramingAccumulatorInternal::accumulator
BaseAccumulator & accumulator(unsigned int index) const
Definition: Histogram.h:356
bug_34121.name
name
Definition: bug_34121.py:20
Gaudi::Accumulators::HistogramingCounterBaseInternal< ND, Atomicity, Arithmetic, Type, Accumulator, std::index_sequence< NDs... > >::reset
friend void reset(HistogramingCounterBaseInternal &c)
Definition: Histogram.h:497
Gaudi::Accumulators::WeightedCountAccumulator::nEntries
Arithmetic nEntries() const
Definition: Histogram.h:102
MonitoringHub.h
std::pair
std::vector::reserve
T reserve(T... args)
Gaudi::Accumulators::HistogramingAccumulatorInternal< Atomicity, HistoInputType< Arithmetic, ND >, unsigned long, std::integral_constant< int, ND >, IntegralAccumulator >::AxisArithmeticType
typename InputType::AxisArithmeticType AxisArithmeticType
Definition: Histogram.h:310
Gaudi::Accumulators::HistoInputType< Arithmetic, 1 >::value
Arithmetic value
Definition: Histogram.h:265
Gaudi::Accumulators::Axis::maxValue
Arithmetic maxValue
Definition: Histogram.h:171
Gaudi::Accumulators::Axis::nBins
unsigned int nBins
number of bins for this Axis
Definition: Histogram.h:167
gaudirun.s
string s
Definition: gaudirun.py:346
Gaudi::Accumulators::HistoInputType< Arithmetic, 1 >::InternalType
Arithmetic InternalType
Definition: Histogram.h:252
Gaudi::Accumulators::HistogramingAccumulatorInternal::binValue
auto binValue(unsigned int i) const
Definition: Histogram.h:351
std::vector< std::string >
Gaudi::Accumulators::IntegralAccumulator
IntegralAccumulator.
Definition: Accumulators.h:640
jsonFromLHCbLog.json
json
Definition: jsonFromLHCbLog.py:86
GaudiException
Definition: GaudiException.h:31
Gaudi::Accumulators::naming::weightedHistogramString
constexpr char weightedHistogramString[]
Definition: Histogram.h:530
Gaudi::Accumulators::HistogramingCounterBaseInternal< ND, Atomicity, Arithmetic, Type, Accumulator, std::index_sequence< NDs... > >::HistogramingCounterBaseInternal
HistogramingCounterBaseInternal(OWNER *owner, std::string const &name, std::string const &title, details::alwaysT< NDs, typename AccumulatorType::AxisType >... allAxis)
Definition: Histogram.h:481
Gaudi::Accumulators::WeightedSumAccumulator::sum
Arithmetic sum() const
Definition: Histogram.h:116
std::tuple
gaudirun.c
c
Definition: gaudirun.py:525
Gaudi::Accumulators::HistogramingAccumulatorInternal::operator+=
HistogramingAccumulatorInternal & operator+=(InputType v)
Definition: Histogram.h:329
Gaudi::Accumulators::details::alwaysT
T alwaysT
Definition: Histogram.h:30
Gaudi::Accumulators::naming::weightedProfilehistogramString
constexpr char weightedProfilehistogramString[]
Definition: Histogram.h:532
Gaudi::Accumulators::AveragingAccumulatorBase
AveragingAccumulatorBase.
Definition: Accumulators.h:752
Gaudi::Accumulators::WeightedSumAccumulator
WeightedSumAccumulator.
Definition: Histogram.h:113
Gaudi::Accumulators::HistogramingCounterBaseInternal< ND, Atomicity, Arithmetic, Type, Accumulator, std::index_sequence< NDs... > >::to_json
friend void to_json(nlohmann::json &j, HistogramingCounterBaseInternal const &h)
Definition: Histogram.h:501
Gaudi::Accumulators::naming::profilehistogramString
constexpr char profilehistogramString[]
Definition: Histogram.h:531
Gaudi::Accumulators::HistogramingAccumulatorInternal::HistogramingAccumulatorInternal
HistogramingAccumulatorInternal(details::GetTuple_t< AxisType, ND::value > axis, std::index_sequence< Is... >)
Definition: Histogram.h:313
Gaudi::Accumulators::HistoInputType< Arithmetic, 1 >::computeTotNBins
static unsigned int computeTotNBins(std::array< AxisType, 1 > axis)
Definition: Histogram.h:260
HistoDef.h
Gaudi::Accumulators::Axis
Definition of an Histogram Axis.
Definition: Histogram.h:154
Gaudi::Accumulators::HistogramingCounterBaseInternal< ND, Atomicity, Arithmetic, Type, Accumulator, std::index_sequence< NDs... > >::AccumulatorType
Accumulator< Atomicity, Arithmetic, std::integral_constant< int, ND > > AccumulatorType
Definition: Histogram.h:471
std::vector::push_back
T push_back(T... args)
Gaudi::Accumulators::HistogramingCounterBaseInternal< ND, Atomicity, Arithmetic, Type, Accumulator, std::index_sequence< NDs... > >::printImpl
stream & printImpl(stream &o, bool) const
Definition: Histogram.h:486
Gaudi::Histo1DDef
Definition: HistoDef.h:41
Gaudi::Accumulators::HistoInputType::computeIndex
unsigned int computeIndex(const std::array< Axis< Arithmetic >, NIndex > &axis) const
Definition: Histogram.h:218
Gaudi::Accumulators::HistogramingCounterBaseInternal< ND, Atomicity, Arithmetic, Type, Accumulator, std::index_sequence< NDs... > >::print
std::ostream & print(std::ostream &o, bool tableFormat=false) const override
prints the counter to a stream
Definition: Histogram.h:493
Gaudi::Accumulators::WeightedHistoInputType::computeIndex
unsigned int computeIndex(const std::array< Axis< Arithmetic >, NIndex > &axis) const
Definition: Histogram.h:275
Gaudi::Accumulators::HistoInputType
small class used as InputType for regular Histograms
Definition: Histogram.h:210
Gaudi::Accumulators::HistoInputType< Arithmetic, 1 >::AxisArithmeticType
Arithmetic AxisArithmeticType
Definition: Histogram.h:251
Gaudi::Accumulators::HistogramingAccumulatorInternal::BaseAccumulator
BaseAccumulatorT< Atomicity, Arithmetic > BaseAccumulator
Definition: Histogram.h:309
details
Definition: AnyDataWrapper.h:18
ProduceConsume.j
j
Definition: ProduceConsume.py:101
std::ostream
STL class.
Gaudi::Accumulators::HistogramingAccumulatorInternal::totNBins
auto totNBins() const
Definition: Histogram.h:353
Gaudi::Accumulators::HistogramingAccumulatorInternal::operator[]
auto operator[](typename InputType::ValueType v)
Definition: Histogram.h:343
Gaudi::Accumulators::HistogramingAccumulatorInternal::mergeAndReset
void mergeAndReset(HistogramingAccumulatorInternal< ato, InputType, Arithmetic, ND, BaseAccumulatorT > &other)
Definition: Histogram.h:337
AlgSequencer.h
h
Definition: AlgSequencer.py:31
Gaudi::Accumulators::HistogramingCounterBaseInternal< ND, Atomicity, Arithmetic, Type, Accumulator, std::index_sequence< NDs... > >::print
MsgStream & print(MsgStream &o, bool tableFormat=false) const override
Definition: Histogram.h:496
Gaudi::Accumulators::WeightedHistoInputType
small class used as InputType for weighted Histograms
Definition: Histogram.h:270
Gaudi::Accumulators::details::GetTuple::type
decltype(std::tuple_cat(std::declval< std::tuple< Type > >(), std::declval< GetTuple_t< Type, ND - 1 > >())) type
Definition: Histogram.h:39
Gaudi::Accumulators::GenericAccumulator< std::pair< Arithmetic, Arithmetic >, Arithmetic, Atomicity, WeightedProduct >::GenericAccumulator
friend class GenericAccumulator
Definition: Accumulators.h:473
Gaudi::Accumulators::WeightedHistoInputType::inAcceptance
unsigned int inAcceptance(const std::array< Axis< Arithmetic >, NIndex > &axis) const
Definition: Histogram.h:278
std::array
STL class.
Gaudi::Accumulators::HistogramingAccumulatorInternal::maxValue
auto maxValue(unsigned int i) const
Definition: Histogram.h:350
Gaudi::Accumulators::Axis::index
unsigned int index(Arithmetic value) const
returns the bin number for a given value, ranging from 0 (underflow) to nBins+1 (overflow)
Definition: Histogram.h:183
Gaudi::Accumulators::HistogramingCounterBaseInternal< ND, Atomicity, Arithmetic, Type, Accumulator, std::index_sequence< NDs... > >::m_title
std::string const m_title
Definition: Histogram.h:521
Gaudi::Accumulators::HistoInputType::forInternalCounter
auto forInternalCounter()
Definition: Histogram.h:236
Gaudi::Accumulators::HistogramingAccumulatorInternal::axis
auto & axis() const
Definition: Histogram.h:347
Gaudi::Accumulators::HistogramingAccumulatorInternal::nEntries
auto nEntries(unsigned int i) const
Definition: Histogram.h:352
Gaudi::Accumulators::HistogramingAccumulatorInternal::reset
void reset()
Definition: Histogram.h:333
format
GAUDI_API std::string format(const char *,...)
MsgStream format utility "a la sprintf(...)".
Definition: MsgStream.cpp:119
Gaudi::Accumulators::WeightedHistoInputType::computeTotNBins
static unsigned int computeTotNBins(std::array< AxisType, NAxis > axis)
Definition: Histogram.h:283
Gaudi::Accumulators::HistoInputType< Arithmetic, 1 >::forInternalCounter
auto forInternalCounter()
Definition: Histogram.h:258
Gaudi::Accumulators::GenericAccumulator
Generic Accumulator, templated by.
Definition: Accumulators.h:471
Gaudi::Accumulators::HistogramingAccumulatorInternal::minValue
auto minValue(unsigned int i) const
Definition: Histogram.h:349
MsgStream
Definition: MsgStream.h:34
Gaudi::Accumulators::HistogramingAccumulatorInternal::HistogramingAccumulatorInternal
HistogramingAccumulatorInternal(construct_empty_t, const HistogramingAccumulatorInternal< ato, InputType, Arithmetic, ND, BaseAccumulatorT > &other)
Definition: Histogram.h:320
Gaudi::Accumulators::to_json
void to_json(nlohmann::json &j, const Axis< Arithmetic > &axis)
automatic conversion of the Axis type to json
Definition: Histogram.h:200
Gaudi::Accumulators::Axis::Axis
Axis(unsigned int _nBins, Arithmetic _minValue, Arithmetic _maxValue, std::string _title={}, std::vector< std::string > _labels={})
Definition: Histogram.h:155
Gaudi::Accumulators::GenericAccumulator< std::pair< Arithmetic, Arithmetic >, Arithmetic, Atomicity, ExtractWeight >::value
OutputType value() const
Definition: Accumulators.h:501
Gaudi::Accumulators::WeightedProduct
A Product functor, take a pair (value, weight) as input.
Definition: Histogram.h:68
Gaudi::Accumulators::BufferableCounter
An empty ancester of all counters that provides a buffer method that returns a buffer on itself Also ...
Definition: Accumulators.h:909
Gaudi::Accumulators::HistoInputType::inAcceptance
bool inAcceptance(const std::array< Axis< Arithmetic >, NIndex > &axis) const
Definition: Histogram.h:230
Gaudi::Accumulators::HistogramingAccumulatorInternal
Internal Accumulator class dealing with Histograming.
Definition: Histogram.h:304
Accumulators.h
Gaudi::Accumulators::HistoInputType< Arithmetic, 1 >::computeIndex
unsigned int computeIndex(const std::array< Axis< Arithmetic >, 1 > &axis) const
Definition: Histogram.h:254
Gaudi::Accumulators
Definition: HistogramsTests.cpp:20
Gaudi::Accumulators::HistoInputType< Arithmetic, 1 >::HistoInputType
HistoInputType(Arithmetic a)
Definition: Histogram.h:253
Gaudi::Accumulators::HistoInputType::AxisArithmeticType
Arithmetic AxisArithmeticType
Definition: Histogram.h:216
Gaudi::Accumulators::Axis::Axis
Axis(Gaudi::Histo1DDef const &def)
Definition: Histogram.h:166
Containers::array
struct GAUDI_API array
Parametrisation class for redirection array - like implementation.
Definition: KeyedObjectManager.h:37
gaudirun.args
args
Definition: gaudirun.py:336
Gaudi::Accumulators::HistoInputType::HistoInputType
HistoInputType(ARGS... args)
Definition: Histogram.h:213
Gaudi::Accumulators::HistogramingAccumulatorInternal::m_value
std::unique_ptr< BaseAccumulator[]> m_value
Histogram content.
Definition: Histogram.h:365
Tuples::Type
Type
Definition: TupleObj.h:91
std
STL namespace.
Gaudi::Accumulators::WeightedSquare
A WeightedSquare functor, take a pair (value, weight) as input.
Definition: Histogram.h:78
Gaudi::Accumulators::HistogramingAccumulatorInternal::m_totNBins
unsigned int m_totNBins
total number of bins in this histogram, under and overflow included
Definition: Histogram.h:363
Gaudi::Accumulators::HistogramingAccumulatorInternal::HistogramingAccumulatorInternal
friend class HistogramingAccumulatorInternal
Definition: Histogram.h:306
Gaudi::Accumulators::SigmaAccumulatorBase
SigmaAccumulatorBase.
Definition: Accumulators.h:781
Gaudi::Accumulators::Buffer
Buffer is a non atomic Accumulator which, when it goes out-of-scope, updates the underlying thread-sa...
Definition: Accumulators.h:849
std::isspace
T isspace(T... args)
Gaudi::Accumulators::atomicity
atomicity
Defines atomicity of the accumulators.
Definition: Accumulators.h:263
std::vector::empty
T empty(T... args)
Properties.v
v
Definition: Properties.py:122
Gaudi::Accumulators::Axis::ratio
Arithmetic ratio
precomputed ratio to convert a value into bin number equal to nBins/(maxValue-minValue).
Definition: Histogram.h:180
Gaudi::Accumulators::construct_empty_t
constant used to disambiguate construction of an empty Accumulator versus the copy constructor.
Definition: Accumulators.h:446
Gaudi::Accumulators::HistoInputType::computeTotNBins
static unsigned int computeTotNBins(std::array< AxisType, NAxis > axis)
Definition: Histogram.h:238
std::tuple_cat
T tuple_cat(T... args)
Gaudi::Accumulators::WeightedCountAccumulator
WeightedCountAccumulator.
Definition: Histogram.h:93
std::size_t
Gaudi::Accumulators::HistogramingCounterBaseInternal< ND, Atomicity, Arithmetic, Type, Accumulator, std::index_sequence< NDs... > >::mergeAndReset
friend void mergeAndReset(HistogramingCounterBaseInternal &h, HistogramingCounterBaseInternal &o)
Definition: Histogram.h:498
Gaudi::Accumulators::details::GetTuple
Definition: Histogram.h:33
Gaudi::Accumulators::HistogramingAccumulatorInternal::m_axis
std::array< AxisType, ND::value > m_axis
set of Axis of this Histogram
Definition: Histogram.h:361
Gaudi::Accumulators::WeightedHistoInputType::AxisArithmeticType
Arithmetic AxisArithmeticType
Definition: Histogram.h:273
StatusCode::FAILURE
constexpr static const auto FAILURE
Definition: StatusCode.h:101
Gaudi::Accumulators::HistoInputType< Arithmetic, 1 >::inAcceptance
bool inAcceptance(const std::array< Axis< Arithmetic >, 1 > &axis) const
Definition: Histogram.h:255
Gaudi::Accumulators::Axis::inAcceptance
bool inAcceptance(Arithmetic value) const
says whether the given value is within the range of the axis
Definition: Histogram.h:195
Gaudi::Accumulators::details::GetTuple_t
typename GetTuple< Type, ND >::type GetTuple_t
Definition: Histogram.h:35
Gaudi::Accumulators::naming::histogramString
constexpr char histogramString[]
Definition: Histogram.h:529
Gaudi::Accumulators::HistogramingCounterBaseInternal
A base counter dealing with Histograms.
Definition: Histogram.h:464
std::unique_ptr< BaseAccumulator[]>
Gaudi::Accumulators::WeightedSquareAccumulator::sum2
Arithmetic sum2() const
Definition: Histogram.h:129
Gaudi::Accumulators::WeightedCountAccumulator::operator+=
WeightedCountAccumulator operator+=(const Arithmetic weight)
Definition: Histogram.h:98
Gaudi::Accumulators::Axis::title
std::string title
title of this axis
Definition: Histogram.h:173
Gaudi::Accumulators::Axis::labels
std::vector< std::string > labels
labels for the bins
Definition: Histogram.h:175
Gaudi::Accumulators::HistoInputType< Arithmetic, 1 >::operator[]
Arithmetic & operator[](int)
Definition: Histogram.h:256
std::declval
T declval(T... args)
Gaudi::ParticleProperties::index
size_t index(const Gaudi::ParticleProperty *property, const Gaudi::Interfaces::IParticlePropertySvc *service)
helper utility for mapping of Gaudi::ParticleProperty object into non-negative integral sequential id...
Definition: IParticlePropertySvc.cpp:39