The Gaudi Framework  v30r3 (a5ef0a68)
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...
 
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 777 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 792 of file Counters.h.

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

Definition at line 796 of file Counters.h.

798  {
800  std::make_tuple( std::make_tuple( std::make_tuple( entries, flag ), flag2 ), minFlag, maxFlag ),
801  std::make_tuple( 0, 0 ) ) );
802  }
T make_tuple(T...args)
void reset()
Definition: Counters.h:803
double flag2() const
Definition: Counters.h:870
double flag() const
Definition: Counters.h:869

Member Function Documentation

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

Definition at line 852 of file Counters.h.

853  {
854  *this += v;
855  return nEntries();
856  }
unsigned long StatEntity::addFlag ( const double  v)
inline

Definition at line 857 of file Counters.h.

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

Definition at line 865 of file Counters.h.

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

Definition at line 876 of file Counters.h.

877  {
878  using boost::algorithm::icontains;
879  return icontains( name, "eff" ) || icontains( name, "acc" ) || icontains( name, "filt" ) ||
880  icontains( name, "fltr" ) || icontains( name, "pass" );
881  }
std::ostream& StatEntity::fillStream ( std::ostream o) const
inline

Definition at line 945 of file Counters.h.

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

Definition at line 869 of file Counters.h.

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

Definition at line 870 of file Counters.h.

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

Definition at line 875 of file Counters.h.

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

Definition at line 871 of file Counters.h.

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

Definition at line 873 of file Counters.h.

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

Definition at line 874 of file Counters.h.

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

Definition at line 872 of file Counters.h.

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

Definition at line 867 of file Counters.h.

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

Definition at line 860 of file Counters.h.

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

Definition at line 861 of file Counters.h.

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

Definition at line 866 of file Counters.h.

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

Definition at line 814 of file Counters.h.

815  {
816  ( *this ) += 1.0;
817  return *this;
818  }
StatEntity StatEntity::operator++ ( int  )
inline

Definition at line 819 of file Counters.h.

820  {
821  auto copy = *this;
822  ++( *this );
823  return copy;
824  }
T copy(T...args)
StatEntity& StatEntity::operator+= ( double  by)
inline

Definition at line 842 of file Counters.h.

843  {
844  this->AccumulatorSet::operator+=( by );
845  return *this;
846  }
StatEntity& StatEntity::operator+= ( StatEntity  by)
inline

Definition at line 847 of file Counters.h.

848  {
849  mergeAndReset( std::move( by ) );
850  return *this;
851  }
void mergeAndReset(AccumulatorSet< Arithmetic, Ato, Bases... > &&other)
Definition: Counters.h:411
T move(T...args)
StatEntity& StatEntity::operator-- ( )
inline

Definition at line 825 of file Counters.h.

826  {
827  ( *this ) += -1.0;
828  return *this;
829  }
StatEntity StatEntity::operator-- ( int  )
inline

Definition at line 830 of file Counters.h.

831  {
832  auto copy = *this;
833  --( *this );
834  return copy;
835  }
T copy(T...args)
StatEntity& StatEntity::operator-= ( double  by)
inline

Definition at line 809 of file Counters.h.

810  {
811  ( *this ) += ( -by );
812  return *this;
813  }
bool StatEntity::operator< ( const StatEntity se) const
inline

Definition at line 836 of file Counters.h.

837  {
838  return std::make_tuple( nEntries(), sum(), min(), max(), sum2() ) <
839  std::make_tuple( se.nEntries(), se.sum(), se.min(), se.max(), se.sum2() );
840  };
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 804 of file Counters.h.

805  {
806  this->reset();
807  ( *this ) += by;
808  }
void reset()
Definition: Counters.h:803
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 889 of file Counters.h.

891  {
892  if ( flag && effCounter( name ) && 0 <= eff() && 0 <= effErr() && sum() <= nEntries() &&
893  ( 0 == min() || 1 == min() ) && ( 0 == max() || 1 == max() ) ) {
894  // efficiency printing
895  std::string fmt;
896  if ( tableFormat ) {
897  if ( name.empty() ) {
898  fmt = "|%|10d| |%|11.5g| |(%|#9.7g| +- %|-#8.7g|)%%| ------- | ------- |";
899  return o << boost::format{fmt} % BinomialAccParent::nEntries() % sum() % ( efficiency() * 100 ) %
900  ( efficiencyErr() * 100 );
901  } else {
902  fmt = "*" + fmtHead + "|%|10d| |%|11.5g| |(%|#9.7g| +- %|-#8.7g|)%%| ------- | ------- |";
903  return o << boost::format{fmt} % ( "\"" + name + "\"" ) % BinomialAccParent::nEntries() % sum() %
904  ( efficiency() * 100 ) % ( efficiencyErr() * 100 );
905  }
906  } else {
907  fmt = "#=%|-7lu| Sum=%|-11.5g| Eff=|(%|#9.7g| +- %|-#8.6g|)%%|";
908  return o << boost::format{fmt} % BinomialAccParent::nEntries() % sum() % ( efficiency() * 100 ) %
909  ( efficiencyErr() * 100 );
910  }
911  } else {
912  // Standard printing
913  std::string fmt;
914  if ( tableFormat ) {
915  if ( name.empty() ) {
916  fmt = "|%|10d| |%|11.7g| |%|#11.5g| |%|#11.5g| |%|#12.5g| |%|#12.5g| |";
917  return o << boost::format{fmt} % nEntries() % sum() % mean() % standard_deviation() % min() % max();
918 
919  } else {
920  fmt = " " + fmtHead + "|%|10d| |%|11.7g| |%|#11.5g| |%|#11.5g| |%|#12.5g| |%|#12.5g| |";
921  return o << boost::format{fmt} % ( "\"" + name + "\"" ) % nEntries() % sum() % mean() % standard_deviation() %
922  min() % max();
923  }
924  } else {
925  fmt = "#=%|-7lu| Sum=%|-11.5g| Mean=%|#10.4g| +- %|-#10.5g| Min/Max=%|#10.4g|/%|-#10.4g|";
926  return o << boost::format{fmt} % nEntries() % sum() % mean() % standard_deviation() % min() % max();
927  }
928  }
929  }
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:876
double flag() const
Definition: Counters.h:869
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 930 of file Counters.h.

931  {
932  return print( o, true, tag, true );
933  }
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:889
std::ostream& StatEntity::print ( std::ostream ,
bool  tableFormat = false 
) const
inlineoverridevirtual

prints the counter to a stream

Implements Gaudi::Accumulators::PrintableCounter.

Definition at line 934 of file Counters.h.

935  {
936  std::string emptyName;
937  return print( o, tableFormat, emptyName, true );
938  }
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:889
std::ostream& StatEntity::printFormatted ( std::ostream o,
const std::string format 
) const
inline

Definition at line 882 of file Counters.h.

883  {
884  boost::format fmt{format};
885  fmt % nEntries() % sum() % mean() % standard_deviation() % min() % max();
886  return o << fmt.str();
887  }
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 803 of file Counters.h.

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

Definition at line 862 of file Counters.h.

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

Definition at line 863 of file Counters.h.

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

Definition at line 864 of file Counters.h.

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

Definition at line 859 of file Counters.h.

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

Definition at line 939 of file Counters.h.

940  {
941  std::ostringstream ost;
942  print( ost );
943  return ost.str();
944  }
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:889

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