/home/bes3soft/bes3soft/Boss/7.0.2/dist/7.0.2/Reconstruction/T0Dummy/T0Dummy-00-00-05/src/T0Dummy.cxx

Go to the documentation of this file.
00001 #include "GaudiKernel/MsgStream.h"
00002 #include "GaudiKernel/AlgFactory.h"
00003 #include "GaudiKernel/ISvcLocator.h"
00004 #include "GaudiKernel/SmartDataPtr.h"
00005 #include "GaudiKernel/IDataManagerSvc.h"
00006 #include "GaudiKernel/Bootstrap.h"
00007 #include "GaudiKernel/StatusCode.h"
00008 #include "GaudiKernel/PropertyMgr.h"
00009 
00010 #include "T0Dummy/T0Dummy.h"
00011 #include "EventModel/Event.h"
00012 #include "EventModel/EventHeader.h"
00013 #include "EventModel/EventModel.h"
00014 #include "McTruth/McParticle.h"
00015 #include "EvTimeEvent/RecEsTime.h"
00016 
00017 using namespace Event;
00018 
00019 T0Dummy::T0Dummy(const std::string& name, ISvcLocator* pSvcLocator):
00020   Algorithm(name, pSvcLocator)
00021 {
00022 
00023 }
00024 
00025 StatusCode T0Dummy::initialize(){
00026 
00027   MsgStream log(msgSvc(), name());
00028   log << MSG::INFO << "in initialize()" << endreq;
00029 
00030   return StatusCode::SUCCESS;
00031 }
00032 
00033 StatusCode T0Dummy:: execute(){
00034 
00035   MsgStream log(msgSvc(), name());
00036   log << MSG::INFO << "in execute()" << endreq;
00037 
00038   // Part 1: Get the event header, print out event and run number
00039   SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),"/Event/EventHeader");
00040   if (!eventHeader) {
00041     log << MSG::FATAL << "Could not find Event Header" << endreq;
00042     return StatusCode::FAILURE;
00043   }
00044 
00045   int eventNo=eventHeader->eventNumber();
00046   int runNo=eventHeader->runNumber();
00047 
00048 
00049   if(runNo>0){
00050     log<<MSG::FATAL<<" Run No:"<<runNo<<" > 0"<<endreq;
00051     return StatusCode::FAILURE;
00052   }
00053 
00054   SmartDataPtr<Event::McParticleCol> mcParticleCol(eventSvc(),"/Event/MC/McParticleCol");
00055   if(!mcParticleCol){
00056     log<<MSG::FATAL<<"Could not retrieve McParticelCol"<<endreq;
00057     return StatusCode::FAILURE;
00058   }
00059 
00060   double mcTestime=-999.;
00061   Event::McParticleCol::iterator iter_mc = mcParticleCol->begin();
00062   for (;iter_mc != mcParticleCol->end(); iter_mc++){
00063     if((*iter_mc)->primaryParticle()){
00064       mcTestime=(*iter_mc)->initialPosition().t();
00065     }
00066   }
00067 
00068   //clear RecEsTimeCol
00069   SmartIF<IDataManagerSvc> dataManSvc(eventSvc());
00070   DataObject *aRecEsTime;
00071   eventSvc()->findObject("/Event/Recon/RecEsTimeCol",aRecEsTime);
00072   if(aRecEsTime!=NULL){
00073     dataManSvc->clearSubTree("/Event/Recon/RecEsTimeCol");
00074     eventSvc()->unregisterObject("/Event/Recon/RecEsTimeCol");
00075   }
00076 
00077   // register event start time to TDS
00078   RecEsTimeCol *aRecEsTimeCol = new RecEsTimeCol;
00079   StatusCode sc = eventSvc()->registerObject("/Event/Recon/RecEsTimeCol", aRecEsTimeCol);
00080   if(sc!=StatusCode::SUCCESS) {
00081     log << MSG::ERROR << "Could not register RecEsTimeCol" << endreq;
00082     return StatusCode::FAILURE;
00083   }
00084 
00085   RecEsTime *arecestime = new RecEsTime;
00086   arecestime->setTest(mcTestime);
00087   arecestime->setStat(-999);
00088 
00089   //std::cout<< " T0Dummy: "<< mcTestime<< std::endl;
00090   aRecEsTimeCol->push_back(arecestime);
00091 
00092   return StatusCode::SUCCESS;
00093 }
00094 
00095 StatusCode T0Dummy::finalize() {
00096 
00097   MsgStream log(msgSvc(), name());
00098   log << MSG::INFO << "in finalize()" << endreq;
00099 
00100   return StatusCode::SUCCESS;
00101 
00102 }

Generated on Tue Nov 29 23:14:09 2016 for BOSS_7.0.2 by  doxygen 1.4.7