BOSS 7.0.6
BESIII Offline Software System
Loading...
Searching...
No Matches
HltEventMaker.cxx
Go to the documentation of this file.
1#include "GaudiKernel/AlgFactory.h"
2#include "GaudiKernel/MsgStream.h"
3#include "GaudiKernel/ISvcLocator.h"
4#include "GaudiKernel/SmartDataPtr.h"
5#include "GaudiKernel/IDataProviderSvc.h"
6#include "GaudiKernel/PropertyMgr.h"
7
9#include "HltEvent/HltInf.h"
10#include "HltEvent/HltRaw.h"
11#include "TofRawEvent/TofDigi.h"
13#include "EventModel/Event.h"
16#include "Identifier/HltID.h"
17
18using namespace Event;
19
20HltEventMaker::HltEventMaker(const std::string& name, ISvcLocator* pSvcLocator) : Algorithm(name, pSvcLocator)
21{
22 //Declare the properties
23}
24
26 MsgStream log(msgSvc(), name());
27 log << MSG::DEBUG << "HltEventMaker: in initialize()" << endreq;
28 m_ntot=0;
29
30 return StatusCode::SUCCESS;
31}
32
34 MsgStream log(msgSvc(),name());
35 log<<MSG::DEBUG<< "HltEventMaker: in execute()" <<endreq;
36
37 // Get the event header, print out event and run number
38 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),"/Event/EventHeader");
39 if (!eventHeader) {
40 log << MSG::FATAL << "Could not find Event Header" << endreq;
41 return StatusCode::FAILURE;
42 }
43
44 int eventId = eventHeader->eventNumber() ;
45 int runId = eventHeader->runNumber();
46 log << MSG::INFO << "HltEventMaker: retrieved event: " <<" Event Number "<< eventId << " run: " <<runId << endreq;
47
48 HltInf* aHlt = new HltInf();
49 //Get EventFilter information from TDS
50 SmartDataPtr<HltRawCol> hltRawCol(eventSvc(),"/Event/Hlt/HltRawCol");
51 if (!hltRawCol) {
52 log << MSG::DEBUG << "Could not find HltRawCol!" << endreq;
53 //return StatusCode::SUCCESS;
54 }
55 else{
56 uint32_t type=0,alg=0,cri=0,ver=0;
57 float etot=0;
58 uint32_t nmdc=0xFF,ntof=0xFF,nemc=0xFF,nmuc=0xFF;
59
60 HltRawCol::iterator iter = hltRawCol->begin();
61 for (;iter != hltRawCol->end(); iter++ ) {
62 Identifier id = (*iter)->identify();
63 log << MSG::VERBOSE << "EventFilter info id: " << hex << id << ": "
64 << (*iter)->getIntChannel() << ","<< dec << (*iter)->getFloatChannel() <<endreq;
65 if(HltID::is_eventtype(id)) aHlt->setEventType(type=(*iter)->getIntChannel());
66 if(HltID::is_algorithm(id)) aHlt->setAlgProcess(alg=(*iter)->getIntChannel());
67 if(HltID::is_criteria(id)) aHlt->setCriteriaTable(cri=(*iter)->getIntChannel());
68 if(HltID::is_version(id)) aHlt->setVersion(ver=(*iter)->getIntChannel());
69 if(HltID::is_energy(id)) aHlt->setTotalEnergy(etot=(*iter)->getFloatChannel());
70
71 uint32_t pureid= id&0xFF;
72 if(HltID::is_number(id)){
73 uint32_t datanum=(*iter)->getIntChannel();
74 aHlt->setNumber(datanum);
75 nmdc=datanum&0xFF;
76 ntof=(datanum&0xFF00)>>8;
77 nemc=(datanum&0xFF0000)>>16;
78 nmuc=(datanum&0xFF000000)>>24;
79 log << MSG::VERBOSE << nmdc << ", " << ntof << ", " << nemc << ", " << nmuc << endreq;
80 }
81 else if(HltID::is_mdc_inf(id)){
82 aHlt->push_mdc((*iter)->getIntChannel());
83 }
84 else if(HltID::is_tof_inf(id)){
85 aHlt->push_tof((*iter)->getIntChannel());
86 }
87 else if(HltID::is_emc_inf(id)){
88 aHlt->push_emc((*iter)->getIntChannel());
89 }
90 else if(HltID::is_muc_inf(id)){
91 aHlt->push_muc((*iter)->getIntChannel());
92 }
93 else if(HltID::is_con_inf(id)){
94 if(HltID::is_ncon(id)) aHlt->setNCON((*iter)->getIntChannel());
95 else aHlt->push_con((*iter)->getIntChannel());
96 }
97 }
98 log<<MSG::DEBUG<<"type="<<type<<", alg="<<alg<<", criteria="<<cri
99 <<", version="<<ver<<", energy="<<etot<<endreq;
100
101 m_ntot++;
102 }
103 //Register related event filter information to TDS for physics analysis
104 StatusCode sc;
105 DataObject *aHltInfEvent;
106 eventSvc()->findObject("/Event/Hlt/HltInf", aHltInfEvent);
107 if(aHltInfEvent!=NULL) {
108 SmartDataPtr<HltInf> hltInf(eventSvc(),"/Event/Hlt/HltInf");
109 log<<MSG::DEBUG<<"old type="<<hltInf->getEventType()<<", alg="<<hltInf->getAlgProcess()
110 <<", criteria="<<hltInf->getCriteriaTable()<<", version="<<hltInf->getVersion()
111 <<", energy="<<hltInf->getTotalEnergy()<<endreq;
112 //then unregister HltInf
113 sc = eventSvc()->unregisterObject("/Event/Hlt/HltInf");
114 delete aHltInfEvent; //it must be delete to avoid memory leakage
115 log << MSG::INFO << "Old HltInf has been unregistered" << endreq;
116 if(sc!=StatusCode::SUCCESS) {
117 log << MSG::FATAL << "Could not unregister HltInf" << endreq;
118 return( StatusCode::FAILURE);
119 }
120 }
121 sc = eventSvc()->registerObject(EventModel::Hlt::HltInf,aHlt);
122 if(sc!=StatusCode::SUCCESS) {
123 log<<MSG::FATAL<< "Could not register HltInf" <<endreq;
124 return StatusCode::FAILURE;
125 }
126
127 return StatusCode::SUCCESS;
128}
129
131 MsgStream log(msgSvc(), name());
132 log << MSG::DEBUG << "==> Finalize HltEventMaker" << endreq;
133 log << MSG::ALWAYS << m_ntot << " events are converted." <<endreq;
134 return StatusCode::SUCCESS;
135}
EvtStreamInputIterator< typename Generator::result_type > iter(Generator gen, int N=0)
IMessageSvc * msgSvc()
void setAlgProcess(const unsigned int i)
Definition: DstHltInf.h:31
void setCriteriaTable(const unsigned int i)
Definition: DstHltInf.h:32
void setNumber(const unsigned int i)
Definition: DstHltInf.h:35
void setNCON(const unsigned int i)
Definition: DstHltInf.h:40
void setEventType(const unsigned int i)
Definition: DstHltInf.h:30
void setTotalEnergy(const float etot)
Definition: DstHltInf.h:34
void setVersion(const unsigned int i)
Definition: DstHltInf.h:33
StatusCode execute()
HltEventMaker(const std::string &name, ISvcLocator *pSvcLocator)
StatusCode finalize()
StatusCode initialize()
static bool is_ncon(const Identifier &id)
Definition: HltID.cxx:108
static bool is_tof_inf(const Identifier &id)
Definition: HltID.cxx:119
static bool is_version(const Identifier &id)
Definition: HltID.cxx:90
static bool is_con_inf(const Identifier &id)
Definition: HltID.cxx:134
static bool is_eventtype(const Identifier &id)
Definition: HltID.cxx:72
static bool is_algorithm(const Identifier &id)
Definition: HltID.cxx:78
static bool is_muc_inf(const Identifier &id)
Definition: HltID.cxx:129
static bool is_criteria(const Identifier &id)
Definition: HltID.cxx:84
static bool is_emc_inf(const Identifier &id)
Definition: HltID.cxx:124
static bool is_number(const Identifier &id)
Definition: HltID.cxx:102
static bool is_mdc_inf(const Identifier &id)
Definition: HltID.cxx:114
static bool is_energy(const Identifier &id)
Definition: HltID.cxx:96
Definition: HltInf.h:16
virtual void push_muc(uint32_t data)
Definition: HltInf.h:34
virtual void push_mdc(uint32_t data)
Definition: HltInf.h:31
virtual void push_tof(uint32_t data)
Definition: HltInf.h:32
virtual void push_con(uint32_t data)
Definition: HltInf.h:35
virtual void push_emc(uint32_t data)
Definition: HltInf.h:33
_EXTERN_ std::string HltInf
Definition: EventModel.h:74
Definition: Event.h:21