CGEM BOSS 6.6.5.f
BESIII Offline Software System
Loading...
Searching...
No Matches
DstHltMaker.cxx
Go to the documentation of this file.
1#include "HltMakerAlg/DstHltMaker.h"
2
3#include "GaudiKernel/MsgStream.h"
4#include "GaudiKernel/AlgFactory.h"
5#include "GaudiKernel/ISvcLocator.h"
6#include "GaudiKernel/SmartDataPtr.h"
7#include "GaudiKernel/IDataProviderSvc.h"
8#include "GaudiKernel/PropertyMgr.h"
9
10#include "EventModel/EventModel.h"
11#include "EventModel/Event.h"
12#include "EventModel/EventHeader.h"
13
14#include "HltEvent/HltEvent.h"
15#include "HltEvent/HltInf.h"
16#include "HltEvent/DstHltInf.h"
17
18using namespace std;
19using namespace Event;
20
21/////////////////////////////////////////////////////////////////////////////
22
23DstHltMaker::DstHltMaker(const std::string& name, ISvcLocator* pSvcLocator) :
24 Algorithm(name, pSvcLocator)
25{
26 // Declare the properties
27 // declareProperty("FittingMethod", m_fittingMethod = 2);
28 // declareProperty("ConfigFile", m_configFile = "MDCConfig.xml");
29}
30
31// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
33
34 MsgStream log(msgSvc(), name());
35 log << MSG::INFO << "in initialize()" << endreq;
36
37 m_ntot=0;
38
39 return StatusCode::SUCCESS;
40}
41
42// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
44
45 MsgStream log(msgSvc(), name());
46 log << MSG::INFO << "in execute()" << endreq;
47
48 // Part 1: Get the event header, print out event and run number
49
50 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),"/Event/EventHeader");
51 if (!eventHeader) {
52 log << MSG::FATAL << "Could not find Event Header" << endreq;
53 return( StatusCode::FAILURE);
54 }
55
56 int eventId = eventHeader->eventNumber() ;
57 int runId = eventHeader->runNumber();
58 log << MSG::INFO << "DstHltMaker: retrieved event: " <<" Event Number "<< eventId << " run: " <<runId << endreq;
59
60 StatusCode sc = StatusCode::SUCCESS ;
61
62 // register ReconEvent Data Object to TDS; 2005/09/14
63 //HltEvent* hltEvt = new HltEvent();
64 //sc = eventSvc()->registerObject(EventModel::Hlt::Event, hltEvt);
65
66 //Part 2: Retrieve
67 DstHltInf* dstHltInf = new DstHltInf();
68 SmartDataPtr<HltInf> recHltInf(eventSvc(),"/Event/Hlt/HltInf");
69 //SmartDataPtr<DstHltInf> recHltInf(eventSvc(),"/Event/Hlt/DstHltInf");
70 if (!recHltInf) {
71 log << MSG::DEBUG << "Could not find HltInf" << endreq;
72 //return StatusCode::SUCCESS;
73 } else {
74 dstHltInf->setEventType(recHltInf->getEventType());
75 dstHltInf->setAlgProcess(recHltInf->getAlgProcess());
76 dstHltInf->setCriteriaTable(recHltInf->getCriteriaTable());
77 dstHltInf->setVersion(recHltInf->getVersion());
78 dstHltInf->setTotalEnergy(recHltInf->getTotalEnergy());
79 dstHltInf->setNumber(recHltInf->getNumber());
80 dstHltInf->setNCON(recHltInf->getNCON());
81 m_ntot++;
82 }
83 DataObject *aDstHltInfEvent;
84 eventSvc()->findObject("/Event/Hlt/DstHltInf", aDstHltInfEvent);
85 if(aDstHltInfEvent!=NULL) {
86 SmartDataPtr<DstHltInf> hltInf(eventSvc(),"/Event/Hlt/DstHltInf");
87 log<<MSG::DEBUG<<"old type="<<hltInf->getEventType()<<", alg="<<hltInf->getAlgProcess()
88 <<", criteria="<<hltInf->getCriteriaTable()<<", version="<<hltInf->getVersion()
89 <<", energy="<<hltInf->getTotalEnergy()<<endreq;
90 //then unregister DstHltInf
91 sc = eventSvc()->unregisterObject("/Event/Hlt/DstHltInf");
92 delete aDstHltInfEvent; //it must be delete to avoid memory leakage
93 log << MSG::INFO << "Old DstHltInf has been unregistered" << endreq;
94 if(sc!=StatusCode::SUCCESS) {
95 log << MSG::FATAL << "Could not unregister DstHltInf" << endreq;
96 return( StatusCode::FAILURE);
97 }
98 }
99 sc = eventSvc()->registerObject(EventModel::Hlt::DstHltInf,dstHltInf);
100
101 log << MSG::DEBUG <<"Event No."<<eventId<<" = "
102 << dstHltInf->getEventType()<<" "
103 << dstHltInf->getAlgProcess()<<" "
104 << dstHltInf->getCriteriaTable()<<" "
105 << dstHltInf->getVersion()<<" "
106 << dstHltInf->getTotalEnergy()<<endreq;
107
108 return sc;
109}
110
111// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
113
114 MsgStream log(msgSvc(), name());
115 log << MSG::DEBUG << "==> Finalize DstHltMaker" << endreq;
116 log << MSG::ALWAYS << m_ntot << " events are converted." <<endreq;
117
118 return StatusCode::SUCCESS;
119}
StatusCode execute()
Definition: DstHltMaker.cxx:43
StatusCode initialize()
Definition: DstHltMaker.cxx:32
StatusCode finalize()
DstHltMaker(const std::string &name, ISvcLocator *pSvcLocator)
Definition: DstHltMaker.cxx:23