BOSS 7.0.3
BESIII Offline Software System
Loading...
Searching...
No Matches
RawEventReader.cxx
Go to the documentation of this file.
1#include "RawEventReader/RawEventReader.h"
2
3#include "GaudiKernel/MsgStream.h"
4#include "GaudiKernel/AlgFactory.h"
5#include "GaudiKernel/Bootstrap.h"
6#include "GaudiKernel/ISvcLocator.h"
7#include "GaudiKernel/SmartDataPtr.h"
8#include "GaudiKernel/IDataProviderSvc.h"
9#include "GaudiKernel/PropertyMgr.h"
10
11#include "RawDataCnv/EventManagement/RAWEVENT.h"
12#include "RawDataCnv/Util/MdcConverter.h"
13#include "RawDataCnv/Util/TofConverter.h"
14#include "RawDataCnv/Util/EmcConverter.h"
15#include "RawDataCnv/Util/MucConverter.h"
16#include "Identifier/Identifier.h"
17#include "Identifier/MdcID.h"
18#include "Identifier/TofID.h"
19#include "Identifier/EmcID.h"
20#include "Identifier/MucID.h"
21#include "IRawFile/RawFileExceptions.h"
22
23#include "RawFile/RawFileReader.h"
24#include "RawEvent/DigiEvent.h"
25
26#include "EventModel/EventModel.h"
27#include "EventModel/EventHeader.h"
28
29/////////////////////////////////////////////////////////////////////////////
30
31RawEventReader::RawEventReader(const std::string& name, ISvcLocator* pSvcLocator) :
32 Algorithm(name, pSvcLocator)
33{
34 m_mdcCnv = MdcConverter::instance();
35 m_tofCnv = TofConverter::instance();
36 m_emcCnv = EmcConverter::instance();
37 m_mucCnv = MucConverter::instance();
38
39 declareProperty("MdcDigi",m_mdcdigi=1);
40 declareProperty("TofDigi",m_tofdigi=1);
41 declareProperty("EmcDigi",m_emcdigi=1);
42 declareProperty("MucDigi",m_mucdigi=1);
43 declareProperty("InputFiles",m_inputFiles);
44
45}
46
48{
53}
54
55// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
57
58 MsgStream log(msgSvc(), name());
59 log << MSG::INFO << "in initialize()" << endreq;
60
61 m_raw_event = new RAWEVENT;
62
63 m_mdcCnv->init(0, 999999);
64
65 ISvcLocator* svcLocator = Gaudi::svcLocator();
66 StatusCode sc=svcLocator->service("EventDataSvc", m_evtSvc);
67 if (sc.isFailure())
68 std::cout<<"Could not accesss EventDataSvc!"<<std::endl;
69
70 return StatusCode::SUCCESS;
71}
72
73// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
75
76 MsgStream log(msgSvc(), name());
77 log << MSG::INFO << "in execute()" << endreq;
78
79 DigiEvent* aDigiEvent = new DigiEvent;
80 StatusCode sc = m_evtSvc->registerObject("/Event/Digi",aDigiEvent);
81 if(sc!=StatusCode::SUCCESS) {
82 std::cout<< "Could not register DigiEvent" <<std::endl;
83 }
84
85 readEvent();
86
87
88 if(m_mdcdigi)
89 {
90 const BufferHolder& mdcBuf = m_raw_event->getMdcBuf();
91
92 MdcDigiCol* mdcDigiCol = new MdcDigiCol;
93 m_mdcCnv->convert(mdcBuf, mdcDigiCol);
94 /*MdcDigiCol::const_iterator mdcDigi = mdcDigiCol->begin();
95 for(; mdcDigi!=mdcDigiCol->end(); mdcDigi++ )
96 {
97 (*mdcDigi)->getTrackIndex();
98 std::cout<<"mdc digi: "<< " trackIndex: "<<(*mdcDigi)->getTrackIndex()<<std::endl;
99 }*/
100 //register MdcDigiCol to TDS...
101 StatusCode scMdc = m_evtSvc->registerObject("/Event/Digi/MdcDigiCol", mdcDigiCol);
102 if( scMdc!=StatusCode::SUCCESS ) {
103 std::cout<< "Could not register MDC digi collection" <<std::endl;
104 }
105 }
106
107
108 if(m_tofdigi)
109 {
110 const BufferHolder& tofBuf = m_raw_event->getTofBuf();
111
112 TofDigiCol* tofDigiCol = new TofDigiCol;
113 m_tofCnv->convert(tofBuf, tofDigiCol);
114 /*TofDigiCol::const_iterator tofDigi = tofDigiCol->begin();
115 for(; tofDigi!=tofDigiCol->end(); tofDigi++ )
116 {
117 (*tofDigi)->getTrackIndex();
118 const Identifier ident = (*tofDigi)->identify();
119 std::cout<<"print tof digi in RawEventReader"<<std::endl;
120 std::cout<<"partId: "<<TofID::barrel_ec(ident);
121 std::cout<<" layer: "<<TofID::layer(ident);
122 std::cout<<" scinNb: "<<TofID::phi_module(ident);
123 std::cout<<" end: "<<TofID::end(ident);
124 std::cout<<" charge: "<<(*tofDigi)->getChargeChannel();
125 std::cout<<" time: "<<(*tofDigi)->getTimeChannel()<<std::endl;
126 }*/
127
128 //register TofDigiCol to TDS...
129 StatusCode scTof = m_evtSvc->registerObject("/Event/Digi/TofDigiCol", tofDigiCol);
130 if( scTof!=StatusCode::SUCCESS ) {
131 std::cout<< "Could not register TOF digi collection" <<std::endl;
132 }
133 }
134
135 if(m_emcdigi)
136 {
137 const BufferHolder& emcBuf = m_raw_event->getEmcBuf();
138
139 EmcDigiCol* emcDigiCol = new EmcDigiCol;
140 m_emcCnv->convert(emcBuf, emcDigiCol);
141 //register EmcDigiCol to TDS...
142 StatusCode scEmc = m_evtSvc->registerObject("/Event/Digi/EmcDigiCol", emcDigiCol);
143 if( scEmc!=StatusCode::SUCCESS ) {
144 std::cout<< "Could not register EMC digi collection" <<std::endl;
145 }
146 }
147
148 if(m_mucdigi)
149 {
150 const BufferHolder& mucBuf = m_raw_event->getMucBuf();
151
152 MucDigiCol* mucDigiCol = new MucDigiCol;
153 m_mucCnv->convert(mucBuf, mucDigiCol);
154 //register MucDigiCol to TDS...
155 StatusCode scMuc = m_evtSvc->registerObject("/Event/Digi/MucDigiCol", mucDigiCol);
156 if( scMuc!=StatusCode::SUCCESS ) {
157 std::cout<< "Could not register MUC digi collection" <<std::endl;
158 }
159 }
160 // clear the Memory Buffer, so that m_raw_event can be used directly during next event loop
161 m_raw_event->reset();
162
163 return StatusCode::SUCCESS;
164}
165
167{
168 static RawFileReader* fileReader = new RawFileReader(m_inputFiles);
169 const uint32_t* fragment;
170
171 try {
172 fragment = fileReader->nextEvent();
173 }
174 catch (RawFileException& ex) {
175 ex.print();
176 }
177 catch (...) {
178 std::cerr << std::endl << "Uncaught unknown exception" << std::endl;
179 }
180
181 RawEvent f(fragment);
182 uint32_t *robs[64];
183 int nrobs = eformat::get_robs(fragment, (const uint32_t **)robs, 64);
184 for (int robi = 0; robi < nrobs; robi++) {
185 eformat::ROBFragment<uint32_t*> rob(robs[robi]);
186 if ((rob.rod_detev_type() & 0x2) != 0) continue; //bad data caogf add
187 uint32_t* dataptr = NULL;
188 rob.rod_data(dataptr);
189 uint32_t source_id_number = rob.rod_source_id();
190 source_id_number <<= 8;
191 source_id_number >>= 24;
192 switch(source_id_number) {
193 case 161:
194 m_raw_event->addReMdcDigi(dataptr, rob.rod_ndata());
195 break;
196 case 163:
197 m_raw_event->addReEmcDigi(dataptr, rob.rod_ndata());
198 break;
199 case 162:
200 m_raw_event->addReTofDigi(dataptr, rob.rod_ndata());
201 break;
202 case 164:
203 m_raw_event->addReMucDigi(dataptr, rob.rod_ndata());
204 break;
205 }
206 }
207 return StatusCode::SUCCESS;
208}
209// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
211
212 MsgStream log(msgSvc(), name());
213 log << MSG::INFO << "in finalize()" << endreq;
214
215 //TODO: release ...
216 delete m_raw_event;
217 //delete fileReader;
218
219 return StatusCode::SUCCESS;
220}
ObjectVector< MdcDigi > MdcDigiCol
ObjectVector< MucDigi > MucDigiCol
ObjectVector< TofDigi > TofDigiCol
static EmcConverter * instance(int runMode=2)
Definition: EmcConverter.cxx:9
static void destroy()
StatusCode convert(const BufferHolder &src, EmcDigiCol *des)
static MdcConverter * instance(int runMode=2)
Definition: MdcConverter.cxx:6
static void destroy()
void init(int runFrom, int runTo)
StatusCode convert(const BufferHolder &src, MdcDigiCol *des)
static MucConverter * instance()
Definition: MucConverter.cxx:5
static void destroy()
StatusCode convert(const BufferHolder &src, MucDigiCol *des)
void reset()
Definition: RAWEVENT.cxx:6
virtual ~RawEventReader()
RawEventReader(const std::string &name, ISvcLocator *pSvcLocator)
StatusCode initialize()
StatusCode finalize()
StatusCode execute()
StatusCode readEvent()
virtual void print() const
const uint32_t * nextEvent()
static void destroy()
StatusCode convert(const BufferHolder &src, TofDigiCol *des, LumiDigiCol *des2=0)
static TofConverter * instance()
Definition: TofConverter.cxx:6
size_t get_robs(const uint32_t *fragment, const uint32_t **rob, size_t max_count)
Definition: util.cxx:105