The Gaudi Framework  v31r0 (aeb156f0)
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 837 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 851 of file Counters.h.

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

Definition at line 854 of file Counters.h.

855  {
857  std::make_tuple( std::make_tuple( std::make_tuple( entries, flag ), flag2 ), minFlag, maxFlag ),
858  std::make_tuple( 0, 0 ) ) );
859  }
T make_tuple(T...args)
void reset()
Definition: Counters.h:860
double flag2() const
Definition: Counters.h:917
double flag() const
Definition: Counters.h:916

Member Function Documentation

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

Definition at line 900 of file Counters.h.

900  {
901  *this += v;
902  return nEntries();
903  }
unsigned long StatEntity::addFlag ( const double  v)
inline

Definition at line 904 of file Counters.h.

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

Definition at line 912 of file Counters.h.

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

Definition at line 923 of file Counters.h.

923  {
924  using boost::algorithm::icontains;
925  return icontains( name, "eff" ) || icontains( name, "acc" ) || icontains( name, "filt" ) ||
926  icontains( name, "fltr" ) || icontains( name, "pass" );
927  }
std::ostream& StatEntity::fillStream ( std::ostream o) const
inline

Definition at line 1005 of file Counters.h.

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

Definition at line 1006 of file Counters.h.

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

Definition at line 916 of file Counters.h.

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

Definition at line 917 of file Counters.h.

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

Definition at line 922 of file Counters.h.

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

Definition at line 918 of file Counters.h.

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

Definition at line 920 of file Counters.h.

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

Definition at line 921 of file Counters.h.

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

Definition at line 919 of file Counters.h.

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

Definition at line 914 of file Counters.h.

914 { 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 907 of file Counters.h.

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

Definition at line 908 of file Counters.h.

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

Definition at line 913 of file Counters.h.

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

Definition at line 869 of file Counters.h.

869  {
870  ( *this ) += 1.0;
871  return *this;
872  }
StatEntity StatEntity::operator++ ( int  )
inline

Definition at line 873 of file Counters.h.

873  {
874  auto copy = *this;
875  ++( *this );
876  return copy;
877  }
T copy(T...args)
StatEntity& StatEntity::operator+= ( double  by)
inline

Definition at line 892 of file Counters.h.

892  {
893  this->AccumulatorSet::operator+=( by );
894  return *this;
895  }
StatEntity& StatEntity::operator+= ( StatEntity  by)
inline

Definition at line 896 of file Counters.h.

896  {
897  mergeAndReset( std::move( by ) );
898  return *this;
899  }
void mergeAndReset(AccumulatorSet< Arithmetic, Ato, Bases... > &&other)
Definition: Counters.h:404
T move(T...args)
StatEntity& StatEntity::operator-- ( )
inline

Definition at line 878 of file Counters.h.

878  {
879  ( *this ) += -1.0;
880  return *this;
881  }
StatEntity StatEntity::operator-- ( int  )
inline

Definition at line 882 of file Counters.h.

882  {
883  auto copy = *this;
884  --( *this );
885  return copy;
886  }
T copy(T...args)
StatEntity& StatEntity::operator-= ( double  by)
inline

Definition at line 865 of file Counters.h.

865  {
866  ( *this ) += ( -by );
867  return *this;
868  }
bool StatEntity::operator< ( const StatEntity se) const
inline

Definition at line 887 of file Counters.h.

887  {
888  return std::make_tuple( nEntries(), sum(), min(), max(), sum2() ) <
889  std::make_tuple( se.nEntries(), se.sum(), se.min(), se.max(), se.sum2() );
890  };
double sum(double x, double y, double z)
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 861 of file Counters.h.

861  {
862  this->reset();
863  ( *this ) += by;
864  }
void reset()
Definition: Counters.h:860
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 978 of file Counters.h.

979  {
980  return printImpl( o, tableFormat, name, flag, fmtHead );
981  }
stream & printImpl(stream &o, bool tableFormat, const std::string &name, bool flag, std::string const &fmtHead) const
Definition: Counters.h:940
double flag() const
Definition: Counters.h:916
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 982 of file Counters.h.

983  {
984  return printImpl( o, tableFormat, name, flag, fmtHead );
985  }
stream & printImpl(stream &o, bool tableFormat, const std::string &name, bool flag, std::string const &fmtHead) const
Definition: Counters.h:940
double flag() const
Definition: Counters.h:916
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 986 of file Counters.h.

986  {
987  return print( o, true, tag, true );
988  }
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:978
virtual MsgStream& StatEntity::print ( MsgStream o,
const std::string tag 
) const
inlineoverridevirtual

Reimplemented from Gaudi::Accumulators::PrintableCounter.

Definition at line 989 of file Counters.h.

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

prints the counter to a stream

Implements Gaudi::Accumulators::PrintableCounter.

Definition at line 992 of file Counters.h.

992  {
993  std::string emptyName;
994  return print( o, tableFormat, emptyName, true );
995  }
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:978
MsgStream& StatEntity::print ( MsgStream o,
bool  tableFormat = false 
) const
inlineoverridevirtual

Implements Gaudi::Accumulators::PrintableCounter.

Definition at line 996 of file Counters.h.

996  {
997  std::string emptyName;
998  return print( o, tableFormat, emptyName, true );
999  }
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:978
std::ostream& StatEntity::printFormatted ( std::ostream o,
const std::string format 
) const
inline

Definition at line 934 of file Counters.h.

934  {
935  return printFormattedImpl( o, format );
936  }
stream & printFormattedImpl(stream &o, const std::string &format) const
Definition: Counters.h:929
MsgStream& StatEntity::printFormatted ( MsgStream o,
const std::string format 
) const
inline

Definition at line 937 of file Counters.h.

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

Definition at line 929 of file Counters.h.

929  {
930  boost::format fmt{format};
931  fmt % nEntries() % sum() % mean() % standard_deviation() % min() % max();
932  return o << fmt.str();
933  }
GAUDI_API std::string format(const char *,...)
MsgStream format utility "a la sprintf(...)".
Definition: MsgStream.cpp:109
double sum(double x, double y, double z)
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 940 of file Counters.h.

941  {
942  if ( flag && effCounter( name ) && 0 <= eff() && 0 <= effErr() && sum() <= nEntries() &&
943  ( 0 == min() || 1 == min() ) && ( 0 == max() || 1 == max() ) ) {
944  // efficiency printing
945  if ( tableFormat ) {
946  if ( name.empty() ) {
947  constexpr auto fmt = "|%|10d| |%|11.5g| |(%|#9.7g| +- %|-#8.7g|)%%| ------- | ------- |";
948  return o << boost::format{fmt} % BinomialAccParent::nEntries() % sum() % ( efficiency() * 100 ) %
949  ( efficiencyErr() * 100 );
950  } else {
951  auto fmt = " |*" + fmtHead + "|%|10d| |%|11.5g| |(%|#9.7g| +- %|-#8.7g|)%%| ------- | ------- |";
952  return o << boost::format{fmt} % ( "\"" + name + "\"" ) % BinomialAccParent::nEntries() % sum() %
953  ( efficiency() * 100 ) % ( efficiencyErr() * 100 );
954  }
955  } else {
956  constexpr auto fmt = "#=%|-7lu| Sum=%|-11.5g| Eff=|(%|#9.7g| +- %|-#8.6g|)%%|";
957  return o << boost::format{fmt} % BinomialAccParent::nEntries() % sum() % ( efficiency() * 100 ) %
958  ( efficiencyErr() * 100 );
959  }
960  } else {
961  // Standard printing
962  if ( tableFormat ) {
963  if ( name.empty() ) {
964  constexpr auto fmt = "|%|10d| |%|11.7g| |%|#11.5g| |%|#11.5g| |%|#12.5g| |%|#12.5g| |";
965  return o << boost::format{fmt} % nEntries() % sum() % mean() % standard_deviation() % min() % max();
966 
967  } else {
968  auto fmt = " | " + fmtHead + "|%|10d| |%|11.7g| |%|#11.5g| |%|#11.5g| |%|#12.5g| |%|#12.5g| |";
969  return o << boost::format{fmt} % ( "\"" + name + "\"" ) % nEntries() % sum() % mean() % standard_deviation() %
970  min() % max();
971  }
972  } else {
973  constexpr auto fmt = "#=%|-7lu| Sum=%|-11.5g| Mean=%|#10.4g| +- %|-#10.5g| Min/Max=%|#10.4g|/%|-#10.4g|";
974  return o << boost::format{fmt} % nEntries() % sum() % mean() % standard_deviation() % min() % max();
975  }
976  }
977  }
T empty(T...args)
GAUDI_API std::string format(const char *,...)
MsgStream format utility "a la sprintf(...)".
Definition: MsgStream.cpp:109
double sum(double x, double y, double z)
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:923
double flag() const
Definition: Counters.h:916
void StatEntity::reset ( )
inline

Definition at line 860 of file Counters.h.

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

Definition at line 909 of file Counters.h.

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

Definition at line 910 of file Counters.h.

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

Definition at line 911 of file Counters.h.

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

Definition at line 906 of file Counters.h.

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

Definition at line 1000 of file Counters.h.

1000  {
1001  std::ostringstream ost;
1002  print( ost );
1003  return ost.str();
1004  }
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:978

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