The Gaudi Framework  v36r1 (3e2fb5a8)
StatEntity Class Reference

backward compatible StatEntity class. More...

#include </builds/gaudi/Gaudi/GaudiKernel/include/GaudiKernel/StatEntity.h>

Inheritance diagram for StatEntity:
Collaboration diagram for StatEntity:

Public Types

using AccParent = Gaudi::Accumulators::AccumulatorSet< double, Gaudi::Accumulators::atomicity::full, double, Gaudi::Accumulators::StatAccumulator, Gaudi::Accumulators::BinomialAccumulator >
 
using BinomialAccParent = Gaudi::Accumulators::BinomialAccumulator< Gaudi::Accumulators::atomicity::full, double >
 
- Public Types inherited from Gaudi::Accumulators::AccumulatorSet< double, Gaudi::Accumulators::atomicity::full, double, Gaudi::Accumulators::StatAccumulator, Gaudi::Accumulators::BinomialAccumulator >
using InputType = double
 
using OutputType = std::tuple< typename Gaudi::Accumulators::StatAccumulator< Atomicity, double >::OutputType... >
 
using InternalType = std::tuple< typename Gaudi::Accumulators::StatAccumulator< Atomicity, double >::InternalType... >
 
using JSONStringEntriesType = std::tuple< typename Gaudi::Accumulators::StatAccumulator< Atomicity, double >::JSONStringEntriesType... >
 
- Public Types inherited from Gaudi::Accumulators::AccumulatorSet< Arithmetic, Atomicity, InputTypeT, Bases >
using InputType = InputTypeT
 
using OutputType = std::tuple< typename Bases< Atomicity, Arithmetic >::OutputType... >
 
using InternalType = std::tuple< typename Bases< Atomicity, Arithmetic >::InternalType... >
 
using JSONStringEntriesType = std::tuple< typename Bases< Atomicity, Arithmetic >::JSONStringEntriesType... >
 

Public Member Functions

 StatEntity ()=default
 the constructor with automatic registration in the owner's counter map More...
 
 StatEntity (const unsigned long entries, const double flag, const double flag2, const double minFlag, const double maxFlag)
 
void reset ()
 
void operator= (double by)
 
StatEntityoperator-= (double by)
 
StatEntityoperator++ ()
 
StatEntity operator++ (int)
 
StatEntityoperator-- ()
 
StatEntity operator-- (int)
 
bool operator< (const StatEntity &se) const
 
StatEntityoperator+= (double by)
 
StatEntityoperator+= (StatEntity by)
 
unsigned long add (const double v)
 
unsigned long addFlag (const double v)
 
double Sum () const
 
double Mean () const
 
double MeanErr () const
 
double rms () const
 
double Rms () const
 
double RMS () const
 
double Eff () const
 
double Min () const
 
double Max () const
 
double flag () const
 
double flag2 () const
 
double flagMean () const
 
double flagRMS () const
 
double flagMeanErr () const
 
double flagMin () const
 
double flagMax () const
 
template<typename stream >
stream & printFormattedImpl (stream &o, const std::string &format) const
 
std::ostreamprintFormatted (std::ostream &o, const std::string &format) const
 
MsgStreamprintFormatted (MsgStream &o, const std::string &format) const
 
template<typename stream >
stream & printImpl (stream &o, bool tableFormat, std::string_view name, bool flag, std::string_view fmtHead) const
 
std::ostreamprint (std::ostream &o, bool tableFormat, std::string_view name, bool flag=true, std::string_view fmtHead="%|-48.48s|%|27t|") const
 
MsgStreamprint (MsgStream &o, bool tableFormat, std::string_view name, bool flag=true, std::string_view fmtHead="%|-48.48s|%|27t|") const
 
virtual std::ostreamprint (std::ostream &o, std::string_view tag) const override
 prints the counter to a stream in table format, with the given tag More...
 
virtual MsgStreamprint (MsgStream &o, std::string_view tag) const override
 
std::ostreamprint (std::ostream &o, bool tableFormat=false) const override
 prints the counter to a stream More...
 
MsgStreamprint (MsgStream &o, bool tableFormat=false) const override
 
std::string toString () const
 
std::ostreamfillStream (std::ostream &o) const
 
MsgStreamfillStream (MsgStream &o) const
 
virtual nlohmann::json toJSON () const override
 Basic JSON export for Gaudi::Monitoring::Hub support. More...
 
- Public Member Functions inherited from Gaudi::Accumulators::PrintableCounter
 PrintableCounter ()=default
 
virtual ~PrintableCounter ()=default
 destructor More...
 
template<typename stream >
stream & printImpl (stream &s, std::string_view tag) const
 
virtual bool toBePrinted () const
 hint whether we should print that counter or not. More...
 
std::string toString () const
 get a string representation More...
 
- Public Member Functions inherited from Gaudi::Accumulators::AccumulatorSet< double, Gaudi::Accumulators::atomicity::full, double, Gaudi::Accumulators::StatAccumulator, Gaudi::Accumulators::BinomialAccumulator >
constexpr AccumulatorSet ()=default
 
 AccumulatorSet (construct_empty_t, const AccumulatorSet< double, ato, InputType, Gaudi::Accumulators::StatAccumulator ... > &)
 constructor of an empty AccumulatorSet, copying the (non existent) config from another GenericAccumulator More...
 
AccumulatorSetoperator+= (const InputType by)
 
OutputType value () const
 
void reset ()
 
void mergeAndReset (AccumulatorSet< double, Ato, InputType, Gaudi::Accumulators::StatAccumulator ... > &&other)
 
void operator+ (AccumulatorSet< double, Ato, InputType, Gaudi::Accumulators::StatAccumulator ... > &&other)
 
- Public Member Functions inherited from Gaudi::Accumulators::AccumulatorSet< Arithmetic, Atomicity, InputTypeT, Bases >
constexpr AccumulatorSet ()=default
 
template<atomicity ato>
 AccumulatorSet (construct_empty_t, const AccumulatorSet< Arithmetic, ato, InputType, Bases... > &)
 constructor of an empty AccumulatorSet, copying the (non existent) config from another GenericAccumulator More...
 
AccumulatorSetoperator+= (const InputType by)
 
OutputType value () const
 
void reset ()
 
template<atomicity Ato>
void mergeAndReset (AccumulatorSet< Arithmetic, Ato, InputType, Bases... > &&other)
 
template<atomicity Ato>
void operator+ (AccumulatorSet< Arithmetic, Ato, InputType, Bases... > &&other)
 

Static Public Member Functions

static bool effCounter (std::string_view name)
 
static StatEntity fromJSON (const nlohmann::json &j)
 

Static Public Attributes

static const std::string typeString {"statentity"}
 

Additional Inherited Members

- Protected Member Functions inherited from Gaudi::Accumulators::AccumulatorSet< double, Gaudi::Accumulators::atomicity::full, double, Gaudi::Accumulators::StatAccumulator, Gaudi::Accumulators::BinomialAccumulator >
void reset (const InternalType &t)
 
- Protected Member Functions inherited from Gaudi::Accumulators::AccumulatorSet< Arithmetic, Atomicity, InputTypeT, Bases >
void reset (const InternalType &t)
 
- Static Protected Member Functions inherited from Gaudi::Accumulators::AccumulatorSet< double, Gaudi::Accumulators::atomicity::full, double, Gaudi::Accumulators::StatAccumulator, Gaudi::Accumulators::BinomialAccumulator >
static InternalType extractJSONData (const nlohmann::json &j, const JSONStringEntriesType &entries)
 
- Static Protected Member Functions inherited from Gaudi::Accumulators::AccumulatorSet< Arithmetic, Atomicity, InputTypeT, Bases >
static InternalType extractJSONData (const nlohmann::json &j, const JSONStringEntriesType &entries)
 

Detailed Description

backward compatible StatEntity class.

Should not be used. Only here for backward compatibility

Definition at line 18 of file StatEntity.h.

Member Typedef Documentation

◆ AccParent

◆ BinomialAccParent

Constructor & Destructor Documentation

◆ StatEntity() [1/2]

StatEntity::StatEntity ( )
default

the constructor with automatic registration in the owner's counter map

◆ StatEntity() [2/2]

StatEntity::StatEntity ( const unsigned long  entries,
const double  flag,
const double  flag2,
const double  minFlag,
const double  maxFlag 
)
inline

Definition at line 32 of file StatEntity.h.

33  {
35  std::make_tuple( std::make_tuple( std::make_tuple( entries, flag ), flag2 ), minFlag, maxFlag ),
36  std::make_tuple( 0, 0 ) ) );
37  }

Member Function Documentation

◆ add()

unsigned long StatEntity::add ( const double  v)
inline

Definition at line 78 of file StatEntity.h.

78  {
79  *this += v;
80  return nEntries();
81  }

◆ addFlag()

unsigned long StatEntity::addFlag ( const double  v)
inline

Definition at line 82 of file StatEntity.h.

82 { return add( v ); }

◆ Eff()

double StatEntity::Eff ( ) const
inline

Definition at line 90 of file StatEntity.h.

90 { return eff(); } // get efficiency

◆ effCounter()

static bool StatEntity::effCounter ( std::string_view  name)
inlinestatic

Definition at line 101 of file StatEntity.h.

101  {
102  using boost::algorithm::icontains;
103  return icontains( name, "eff" ) || icontains( name, "acc" ) || icontains( name, "filt" ) ||
104  icontains( name, "fltr" ) || icontains( name, "pass" );
105  }

◆ fillStream() [1/2]

MsgStream& StatEntity::fillStream ( MsgStream o) const
inline

Definition at line 183 of file StatEntity.h.

183 { return print( o ); }

◆ fillStream() [2/2]

std::ostream& StatEntity::fillStream ( std::ostream o) const
inline

Definition at line 182 of file StatEntity.h.

182 { return print( o ); }

◆ flag()

double StatEntity::flag ( ) const
inline

Definition at line 94 of file StatEntity.h.

94 { return sum(); }

◆ flag2()

double StatEntity::flag2 ( ) const
inline

Definition at line 95 of file StatEntity.h.

95 { return sum2(); }

◆ flagMax()

double StatEntity::flagMax ( ) const
inline

Definition at line 100 of file StatEntity.h.

100 { return max(); }

◆ flagMean()

double StatEntity::flagMean ( ) const
inline

Definition at line 96 of file StatEntity.h.

96 { return mean(); }

◆ flagMeanErr()

double StatEntity::flagMeanErr ( ) const
inline

Definition at line 98 of file StatEntity.h.

98 { return meanErr(); }

◆ flagMin()

double StatEntity::flagMin ( ) const
inline

Definition at line 99 of file StatEntity.h.

99 { return min(); }

◆ flagRMS()

double StatEntity::flagRMS ( ) const
inline

Definition at line 97 of file StatEntity.h.

97 { return standard_deviation(); }

◆ fromJSON()

static StatEntity StatEntity::fromJSON ( const nlohmann::json &  j)
inlinestatic

Definition at line 200 of file StatEntity.h.

200  {
201  StatEntity res;
203  j, {{{{"nEntries", "sum"}, "sum2"}, "min", "max"}, {"nTrueEntries", "nFalseEntries"}} ) );
204  return res;
205  }

◆ Max()

double StatEntity::Max ( ) const
inline

Definition at line 92 of file StatEntity.h.

92 { return max(); } // get maximal value

◆ Mean()

double StatEntity::Mean ( ) const
inline

Definition at line 85 of file StatEntity.h.

85 { return mean(); } // get mean

◆ MeanErr()

double StatEntity::MeanErr ( ) const
inline

Definition at line 86 of file StatEntity.h.

86 { return meanErr(); } // get error in mean

◆ Min()

double StatEntity::Min ( ) const
inline

Definition at line 91 of file StatEntity.h.

91 { return min(); } // get minimal value

◆ operator++() [1/2]

StatEntity& StatEntity::operator++ ( )
inline

Definition at line 47 of file StatEntity.h.

47  {
48  ( *this ) += 1.0;
49  return *this;
50  }

◆ operator++() [2/2]

StatEntity StatEntity::operator++ ( int  )
inline

Definition at line 51 of file StatEntity.h.

51  {
52  auto copy = *this;
53  ++( *this );
54  return copy;
55  }

◆ operator+=() [1/2]

StatEntity& StatEntity::operator+= ( double  by)
inline

Definition at line 70 of file StatEntity.h.

70  {
71  this->AccumulatorSet::operator+=( by );
72  return *this;
73  }

◆ operator+=() [2/2]

StatEntity& StatEntity::operator+= ( StatEntity  by)
inline

Definition at line 74 of file StatEntity.h.

74  {
75  mergeAndReset( std::move( by ) );
76  return *this;
77  }

◆ operator--() [1/2]

StatEntity& StatEntity::operator-- ( )
inline

Definition at line 56 of file StatEntity.h.

56  {
57  ( *this ) += -1.0;
58  return *this;
59  }

◆ operator--() [2/2]

StatEntity StatEntity::operator-- ( int  )
inline

Definition at line 60 of file StatEntity.h.

60  {
61  auto copy = *this;
62  --( *this );
63  return copy;
64  }

◆ operator-=()

StatEntity& StatEntity::operator-= ( double  by)
inline

Definition at line 43 of file StatEntity.h.

43  {
44  ( *this ) += ( -by );
45  return *this;
46  }

◆ operator<()

bool StatEntity::operator< ( const StatEntity se) const
inline

Definition at line 65 of file StatEntity.h.

65  {
66  return std::make_tuple( nEntries(), sum(), min(), max(), sum2() ) <
67  std::make_tuple( se.nEntries(), se.sum(), se.min(), se.max(), se.sum2() );
68  };

◆ operator=()

void StatEntity::operator= ( double  by)
inline

Definition at line 39 of file StatEntity.h.

39  {
40  this->reset();
41  ( *this ) += by;
42  }

◆ print() [1/6]

MsgStream& StatEntity::print ( MsgStream o,
bool  tableFormat,
std::string_view  name,
bool  flag = true,
std::string_view  fmtHead = "%|-48.48s|%|27t|" 
) const
inline

Definition at line 161 of file StatEntity.h.

162  {
163  return printImpl( o, tableFormat, name, flag, fmtHead );
164  }

◆ print() [2/6]

MsgStream& StatEntity::print ( MsgStream o,
bool  tableFormat = false 
) const
inlineoverridevirtual

Implements Gaudi::Accumulators::PrintableCounter.

Definition at line 173 of file StatEntity.h.

173  {
174  std::string emptyName;
175  return print( o, tableFormat, emptyName, true );
176  }

◆ print() [3/6]

virtual MsgStream& StatEntity::print ( MsgStream o,
std::string_view  tag 
) const
inlineoverridevirtual

Reimplemented from Gaudi::Accumulators::PrintableCounter.

Definition at line 168 of file StatEntity.h.

168 { return print( o, true, tag, true ); }

◆ print() [4/6]

std::ostream& StatEntity::print ( std::ostream o,
bool  tableFormat,
std::string_view  name,
bool  flag = true,
std::string_view  fmtHead = "%|-48.48s|%|27t|" 
) const
inline

Definition at line 157 of file StatEntity.h.

158  {
159  return printImpl( o, tableFormat, name, flag, fmtHead );
160  }

◆ print() [5/6]

std::ostream& StatEntity::print ( std::ostream ,
bool  tableFormat = false 
) const
inlineoverridevirtual

prints the counter to a stream

Implements Gaudi::Accumulators::PrintableCounter.

Definition at line 169 of file StatEntity.h.

169  {
170  std::string emptyName;
171  return print( o, tableFormat, emptyName, true );
172  }

◆ print() [6/6]

virtual std::ostream& StatEntity::print ( std::ostream o,
std::string_view  tag 
) const
inlineoverridevirtual

prints the counter to a stream in table format, with the given tag

Reimplemented from Gaudi::Accumulators::PrintableCounter.

Definition at line 165 of file StatEntity.h.

165  {
166  return print( o, true, tag, true );
167  }

◆ printFormatted() [1/2]

MsgStream& StatEntity::printFormatted ( MsgStream o,
const std::string format 
) const
inline

Definition at line 115 of file StatEntity.h.

115 { return printFormattedImpl( o, format ); }

◆ printFormatted() [2/2]

std::ostream& StatEntity::printFormatted ( std::ostream o,
const std::string format 
) const
inline

Definition at line 112 of file StatEntity.h.

112  {
113  return printFormattedImpl( o, format );
114  }

◆ printFormattedImpl()

template<typename stream >
stream& StatEntity::printFormattedImpl ( stream &  o,
const std::string format 
) const
inline

Definition at line 107 of file StatEntity.h.

107  {
109  fmt % nEntries() % sum() % mean() % standard_deviation() % min() % max();
110  return o << fmt.str();
111  }

◆ printImpl()

template<typename stream >
stream& StatEntity::printImpl ( stream &  o,
bool  tableFormat,
std::string_view  name,
bool  flag,
std::string_view  fmtHead 
) const
inline

Definition at line 118 of file StatEntity.h.

118  {
119  if ( flag && effCounter( name ) && 0 <= eff() && 0 <= effErr() && sum() <= nEntries() &&
120  ( 0 == min() || 1 == min() ) && ( 0 == max() || 1 == max() ) ) {
121  // efficiency printing
122  if ( tableFormat ) {
123  if ( name.empty() ) {
124  constexpr auto fmt = "|%|10d| |%|11.5g| |(%|#9.7g| +- %|-#8.7g|)%%| ------- | ------- |";
125  return o << boost::format{fmt} % BinomialAccParent::nEntries() % sum() % ( efficiency() * 100 ) %
126  ( efficiencyErr() * 100 );
127  } else {
128  auto fmt = std::string{" |*"}.append( fmtHead ).append(
129  "|%|10d| |%|11.5g| |(%|#9.7g| +- %|-#8.7g|)%%| ------- | ------- |" );
130  return o << boost::format{fmt} % ( std::string{"\""}.append( name ).append( "\"" ) ) %
131  BinomialAccParent::nEntries() % sum() % ( efficiency() * 100 ) % ( efficiencyErr() * 100 );
132  }
133  } else {
134  constexpr auto fmt = "#=%|-7lu| Sum=%|-11.5g| Eff=|(%|#9.7g| +- %|-#8.6g|)%%|";
135  return o << boost::format{fmt} % BinomialAccParent::nEntries() % sum() % ( efficiency() * 100 ) %
136  ( efficiencyErr() * 100 );
137  }
138  } else {
139  // Standard printing
140  if ( tableFormat ) {
141  if ( name.empty() ) {
142  constexpr auto fmt = "|%|10d| |%|11.7g| |%|#11.5g| |%|#11.5g| |%|#12.5g| |%|#12.5g| |";
143  return o << boost::format{fmt} % nEntries() % sum() % mean() % standard_deviation() % min() % max();
144 
145  } else {
146  auto fmt = std::string{" | "}.append( fmtHead ).append(
147  "|%|10d| |%|11.7g| |%|#11.5g| |%|#11.5g| |%|#12.5g| |%|#12.5g| |" );
148  return o << boost::format{fmt} % std::string{"\""}.append( name ).append( "\"" ) % nEntries() % sum() %
149  mean() % standard_deviation() % min() % max();
150  }
151  } else {
152  constexpr auto fmt = "#=%|-7lu| Sum=%|-11.5g| Mean=%|#10.4g| +- %|-#10.5g| Min/Max=%|#10.4g|/%|-#10.4g|";
153  return o << boost::format{fmt} % nEntries() % sum() % mean() % standard_deviation() % min() % max();
154  }
155  }
156  }

◆ reset()

void StatEntity::reset ( )
inline

Definition at line 38 of file StatEntity.h.

38 { AccParent::reset(); }

◆ rms()

double StatEntity::rms ( ) const
inline

Definition at line 87 of file StatEntity.h.

87 { return standard_deviation(); } // get rms

◆ Rms()

double StatEntity::Rms ( ) const
inline

Definition at line 88 of file StatEntity.h.

88 { return standard_deviation(); } // get rms

◆ RMS()

double StatEntity::RMS ( ) const
inline

Definition at line 89 of file StatEntity.h.

89 { return standard_deviation(); } // get rms

◆ Sum()

double StatEntity::Sum ( ) const
inline

Definition at line 84 of file StatEntity.h.

84 { return sum(); } // get sum

◆ toJSON()

virtual nlohmann::json StatEntity::toJSON ( ) const
inlineoverridevirtual

Basic JSON export for Gaudi::Monitoring::Hub support.

Implements Gaudi::Accumulators::PrintableCounter.

Definition at line 185 of file StatEntity.h.

185  {
186  return {{"type", typeString},
187  {"empty", this->nEntries() == 0},
188  {"nEntries", this->nEntries()},
189  {"sum", this->sum()},
190  {"mean", this->mean()},
191  {"sum2", this->sum2()},
192  {"standard_deviation", this->standard_deviation()},
193  {"min", this->min()},
194  {"max", this->max()},
195  {"nTrueEntries", this->nTrueEntries()},
196  {"nFalseEntries", this->nFalseEntries()},
197  {"efficiency", this->efficiency()},
198  {"efficiencyErr", this->efficiencyErr()}};
199  }

◆ toString()

std::string StatEntity::toString ( ) const
inline

Definition at line 177 of file StatEntity.h.

177  {
178  std::ostringstream ost;
179  print( ost );
180  return ost.str();
181  }

Member Data Documentation

◆ typeString

const std::string StatEntity::typeString {"statentity"}
inlinestatic

Definition at line 23 of file StatEntity.h.


The documentation for this class was generated from the following file:
StatEntity::reset
void reset()
Definition: StatEntity.h:38
Gaudi::Accumulators::AccumulatorSet< double, Gaudi::Accumulators::atomicity::full, double, Gaudi::Accumulators::StatAccumulator, Gaudi::Accumulators::BinomialAccumulator >::extractJSONData
static InternalType extractJSONData(const nlohmann::json &j, const JSONStringEntriesType &entries)
Definition: Accumulators.h:520
std::make_tuple
T make_tuple(T... args)
std::string
STL class.
GaudiPython.HistoUtils.nEntries
nEntries
Definition: HistoUtils.py:921
std::move
T move(T... args)
StatEntity::printFormattedImpl
stream & printFormattedImpl(stream &o, const std::string &format) const
Definition: StatEntity.h:107
StatEntity::printImpl
stream & printImpl(stream &o, bool tableFormat, std::string_view name, bool flag, std::string_view fmtHead) const
Definition: StatEntity.h:118
StatEntity
backward compatible StatEntity class.
Definition: StatEntity.h:21
Gaudi::Accumulators::AccumulatorSet< double, Gaudi::Accumulators::atomicity::full, double, Gaudi::Accumulators::StatAccumulator, Gaudi::Accumulators::BinomialAccumulator >::reset
void reset()
Definition: Accumulators.h:506
StatEntity::flag2
double flag2() const
Definition: StatEntity.h:95
max
EventIDBase max(const EventIDBase &lhs, const EventIDBase &rhs)
Definition: EventIDBase.h:225
StatEntity::flag
double flag() const
Definition: StatEntity.h:94
Gaudi::Accumulators::AccumulatorSet< double, Gaudi::Accumulators::atomicity::full, double, Gaudi::Accumulators::StatAccumulator, Gaudi::Accumulators::BinomialAccumulator >::mergeAndReset
void mergeAndReset(AccumulatorSet< double, Ato, InputType, Gaudi::Accumulators::StatAccumulator ... > &&other)
Definition: Accumulators.h:508
TimingHistograms.name
name
Definition: TimingHistograms.py:23
StatEntity::print
std::ostream & print(std::ostream &o, bool tableFormat, std::string_view name, bool flag=true, std::string_view fmtHead="%|-48.48s|%|27t|") const
Definition: StatEntity.h:157
std::copy
T copy(T... args)
format
GAUDI_API std::string format(const char *,...)
MsgStream format utility "a la sprintf(...)".
Definition: MsgStream.cpp:119
StatEntity::typeString
static const std::string typeString
Definition: StatEntity.h:23
min
EventIDBase min(const EventIDBase &lhs, const EventIDBase &rhs)
Definition: EventIDBase.h:212
GaudiPython.HistoUtils.mean
mean
Definition: HistoUtils.py:886
std::string::append
T append(T... args)
HistoDumpEx.v
v
Definition: HistoDumpEx.py:27
std::ostringstream
STL class.
StatEntity::add
unsigned long add(const double v)
Definition: StatEntity.h:78
fmt
std::ostringstream::str
T str(T... args)
StatEntity::effCounter
static bool effCounter(std::string_view name)
Definition: StatEntity.h:101
Gaudi::Accumulators::BinomialAccumulator::nEntries
unsigned long nEntries() const
Definition: Accumulators.h:666
GaudiPython.HistoUtils.meanErr
meanErr
Definition: HistoUtils.py:888