The Gaudi Framework  v30r4 (9b837755)
StatEntity Class Reference

backward compatible StatEntity class. More...

#include <GaudiKernel/Counters.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 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
 
std::ostreamprintFormatted (std::ostream &o, const std::string &format) const
 
std::ostreamprint (std::ostream &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...
 
std::ostreamprint (std::ostream &o, bool tableFormat=false) const override
 prints the counter to a stream More...
 
std::string toString () const
 
std::ostreamfillStream (std::ostream &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...
 
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 855 of file Counters.h.

Member Typedef Documentation

Constructor & Destructor Documentation

StatEntity::StatEntity ( )
default

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

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

Definition at line 870 of file Counters.h.

871  {
872  o->registerCounter( tag, *this );
873  }
StatEntity::StatEntity ( const unsigned long  entries,
const double  flag,
const double  flag2,
const double  minFlag,
const double  maxFlag 
)
inline

Definition at line 874 of file Counters.h.

876  {
878  std::make_tuple( std::make_tuple( std::make_tuple( entries, flag ), flag2 ), minFlag, maxFlag ),
879  std::make_tuple( 0, 0 ) ) );
880  }
T make_tuple(T...args)
void reset()
Definition: Counters.h:881
double flag2() const
Definition: Counters.h:948
double flag() const
Definition: Counters.h:947

Member Function Documentation

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

Definition at line 930 of file Counters.h.

931  {
932  *this += v;
933  return nEntries();
934  }
unsigned long StatEntity::addFlag ( const double  v)
inline

Definition at line 935 of file Counters.h.

935 { return add( v ); }
unsigned long add(const double v)
Definition: Counters.h:930
double StatEntity::Eff ( ) const
inline

Definition at line 943 of file Counters.h.

943 { return eff(); } // get efficiency
static bool StatEntity::effCounter ( const std::string name)
inlinestatic

Definition at line 954 of file Counters.h.

955  {
956  using boost::algorithm::icontains;
957  return icontains( name, "eff" ) || icontains( name, "acc" ) || icontains( name, "filt" ) ||
958  icontains( name, "fltr" ) || icontains( name, "pass" );
959  }
std::ostream& StatEntity::fillStream ( std::ostream o) const
inline

Definition at line 1023 of file Counters.h.

1023 { 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:967
double StatEntity::flag ( ) const
inline

Definition at line 947 of file Counters.h.

947 { return sum(); }
double sum(double x, double y, double z)
double StatEntity::flag2 ( ) const
inline

Definition at line 948 of file Counters.h.

948 { return sum2(); }
double StatEntity::flagMax ( ) const
inline

Definition at line 953 of file Counters.h.

953 { return max(); }
T max(T...args)
double StatEntity::flagMean ( ) const
inline

Definition at line 949 of file Counters.h.

949 { return mean(); }
double StatEntity::flagMeanErr ( ) const
inline

Definition at line 951 of file Counters.h.

951 { return meanErr(); }
double StatEntity::flagMin ( ) const
inline

Definition at line 952 of file Counters.h.

952 { return min(); }
T min(T...args)
double StatEntity::flagRMS ( ) const
inline

Definition at line 950 of file Counters.h.

950 { return standard_deviation(); }
double StatEntity::Max ( ) const
inline

Definition at line 945 of file Counters.h.

945 { return max(); } // get maximal value
T max(T...args)
double StatEntity::Mean ( ) const
inline

Definition at line 938 of file Counters.h.

938 { return mean(); } // get mean
double StatEntity::MeanErr ( ) const
inline

Definition at line 939 of file Counters.h.

939 { return meanErr(); } // get error in mean
double StatEntity::Min ( ) const
inline

Definition at line 944 of file Counters.h.

944 { return min(); } // get minimal value
T min(T...args)
StatEntity& StatEntity::operator++ ( )
inline

Definition at line 892 of file Counters.h.

893  {
894  ( *this ) += 1.0;
895  return *this;
896  }
StatEntity StatEntity::operator++ ( int  )
inline

Definition at line 897 of file Counters.h.

898  {
899  auto copy = *this;
900  ++( *this );
901  return copy;
902  }
T copy(T...args)
StatEntity& StatEntity::operator+= ( double  by)
inline

Definition at line 920 of file Counters.h.

921  {
922  this->AccumulatorSet::operator+=( by );
923  return *this;
924  }
StatEntity& StatEntity::operator+= ( StatEntity  by)
inline

Definition at line 925 of file Counters.h.

926  {
927  mergeAndReset( std::move( by ) );
928  return *this;
929  }
void mergeAndReset(AccumulatorSet< Arithmetic, Ato, Bases... > &&other)
Definition: Counters.h:421
T move(T...args)
StatEntity& StatEntity::operator-- ( )
inline

Definition at line 903 of file Counters.h.

904  {
905  ( *this ) += -1.0;
906  return *this;
907  }
StatEntity StatEntity::operator-- ( int  )
inline

Definition at line 908 of file Counters.h.

909  {
910  auto copy = *this;
911  --( *this );
912  return copy;
913  }
T copy(T...args)
StatEntity& StatEntity::operator-= ( double  by)
inline

Definition at line 887 of file Counters.h.

888  {
889  ( *this ) += ( -by );
890  return *this;
891  }
bool StatEntity::operator< ( const StatEntity se) const
inline

Definition at line 914 of file Counters.h.

915  {
916  return std::make_tuple( nEntries(), sum(), min(), max(), sum2() ) <
917  std::make_tuple( se.nEntries(), se.sum(), se.min(), se.max(), se.sum2() );
918  };
double sum(double x, double y, double z)
T make_tuple(T...args)
T min(T...args)
T max(T...args)
void StatEntity::operator= ( double  by)
inline

Definition at line 882 of file Counters.h.

883  {
884  this->reset();
885  ( *this ) += by;
886  }
void reset()
Definition: Counters.h:881
std::ostream& 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 967 of file Counters.h.

969  {
970  if ( flag && effCounter( name ) && 0 <= eff() && 0 <= effErr() && sum() <= nEntries() &&
971  ( 0 == min() || 1 == min() ) && ( 0 == max() || 1 == max() ) ) {
972  // efficiency printing
973  std::string fmt;
974  if ( tableFormat ) {
975  if ( name.empty() ) {
976  fmt = "|%|10d| |%|11.5g| |(%|#9.7g| +- %|-#8.7g|)%%| ------- | ------- |";
977  return o << boost::format{fmt} % BinomialAccParent::nEntries() % sum() % ( efficiency() * 100 ) %
978  ( efficiencyErr() * 100 );
979  } else {
980  fmt = " |*" + fmtHead + "|%|10d| |%|11.5g| |(%|#9.7g| +- %|-#8.7g|)%%| ------- | ------- |";
981  return o << boost::format{fmt} % ( "\"" + name + "\"" ) % BinomialAccParent::nEntries() % sum() %
982  ( efficiency() * 100 ) % ( efficiencyErr() * 100 );
983  }
984  } else {
985  fmt = "#=%|-7lu| Sum=%|-11.5g| Eff=|(%|#9.7g| +- %|-#8.6g|)%%|";
986  return o << boost::format{fmt} % BinomialAccParent::nEntries() % sum() % ( efficiency() * 100 ) %
987  ( efficiencyErr() * 100 );
988  }
989  } else {
990  // Standard printing
991  std::string fmt;
992  if ( tableFormat ) {
993  if ( name.empty() ) {
994  fmt = "|%|10d| |%|11.7g| |%|#11.5g| |%|#11.5g| |%|#12.5g| |%|#12.5g| |";
995  return o << boost::format{fmt} % nEntries() % sum() % mean() % standard_deviation() % min() % max();
996 
997  } else {
998  fmt = " | " + fmtHead + "|%|10d| |%|11.7g| |%|#11.5g| |%|#11.5g| |%|#12.5g| |%|#12.5g| |";
999  return o << boost::format{fmt} % ( "\"" + name + "\"" ) % nEntries() % sum() % mean() % standard_deviation() %
1000  min() % max();
1001  }
1002  } else {
1003  fmt = "#=%|-7lu| Sum=%|-11.5g| Mean=%|#10.4g| +- %|-#10.5g| Min/Max=%|#10.4g|/%|-#10.4g|";
1004  return o << boost::format{fmt} % nEntries() % sum() % mean() % standard_deviation() % min() % max();
1005  }
1006  }
1007  }
T empty(T...args)
GAUDI_API std::string format(const char *,...)
MsgStream format utility "a la sprintf(...)".
Definition: MsgStream.cpp:120
double sum(double x, double y, double z)
STL class.
T min(T...args)
T max(T...args)
static bool effCounter(const std::string &name)
Definition: Counters.h:954
double flag() const
Definition: Counters.h:947
virtual std::ostream& 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 1008 of file Counters.h.

1009  {
1010  return print( o, true, tag, true );
1011  }
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:967
std::ostream& StatEntity::print ( std::ostream ,
bool  tableFormat = false 
) const
inlineoverridevirtual

prints the counter to a stream

Implements Gaudi::Accumulators::PrintableCounter.

Definition at line 1012 of file Counters.h.

1013  {
1014  std::string emptyName;
1015  return print( o, tableFormat, emptyName, true );
1016  }
STL class.
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:967
std::ostream& StatEntity::printFormatted ( std::ostream o,
const std::string format 
) const
inline

Definition at line 960 of file Counters.h.

961  {
962  boost::format fmt{format};
963  fmt % nEntries() % sum() % mean() % standard_deviation() % min() % max();
964  return o << fmt.str();
965  }
GAUDI_API std::string format(const char *,...)
MsgStream format utility "a la sprintf(...)".
Definition: MsgStream.cpp:120
double sum(double x, double y, double z)
T min(T...args)
T max(T...args)
void StatEntity::reset ( )
inline

Definition at line 881 of file Counters.h.

881 { AccParent::reset(); }
double StatEntity::rms ( ) const
inline

Definition at line 940 of file Counters.h.

940 { return standard_deviation(); } // get rms
double StatEntity::Rms ( ) const
inline

Definition at line 941 of file Counters.h.

941 { return standard_deviation(); } // get rms
double StatEntity::RMS ( ) const
inline

Definition at line 942 of file Counters.h.

942 { return standard_deviation(); } // get rms
double StatEntity::Sum ( ) const
inline

Definition at line 937 of file Counters.h.

937 { return sum(); } // get sum
double sum(double x, double y, double z)
std::string StatEntity::toString ( ) const
inline

Definition at line 1017 of file Counters.h.

1018  {
1019  std::ostringstream ost;
1020  print( ost );
1021  return ost.str();
1022  }
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:967

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