29 using extends::extends;
66 Counter*& refpCounter )
override;
126 StatusCode print(
const CountObject& pCounter, Printout& printer )
const override;
140 auto j =
std::find_if( i.second.begin(), i.second.end(),
142 if ( j != i.second.end() )
return {i.first, j->first};
168 " Counter :: Group | # | sum | " 169 "mean/eff^* | rms/err^* | min | max |",
170 "the header row for the output Stat-table"};
172 this,
"RegularRowFormat",
173 " %|15.15s|%|-15.15s|%|32t||%|10d| |%|11.7g| |%|#11.5g| |%|#11.5g| |%|#12.5g| |%|#12.5g| |",
174 "the format for the regular row in the output Stat-table"};
176 this,
"EfficiencyRowFormat",
177 "*%|15.15s|%|-15.15s|%|32t||%|10d| |%|11.5g| |(%|#9.7g| +- %|-#9.7g|)%%| ------- | ------- |",
178 "the format for the regular row in the outptu Stat-table"};
180 "use the special format for printout of efficiency counters"};
195 auto j = i->second.find( nam );
196 if ( i->second.end() == j ) {
211 return CountObject{j.second, i->first, j.first};
221 #pragma warning( push ) 222 #pragma warning( disable : 2259 ) 228 refpCounter =
get( grp, nam );
230 return COUNTER_EXISTS;
235 if ( 0 != initial_value ) {
236 refpCounter->addFlag( static_cast<double>( initial_value ) );
245 i->second.emplace( nam, newc );
250 #pragma warning( pop ) 260 return CountObject( p, group, name );
262 throw std::runtime_error(
"CounterSvc::Counter('" + group +
"::" + name +
"') exists already!" );
271 return COUNTER_NOT_PRESENT;
273 auto j = i->second.find( nam );
274 if ( i->second.end() == j ) {
275 return COUNTER_NOT_PRESENT;
278 i->second.erase( j );
288 return COUNTER_NOT_PRESENT;
290 for (
auto& j : i->second )
delete j.second;
300 for (
auto& i :
m_counts )
remove( i.first ).ignore();
311 return COUNTER_NOT_PRESENT;
320 class conditionalPrint
323 CounterSvc::Printout* printer;
327 conditionalPrint( CounterSvc::Printout& _p,
MsgStream& _l ) : printer( &_p ),
log( &_l ) {}
328 template <
class Pair>
332 ( *printer )( *
log, p.second ).ignore();
344 return COUNTER_NOT_PRESENT;
364 return print( refCounter.counter(), printer );
374 for (
const auto& j : i.second ) sorted_map[{i.first, j.first}] = j.second;
388 log << MSG::ALWAYS << CountObject( const_cast<Counter*>(
c ), p.first, p.second ) <<
endmsg;
398 const auto _num =
num();
405 for (
const auto& j : i.second ) {
406 if ( j.second ) sorted_map[{i.first, j.first}] = j.second;
409 for (
const auto& i : sorted_map ) {
Gaudi::Property< bool > m_useEffFormat
Definition of the MsgStream class used to transmit messages.
virtual StatusCode remove()
Remove all known counter objects.
Gaudi::Property< bool > m_print
const std::string & name() const override
Retrieve name of the service.
StatusCode finalize() override
Implementation of property with value of concrete type.
GaudiUtils::HashMap< std::string, Counter * > NameMap
bool isSuccess() const
Test for a status code of SUCCESS.
Gaudi::Property< std::string > m_format1
Gaudi::Property< std::string > m_header
Simple implementation of the abstract interface ICounterSvc.
Gaudi::Property< std::string > m_format2
StatusCode defaultPrintout(MsgStream &log, const Counter *pCounter) const override
Default Printout for counters.
#define DECLARE_COMPONENT(type)
GAUDI_API std::string formatAsTableRow(const StatEntity &counter, const bool flag, const std::string &format1=" |%|7d| |%|11.7g| |%|#11.5g| |%|#10.5g| |%|#10.5g| |%|#10.5g| |", const std::string &format2="*|%|7d| |%|11.5g| |(%|#9.7g| +- %|-#8.6g|)%%| ----- | ----- |")
print the counter in a form of the table row
StatusCode create(const std::string &group, const std::string &name, longlong initial_value, Counter *&refpCounter) override
Create a new counter object.
GaudiUtils::HashMap< std::string, NameMap > CountMap
void print() const
"standard" printout a'la GaudiCommon
This class is used for returning status codes from appropriate routines.
CountMap m_counts
the actual map of counters
iterator find(const key_type &key)
std::pair< iterator, bool > emplace(Args &&...args)
std::pair< std::string, std::string > _find(const Counter *c) const
virtual Out operator()(const vector_of_const_< In > &inputs) const =0
Base class used to extend a class implementing other interfaces.
T back_inserter(T...args)
Common class providing an architecture-independent hash map.
MsgStream & msgStream() const
Return an uninitialized MsgStream.
Counter * get(const std::string &group, const std::string &name) const override
Access an existing counter object.
MSG::Level msgLevel() const
get the output level from the embedded MsgStream
MsgStream & always() const
shortcut for the method msgStream(MSG::ALWAYS)
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
~CounterSvc() override
Standard destructor.
StatusCode finalize() override
Finalization.