CGEM BOSS 6.6.5.g
BESIII Offline Software System
Loading...
Searching...
No Matches
T0Dummy.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/IDataManagerSvc.h"
6#include "GaudiKernel/Bootstrap.h"
7#include "GaudiKernel/StatusCode.h"
8#include "GaudiKernel/PropertyMgr.h"
9
10#include "T0Dummy/T0Dummy.h"
11#include "EventModel/Event.h"
14#include "McTruth/McParticle.h"
16
17using namespace Event;
18
19T0Dummy::T0Dummy(const std::string& name, ISvcLocator* pSvcLocator):
20 Algorithm(name, pSvcLocator)
21{
22
23}
24
26
27 MsgStream log(msgSvc(), name());
28 log << MSG::INFO << "in initialize()" << endreq;
29
30 return StatusCode::SUCCESS;
31}
32
33StatusCode T0Dummy:: execute(){
34
35 MsgStream log(msgSvc(), name());
36 log << MSG::INFO << "in execute()" << endreq;
37
38 // Part 1: Get the event header, print out event and run number
39 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),"/Event/EventHeader");
40 if (!eventHeader) {
41 log << MSG::FATAL << "Could not find Event Header" << endreq;
42 return StatusCode::FAILURE;
43 }
44
45 int eventNo=eventHeader->eventNumber();
46 int runNo=eventHeader->runNumber();
47
48
49 if(runNo>0){
50 log<<MSG::FATAL<<" Run No:"<<runNo<<" > 0"<<endreq;
51 return StatusCode::FAILURE;
52 }
53
54 SmartDataPtr<Event::McParticleCol> mcParticleCol(eventSvc(),"/Event/MC/McParticleCol");
55 if(!mcParticleCol){
56 log<<MSG::FATAL<<"Could not retrieve McParticelCol"<<endreq;
57 return StatusCode::FAILURE;
58 }
59
60 double mcTestime=-999.;
61 Event::McParticleCol::iterator iter_mc = mcParticleCol->begin();
62 for (;iter_mc != mcParticleCol->end(); iter_mc++){
63 if((*iter_mc)->primaryParticle()){
64 mcTestime=(*iter_mc)->initialPosition().t();
65 }
66 }
67
68 //clear RecEsTimeCol
69 SmartIF<IDataManagerSvc> dataManSvc(eventSvc());
70 DataObject *aRecEsTime;
71 eventSvc()->findObject("/Event/Recon/RecEsTimeCol",aRecEsTime);
72 if(aRecEsTime!=NULL){
73 dataManSvc->clearSubTree("/Event/Recon/RecEsTimeCol");
74 eventSvc()->unregisterObject("/Event/Recon/RecEsTimeCol");
75 }
76
77 // register event start time to TDS
78 RecEsTimeCol *aRecEsTimeCol = new RecEsTimeCol;
79 StatusCode sc = eventSvc()->registerObject("/Event/Recon/RecEsTimeCol", aRecEsTimeCol);
80 if(sc!=StatusCode::SUCCESS) {
81 log << MSG::ERROR << "Could not register RecEsTimeCol" << endreq;
82 return StatusCode::FAILURE;
83 }
84
85 RecEsTime *arecestime = new RecEsTime;
86 arecestime->setTest(mcTestime);
87 arecestime->setStat(-999);
88
89 //std::cout<< " T0Dummy: "<< mcTestime<< std::endl;
90 aRecEsTimeCol->push_back(arecestime);
91
92 return StatusCode::SUCCESS;
93}
94
95StatusCode T0Dummy::finalize() {
96
97 MsgStream log(msgSvc(), name());
98 log << MSG::INFO << "in finalize()" << endreq;
99
100 return StatusCode::SUCCESS;
101
102}
int runNo
int eventNo
ObjectVector< RecEsTime > RecEsTimeCol
Definition: RecEsTime.h:53
IMessageSvc * msgSvc()
void setStat(int Stat)
Definition: RecEsTime.h:37
void setTest(double Test)
Definition: RecEsTime.h:36
StatusCode execute()
Definition: T0Dummy.cxx:33
T0Dummy(const std::string &name, ISvcLocator *pSvcLocator)
Definition: T0Dummy.cxx:19
StatusCode initialize()
Definition: T0Dummy.cxx:25
StatusCode finalize()
Definition: T0Dummy.cxx:95
Definition: Event.h:21