The Gaudi Framework  v41r0 (bdbe7744)
Loading...
Searching...
No Matches
Gaudi::Accumulators::SigmasValueHandler< Arithmetic, Atomicity, ND > Struct Template Reference

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

Classes

struct  OutputTypeTS

Public Types

using InputType = std::conditional_t<ND == 1, Arithmetic, std::array<Arithmetic, ND>>
using OutputType = std::array<Arithmetic, NSUMS( ND )>
using InternalType = std::conditional_t<Atomicity == atomicity::full, OutputTypeTS, OutputType>

Static Public Member Functions

static constexpr OutputType getValue (const InternalType &v) noexcept
static OutputType exchange (InternalType &v, OutputType newv) noexcept
static constexpr OutputType DefaultValue ()
static void merge (InternalType &a, const OutputType &b) noexcept
static void merge (InternalType &a, InputType b) noexcept

Detailed Description

template<typename Arithmetic, atomicity Atomicity, unsigned int ND>
struct Gaudi::Accumulators::SigmasValueHandler< Arithmetic, Atomicity, ND >

Definition at line 32 of file StaticRootHistogram.h.

Member Typedef Documentation

◆ InputType

template<typename Arithmetic, atomicity Atomicity, unsigned int ND>
using Gaudi::Accumulators::SigmasValueHandler< Arithmetic, Atomicity, ND >::InputType = std::conditional_t<ND == 1, Arithmetic, std::array<Arithmetic, ND>>

Definition at line 33 of file StaticRootHistogram.h.

◆ InternalType

template<typename Arithmetic, atomicity Atomicity, unsigned int ND>
using Gaudi::Accumulators::SigmasValueHandler< Arithmetic, Atomicity, ND >::InternalType = std::conditional_t<Atomicity == atomicity::full, OutputTypeTS, OutputType>

Definition at line 53 of file StaticRootHistogram.h.

◆ OutputType

template<typename Arithmetic, atomicity Atomicity, unsigned int ND>
using Gaudi::Accumulators::SigmasValueHandler< Arithmetic, Atomicity, ND >::OutputType = std::array<Arithmetic, NSUMS( ND )>

Definition at line 34 of file StaticRootHistogram.h.

Member Function Documentation

◆ DefaultValue()

template<typename Arithmetic, atomicity Atomicity, unsigned int ND>
constexpr OutputType Gaudi::Accumulators::SigmasValueHandler< Arithmetic, Atomicity, ND >::DefaultValue ( )
inlinestaticconstexpr

Definition at line 67 of file StaticRootHistogram.h.

67{ return InternalType{}; }
std::conditional_t< Atomicity==atomicity::full, OutputTypeTS, OutputType > InternalType

◆ exchange()

template<typename Arithmetic, atomicity Atomicity, unsigned int ND>
OutputType Gaudi::Accumulators::SigmasValueHandler< Arithmetic, Atomicity, ND >::exchange ( InternalType & v,
OutputType newv )
inlinestaticnoexcept

Definition at line 58 of file StaticRootHistogram.h.

58 {
59 if constexpr ( Atomicity == atomicity::full ) {
61 for ( unsigned int i = 0; i < NSUMS( ND ); i++ ) { old[i] = v[i].exchange( newv[i] ); }
62 return old;
63 } else {
64 return std::exchange( v, newv );
65 }
66 }
constexpr unsigned int NSUMS(unsigned int ND)
number of items in sums for a given dimension = 1 (nb items) + ND (sums of each dimension) + ND*(ND+1...
std::array< Arithmetic, NSUMS(ND)> OutputType
static OutputType exchange(InternalType &v, OutputType newv) noexcept

◆ getValue()

template<typename Arithmetic, atomicity Atomicity, unsigned int ND>
constexpr OutputType Gaudi::Accumulators::SigmasValueHandler< Arithmetic, Atomicity, ND >::getValue ( const InternalType & v)
inlinestaticconstexprnoexcept

Definition at line 54 of file StaticRootHistogram.h.

54 {
55 // Note automatic conversion will happen
56 return v;
57 };

◆ merge() [1/2]

template<typename Arithmetic, atomicity Atomicity, unsigned int ND>
void Gaudi::Accumulators::SigmasValueHandler< Arithmetic, Atomicity, ND >::merge ( InternalType & a,
const OutputType & b )
inlinestaticnoexcept

Definition at line 68 of file StaticRootHistogram.h.

68 {
69 if constexpr ( Atomicity == atomicity::full ) {
70 for ( unsigned int i = 0; i < NSUMS( ND ); i++ ) { fetch_add( a[i], b[i] ); }
71 } else {
72 for ( unsigned int i = 0; i < ND * ( ND + 3 ); i++ ) a[i] += b[i];
73 }
74 }
void fetch_add(AtomicType &atVar, Arithmetic value)
generic fetch_add, also dealing with atomic types with no fetch_add member method

◆ merge() [2/2]

template<typename Arithmetic, atomicity Atomicity, unsigned int ND>
void Gaudi::Accumulators::SigmasValueHandler< Arithmetic, Atomicity, ND >::merge ( InternalType & a,
InputType b )
inlinestaticnoexcept

Definition at line 75 of file StaticRootHistogram.h.

75 {
76 // prepare values to increment internal values
78 diff[0] = 1.;
79 if constexpr ( ND == 1 ) {
80 // no operator[] for b in this case
81 diff[1] = b;
82 diff[2] = b * b;
83 } else {
84 for ( unsigned int i = 0; i < ND; i++ ) diff[i + 1] += b[i];
85 unsigned int n = 1 + ND;
86 for ( unsigned int i = 0; i < ND; i++ ) {
87 for ( unsigned int j = i; j < ND; j++ ) {
88 diff[n] = b[i] * b[j];
89 n++;
90 }
91 }
92 }
93 // Now increase original counter
94 if constexpr ( Atomicity == atomicity::full ) {
95 for ( unsigned int i = 0; i < NSUMS( ND ); i++ ) { fetch_add( a[i], diff[i] ); }
96 } else {
97 for ( unsigned int i = 0; i < NSUMS( ND ); i++ ) a[i] += diff[i];
98 }
99 }

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