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