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