BOSS 7.1.1
BESIII Offline Software System
Loading...
Searching...
No Matches
RunEventNumber.cxx
Go to the documentation of this file.
1#include "GaudiKernel/MsgStream.h"
2#include "GaudiKernel/AlgFactory.h"
3#include "GaudiKernel/ISvcLocator.h"
4#include "GaudiKernel/SmartDataPtr.h"
5#include "GaudiKernel/IDataProviderSvc.h"
6#include "GaudiKernel/PropertyMgr.h"
7#include "GaudiKernel/Bootstrap.h"
8
10#include "EventModel/Event.h"
12
14#include <time.h>
15
16time_t rawtime;
17
18
19/////////////////////////////////////////////////////////////////////////////
20
21DECLARE_COMPONENT(RunEventNumber)
22
23RunEventNumber::RunEventNumber(const std::string& name, ISvcLocator* pSvcLocator) :
24 Algorithm(name, pSvcLocator) {
25
26 //Declare the properties
27 declareProperty("Period", m_period = 0);
28
29}
30
31// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
33 MsgStream log(msgSvc(), name());
34
35 log << MSG::INFO << "in initialize()" << endmsg;
36 StatusCode sc;
37
38 numEvents = 0;
39 numRuns = 0;
40 prevRun = 0;
41
42 log << MSG::INFO << "successfully return from initialize()" <<endmsg;
43 return StatusCode::SUCCESS;
44
45}
46
47// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
49
50 MsgStream log(msgSvc(), name());
51 log << MSG::INFO << "in execute()" << endreq;
52
53 numEvents++;
54
55 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),"/Event/EventHeader");
56 int runNum=eventHeader->runNumber();
57 int eventNum=eventHeader->eventNumber();
58
59 if(runNum != prevRun) {
60 numRuns++;
61 prevRun = runNum;
62 }
63
64 if((m_period != 0)&&(numEvents % m_period == 0)) {
65 time ( &rawtime );
66 std::cout << " RunEventNumberAlg: Run, event, time = "
67 << runNum << ", " << eventNum << ", " << asctime(localtime(&rawtime));
68 }
69
70 return StatusCode::SUCCESS;
71}
72
73
74// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
76
77 MsgStream log(msgSvc(), name());
78 log << MSG::INFO << "in finalize()" << endmsg;
79
80 std::cout << std::endl;
81 std::cout << " RunEventNumberAlg: Number of processed runs = " << numRuns << std::endl;
82 std::cout << " RunEventNumberAlg: Number of processed events = " << numEvents << std::endl;
83 std::cout << std::endl;
84
85 return StatusCode::SUCCESS;
86}
87
Double_t time
time_t rawtime
IMessageSvc * msgSvc()
StatusCode initialize()
StatusCode execute()
StatusCode finalize()