CGEM BOSS 6.6.5.i
BESIII Offline Software System
Loading...
Searching...
No Matches
BesTimerSvc.cxx
Go to the documentation of this file.
1// this is -*- c++ -*-
2// $Id: BesTimerSvc.cxx,v 1.4 2011/02/18 04:23:58 maqm Exp $
3// $Name: BesTimerSvc-00-00-12 $
4#include <algorithm>
5#include <string>
6#include <vector>
7#include "GaudiKernel/Kernel.h"
8#include "GaudiKernel/IInterface.h"
9#include "GaudiKernel/StatusCode.h"
10//#include "GaudiKernel/ISvcFactory.h"
11#include "GaudiKernel/SvcFactory.h"
12#include "GaudiKernel/MsgStream.h"
14
15
16BesTimerSvc::BesTimerSvc( const std::string& name, ISvcLocator* svcloc ) : Service(name, svcloc) {}
17
19 std::vector < BesTimer* >::iterator it = m_itemList.begin();
20 for (; it != m_itemList.end(); it++) {
21 delete (*it);
22 }
23}
24
25StatusCode BesTimerSvc::queryInterface (const InterfaceID& riid, void** ppvInterface ) {
26
27 if ( IID_IBesTimerSvc.versionMatch(riid) ) {
28 *ppvInterface = static_cast<IBesTimerSvc*> (this);
29 } else {
30 return Service::queryInterface(riid, ppvInterface) ;
31 }
32 return StatusCode::SUCCESS;
33}
35 MsgStream log(messageService(), name());
36 log << MSG::INFO << name() << ": Start of run initialisation" << endreq;
37
38 StatusCode sc = Service::initialize();
39 if ( sc.isFailure() ) return sc;
40 // Set my own properties
41 setProperties();
42
43 return StatusCode::SUCCESS;
44}
45
46
47StatusCode BesTimerSvc::finalize ( ) {
48 MsgStream log(messageService(), name());
49 log << MSG::INFO << name() << ": End of Run Statistics" << endreq;
50 this->print();
51 return StatusCode::SUCCESS;
52}
53
54
55
56BesTimer* BesTimerSvc::addItem(const std::string &itemName) {
57
58 // Create a BesTimer and return a pointer to it
59 // If an item of that name already exists, flag error
60 // by returning NULL
61
62 MsgStream log(messageService(), name());
63 log << MSG::DEBUG << name() << " adding " << itemName << endreq;
64
65 BesTimer* item = new BesTimer(itemName);
66 m_itemList.push_back(item);
67 return item;
68}
69
71 MsgStream log(messageService(), name());
72
73 log << MSG::INFO << "==============================BesTimerSvc::Print===============================" << endreq;
74 unsigned int maxname=0;
75 std::vector < BesTimer* >::iterator it = m_itemList.begin();
76 for (; it != m_itemList.end(); it++) {
77 if ((*it)->name().length() > maxname) maxname = static_cast<int>((*it)->name().length());
78 if (!(*it)->propName().empty()) {
79 if ((*it)->propName().length() > maxname) maxname = static_cast<int>((*it)->propName().length());
80 }
81 }
82
83 it = m_itemList.begin();
84 for (; it != m_itemList.end(); it++) {
85 std::string nam = (*it)->name();
86 for (unsigned int i = static_cast<int>(nam.length()); i<maxname; i++) nam.insert(i," ");
87 log << MSG::INFO << nam << " mean(t) : " << std::setw(12) << (*it)->mean()<<
88 " ms rms : " << std::setw(12) << (*it)->rms() << " ms " << endreq;
89 }
90 log << MSG::INFO << "------------------------------------------------------------------------------" << endreq;
91 it = m_itemList.begin();
92 for (; it != m_itemList.end(); it++) {
93 if (!(*it)->propName().empty()) {
94 std::string nam = (*it)->name();
95 for (unsigned int i = static_cast<int>(nam.length()); i<maxname; i++) nam.insert(i," ");
96 log << MSG::INFO << nam << " mean(t) : " << std::setw(12) << (*it)->mean()<<
97 " ms rms : " << std::setw(12) << (*it)->rms() << " ms " << endreq;
98
99 nam = (*it)->propName();
100 for (unsigned int i = static_cast<int>(nam.length()); i<maxname; i++) nam.insert(i," ");
101 if ((*it)->meanPropVal() == 0) {
102 log << MSG::INFO << nam << " mean(N) : " << std::setw(12) << endreq;
103 } else {
104 log << MSG::INFO << nam << " mean(N) : " << std::setw(12) << (*it)->meanPropVal() <<
105 " mean(t/N) : "
106 << 1000.*(*it)->meanTimePerObject() << " us " << endreq;
107 }
108 }
109 }
110
111 log << MSG::INFO << "==============================BesTimerSvc::Print===============================" << endreq;
112 }
113
114std::vector < BesTimer* >::iterator BesTimerSvc::begin( void ) {
115 return m_itemList.begin();
116}
117std::vector < BesTimer* >::iterator BesTimerSvc::end( void ){
118 return m_itemList.end();
119}
120
double length
virtual std::vector< BesTimer * >::iterator begin(void)
virtual BesTimer * addItem(const std::string &name)
virtual StatusCode queryInterface(const InterfaceID &riid, void **ppvUnknown)
virtual StatusCode initialize()
virtual void print()
virtual StatusCode finalize()
virtual std::vector< BesTimer * >::iterator end(void)
BesTimerSvc(const std::string &name, ISvcLocator *svcloc)