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