The Gaudi Framework  v36r11 (bdb84f5f)
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 >
 AccumulatorSet (const InternalType &t)
 
void reset (const InternalType &t)
 
- Protected Member Functions inherited from Gaudi::Accumulators::AccumulatorSet< Arithmetic, Atomicity, InputTypeT, Bases >
 AccumulatorSet (const InternalType &t)
 
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 20 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 34 of file StatEntity.h.

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

Member Function Documentation

◆ add()

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

Definition at line 80 of file StatEntity.h.

80  {
81  *this += v;
82  return nEntries();
83  }

◆ addFlag()

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

Definition at line 84 of file StatEntity.h.

84 { return add( v ); }

◆ Eff()

double StatEntity::Eff ( ) const
inline

Definition at line 92 of file StatEntity.h.

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

◆ effCounter()

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

Definition at line 103 of file StatEntity.h.

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

◆ fillStream() [1/2]

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

Definition at line 185 of file StatEntity.h.

185 { return print( o ); }

◆ fillStream() [2/2]

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

Definition at line 184 of file StatEntity.h.

184 { return print( o ); }

◆ flag()

double StatEntity::flag ( ) const
inline

Definition at line 96 of file StatEntity.h.

96 { return sum(); }

◆ flag2()

double StatEntity::flag2 ( ) const
inline

Definition at line 97 of file StatEntity.h.

97 { return sum2(); }

◆ flagMax()

double StatEntity::flagMax ( ) const
inline

Definition at line 102 of file StatEntity.h.

102 { return max(); }

◆ flagMean()

double StatEntity::flagMean ( ) const
inline

Definition at line 98 of file StatEntity.h.

98 { return mean(); }

◆ flagMeanErr()

double StatEntity::flagMeanErr ( ) const
inline

Definition at line 100 of file StatEntity.h.

100 { return meanErr(); }

◆ flagMin()

double StatEntity::flagMin ( ) const
inline

Definition at line 101 of file StatEntity.h.

101 { return min(); }

◆ flagRMS()

double StatEntity::flagRMS ( ) const
inline

Definition at line 99 of file StatEntity.h.

99 { return standard_deviation(); }

◆ fromJSON()

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

Definition at line 202 of file StatEntity.h.

202  {
203  StatEntity res;
205  j, { { { { "nEntries", "sum" }, "sum2" }, "min", "max" }, { "nTrueEntries", "nFalseEntries" } } ) );
206  return res;
207  }

◆ Max()

double StatEntity::Max ( ) const
inline

Definition at line 94 of file StatEntity.h.

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

◆ Mean()

double StatEntity::Mean ( ) const
inline

Definition at line 87 of file StatEntity.h.

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

◆ MeanErr()

double StatEntity::MeanErr ( ) const
inline

Definition at line 88 of file StatEntity.h.

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

◆ Min()

double StatEntity::Min ( ) const
inline

Definition at line 93 of file StatEntity.h.

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

◆ operator++() [1/2]

StatEntity& StatEntity::operator++ ( )
inline

Definition at line 49 of file StatEntity.h.

49  {
50  ( *this ) += 1.0;
51  return *this;
52  }

◆ operator++() [2/2]

StatEntity StatEntity::operator++ ( int  )
inline

Definition at line 53 of file StatEntity.h.

53  {
54  auto copy = *this;
55  ++( *this );
56  return copy;
57  }

◆ operator+=() [1/2]

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

Definition at line 72 of file StatEntity.h.

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

◆ operator+=() [2/2]

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

Definition at line 76 of file StatEntity.h.

76  {
77  mergeAndReset( std::move( by ) );
78  return *this;
79  }

◆ operator--() [1/2]

StatEntity& StatEntity::operator-- ( )
inline

Definition at line 58 of file StatEntity.h.

58  {
59  ( *this ) += -1.0;
60  return *this;
61  }

◆ operator--() [2/2]

StatEntity StatEntity::operator-- ( int  )
inline

Definition at line 62 of file StatEntity.h.

62  {
63  auto copy = *this;
64  --( *this );
65  return copy;
66  }

◆ operator-=()

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

Definition at line 45 of file StatEntity.h.

45  {
46  ( *this ) += ( -by );
47  return *this;
48  }

◆ operator<()

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

Definition at line 67 of file StatEntity.h.

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

◆ operator=()

void StatEntity::operator= ( double  by)
inline

Definition at line 41 of file StatEntity.h.

41  {
42  this->reset();
43  ( *this ) += by;
44  }

◆ 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 163 of file StatEntity.h.

164  {
165  return printImpl( o, tableFormat, name, flag, fmtHead );
166  }

◆ print() [2/6]

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

Implements Gaudi::Accumulators::PrintableCounter.

Definition at line 175 of file StatEntity.h.

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

◆ print() [3/6]

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

Reimplemented from Gaudi::Accumulators::PrintableCounter.

Definition at line 170 of file StatEntity.h.

170 { 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 159 of file StatEntity.h.

160  {
161  return printImpl( o, tableFormat, name, flag, fmtHead );
162  }

◆ 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 171 of file StatEntity.h.

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

◆ 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 167 of file StatEntity.h.

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

◆ printFormatted() [1/2]

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

Definition at line 117 of file StatEntity.h.

117 { return printFormattedImpl( o, format ); }

◆ printFormatted() [2/2]

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

Definition at line 114 of file StatEntity.h.

114  {
115  return printFormattedImpl( o, format );
116  }

◆ printFormattedImpl()

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

Definition at line 109 of file StatEntity.h.

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

◆ 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 120 of file StatEntity.h.

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

◆ reset()

void StatEntity::reset ( )
inline

Definition at line 40 of file StatEntity.h.

40 { AccParent::reset(); }

◆ rms()

double StatEntity::rms ( ) const
inline

Definition at line 89 of file StatEntity.h.

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

◆ Rms()

double StatEntity::Rms ( ) const
inline

Definition at line 90 of file StatEntity.h.

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

◆ RMS()

double StatEntity::RMS ( ) const
inline

Definition at line 91 of file StatEntity.h.

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

◆ Sum()

double StatEntity::Sum ( ) const
inline

Definition at line 86 of file StatEntity.h.

86 { 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 187 of file StatEntity.h.

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

◆ toString()

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

Definition at line 179 of file StatEntity.h.

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

Member Data Documentation

◆ typeString

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

Definition at line 25 of file StatEntity.h.


The documentation for this class was generated from the following file:
StatEntity::reset
void reset()
Definition: StatEntity.h:40
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:525
std::make_tuple
T make_tuple(T... args)
std::string
STL class.
GaudiPython.HistoUtils.nEntries
nEntries
Definition: HistoUtils.py:939
std::move
T move(T... args)
StatEntity::printFormattedImpl
stream & printFormattedImpl(stream &o, const std::string &format) const
Definition: StatEntity.h:109
StatEntity::printImpl
stream & printImpl(stream &o, bool tableFormat, std::string_view name, bool flag, std::string_view fmtHead) const
Definition: StatEntity.h:120
StatEntity
backward compatible StatEntity class.
Definition: StatEntity.h:23
Gaudi::Accumulators::AccumulatorSet< double, Gaudi::Accumulators::atomicity::full, double, Gaudi::Accumulators::StatAccumulator, Gaudi::Accumulators::BinomialAccumulator >::reset
void reset()
Definition: Accumulators.h:510
StatEntity::flag2
double flag2() const
Definition: StatEntity.h:97
max
EventIDBase max(const EventIDBase &lhs, const EventIDBase &rhs)
Definition: EventIDBase.h:225
StatEntity::flag
double flag() const
Definition: StatEntity.h:96
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:512
TimingHistograms.name
name
Definition: TimingHistograms.py:25
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:159
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:25
min
EventIDBase min(const EventIDBase &lhs, const EventIDBase &rhs)
Definition: EventIDBase.h:212
GaudiPython.HistoUtils.mean
mean
Definition: HistoUtils.py:904
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:80
fmt
std::ostringstream::str
T str(T... args)
StatEntity::effCounter
static bool effCounter(std::string_view name)
Definition: StatEntity.h:103
Gaudi::Accumulators::BinomialAccumulator::nEntries
unsigned long nEntries() const
Definition: Accumulators.h:671
GaudiPython.HistoUtils.meanErr
meanErr
Definition: HistoUtils.py:906