13#include <boost/algorithm/string/predicate.hpp> 
   14#include <boost/format.hpp> 
   22                                                              Gaudi::Accumulators::StatAccumulator,
 
   23                                                              Gaudi::Accumulators::BinomialAccumulator> {
 
   25  inline static const std::string 
typeString{ 
"statentity" };
 
   35              const double maxFlag ) {
 
   36    reset( std::make_tuple(
 
   37        std::make_tuple( std::make_tuple( std::make_tuple( entries, 
flag ), 
flag2 ), minFlag, maxFlag ),
 
   38        std::make_tuple( 0, 0 ) ) );
 
 
   68    return std::make_tuple( nEntries(), sum(), min(), max(), sum2() ) <
 
   69           std::make_tuple( se.nEntries(), se.sum(), se.min(), se.max(), se.sum2() );
 
 
   73    this->AccumulatorSet::operator+=( by );
 
 
   80  unsigned long add( 
const double v ) {
 
 
   84  unsigned long addFlag( 
const double v ) { 
return add( v ); }
 
   86  double Sum()
 const { 
return sum(); }                
 
   87  double Mean()
 const { 
return mean(); }              
 
   92  double Eff()
 const { 
return eff(); }                
 
   93  double Min()
 const { 
return min(); }                
 
   94  double Max()
 const { 
return max(); }                
 
   96  double      flag()
 const { 
return sum(); }
 
   97  double      flag2()
 const { 
return sum2(); }
 
  104    using boost::algorithm::icontains;
 
  105    return icontains( name, 
"eff" ) || icontains( name, 
"acc" ) || icontains( name, 
"filt" ) ||
 
  106           icontains( name, 
"fltr" ) || icontains( name, 
"pass" );
 
 
  108  template <
typename stream>
 
  110    boost::format fmt{ 
format };
 
  112    return o << fmt.str();
 
 
  119  template <
typename stream>
 
  120  stream& 
printImpl( stream& o, 
bool tableFormat, std::string_view name, 
bool flag, std::string_view fmtHead )
 const {
 
  121    if ( 
flag && 
effCounter( name ) && 0 <= eff() && 0 <= effErr() && sum() <= nEntries() &&
 
  126        if ( name.empty() ) {
 
  127          constexpr auto fmt = 
"|%|10d| |%|11.5g| |(%|#9.7g| +- %|-#8.7g|)%%|   -------   |   -------   |";
 
  129                          ( efficiencyErr() * 100 );
 
  131          auto fmt = std::string{ 
" |*" }.append( fmtHead ).append(
 
  132              "|%|10d| |%|11.5g| |(%|#9.7g| +- %|-#8.7g|)%%|   -------   |   -------   |" );
 
  133          return o << boost::format{ fmt } % ( std::string{ 
"\"" }.append( name ).append( 
"\"" ) ) %
 
  137        constexpr auto fmt = 
"#=%|-7lu| Sum=%|-11.5g| Eff=|(%|#9.7g| +- %|-#8.6g|)%%|";
 
  139                        ( efficiencyErr() * 100 );
 
  144        if ( name.empty() ) {
 
  145          constexpr auto fmt = 
"|%|10d| |%|11.7g| |%|#11.5g| |%|#11.5g| |%|#12.5g| |%|#12.5g| |";
 
  146          return o << boost::format{ fmt } % nEntries() % sum() % mean() % 
standard_deviation() % min() % max();
 
  149          auto fmt = std::string{ 
" | " }.append( fmtHead ).append(
 
  150              "|%|10d| |%|11.7g| |%|#11.5g| |%|#11.5g| |%|#12.5g| |%|#12.5g| |" );
 
  151          return ( o << boost::format{ fmt } % std::string{ 
"\"" }.append( name ).append( 
"\"" ) % nEntries() % sum() %
 
  155        constexpr auto fmt = 
"#=%|-7lu| Sum=%|-11.5g| Mean=%|#10.4g| +- %|-#10.5g| Min/Max=%|#10.4g|/%|-#10.4g|";
 
  156        return o << boost::format{ fmt } % nEntries() % sum() % mean() % 
standard_deviation() % min() % max();
 
 
  160  std::ostream& 
print( std::ostream& o, 
bool tableFormat, std::string_view name, 
bool flag = 
true,
 
  161                       std::string_view fmtHead = 
"%|-48.48s|%|27t|" )
 const {
 
 
  165                    std::string_view fmtHead = 
"%|-48.48s|%|27t|" )
 const {
 
 
  168  virtual std::ostream& 
print( std::ostream& o, std::string_view tag )
 const override {
 
  169    return print( o, 
true, tag, 
true );
 
 
  172  std::ostream&      
print( std::ostream& o, 
bool tableFormat = 
false )
 const override {
 
  173    std::string emptyName;
 
  174    return print( o, tableFormat, emptyName, 
true );
 
 
  177    std::string emptyName;
 
  178    return print( o, tableFormat, emptyName, 
true );
 
 
  181    std::ostringstream ost;
 
 
  192        j, { { { { 
"nEntries", 
"sum" }, 
"sum2" }, 
"min", 
"max" }, { 
"nTrueEntries", 
"nFalseEntries" } } ) );
 
 
 
GAUDI_API std::string format(const char *,...)
MsgStream format utility "a la sprintf(...)".
AccumulatorSet is an Accumulator that holds a set of Accumulators templated by same Arithmetic and At...
static InternalType extractJSONData(const nlohmann::json &j, const JSONStringEntriesType &entries)
void mergeAndReset(AccumulatorSet< double, Ato, InputType, Gaudi::Accumulators::StatAccumulator... > &other)
Definition of the MsgStream class used to transmit messages.
backward compatible StatEntity class.
StatEntity & operator+=(StatEntity by)
MsgStream & print(MsgStream &o, bool tableFormat=false) const override
unsigned long addFlag(const double v)
static StatEntity fromJSON(const nlohmann::json &j)
void operator=(double by)
MsgStream & print(MsgStream &o, bool tableFormat, std::string_view name, bool flag=true, std::string_view fmtHead="%|-48.48s|%|27t|") const
stream & printFormattedImpl(stream &o, const std::string &format) const
MsgStream & printFormatted(MsgStream &o, const std::string &format) const
StatEntity & operator--()
friend void reset(StatEntity &s)
std::ostream & printFormatted(std::ostream &o, const std::string &format) const
StatEntity & operator++()
std::ostream & print(std::ostream &o, bool tableFormat, std::string_view name, bool flag=true, std::string_view fmtHead="%|-48.48s|%|27t|") const
StatEntity operator++(int)
MsgStream & fillStream(MsgStream &o) const
bool operator<(const StatEntity &se) const
Gaudi::Accumulators::BinomialAccumulator< Gaudi::Accumulators::atomicity::full, double > BinomialAccParent
StatEntity(const unsigned long entries, const double flag, const double flag2, const double minFlag, const double maxFlag)
double flagMeanErr() const
StatEntity & operator+=(double by)
StatEntity()=default
the constructor with automatic registration in the owner's counter map
static const std::string typeString
stream & printImpl(stream &o, bool tableFormat, std::string_view name, bool flag, std::string_view fmtHead) const
static bool effCounter(std::string_view name)
StatEntity operator--(int)
Gaudi::Accumulators::AccumulatorSet< double, Gaudi::Accumulators::atomicity::full, double, Gaudi::Accumulators::StatAccumulator, Gaudi::Accumulators::BinomialAccumulator > AccParent
friend void to_json(nlohmann::json &j, StatEntity const &s)
Basic JSON export for Gaudi::Monitoring::Hub support.
unsigned long add(const double v)
StatEntity & operator-=(double by)
static constexpr bool essentiallyEqual(double const a, double const b)
std::ostream & print(std::ostream &o, bool tableFormat=false) const override
prints the counter to a stream
virtual MsgStream & print(MsgStream &o, std::string_view tag) const override
std::ostream & fillStream(std::ostream &o) const
std::string toString() const
virtual std::ostream & print(std::ostream &o, std::string_view tag) const override
prints the counter to a stream in table format, with the given tag
AccumulatorSet< Arithmetic, Atomicity, Arithmetic, SigmaAccumulator, MinAccumulator, MaxAccumulator > StatAccumulator
StatAccumulator.
Gaudi::ParticleID abs(const Gaudi::ParticleID &p)
Return the absolute value for a PID.
unsigned long nEntries() const
An empty ancester of all counters that knows how to print themselves.
virtual std::ostream & print(std::ostream &, bool tableFormat=false) const =0
prints the counter to a stream
auto standard_deviation() const