The Gaudi Framework  v33r1 (b1225454)
StatEntity Class Reference

backward compatible StatEntity class. More...

#include <GaudiKernel/StatEntity.h>

Inheritance diagram for StatEntity:
Collaboration diagram for StatEntity:

Public Types

using AccParent = Gaudi::Accumulators::AccumulatorSet< double, Gaudi::Accumulators::atomicity::full, Gaudi::Accumulators::StatAccumulator, Gaudi::Accumulators::BinomialAccumulator >
 
using BinomialAccParent = Gaudi::Accumulators::BinomialAccumulator< double, Gaudi::Accumulators::atomicity::full >
 

Public Member Functions

 StatEntity ()=default
 the constructor with automatic registration in the owner's counter map More...
 
template<class OWNER >
 StatEntity (OWNER *o, const std::string &tag)
 
 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
 
virtual MsgStreamprint (MsgStream &o, std::string_view tag) const override
 
std::ostreamprint (std::ostream &o, bool tableFormat=false) const override
 
MsgStreamprint (MsgStream &o, bool tableFormat=false) const override
 
std::string toString () const
 
std::ostreamfillStream (std::ostream &o) const
 
MsgStreamfillStream (MsgStream &o) const
 

Static Public Member Functions

static bool effCounter (std::string_view name)
 

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

using StatEntity::AccParent = Gaudi::Accumulators::AccumulatorSet<double, Gaudi::Accumulators::atomicity::full, Gaudi::Accumulators::StatAccumulator, Gaudi::Accumulators::BinomialAccumulator>

Definition at line 25 of file StatEntity.h.

◆ BinomialAccParent

using StatEntity::BinomialAccParent = Gaudi::Accumulators::BinomialAccumulator<double, Gaudi::Accumulators::atomicity::full>

Definition at line 26 of file StatEntity.h.

Constructor & Destructor Documentation

◆ StatEntity() [1/3]

StatEntity::StatEntity ( )
default

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

◆ StatEntity() [2/3]

template<class OWNER >
StatEntity::StatEntity ( OWNER *  o,
const std::string tag 
)
inline

Definition at line 32 of file StatEntity.h.

32  {
33  o->declareCounter( tag, *this );
34  }

◆ StatEntity() [3/3]

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

Definition at line 35 of file StatEntity.h.

36  {
38  std::make_tuple( std::make_tuple( std::make_tuple( entries, flag ), flag2 ), minFlag, maxFlag ),
39  std::make_tuple( 0, 0 ) ) );
40  }
T make_tuple(T... args)
void reset()
Definition: StatEntity.h:41
double flag2() const
Definition: StatEntity.h:98
double flag() const
Definition: StatEntity.h:97

Member Function Documentation

◆ add()

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

Definition at line 81 of file StatEntity.h.

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

◆ addFlag()

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

Definition at line 85 of file StatEntity.h.

85 { return add( v ); }
unsigned long add(const double v)
Definition: StatEntity.h:81

◆ Eff()

double StatEntity::Eff ( ) const
inline

Definition at line 93 of file StatEntity.h.

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

◆ effCounter()

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

Definition at line 104 of file StatEntity.h.

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

◆ fillStream() [1/2]

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

Definition at line 185 of file StatEntity.h.

185 { return print( o ); }
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:160

◆ fillStream() [2/2]

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

Definition at line 186 of file StatEntity.h.

186 { return print( o ); }
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:160

◆ flag()

double StatEntity::flag ( ) const
inline

Definition at line 97 of file StatEntity.h.

97 { return sum(); }

◆ flag2()

double StatEntity::flag2 ( ) const
inline

Definition at line 98 of file StatEntity.h.

98 { return sum2(); }

◆ flagMax()

double StatEntity::flagMax ( ) const
inline

Definition at line 103 of file StatEntity.h.

103 { return max(); }
EventIDBase max(const EventIDBase &lhs, const EventIDBase &rhs)
Definition: EventIDBase.h:225

◆ flagMean()

double StatEntity::flagMean ( ) const
inline

Definition at line 99 of file StatEntity.h.

99 { return mean(); }

◆ flagMeanErr()

double StatEntity::flagMeanErr ( ) const
inline

Definition at line 101 of file StatEntity.h.

101 { return meanErr(); }

◆ flagMin()

double StatEntity::flagMin ( ) const
inline

Definition at line 102 of file StatEntity.h.

102 { return min(); }
EventIDBase min(const EventIDBase &lhs, const EventIDBase &rhs)
Definition: EventIDBase.h:212

◆ flagRMS()

double StatEntity::flagRMS ( ) const
inline

Definition at line 100 of file StatEntity.h.

100 { return standard_deviation(); }

◆ Max()

double StatEntity::Max ( ) const
inline

Definition at line 95 of file StatEntity.h.

95 { return max(); } // get maximal value
EventIDBase max(const EventIDBase &lhs, const EventIDBase &rhs)
Definition: EventIDBase.h:225

◆ Mean()

double StatEntity::Mean ( ) const
inline

Definition at line 88 of file StatEntity.h.

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

◆ MeanErr()

double StatEntity::MeanErr ( ) const
inline

Definition at line 89 of file StatEntity.h.

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

◆ Min()

double StatEntity::Min ( ) const
inline

Definition at line 94 of file StatEntity.h.

94 { return min(); } // get minimal value
EventIDBase min(const EventIDBase &lhs, const EventIDBase &rhs)
Definition: EventIDBase.h:212

◆ operator++() [1/2]

StatEntity& StatEntity::operator++ ( )
inline

Definition at line 50 of file StatEntity.h.

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

◆ operator++() [2/2]

StatEntity StatEntity::operator++ ( int  )
inline

Definition at line 54 of file StatEntity.h.

54  {
55  auto copy = *this;
56  ++( *this );
57  return copy;
58  }
T copy(T... args)

◆ operator+=() [1/2]

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

Definition at line 73 of file StatEntity.h.

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

◆ operator+=() [2/2]

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

Definition at line 77 of file StatEntity.h.

77  {
78  mergeAndReset( std::move( by ) );
79  return *this;
80  }
T move(T... args)

◆ operator--() [1/2]

StatEntity& StatEntity::operator-- ( )
inline

Definition at line 59 of file StatEntity.h.

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

◆ operator--() [2/2]

StatEntity StatEntity::operator-- ( int  )
inline

Definition at line 63 of file StatEntity.h.

63  {
64  auto copy = *this;
65  --( *this );
66  return copy;
67  }
T copy(T... args)

◆ operator-=()

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

Definition at line 46 of file StatEntity.h.

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

◆ operator<()

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

Definition at line 68 of file StatEntity.h.

68  {
69  return std::make_tuple( nEntries(), sum(), min(), max(), sum2() ) <
70  std::make_tuple( se.nEntries(), se.sum(), se.min(), se.max(), se.sum2() );
71  };
EventIDBase min(const EventIDBase &lhs, const EventIDBase &rhs)
Definition: EventIDBase.h:212
T make_tuple(T... args)
EventIDBase max(const EventIDBase &lhs, const EventIDBase &rhs)
Definition: EventIDBase.h:225

◆ operator=()

void StatEntity::operator= ( double  by)
inline

Definition at line 42 of file StatEntity.h.

42  {
43  this->reset();
44  ( *this ) += by;
45  }
void reset()
Definition: StatEntity.h:41

◆ print() [1/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 160 of file StatEntity.h.

161  {
162  return printImpl( o, tableFormat, name, flag, fmtHead );
163  }
stream & printImpl(stream &o, bool tableFormat, std::string_view name, bool flag, std::string_view fmtHead) const
Definition: StatEntity.h:121
double flag() const
Definition: StatEntity.h:97

◆ print() [2/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 164 of file StatEntity.h.

165  {
166  return printImpl( o, tableFormat, name, flag, fmtHead );
167  }
stream & printImpl(stream &o, bool tableFormat, std::string_view name, bool flag, std::string_view fmtHead) const
Definition: StatEntity.h:121
double flag() const
Definition: StatEntity.h:97

◆ print() [3/6]

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

Definition at line 168 of file StatEntity.h.

168  {
169  return print( o, true, tag, true );
170  }
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:160

◆ print() [4/6]

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

Definition at line 171 of file StatEntity.h.

171 { return print( o, true, tag, true ); }
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:160

◆ print() [5/6]

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

Definition at line 172 of file StatEntity.h.

172  {
173  std::string emptyName;
174  return print( o, tableFormat, emptyName, true );
175  }
STL class.
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:160

◆ print() [6/6]

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

Definition at line 176 of file StatEntity.h.

176  {
177  std::string emptyName;
178  return print( o, tableFormat, emptyName, true );
179  }
STL class.
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:160

◆ printFormatted() [1/2]

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

Definition at line 115 of file StatEntity.h.

115  {
116  return printFormattedImpl( o, format );
117  }
GAUDI_API std::string format(const char *,...)
MsgStream format utility "a la sprintf(...)".
Definition: MsgStream.cpp:119
stream & printFormattedImpl(stream &o, const std::string &format) const
Definition: StatEntity.h:110

◆ printFormatted() [2/2]

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

Definition at line 118 of file StatEntity.h.

118 { return printFormattedImpl( o, format ); }
GAUDI_API std::string format(const char *,...)
MsgStream format utility "a la sprintf(...)".
Definition: MsgStream.cpp:119
stream & printFormattedImpl(stream &o, const std::string &format) const
Definition: StatEntity.h:110

◆ printFormattedImpl()

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

Definition at line 110 of file StatEntity.h.

110  {
111  boost::format fmt{format};
112  fmt % nEntries() % sum() % mean() % standard_deviation() % min() % max();
113  return o << fmt.str();
114  }
GAUDI_API std::string format(const char *,...)
MsgStream format utility "a la sprintf(...)".
Definition: MsgStream.cpp:119
EventIDBase min(const EventIDBase &lhs, const EventIDBase &rhs)
Definition: EventIDBase.h:212
EventIDBase max(const EventIDBase &lhs, const EventIDBase &rhs)
Definition: EventIDBase.h:225

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

121  {
122  if ( flag && effCounter( name ) && 0 <= eff() && 0 <= effErr() && sum() <= nEntries() &&
123  ( 0 == min() || 1 == min() ) && ( 0 == max() || 1 == max() ) ) {
124  // efficiency printing
125  if ( tableFormat ) {
126  if ( name.empty() ) {
127  constexpr auto fmt = "|%|10d| |%|11.5g| |(%|#9.7g| +- %|-#8.7g|)%%| ------- | ------- |";
128  return o << boost::format{fmt} % BinomialAccParent::nEntries() % sum() % ( efficiency() * 100 ) %
129  ( efficiencyErr() * 100 );
130  } else {
131  auto fmt = std::string{" |*"}.append( fmtHead ).append(
132  "|%|10d| |%|11.5g| |(%|#9.7g| +- %|-#8.7g|)%%| ------- | ------- |" );
133  return o << boost::format{fmt} % ( std::string{"\""}.append( name ).append( "\"" ) ) %
134  BinomialAccParent::nEntries() % sum() % ( efficiency() * 100 ) % ( efficiencyErr() * 100 );
135  }
136  } else {
137  constexpr auto fmt = "#=%|-7lu| Sum=%|-11.5g| Eff=|(%|#9.7g| +- %|-#8.6g|)%%|";
138  return o << boost::format{fmt} % BinomialAccParent::nEntries() % sum() % ( efficiency() * 100 ) %
139  ( efficiencyErr() * 100 );
140  }
141  } else {
142  // Standard printing
143  if ( tableFormat ) {
144  if ( name.empty() ) {
145  constexpr auto fmt = "|%|10d| |%|11.7g| |%|#11.5g| |%|#11.5g| |%|#12.5g| |%|#12.5g| |";
146  return o << boost::format{fmt} % nEntries() % sum() % mean() % standard_deviation() % min() % max();
147 
148  } else {
149  auto fmt = std::string{" | "}.append( fmtHead ).append(
150  "|%|10d| |%|11.7g| |%|#11.5g| |%|#11.5g| |%|#12.5g| |%|#12.5g| |" );
151  return o << boost::format{fmt} % std::string{"\""}.append( name ).append( "\"" ) % nEntries() % sum() %
152  mean() % standard_deviation() % min() % max();
153  }
154  } else {
155  constexpr auto fmt = "#=%|-7lu| Sum=%|-11.5g| Mean=%|#10.4g| +- %|-#10.5g| Min/Max=%|#10.4g|/%|-#10.4g|";
156  return o << boost::format{fmt} % nEntries() % sum() % mean() % standard_deviation() % min() % max();
157  }
158  }
159  }
GAUDI_API std::string format(const char *,...)
MsgStream format utility "a la sprintf(...)".
Definition: MsgStream.cpp:119
EventIDBase min(const EventIDBase &lhs, const EventIDBase &rhs)
Definition: EventIDBase.h:212
EventIDBase max(const EventIDBase &lhs, const EventIDBase &rhs)
Definition: EventIDBase.h:225
STL class.
static bool effCounter(std::string_view name)
Definition: StatEntity.h:104
T append(T... args)
double flag() const
Definition: StatEntity.h:97

◆ reset()

void StatEntity::reset ( )
inline

Definition at line 41 of file StatEntity.h.

41 { AccParent::reset(); }

◆ 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

◆ RMS()

double StatEntity::RMS ( ) const
inline

Definition at line 92 of file StatEntity.h.

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

◆ Sum()

double StatEntity::Sum ( ) const
inline

Definition at line 87 of file StatEntity.h.

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

◆ toString()

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

Definition at line 180 of file StatEntity.h.

180  {
181  std::ostringstream ost;
182  print( ost );
183  return ost.str();
184  }
T str(T... args)
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:160

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