The Gaudi Framework  v32r2 (46d42edc)
Gaudi::StatEntity Class Reference

backward compatible StatEntity class. More...

#include <GaudiKernel/Counters.h>

Inheritance diagram for Gaudi::StatEntity:
Collaboration diagram for Gaudi::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 Types inherited from Gaudi::Accumulators::AccumulatorSet< Arithmetic, Atomicity, Bases >
using InputType = Arithmetic
 
using OutputType = std::tuple< typename Bases< Arithmetic, Atomicity >::OutputType... >
 

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, const std::string &name, bool flag, std::string const &fmtHead) const
 
std::ostreamprint (std::ostream &o, bool tableFormat, const std::string &name, bool flag=true, std::string fmtHead="%|-48.48s|%|27t|") const
 
MsgStreamprint (MsgStream &o, bool tableFormat, const std::string &name, bool flag=true, std::string fmtHead="%|-48.48s|%|27t|") const
 
virtual std::ostreamprint (std::ostream &o, const std::string &tag) const override
 prints the counter to a stream in table format, with the given tag More...
 
virtual MsgStreamprint (MsgStream &o, const std::string &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
 
- Public Member Functions inherited from Gaudi::Accumulators::PrintableCounter
 PrintableCounter ()=default
 
template<class OWNER >
 PrintableCounter (OWNER *o, const std::string &tag)
 
virtual ~PrintableCounter ()=default
 destructor More...
 
template<typename stream >
stream & printImpl (stream &s, const std::string &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< Arithmetic, Atomicity, Bases >
constexpr AccumulatorSet ()=default
 
AccumulatorSetoperator+= (const InputType by)
 
OutputType value () const
 
void reset ()
 
template<atomicity Ato>
void mergeAndReset (AccumulatorSet< Arithmetic, Ato, Bases... > &&other)
 

Static Public Member Functions

static bool effCounter (const std::string &name)
 

Additional Inherited Members

- Protected Member Functions inherited from Gaudi::Accumulators::AccumulatorSet< Arithmetic, Atomicity, Bases >
void reset (const std::tuple< typename Bases< Arithmetic, Atomicity >::OutputType... > &t)
 

Detailed Description

backward compatible StatEntity class.

Should not be used. Only here for backward compatibility

Definition at line 893 of file Counters.h.

Member Typedef Documentation

◆ AccParent

◆ BinomialAccParent

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

Definition at line 901 of file Counters.h.

Constructor & Destructor Documentation

◆ StatEntity() [1/3]

Gaudi::StatEntity::StatEntity ( )
default

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

◆ StatEntity() [2/3]

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

Definition at line 907 of file Counters.h.

907  {
908  o->declareCounter( tag, *this );
909  }

◆ StatEntity() [3/3]

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

Definition at line 910 of file Counters.h.

911  {
913  std::make_tuple( std::make_tuple( std::make_tuple( entries, flag ), flag2 ), minFlag, maxFlag ),
914  std::make_tuple( 0, 0 ) ) );
915  }
T make_tuple(T... args)
double flag2() const
Definition: Counters.h:973
double flag() const
Definition: Counters.h:972

Member Function Documentation

◆ add()

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

Definition at line 956 of file Counters.h.

956  {
957  *this += v;
958  return nEntries();
959  }

◆ addFlag()

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

Definition at line 960 of file Counters.h.

960 { return add( v ); }
unsigned long add(const double v)
Definition: Counters.h:956

◆ Eff()

double Gaudi::StatEntity::Eff ( ) const
inline

Definition at line 968 of file Counters.h.

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

◆ effCounter()

static bool Gaudi::StatEntity::effCounter ( const std::string name)
inlinestatic

Definition at line 979 of file Counters.h.

979  {
980  using boost::algorithm::icontains;
981  return icontains( name, "eff" ) || icontains( name, "acc" ) || icontains( name, "filt" ) ||
982  icontains( name, "fltr" ) || icontains( name, "pass" );
983  }

◆ fillStream() [1/2]

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

Definition at line 1061 of file Counters.h.

1061 { return print( o ); }
std::ostream & print(std::ostream &o, bool tableFormat, const std::string &name, bool flag=true, std::string fmtHead="%|-48.48s|%|27t|") const
Definition: Counters.h:1034

◆ fillStream() [2/2]

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

Definition at line 1062 of file Counters.h.

1062 { return print( o ); }
std::ostream & print(std::ostream &o, bool tableFormat, const std::string &name, bool flag=true, std::string fmtHead="%|-48.48s|%|27t|") const
Definition: Counters.h:1034

◆ flag()

double Gaudi::StatEntity::flag ( ) const
inline

Definition at line 972 of file Counters.h.

972 { return sum(); }

◆ flag2()

double Gaudi::StatEntity::flag2 ( ) const
inline

Definition at line 973 of file Counters.h.

973 { return sum2(); }

◆ flagMax()

double Gaudi::StatEntity::flagMax ( ) const
inline

Definition at line 978 of file Counters.h.

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

◆ flagMean()

double Gaudi::StatEntity::flagMean ( ) const
inline

Definition at line 974 of file Counters.h.

974 { return mean(); }

◆ flagMeanErr()

double Gaudi::StatEntity::flagMeanErr ( ) const
inline

Definition at line 976 of file Counters.h.

976 { return meanErr(); }

◆ flagMin()

double Gaudi::StatEntity::flagMin ( ) const
inline

Definition at line 977 of file Counters.h.

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

◆ flagRMS()

double Gaudi::StatEntity::flagRMS ( ) const
inline

Definition at line 975 of file Counters.h.

975 { return standard_deviation(); }

◆ Max()

double Gaudi::StatEntity::Max ( ) const
inline

Definition at line 970 of file Counters.h.

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

◆ Mean()

double Gaudi::StatEntity::Mean ( ) const
inline

Definition at line 963 of file Counters.h.

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

◆ MeanErr()

double Gaudi::StatEntity::MeanErr ( ) const
inline

Definition at line 964 of file Counters.h.

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

◆ Min()

double Gaudi::StatEntity::Min ( ) const
inline

Definition at line 969 of file Counters.h.

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

◆ operator++() [1/2]

StatEntity& Gaudi::StatEntity::operator++ ( )
inline

Definition at line 925 of file Counters.h.

925  {
926  ( *this ) += 1.0;
927  return *this;
928  }

◆ operator++() [2/2]

StatEntity Gaudi::StatEntity::operator++ ( int  )
inline

Definition at line 929 of file Counters.h.

929  {
930  auto copy = *this;
931  ++( *this );
932  return copy;
933  }
T copy(T... args)

◆ operator+=() [1/2]

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

Definition at line 948 of file Counters.h.

948  {
949  this->AccumulatorSet::operator+=( by );
950  return *this;
951  }

◆ operator+=() [2/2]

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

Definition at line 952 of file Counters.h.

952  {
953  mergeAndReset( std::move( by ) );
954  return *this;
955  }
void mergeAndReset(AccumulatorSet< Arithmetic, Ato, Bases... > &&other)
Definition: Counters.h:387
T move(T... args)

◆ operator--() [1/2]

StatEntity& Gaudi::StatEntity::operator-- ( )
inline

Definition at line 934 of file Counters.h.

934  {
935  ( *this ) += -1.0;
936  return *this;
937  }

◆ operator--() [2/2]

StatEntity Gaudi::StatEntity::operator-- ( int  )
inline

Definition at line 938 of file Counters.h.

938  {
939  auto copy = *this;
940  --( *this );
941  return copy;
942  }
T copy(T... args)

◆ operator-=()

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

Definition at line 921 of file Counters.h.

921  {
922  ( *this ) += ( -by );
923  return *this;
924  }

◆ operator<()

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

Definition at line 943 of file Counters.h.

943  {
944  return std::make_tuple( nEntries(), sum(), min(), max(), sum2() ) <
945  std::make_tuple( se.nEntries(), se.sum(), se.min(), se.max(), se.sum2() );
946  };
EventIDBase min(const EventIDBase &lhs, const EventIDBase &rhs)
Definition: EventIDBase.h:202
T make_tuple(T... args)
EventIDBase max(const EventIDBase &lhs, const EventIDBase &rhs)
Definition: EventIDBase.h:215

◆ operator=()

void Gaudi::StatEntity::operator= ( double  by)
inline

Definition at line 917 of file Counters.h.

917  {
918  this->reset();
919  ( *this ) += by;
920  }

◆ print() [1/6]

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

Definition at line 1034 of file Counters.h.

1035  {
1036  return printImpl( o, tableFormat, name, flag, fmtHead );
1037  }
stream & printImpl(stream &o, bool tableFormat, const std::string &name, bool flag, std::string const &fmtHead) const
Definition: Counters.h:996
double flag() const
Definition: Counters.h:972

◆ print() [2/6]

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

Definition at line 1038 of file Counters.h.

1039  {
1040  return printImpl( o, tableFormat, name, flag, fmtHead );
1041  }
stream & printImpl(stream &o, bool tableFormat, const std::string &name, bool flag, std::string const &fmtHead) const
Definition: Counters.h:996
double flag() const
Definition: Counters.h:972

◆ print() [3/6]

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

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

Reimplemented from Gaudi::Accumulators::PrintableCounter.

Definition at line 1042 of file Counters.h.

1042  {
1043  return print( o, true, tag, true );
1044  }
std::ostream & print(std::ostream &o, bool tableFormat, const std::string &name, bool flag=true, std::string fmtHead="%|-48.48s|%|27t|") const
Definition: Counters.h:1034

◆ print() [4/6]

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

Reimplemented from Gaudi::Accumulators::PrintableCounter.

Definition at line 1045 of file Counters.h.

1045  {
1046  return print( o, true, tag, true );
1047  }
std::ostream & print(std::ostream &o, bool tableFormat, const std::string &name, bool flag=true, std::string fmtHead="%|-48.48s|%|27t|") const
Definition: Counters.h:1034

◆ print() [5/6]

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

prints the counter to a stream

Implements Gaudi::Accumulators::PrintableCounter.

Definition at line 1048 of file Counters.h.

1048  {
1049  std::string emptyName;
1050  return print( o, tableFormat, emptyName, true );
1051  }
std::ostream & print(std::ostream &o, bool tableFormat, const std::string &name, bool flag=true, std::string fmtHead="%|-48.48s|%|27t|") const
Definition: Counters.h:1034
STL class.

◆ print() [6/6]

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

Implements Gaudi::Accumulators::PrintableCounter.

Definition at line 1052 of file Counters.h.

1052  {
1053  std::string emptyName;
1054  return print( o, tableFormat, emptyName, true );
1055  }
std::ostream & print(std::ostream &o, bool tableFormat, const std::string &name, bool flag=true, std::string fmtHead="%|-48.48s|%|27t|") const
Definition: Counters.h:1034
STL class.

◆ printFormatted() [1/2]

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

Definition at line 990 of file Counters.h.

990  {
991  return printFormattedImpl( o, format );
992  }
GAUDI_API std::string format(const char *,...)
MsgStream format utility "a la sprintf(...)".
Definition: MsgStream.cpp:109
stream & printFormattedImpl(stream &o, const std::string &format) const
Definition: Counters.h:985

◆ printFormatted() [2/2]

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

Definition at line 993 of file Counters.h.

993 { return printFormattedImpl( o, format ); }
GAUDI_API std::string format(const char *,...)
MsgStream format utility "a la sprintf(...)".
Definition: MsgStream.cpp:109
stream & printFormattedImpl(stream &o, const std::string &format) const
Definition: Counters.h:985

◆ printFormattedImpl()

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

Definition at line 985 of file Counters.h.

985  {
986  boost::format fmt{format};
987  fmt % nEntries() % sum() % mean() % standard_deviation() % min() % max();
988  return o << fmt.str();
989  }
GAUDI_API std::string format(const char *,...)
MsgStream format utility "a la sprintf(...)".
Definition: MsgStream.cpp:109
EventIDBase min(const EventIDBase &lhs, const EventIDBase &rhs)
Definition: EventIDBase.h:202
EventIDBase max(const EventIDBase &lhs, const EventIDBase &rhs)
Definition: EventIDBase.h:215

◆ printImpl()

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

Definition at line 996 of file Counters.h.

997  {
998  if ( flag && effCounter( name ) && 0 <= eff() && 0 <= effErr() && sum() <= nEntries() &&
999  ( 0 == min() || 1 == min() ) && ( 0 == max() || 1 == max() ) ) {
1000  // efficiency printing
1001  if ( tableFormat ) {
1002  if ( name.empty() ) {
1003  constexpr auto fmt = "|%|10d| |%|11.5g| |(%|#9.7g| +- %|-#8.7g|)%%| ------- | ------- |";
1004  return o << boost::format{fmt} % BinomialAccParent::nEntries() % sum() % ( efficiency() * 100 ) %
1005  ( efficiencyErr() * 100 );
1006  } else {
1007  auto fmt = " |*" + fmtHead + "|%|10d| |%|11.5g| |(%|#9.7g| +- %|-#8.7g|)%%| ------- | ------- |";
1008  return o << boost::format{fmt} % ( "\"" + name + "\"" ) % BinomialAccParent::nEntries() % sum() %
1009  ( efficiency() * 100 ) % ( efficiencyErr() * 100 );
1010  }
1011  } else {
1012  constexpr auto fmt = "#=%|-7lu| Sum=%|-11.5g| Eff=|(%|#9.7g| +- %|-#8.6g|)%%|";
1013  return o << boost::format{fmt} % BinomialAccParent::nEntries() % sum() % ( efficiency() * 100 ) %
1014  ( efficiencyErr() * 100 );
1015  }
1016  } else {
1017  // Standard printing
1018  if ( tableFormat ) {
1019  if ( name.empty() ) {
1020  constexpr auto fmt = "|%|10d| |%|11.7g| |%|#11.5g| |%|#11.5g| |%|#12.5g| |%|#12.5g| |";
1021  return o << boost::format{fmt} % nEntries() % sum() % mean() % standard_deviation() % min() % max();
1022 
1023  } else {
1024  auto fmt = " | " + fmtHead + "|%|10d| |%|11.7g| |%|#11.5g| |%|#11.5g| |%|#12.5g| |%|#12.5g| |";
1025  return o << boost::format{fmt} % ( "\"" + name + "\"" ) % nEntries() % sum() % mean() % standard_deviation() %
1026  min() % max();
1027  }
1028  } else {
1029  constexpr auto fmt = "#=%|-7lu| Sum=%|-11.5g| Mean=%|#10.4g| +- %|-#10.5g| Min/Max=%|#10.4g|/%|-#10.4g|";
1030  return o << boost::format{fmt} % nEntries() % sum() % mean() % standard_deviation() % min() % max();
1031  }
1032  }
1033  }
GAUDI_API std::string format(const char *,...)
MsgStream format utility "a la sprintf(...)".
Definition: MsgStream.cpp:109
EventIDBase min(const EventIDBase &lhs, const EventIDBase &rhs)
Definition: EventIDBase.h:202
EventIDBase max(const EventIDBase &lhs, const EventIDBase &rhs)
Definition: EventIDBase.h:215
static bool effCounter(const std::string &name)
Definition: Counters.h:979
double flag() const
Definition: Counters.h:972

◆ reset()

void Gaudi::StatEntity::reset ( )
inline

Definition at line 916 of file Counters.h.

916 { AccParent::reset(); }

◆ rms()

double Gaudi::StatEntity::rms ( ) const
inline

Definition at line 965 of file Counters.h.

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

◆ Rms()

double Gaudi::StatEntity::Rms ( ) const
inline

Definition at line 966 of file Counters.h.

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

◆ RMS()

double Gaudi::StatEntity::RMS ( ) const
inline

Definition at line 967 of file Counters.h.

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

◆ Sum()

double Gaudi::StatEntity::Sum ( ) const
inline

Definition at line 962 of file Counters.h.

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

◆ toString()

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

Definition at line 1056 of file Counters.h.

1056  {
1057  std::ostringstream ost;
1058  print( ost );
1059  return ost.str();
1060  }
std::ostream & print(std::ostream &o, bool tableFormat, const std::string &name, bool flag=true, std::string fmtHead="%|-48.48s|%|27t|") const
Definition: Counters.h:1034
T str(T... args)

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