BOSS 7.0.7
BESIII Offline Software System
Loading...
Searching...
No Matches
RawEventReader.cxx
Go to the documentation of this file.
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
17#include "Identifier/MdcID.h"
18#include "Identifier/TofID.h"
19#include "Identifier/EmcID.h"
20#include "Identifier/MucID.h"
22
24#include "RawEvent/DigiEvent.h"
25
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 const BufferHolder& etfBuf = m_raw_event->getEtfBuf();
112
113 TofDigiCol* tofDigiCol = new TofDigiCol;
114 // m_tofCnv->convert(tofBuf, tofDigiCol);
115 m_tofCnv->convert(tofBuf, etfBuf, tofDigiCol);
116
117 /*TofDigiCol::const_iterator tofDigi = tofDigiCol->begin();
118 for(; tofDigi!=tofDigiCol->end(); tofDigi++ )
119 {
120 (*tofDigi)->getTrackIndex();
121 const Identifier ident = (*tofDigi)->identify();
122 std::cout<<"print tof digi in RawEventReader"<<std::endl;
123 std::cout<<"partId: "<<TofID::barrel_ec(ident);
124 std::cout<<" layer: "<<TofID::layer(ident);
125 std::cout<<" scinNb: "<<TofID::phi_module(ident);
126 std::cout<<" end: "<<TofID::end(ident);
127 std::cout<<" charge: "<<(*tofDigi)->getChargeChannel();
128 std::cout<<" time: "<<(*tofDigi)->getTimeChannel()<<std::endl;
129 }*/
130
131 //register TofDigiCol to TDS...
132 StatusCode scTof = m_evtSvc->registerObject("/Event/Digi/TofDigiCol", tofDigiCol);
133 if( scTof!=StatusCode::SUCCESS ) {
134 std::cout<< "Could not register TOF digi collection" <<std::endl;
135 }
136 }
137
138 if(m_emcdigi)
139 {
140 const BufferHolder& emcBuf = m_raw_event->getEmcBuf();
141
142 EmcDigiCol* emcDigiCol = new EmcDigiCol;
143 m_emcCnv->convert(emcBuf, emcDigiCol);
144 //register EmcDigiCol to TDS...
145 StatusCode scEmc = m_evtSvc->registerObject("/Event/Digi/EmcDigiCol", emcDigiCol);
146 if( scEmc!=StatusCode::SUCCESS ) {
147 std::cout<< "Could not register EMC digi collection" <<std::endl;
148 }
149 }
150
151 if(m_mucdigi)
152 {
153 const BufferHolder& mucBuf = m_raw_event->getMucBuf();
154
155 MucDigiCol* mucDigiCol = new MucDigiCol;
156 m_mucCnv->convert(mucBuf, mucDigiCol);
157 //register MucDigiCol to TDS...
158 StatusCode scMuc = m_evtSvc->registerObject("/Event/Digi/MucDigiCol", mucDigiCol);
159 if( scMuc!=StatusCode::SUCCESS ) {
160 std::cout<< "Could not register MUC digi collection" <<std::endl;
161 }
162 }
163 // clear the Memory Buffer, so that m_raw_event can be used directly during next event loop
164 m_raw_event->reset();
165
166 return StatusCode::SUCCESS;
167}
168
170{
171 static RawFileReader* fileReader = new RawFileReader(m_inputFiles);
172 const uint32_t* fragment;
173
174 try {
175 fragment = fileReader->nextEvent();
176 }
177 catch (RawFileException& ex) {
178 ex.print();
179 }
180 catch (...) {
181 std::cerr << std::endl << "Uncaught unknown exception" << std::endl;
182 }
183
184 RawEvent f(fragment);
185 uint32_t *robs[64];
186 int nrobs = eformat::get_robs(fragment, (const uint32_t **)robs, 64);
187 for (int robi = 0; robi < nrobs; robi++) {
188 eformat::ROBFragment<uint32_t*> rob(robs[robi]);
189 if ((rob.rod_detev_type() & 0x2) != 0) continue; //bad data caogf add
190 uint32_t* dataptr = NULL;
191 rob.rod_data(dataptr);
192 uint32_t source_id_number = rob.rod_source_id();
193 source_id_number <<= 8;
194 source_id_number >>= 24;
195 switch(source_id_number) {
196 case 161:
197 m_raw_event->addReMdcDigi(dataptr, rob.rod_ndata());
198 break;
199 case 163:
200 m_raw_event->addReEmcDigi(dataptr, rob.rod_ndata());
201 break;
202 case 162:
203 m_raw_event->addReTofDigi(dataptr, rob.rod_ndata());
204 break;
205 case 164:
206 m_raw_event->addReMucDigi(dataptr, rob.rod_ndata());
207 break;
208 case 167:
209 m_raw_event->addReEtfDigi(dataptr, rob.rod_ndata());
210 break;
211 }
212 }
213 return StatusCode::SUCCESS;
214}
215// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
217
218 MsgStream log(msgSvc(), name());
219 log << MSG::INFO << "in finalize()" << endreq;
220
221 //TODO: release ...
222 delete m_raw_event;
223 //delete fileReader;
224
225 return StatusCode::SUCCESS;
226}
ObjectVector< EmcDigi > EmcDigiCol
Definition: EmcDigi.h:43
ObjectVector< MdcDigi > MdcDigiCol
Definition: MdcDigi.h:39
ObjectVector< MucDigi > MucDigiCol
Definition: MucDigi.h:29
IMessageSvc * msgSvc()
ObjectVector< TofDigi > TofDigiCol
Definition: TofDigi.h:41
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 addReTofDigi(uint32_t *digi, uint32_t size)
Definition: RAWEVENT.h:59
const BufferHolder & getEtfBuf() const
Definition: RAWEVENT.h:102
void addReMdcDigi(uint32_t *digi, uint32_t size)
Definition: RAWEVENT.h:53
const BufferHolder & getEmcBuf() const
Definition: RAWEVENT.h:97
void addReMucDigi(uint32_t *digi, uint32_t size)
Definition: RAWEVENT.h:62
const BufferHolder & getMdcBuf() const
Definition: RAWEVENT.h:95
const BufferHolder & getMucBuf() const
Definition: RAWEVENT.h:98
const BufferHolder & getTofBuf() const
Definition: RAWEVENT.h:96
void addReEtfDigi(uint32_t *digi, uint32_t size)
Definition: RAWEVENT.h:74
void addReEmcDigi(uint32_t *digi, uint32_t size)
Definition: RAWEVENT.h:56
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
void rod_data(TPointer &it) const
Definition: ROBFragment.h:257
uint32_t rod_source_id() const
Definition: ROBFragment.h:115
uint32_t rod_ndata() const
Definition: ROBFragment.h:159
uint32_t rod_detev_type() const
Definition: ROBFragment.h:140
TFile f("ana_bhabha660a_dqa_mcPat_zy_old.root")
size_t get_robs(const uint32_t *fragment, const uint32_t **rob, size_t max_count)
Definition: util.cxx:105