| The Gaudi Framework v27r1

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
CounterSvc Class Reference

Simple implementation of the abstract interface ICounterSvc. More...

Inheritance diagram for CounterSvc:
[legend]
Collaboration diagram for CounterSvc:
[legend]

## Public Member Functions
| CounterSvc (const std::string &name, ISvcLocator *svcLoc)
| Standard Constructor. More...
| ~CounterSvc () override
| Standard destructor. More...
StatusCode | finalize () override
| Finalization. More...
Counter * | get (const std::string &group, const std::string &name) const override
| Access an existing counter object. More...
ICounterSvc::Counters | get (const std::string &group) const override
| get all counters form the given group: More...
StatusCode | create (const std::string &group, const std::string &name, longlong initial_value, Counter *&refpCounter) override
| Create a new counter object. More...
CountObject | create (const std::string &group, const std::string &name, longlong initial_value=0) override
| Create a new counter object. More...
StatusCode | remove (const std::string &group, const std::string &name) override
| Remove a counter object. More...
StatusCode | remove (const std::string &group) override
| Remove all counters of a given group. More...
virtual StatusCode | remove ()
| Remove all known counter objects. More...
StatusCode | print (const std::string &group, const std::string &name, Printout &printer) const override
| Print counter value. More...
StatusCode | print (const std::string &group, Printout &printer) const override
| If no such counter exists the return code is COUNTER_NOT_PRESENT Note: This call is not direct access. More...
StatusCode | print (const Counter *pCounter, Printout &printer) const override
| Print counter value. More...
StatusCode | print (const CountObject &pCounter, Printout &printer) const override
| Print counter value. More...
StatusCode | print (Printout &printer) const override
StatusCode | defaultPrintout (MsgStream &log, const Counter *pCounter) const override
| Default Printout for counters. More...
void | print () const
| "standard" printout a'la GaudiCommon More...
Public Member Functions inherited from extends< Service, ICounterSvc >
void * | i_cast (const InterfaceID &tid) const override
| Implementation of IInterface::i_cast. More...
StatusCode | queryInterface (const InterfaceID &ti, void **pp) override
| Implementation of IInterface::queryInterface. More...
std::vector< std::string > | getInterfaceNames () const override
| Implementation of IInterface::getInterfaceNames. More...
| ~extends () override=default
| Virtual destructor. More...
Public Member Functions inherited from Service
const std::string & | name () const override
| Retrieve name of the service. More...
StatusCode | configure () override
StatusCode | initialize () override
StatusCode | start () override
StatusCode | stop () override
StatusCode | finalize () override
StatusCode | terminate () override
Gaudi::StateMachine::State | FSMState () const override
Gaudi::StateMachine::State | targetFSMState () const override
StatusCode | reinitialize () override
StatusCode | restart () override
StatusCode | sysInitialize () override
| Initialize Service. More...
StatusCode | sysStart () override
| Initialize Service. More...
StatusCode | sysStop () override
| Initialize Service. More...
StatusCode | sysFinalize () override
| Finalize Service. More...
StatusCode | sysReinitialize () override
| Re-initialize the Service. More...
StatusCode | sysRestart () override
| Re-initialize the Service. More...
StatusCode | setProperty (const Property &p) override
StatusCode | setProperty (const std::string &s) override
StatusCode | setProperty (const std::string &n, const std::string &v) override
StatusCode | getProperty (Property *p) const override
const Property & | getProperty (const std::string &name) const override
StatusCode | getProperty (const std::string &n, std::string &v) const override
const std::vector< Property * > & | getProperties () const override
bool | hasProperty (const std::string &name) const override
template<class TYPE >
StatusCode | setProperty (const std::string &name, const TYPE &value)
| set the property form the value More...
| Service (std::string name, ISvcLocator *svcloc)
| Standard Constructor. More...
SmartIF< ISvcLocator > & | serviceLocator () const override
| Retrieve pointer to service locator. More...
StatusCode | setProperties ()
| Method for setting declared properties to the values specified for the job. More...
template<class T >
StatusCode | service (const std::string &name, const T *&psvc, bool createIf=true) const
| Access a service by name, creating it if it doesn't already exist. More...
template<class T >
StatusCode | service (const std::string &name, T *&psvc, bool createIf=true) const
template<typename IFace = IService>
SmartIF< IFace > | service (const std::string &name, bool createIf=true) const
template<class T >
StatusCode | service (const std::string &svcType, const std::string &svcName, T *&psvc) const
| Access a service by name and type, creating it if it doesn't already exist. More...
template<class T >
Property * | declareProperty (const std::string &name, T &property, const std::string &doc="none") const
| Declare the named property. More...
Property * | declareRemoteProperty (const std::string &name, IProperty *rsvc, const std::string &rname="") const
| Declare remote named properties. More...
template<class T >
StatusCode | declarePrivateTool (ToolHandle< T > &handle, std::string toolTypeAndName="", bool createIf=true)
| Declare used Private tool. More...
template<class T >
StatusCode | declarePublicTool (ToolHandle< T > &handle, std::string toolTypeAndName="", bool createIf=true)
| Declare used Public tool. More...
SmartIF< IAuditorSvc > & | auditorSvc () const
| The standard auditor service.May not be invoked before sysInitialize() has been invoked. More...
Public Member Functions inherited from CommonMessagingBase
virtual | ~CommonMessagingBase ()=default
| Virtual destructor. More...
SmartIF< IMessageSvc > & | msgSvc () const
| The standard message service. More...
MsgStream & | msgStream () const
| Return an uninitialized MsgStream. More...
MsgStream & | msgStream (const MSG::Level level) const
| Predefined configurable message stream for the efficient printouts. More...
MsgStream & | always () const
| shortcut for the method msgStream(MSG::ALWAYS) More...
MsgStream & | fatal () const
| shortcut for the method msgStream(MSG::FATAL) More...
MsgStream & | err () const
| shortcut for the method msgStream(MSG::ERROR) More...
MsgStream & | error () const
| shortcut for the method msgStream(MSG::ERROR) More...
MsgStream & | warning () const
| shortcut for the method msgStream(MSG::WARNING) More...
MsgStream & | info () const
| shortcut for the method msgStream(MSG::INFO) More...
MsgStream & | debug () const
| shortcut for the method msgStream(MSG::DEBUG) More...
MsgStream & | verbose () const
| shortcut for the method msgStream(MSG::VERBOSE) More...
MsgStream & | msg () const
| shortcut for the method msgStream(MSG::INFO) More...
MSG::Level | msgLevel () const
| get the output level from the embedded MsgStream More...
MSG::Level | outputLevel () const __attribute__((deprecated))
| Backward compatibility function for getting the output level. More...
bool | msgLevel (MSG::Level lvl) const
| get the output level from the embedded MsgStream More...
Public Member Functions inherited from extend_interfaces< Interfaces...>
| ~extend_interfaces () override=default
| Virtual destructor. More...

## Private Types
typedef GaudiUtils::HashMap< std::string, Counter * > | NameMap
typedef GaudiUtils::HashMap< std::string, NameMap > | CountMap

## Private Member Functions
std::pair< std::string, std::string > | _find (const Counter *c) const
size_t | num () const

## Private Attributes
CountMap | m_counts
| the actual map of counters More...
bool | m_print = true
| boolean flag to print statistics More...
std::string | m_header
| the header row More...
std::string | m_format1
| format for regular statistical printout rows More...
std::string | m_format2
| format for "efficiency" statistical printout rows More...
bool | m_useEffFormat = true
| flag to use the special "efficiency" format More...

## Additional Inherited Members
Public Types inherited from extends< Service, ICounterSvc >
using | base_class = extends
| Typedef to this class. More...
using | extend_interfaces_base = extend_interfaces< Interfaces...>
| Typedef to the base of this class. More...
Public Types inherited from Service
typedef Gaudi::PluginService::Factory< IService *, const std::string &, ISvcLocator * > | Factory
Public Types inherited from CommonMessaging< implements< IService, IProperty, IStateful > >
using | base_class = CommonMessaging
Public Types inherited from extend_interfaces< Interfaces...>
using | ext_iids = typename Gaudi::interface_list_cat< typename Interfaces::ext_iids...>::type
| take union of the ext_iids of all Interfaces... More...
Protected Member Functions inherited from Service
| ~Service () override
| Standard Destructor. More...
int | outputLevel () const
| get the `Service's` output level More...
Protected Member Functions inherited from CommonMessaging< implements< IService, IProperty, IStateful > >
void | updateMsgStreamOutputLevel (int level)
| Update the output level of the cached MsgStream. More...
Protected Attributes inherited from Service
IntegerProperty | m_outputLevel = MSG::NIL
| Service output level. More...
Gaudi::StateMachine::State | m_state = Gaudi::StateMachine::OFFLINE
| Service state. More...
Gaudi::StateMachine::State | m_targetState = Gaudi::StateMachine::OFFLINE
| Service state. More...

## Detailed Description

Simple implementation of the abstract interface ICounterSvc.

Author
  Markus FRANK
  Vanya BELYAEV ibely.nosp@m.aev@.nosp@m.physi.nosp@m.cs.s.nosp@m.yr.ed.nosp@m.u

Date
  2007-05-25

Definition at line 24 of file CounterSvc.cpp.

## Member Typedef Documentation

typedef GaudiUtils::HashMap<std::string,NameMap> CounterSvc::CountMap
| private

Definition at line 209 of file CounterSvc.cpp.

typedef GaudiUtils::HashMap<std::string,Counter*> CounterSvc::NameMap
| private

Definition at line 208 of file CounterSvc.cpp.

## Constructor & Destructor Documentation

CounterSvc::CounterSvc | ( | const std::string & | name,
|  | ISvcLocator * | svcLoc
| ) |  |
| inline

Standard Constructor.

Definition at line 28 of file CounterSvc.cpp.

30 : base_class(name, svcLoc)
31 // the header row
32 , m_header ( " Counter :: Group | # | sum | mean/eff^* | rms/err^* | min | max |")
33 // format for regular statistical printout rows
34 , m_format1 ( " %|15.15s|%|-15.15s|%|32t||%|10d| |%|11.7g| |%|#11.5g| |%|#11.5g| |%|#12.5g| |%|#12.5g| |" )
35 // format for "efficiency" statistical printout rows
36 , m_format2 ( "*%|15.15s|%|-15.15s|%|32t||%|10d| |%|11.5g| |(%|#9.7g| +- %|-#9.7g|)%%| ------- | ------- |" )
37 //
38 {
39 declareProperty ("PrintStat" , m_print ) ;
40 //
41 declareProperty
42 ( "StatTableHeader" , m_header ,
43 "The header row for the output Stat-table" ) ;
44 //
45 declareProperty
46 ( "RegularRowFormat" , m_format1 ,
47 "The format for the regular row in the output Stat-table" ) ;
48 //
49 declareProperty
50 ( "EfficiencyRowFormat" , m_format2 ,
51 "The format for the regular row in the outptu Stat-table" ) ;
52 //
53 declareProperty
54 ( "UseEfficiencyRowFormat" , m_useEffFormat ,
55 "Use the special format for printout of efficiency counters" ) ;
56 }
CounterSvc::m_header
std::string m_header
the header row
Definition: CounterSvc.cpp:215
CounterSvc::m_useEffFormat
bool m_useEffFormat
flag to use the special "efficiency" format
Definition: CounterSvc.cpp:221
CounterSvc::m_print
bool m_print
boolean flag to print statistics
Definition: CounterSvc.cpp:213
CounterSvc::m_format2
std::string m_format2
format for "efficiency" statistical printout rows
Definition: CounterSvc.cpp:219
extends< Service, ICounterSvc >::base_class
extends base_class
Typedef to this class.
Definition: extends.h:14
CounterSvc::m_format1
std::string m_format1
format for regular statistical printout rows
Definition: CounterSvc.cpp:217
Service::declareProperty
Property * declareProperty(const std::string &name, T &property, const std::string &doc="none") const
Declare the named property.
Definition: Service.h:215

CounterSvc::~CounterSvc | ( |  | ) |
| inline override

Standard destructor.

Definition at line 58 of file CounterSvc.cpp.

58 { remove().ignore() ; }

## Member Function Documentation

std::pair<std::string,std::string> CounterSvc::_find | ( | const Counter * | c | ) | const
| inline private

Definition at line 182 of file CounterSvc.cpp.

183 {
184 if ( c ) {
185 for ( const auto& i : m_counts ) {
186 auto j = std::find_if( i.second.begin(), i.second.end(),
187 [&](const NameMap::value_type& k) {
188 return k.second == c;
189 });
190 if (j!=i.second.end()) return { i.first, j->first } ;
191 }
192 }
193 return { };
194 }
gaudirun.c
tuple c
Definition: gaudirun.py:391
GaudiUtils::Map::value_type
std::pair< const K, T > value_type
Definition: Map.h:94
CounterSvc::m_counts
CountMap m_counts
the actual map of counters
Definition: CounterSvc.cpp:211
std::find_if
T find_if(T...args)
ana.i
list i
Definition: ana.py:128

StatusCode CounterSvc::create | ( | const std::string & | group,
|  | const std::string & | name,
|  | longlong | initial_value,
|  | Counter *& | refpCounter
| ) |  |
| override

Create a new counter object.

If the counter object exists already the existing object is returned. In this event the return code is COUNTER_EXISTS. The ownership of the actual counter stays with the service.

Parameters

  group | [IN] Hint for smart printing
  name | [IN] Counter name
  initial_value | [IN] Initial counter value
  refpCounter | [OUT] Reference to store pointer to counter.

Returns
  StatusCode indicating failure or success.

Definition at line 265 of file CounterSvc.cpp.

269 {
270 // try to find existing counter:
271 refpCounter = get ( grp , nam ) ;
272 if ( refpCounter ) { return COUNTER_EXISTS ; } // RETURN
273 // create the new counter
274 auto newc = new Counter() ;
275 refpCounter = newc ;
276 if ( 0 != initial_value ) {
277 refpCounter->addFlag ( static_cast<double>(initial_value) ) ; // icc remark #2259
278 }
279 // find a proper group
280 auto i = m_counts.find ( grp ) ;
281 // (create a group if needed)
282 if ( m_counts.end() == i )
283 { i = m_counts.emplace ( grp , NameMap() ).first ; }
284 // insert new counter with proper name into proper group:
285 i->second.emplace( nam , newc );
286 return StatusCode::SUCCESS ; // RETURN
287 }
GaudiUtils::Map::emplace
std::pair< iterator, bool > emplace(Args &&...args)
Definition: Map.h:166
CounterSvc::NameMap
GaudiUtils::HashMap< std::string, Counter * > NameMap
Definition: CounterSvc.cpp:208
GaudiUtils::Map::end
iterator end()
Definition: Map.h:132
StatusCode::SUCCESS
Definition: StatusCode.h:30
CounterSvc::m_counts
CountMap m_counts
the actual map of counters
Definition: CounterSvc.cpp:211
GaudiUtils::Map::find
iterator find(const key_type &key)
Definition: Map.h:149
ana.i
list i
Definition: ana.py:128

CounterSvc::CountObject CounterSvc::create | ( | const std::string & | group,
|  | const std::string & | name,
|  | longlong | initial_value = `0`
| ) |  |
| override

Create a new counter object.

If the counter object exists already, a std::runtime_error exception is thrown. The ownership of the actual counter stays with the service.

Parameters

  group | [IN] Hint for smart printing
  name | [IN] Counter name
  initial_value | [IN] Initial counter value
  refpCounter | [OUT] Reference to store pointer to counter.

Returns
  Fully initialized CountObject.

Definition at line 296 of file CounterSvc.cpp.

299 {
300 Counter* p = nullptr;
301 StatusCode sc = create ( group, name, initial_value, p ) ;
302 if ( sc.isSuccess() && p ) { return CountObject ( p , group , name ) ; }
303 throw std::runtime_error("CounterSvc::Counter('"+group+"::"+name+"') exists already!");
304 }
StatusCode::isSuccess
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:76
merge_files.sc
int sc
Definition: merge_files.py:167
CounterSvc::create
StatusCode create(const std::string &group, const std::string &name, longlong initial_value, Counter *&refpCounter) override
Create a new counter object.
Definition: CounterSvc.cpp:265
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
std::runtime_error
STL class.

StatusCode CounterSvc::defaultPrintout | ( | MsgStream & | log,
|  | const Counter * | pCounter
| ) |  | const
| override

Default Printout for counters.

Definition at line 420 of file CounterSvc.cpp.

422 {
423 if ( !c ) { return StatusCode::FAILURE ; }
424 auto p = _find ( c ) ;
425
426 log << MSG::ALWAYS
427 << CountObject( const_cast<Counter*>(c) , p.first , p.second )
428 << endmsg ;
429
430 return StatusCode::SUCCESS;
431 }
CounterSvc::_find
std::pair< std::string, std::string > _find(const Counter *c) const
Definition: CounterSvc.cpp:182
gaudirun.c
tuple c
Definition: gaudirun.py:391
StatusCode::FAILURE
Definition: StatusCode.h:29
StatusCode::SUCCESS
Definition: StatusCode.h:30
MSG::ALWAYS
Definition: IMessageSvc.h:23
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244

StatusCode CounterSvc::finalize | ( |  | ) |
| inline override

Finalization.

< finalize the base class

Definition at line 60 of file CounterSvc.cpp.

61 {
62 if ( msgLevel(MSG::DEBUG) || m_print ) { print () ; }
63 remove().ignore() ;
64 // finalize the base class
65 return Service::finalize() ;
66 }
Service::finalize
StatusCode finalize() override
Definition: Service.cpp:193
MSG::DEBUG
Definition: IMessageSvc.h:18
CounterSvc::m_print
bool m_print
boolean flag to print statistics
Definition: CounterSvc.cpp:213
CounterSvc::print
void print() const
"standard" printout a'la GaudiCommon
Definition: CounterSvc.cpp:435
CommonMessagingBase::msgLevel
MSG::Level msgLevel() const
get the output level from the embedded MsgStream
Definition: CommonMessaging.h:136

CounterSvc::Counter * CounterSvc::get | ( | const std::string & | group,
|  | const std::string & | name
| ) |  | const
| override

Access an existing counter object.

Parameters

  group | [IN] Hint for smart printing
  name | [IN] Counter name

Returns
  Pointer to existing counter object (NULL if non existing).

Definition at line 231 of file CounterSvc.cpp.

233 {
234 auto i = m_counts.find ( grp ) ;
235 if ( m_counts.end() == i ) { return nullptr ; } // RETURN
236 auto j = i->second.find ( nam ) ;
237 if ( i->second.end() == j ) { return nullptr ; } // RETURN
238 return j->second ; // RETURN
239 }
GaudiUtils::Map::end
iterator end()
Definition: Map.h:132
CounterSvc::m_counts
CountMap m_counts
the actual map of counters
Definition: CounterSvc.cpp:211
GaudiUtils::Map::find
iterator find(const key_type &key)
Definition: Map.h:149
ana.i
list i
Definition: ana.py:128

ICounterSvc::Counters CounterSvc::get | ( | const std::string & | group | ) | const
| override

get all counters form the given group:

Definition at line 243 of file CounterSvc.cpp.

244 {
245 ICounterSvc::Counters result ;
246 auto i = m_counts.find ( group ) ;
247 if ( i != m_counts.end() ) {
248 std::transform( i->second.begin(), i->second.end(),
249 std::back_inserter(result),
250 [&](const NameMap::value_type& j) {
251 return CountObject{ j.second, i->first, j.first };
252 } );
253 }
254 return result ;
255 }
GaudiUtils::Map::end
iterator end()
Definition: Map.h:132
GaudiUtils::Map::value_type
std::pair< const K, T > value_type
Definition: Map.h:94
CounterSvc::m_counts
CountMap m_counts
the actual map of counters
Definition: CounterSvc.cpp:211
GaudiUtils::Map::find
iterator find(const key_type &key)
Definition: Map.h:149
std::vector
STL class.
std::back_inserter
T back_inserter(T...args)
std::transform
T transform(T...args)
ana.i
list i
Definition: ana.py:128

size_t CounterSvc::num | ( |  | ) | const
| inline private

Definition at line 196 of file CounterSvc.cpp.

197 {
198 return std::accumulate( m_counts.begin(), m_counts.end(), size_t{0},
199 [](size_t r, const CountMap::value_type& i) {
200 return r + std::count_if(i.second.begin(),i.second.end(),
201 [](const NameMap::value_type& j) -> bool { return j.second; });
202 });
203 }
GaudiUtils::Map::end
iterator end()
Definition: Map.h:132
GaudiUtils::Map::value_type
std::pair< const K, T > value_type
Definition: Map.h:94
CounterSvc::m_counts
CountMap m_counts
the actual map of counters
Definition: CounterSvc.cpp:211
std::count_if
T count_if(T...args)
GaudiUtils::Map::begin
iterator begin()
Definition: Map.h:131
std::accumulate
T accumulate(T...args)
ana.i
list i
Definition: ana.py:128

StatusCode CounterSvc::print | ( | const std::string & | group,
|  | const std::string & | name,
|  | Printout & | printer
| ) |  | const
| override

Print counter value.

Parameters

  group | [IN] Hint for smart printing
  name | [IN] Counter name
  printer | [IN] Print actor

Returns
  StatusCode indicating failure or success.

Definition at line 345 of file CounterSvc.cpp.

348 {
349 const Counter* c = get( grp , nam ) ;
350 if ( !c ) { return COUNTER_NOT_PRESENT ; } // RETURN
351 // create the stream and use it!
352 return printer ( msgStream() , c ) ;
353 }
gaudirun.c
tuple c
Definition: gaudirun.py:391
CommonMessagingBase::msgStream
MsgStream & msgStream() const
Return an uninitialized MsgStream.
Definition: CommonMessaging.h:89

StatusCode CounterSvc::print | ( | const std::string & | group,
|  | Printout & | printer
| ) |  | const
| override

If no such counter exists the return code is COUNTER_NOT_PRESENT Note: This call is not direct access.

Parameters

  group | [IN] Hint for smart printing
  printer | [IN] Print actor

Returns
  StatusCode indicating failure or success.

Definition at line 375 of file CounterSvc.cpp.

377 {
378 auto i = m_counts.find ( grp ) ;
379 if ( m_counts.end() == i ) { return COUNTER_NOT_PRESENT ; }
380
381 // Force printing in alphabetical order
382 std::map<std::string, Counter*> sorted_map(i->second.begin(), i->second.end());
383 std::for_each(sorted_map.begin(), sorted_map.end(),
384 conditionalPrint(printer, msgStream()));
385 return StatusCode::SUCCESS; // RETURN
386 }
std::map
STL class.
GaudiUtils::Map::end
iterator end()
Definition: Map.h:132
StatusCode::SUCCESS
Definition: StatusCode.h:30
CounterSvc::m_counts
CountMap m_counts
the actual map of counters
Definition: CounterSvc.cpp:211
GaudiUtils::Map::find
iterator find(const key_type &key)
Definition: Map.h:149
CommonMessagingBase::msgStream
MsgStream & msgStream() const
Return an uninitialized MsgStream.
Definition: CommonMessaging.h:89
std::for_each
T for_each(T...args)
ana.i
list i
Definition: ana.py:128

StatusCode CounterSvc::print | ( | const Counter * | pCounter,
|  | Printout & | printer
| ) |  | const
| override

Print counter value.

Parameters

  pCounter | [IN] Pointer to Counter object
  printer | [IN] Print actor

Returns
  StatusCode indicating failure or success.

Definition at line 391 of file CounterSvc.cpp.

393 {
394 return printer ( msgStream() , pCounter ) ;
395 }
CommonMessagingBase::msgStream
MsgStream & msgStream() const
Return an uninitialized MsgStream.
Definition: CommonMessaging.h:89

StatusCode CounterSvc::print | ( | const CountObject & | pCounter,
|  | Printout & | printer
| ) |  | const
| override

Print counter value.

Parameters

  refCounter | [IN] Reference to CountObject object
  printer | [IN] Print actor

Returns
  StatusCode indicating failure or success.

Definition at line 400 of file CounterSvc.cpp.

402 { return print( refCounter.counter() , printer ) ; }
CounterSvc::print
void print() const
"standard" printout a'la GaudiCommon
Definition: CounterSvc.cpp:435

StatusCode CounterSvc::print | ( | Printout & | printer | ) | const
| override

Parameters

  printer | [IN] Print actor

Returns
  StatusCode indicating failure or success.

Definition at line 406 of file CounterSvc.cpp.

407 {
408 // Force printing in alphabetical order
409 std::map<std::pair<std::string,std::string>, Counter*> sorted_map;
410 for ( const auto& i : m_counts ) for ( const auto& j : i.second )
411 sorted_map[ { i.first, j.first } ] = j.second;
412 std::for_each(sorted_map.begin(), sorted_map.end(),
413 conditionalPrint(printer, msgStream()));
414 return StatusCode::SUCCESS;
415 }
std::map::end
T end(T...args)
std::map
STL class.
StatusCode::SUCCESS
Definition: StatusCode.h:30
CounterSvc::m_counts
CountMap m_counts
the actual map of counters
Definition: CounterSvc.cpp:211
std::map::begin
T begin(T...args)
CommonMessagingBase::msgStream
MsgStream & msgStream() const
Return an uninitialized MsgStream.
Definition: CommonMessaging.h:89
std::for_each
T for_each(T...args)
ana.i
list i
Definition: ana.py:128

void CounterSvc::print | ( |  | ) | const

"standard" printout a'la GaudiCommon

Definition at line 435 of file CounterSvc.cpp.

436 {
437 // number of counters
438 const auto _num = num() ;
439 if ( 0 != _num )
440 {
441 always()
442 << "Number of counters : " << _num << endmsg
443 << m_header << endmsg ;
444 }
445 // Force printing in alphabetical order
446 std::map<std::pair<std::string,std::string>, Counter*> sorted_map;
447 for ( const auto& i : m_counts ) {
448 for ( const auto& j : i.second ) {
449 if ( j.second ) sorted_map[ {i.first, j.first} ] = j.second;
450 }
451 }
452 for ( const auto& i : sorted_map ) {
453 always() << Gaudi::Utils::formatAsTableRow( i.first.second
454 , i.first.first
455 , *i.second
456 , m_useEffFormat
457 , m_format1
458 , m_format2 )
459 << endmsg ;
460 }
461 }
CounterSvc::m_header
std::string m_header
the header row
Definition: CounterSvc.cpp:215
CounterSvc::m_useEffFormat
bool m_useEffFormat
flag to use the special "efficiency" format
Definition: CounterSvc.cpp:221
CounterSvc::m_format2
std::string m_format2
format for "efficiency" statistical printout rows
Definition: CounterSvc.cpp:219
std::map
STL class.
Gaudi::Utils::formatAsTableRow
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
Definition: StatEntity.cpp:299
CounterSvc::m_counts
CountMap m_counts
the actual map of counters
Definition: CounterSvc.cpp:211
CounterSvc::m_format1
std::string m_format1
format for regular statistical printout rows
Definition: CounterSvc.cpp:217
CommonMessagingBase::always
MsgStream & always() const
shortcut for the method msgStream(MSG::ALWAYS)
Definition: CommonMessaging.h:109
CounterSvc::num
size_t num() const
Definition: CounterSvc.cpp:196
ana.i
list i
Definition: ana.py:128
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244

StatusCode CounterSvc::remove | ( | const std::string & | group,
|  | const std::string & | name
| ) |  |
| override

Remove a counter object.

If the counter object does not exists, the return code is COUNTER_NOT_PRESENT. The counter may not be used anymore after this call.

Parameters

  group | [IN] Hint for smart printing
  name | [IN] Counter name
  initial_value | [IN] Initial counter value
  refpCounter | [OUT] Reference to store pointer to counter.

Returns
  StatusCode indicating failure or success.

Definition at line 309 of file CounterSvc.cpp.

311 {
312 auto i = m_counts.find ( grp ) ;
313 if ( m_counts.end() == i ) { return COUNTER_NOT_PRESENT ; } // RETURN
314 auto j = i->second.find ( nam ) ;
315 if ( i->second.end() == j ) { return COUNTER_NOT_PRESENT ; } // RETURN
316 delete j->second ;
317 i->second.erase ( j ) ;
318 return StatusCode::SUCCESS ;
319 }
GaudiUtils::Map::end
iterator end()
Definition: Map.h:132
StatusCode::SUCCESS
Definition: StatusCode.h:30
CounterSvc::m_counts
CountMap m_counts
the actual map of counters
Definition: CounterSvc.cpp:211
GaudiUtils::Map::find
iterator find(const key_type &key)
Definition: Map.h:149
ana.i
list i
Definition: ana.py:128

StatusCode CounterSvc::remove | ( | const std::string & | group | ) |
| override

Remove all counters of a given group.

If no such counter exists the return code is COUNTER_NOT_PRESENT

Parameters

  group | [IN] Hint for smart printing

Returns
  StatusCode indicating failure or success.

Definition at line 323 of file CounterSvc.cpp.

324 {
325 auto i = m_counts.find ( grp ) ;
326 if ( m_counts.end() == i ) { return COUNTER_NOT_PRESENT ; } // RETURN
327 for ( auto& j : i->second ) delete j.second ;
328 i->second.clear() ;
329 return StatusCode::SUCCESS ;
330 }
GaudiUtils::Map::end
iterator end()
Definition: Map.h:132
StatusCode::SUCCESS
Definition: StatusCode.h:30
CounterSvc::m_counts
CountMap m_counts
the actual map of counters
Definition: CounterSvc.cpp:211
GaudiUtils::Map::find
iterator find(const key_type &key)
Definition: Map.h:149
ana.i
list i
Definition: ana.py:128

StatusCode CounterSvc::remove | ( |  | ) |
| virtual

Remove all known counter objects.

Definition at line 334 of file CounterSvc.cpp.

335 {
336 // remove group by group
337 for ( auto& i : m_counts ) remove ( i.first ).ignore () ;
338 m_counts.clear() ;
339 return StatusCode::SUCCESS;
340 }
StatusCode::SUCCESS
Definition: StatusCode.h:30
CounterSvc::m_counts
CountMap m_counts
the actual map of counters
Definition: CounterSvc.cpp:211
ana.i
list i
Definition: ana.py:128

## Member Data Documentation

CountMap CounterSvc::m_counts
| private

the actual map of counters

Definition at line 211 of file CounterSvc.cpp.

std::string CounterSvc::m_format1
| private

format for regular statistical printout rows

Definition at line 217 of file CounterSvc.cpp.

std::string CounterSvc::m_format2
| private

format for "efficiency" statistical printout rows

Definition at line 219 of file CounterSvc.cpp.

std::string CounterSvc::m_header
| private

the header row

Definition at line 215 of file CounterSvc.cpp.

bool CounterSvc::m_print = true
| private

boolean flag to print statistics

Definition at line 213 of file CounterSvc.cpp.

bool CounterSvc::m_useEffFormat = true
| private

flag to use the special "efficiency" format

Definition at line 221 of file CounterSvc.cpp.

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

- GaudiCommonSvc/src/CounterSvc.cpp