The Gaudi Framework  v32r0 (3325bb39)
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
 
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 824 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 838 of file Counters.h.

838  {
839  o->declareCounter( tag, *this );
840  }
StatEntity::StatEntity ( const unsigned long  entries,
const double  flag,
const double  flag2,
const double  minFlag,
const double  maxFlag 
)
inline

Definition at line 841 of file Counters.h.

842  {
844  std::make_tuple( std::make_tuple( std::make_tuple( entries, flag ), flag2 ), minFlag, maxFlag ),
845  std::make_tuple( 0, 0 ) ) );
846  }
T make_tuple(T...args)
void reset()
Definition: Counters.h:847
double flag2() const
Definition: Counters.h:904
double flag() const
Definition: Counters.h:903

Member Function Documentation

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

Definition at line 887 of file Counters.h.

887  {
888  *this += v;
889  return nEntries();
890  }
unsigned long StatEntity::addFlag ( const double  v)
inline

Definition at line 891 of file Counters.h.

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

Definition at line 899 of file Counters.h.

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

Definition at line 910 of file Counters.h.

910  {
911  using boost::algorithm::icontains;
912  return icontains( name, "eff" ) || icontains( name, "acc" ) || icontains( name, "filt" ) ||
913  icontains( name, "fltr" ) || icontains( name, "pass" );
914  }
std::ostream& StatEntity::fillStream ( std::ostream o) const
inline

Definition at line 992 of file Counters.h.

992 { 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:965
MsgStream& StatEntity::fillStream ( MsgStream o) const
inline

Definition at line 993 of file Counters.h.

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

Definition at line 903 of file Counters.h.

903 { return sum(); }
double StatEntity::flag2 ( ) const
inline

Definition at line 904 of file Counters.h.

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

Definition at line 909 of file Counters.h.

909 { return max(); }
EventIDBase max(const EventIDBase &lhs, const EventIDBase &rhs)
Definition: EventIDBase.h:215
double StatEntity::flagMean ( ) const
inline

Definition at line 905 of file Counters.h.

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

Definition at line 907 of file Counters.h.

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

Definition at line 908 of file Counters.h.

908 { return min(); }
EventIDBase min(const EventIDBase &lhs, const EventIDBase &rhs)
Definition: EventIDBase.h:202
double StatEntity::flagRMS ( ) const
inline

Definition at line 906 of file Counters.h.

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

Definition at line 901 of file Counters.h.

901 { return max(); } // get maximal value
EventIDBase max(const EventIDBase &lhs, const EventIDBase &rhs)
Definition: EventIDBase.h:215
double StatEntity::Mean ( ) const
inline

Definition at line 894 of file Counters.h.

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

Definition at line 895 of file Counters.h.

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

Definition at line 900 of file Counters.h.

900 { return min(); } // get minimal value
EventIDBase min(const EventIDBase &lhs, const EventIDBase &rhs)
Definition: EventIDBase.h:202
StatEntity& StatEntity::operator++ ( )
inline

Definition at line 856 of file Counters.h.

856  {
857  ( *this ) += 1.0;
858  return *this;
859  }
StatEntity StatEntity::operator++ ( int  )
inline

Definition at line 860 of file Counters.h.

860  {
861  auto copy = *this;
862  ++( *this );
863  return copy;
864  }
T copy(T...args)
StatEntity& StatEntity::operator+= ( double  by)
inline

Definition at line 879 of file Counters.h.

879  {
880  this->AccumulatorSet::operator+=( by );
881  return *this;
882  }
StatEntity& StatEntity::operator+= ( StatEntity  by)
inline

Definition at line 883 of file Counters.h.

883  {
884  mergeAndReset( std::move( by ) );
885  return *this;
886  }
void mergeAndReset(AccumulatorSet< Arithmetic, Ato, Bases... > &&other)
Definition: Counters.h:386
T move(T...args)
StatEntity& StatEntity::operator-- ( )
inline

Definition at line 865 of file Counters.h.

865  {
866  ( *this ) += -1.0;
867  return *this;
868  }
StatEntity StatEntity::operator-- ( int  )
inline

Definition at line 869 of file Counters.h.

869  {
870  auto copy = *this;
871  --( *this );
872  return copy;
873  }
T copy(T...args)
StatEntity& StatEntity::operator-= ( double  by)
inline

Definition at line 852 of file Counters.h.

852  {
853  ( *this ) += ( -by );
854  return *this;
855  }
bool StatEntity::operator< ( const StatEntity se) const
inline

Definition at line 874 of file Counters.h.

874  {
875  return std::make_tuple( nEntries(), sum(), min(), max(), sum2() ) <
876  std::make_tuple( se.nEntries(), se.sum(), se.min(), se.max(), se.sum2() );
877  };
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
void StatEntity::operator= ( double  by)
inline

Definition at line 848 of file Counters.h.

848  {
849  this->reset();
850  ( *this ) += by;
851  }
void reset()
Definition: Counters.h:847
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 965 of file Counters.h.

966  {
967  return printImpl( o, tableFormat, name, flag, fmtHead );
968  }
stream & printImpl(stream &o, bool tableFormat, const std::string &name, bool flag, std::string const &fmtHead) const
Definition: Counters.h:927
double flag() const
Definition: Counters.h:903
MsgStream& StatEntity::print ( MsgStream o,
bool  tableFormat,
const std::string name,
bool  flag = true,
std::string  fmtHead = "%|-48.48s|%|27t|" 
) const
inline

Definition at line 969 of file Counters.h.

970  {
971  return printImpl( o, tableFormat, name, flag, fmtHead );
972  }
stream & printImpl(stream &o, bool tableFormat, const std::string &name, bool flag, std::string const &fmtHead) const
Definition: Counters.h:927
double flag() const
Definition: Counters.h:903
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 973 of file Counters.h.

973  {
974  return print( o, true, tag, true );
975  }
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:965
virtual MsgStream& StatEntity::print ( MsgStream o,
const std::string tag 
) const
inlineoverridevirtual

Reimplemented from Gaudi::Accumulators::PrintableCounter.

Definition at line 976 of file Counters.h.

976  {
977  return print( o, true, tag, true );
978  }
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:965
std::ostream& StatEntity::print ( std::ostream ,
bool  tableFormat = false 
) const
inlineoverridevirtual

prints the counter to a stream

Implements Gaudi::Accumulators::PrintableCounter.

Definition at line 979 of file Counters.h.

979  {
980  std::string emptyName;
981  return print( o, tableFormat, emptyName, true );
982  }
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:965
MsgStream& StatEntity::print ( MsgStream o,
bool  tableFormat = false 
) const
inlineoverridevirtual

Implements Gaudi::Accumulators::PrintableCounter.

Definition at line 983 of file Counters.h.

983  {
984  std::string emptyName;
985  return print( o, tableFormat, emptyName, true );
986  }
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:965
std::ostream& StatEntity::printFormatted ( std::ostream o,
const std::string format 
) const
inline

Definition at line 921 of file Counters.h.

921  {
922  return printFormattedImpl( o, format );
923  }
stream & printFormattedImpl(stream &o, const std::string &format) const
Definition: Counters.h:916
MsgStream& StatEntity::printFormatted ( MsgStream o,
const std::string format 
) const
inline

Definition at line 924 of file Counters.h.

924 { return printFormattedImpl( o, format ); }
stream & printFormattedImpl(stream &o, const std::string &format) const
Definition: Counters.h:916
template<typename stream >
stream& StatEntity::printFormattedImpl ( stream &  o,
const std::string format 
) const
inline

Definition at line 916 of file Counters.h.

916  {
917  boost::format fmt{format};
918  fmt % nEntries() % sum() % mean() % standard_deviation() % min() % max();
919  return o << fmt.str();
920  }
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
template<typename stream >
stream& StatEntity::printImpl ( stream &  o,
bool  tableFormat,
const std::string name,
bool  flag,
std::string const &  fmtHead 
) const
inline

Definition at line 927 of file Counters.h.

928  {
929  if ( flag && effCounter( name ) && 0 <= eff() && 0 <= effErr() && sum() <= nEntries() &&
930  ( 0 == min() || 1 == min() ) && ( 0 == max() || 1 == max() ) ) {
931  // efficiency printing
932  if ( tableFormat ) {
933  if ( name.empty() ) {
934  constexpr auto fmt = "|%|10d| |%|11.5g| |(%|#9.7g| +- %|-#8.7g|)%%| ------- | ------- |";
935  return o << boost::format{fmt} % BinomialAccParent::nEntries() % sum() % ( efficiency() * 100 ) %
936  ( efficiencyErr() * 100 );
937  } else {
938  auto fmt = " |*" + fmtHead + "|%|10d| |%|11.5g| |(%|#9.7g| +- %|-#8.7g|)%%| ------- | ------- |";
939  return o << boost::format{fmt} % ( "\"" + name + "\"" ) % BinomialAccParent::nEntries() % sum() %
940  ( efficiency() * 100 ) % ( efficiencyErr() * 100 );
941  }
942  } else {
943  constexpr auto fmt = "#=%|-7lu| Sum=%|-11.5g| Eff=|(%|#9.7g| +- %|-#8.6g|)%%|";
944  return o << boost::format{fmt} % BinomialAccParent::nEntries() % sum() % ( efficiency() * 100 ) %
945  ( efficiencyErr() * 100 );
946  }
947  } else {
948  // Standard printing
949  if ( tableFormat ) {
950  if ( name.empty() ) {
951  constexpr auto fmt = "|%|10d| |%|11.7g| |%|#11.5g| |%|#11.5g| |%|#12.5g| |%|#12.5g| |";
952  return o << boost::format{fmt} % nEntries() % sum() % mean() % standard_deviation() % min() % max();
953 
954  } else {
955  auto fmt = " | " + fmtHead + "|%|10d| |%|11.7g| |%|#11.5g| |%|#11.5g| |%|#12.5g| |%|#12.5g| |";
956  return o << boost::format{fmt} % ( "\"" + name + "\"" ) % nEntries() % sum() % mean() % standard_deviation() %
957  min() % max();
958  }
959  } else {
960  constexpr auto fmt = "#=%|-7lu| Sum=%|-11.5g| Mean=%|#10.4g| +- %|-#10.5g| Min/Max=%|#10.4g|/%|-#10.4g|";
961  return o << boost::format{fmt} % nEntries() % sum() % mean() % standard_deviation() % min() % max();
962  }
963  }
964  }
T empty(T...args)
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:910
double flag() const
Definition: Counters.h:903
void StatEntity::reset ( )
inline

Definition at line 847 of file Counters.h.

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

Definition at line 896 of file Counters.h.

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

Definition at line 897 of file Counters.h.

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

Definition at line 898 of file Counters.h.

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

Definition at line 893 of file Counters.h.

893 { return sum(); } // get sum
std::string StatEntity::toString ( ) const
inline

Definition at line 987 of file Counters.h.

987  {
988  std::ostringstream ost;
989  print( ost );
990  return ost.str();
991  }
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:965

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