BOSS 7.1.1
BESIII Offline Software System
Loading...
Searching...
No Matches
RootRawEvtReader.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#include "GaudiKernel/DataObject.h"
11#include "GaudiKernel/GenericAddress.h"
12#include "GaudiKernel/ClassID.h"
13
14#include "RawEvent/DigiEvent.h" //TDS object
17
18//Digi
19#include "MdcRawEvent/MdcDigi.h"
20#include "EmcRawEvent/EmcDigi.h"
21#include "TofRawEvent/TofDigi.h"
22#include "MucRawEvent/MucDigi.h"
23
28
29
30#include "TFile.h"
31#include "TTree.h"
32#include "TBranch.h"
33#include "TObjArray.h"
34
35/////////////////////////////////////////////////////////////////////////////
36DECLARE_COMPONENT(RootRawEvtReader)
37
38RootRawEvtReader::RootRawEvtReader(const std::string& name, ISvcLocator* pSvcLocator) :
39 Algorithm(name, pSvcLocator)
40{
41
42 declareProperty("MdcDigi",m_mdcDigi=1);
43 declareProperty("TofDigi",m_tofDigi=1);
44 declareProperty("EmcDigi",m_emcDigi=1);
45 declareProperty("MucDigi",m_mucDigi=1);
46 declareProperty("InputFiles",m_inputFiles);
47
48 m_totalEvents=0;
49 m_fileNumber=0;
50 m_tempNumber=-1;
51 m_currentEntries=-1;
52 m_currentEntry=-1;
53}
54
58
59// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
61
62 MsgStream log(msgSvc(), name());
63 log << MSG::INFO << "in initialize()" << endreq;
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
86 if(m_tempNumber != m_fileNumber)
87 {
88 m_currentEntry = 0;
89 TFile* m_input = TFile::Open(m_inputFiles[m_fileNumber].c_str(), "READ");
90 std::cout<<"input file: "<<m_inputFiles[m_fileNumber].c_str()<<std::endl;
91 m_tree= (TTree *)m_input->Get("Event");
92 m_tree->SetMakeClass(1);
93 m_currentEntries=(Int_t)m_tree->GetEntries();
94 std::cout<<"m_currentEntries: "<<m_currentEntries<<std::endl;
95
96 m_tempNumber = m_fileNumber;
97 }
98
99 if(m_mdcDigi)
100 readMdc(m_currentEntry);
101
102 if(m_tofDigi)
103 readTof(m_currentEntry);
104
105 if(m_emcDigi)
106 readEmc(m_currentEntry);
107
108 if(m_mucDigi)
109 readMuc(m_currentEntry);
110
111 log << MSG::INFO << "current Entry: "<< m_currentEntry << endreq;
112 //std::cout << "current Entry: "<< m_currentEntry << std::endl;
113 m_currentEntry++;
114
115 if(m_currentEntry==m_currentEntries)
116 {
117 m_fileNumber++;
118 }
119
120 m_totalEvents++;
121 log << MSG::INFO << "total events: "<< m_totalEvents << endreq;
122 //std::cout << "total events: "<< m_totalEvents << std::endl;
123
124 return StatusCode::SUCCESS;
125}
126
127
128// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
129StatusCode RootRawEvtReader::readMdc(int entry)
130{
131 TBranch *branch = m_tree->GetBranch("m_mdcDigiCol");
132
133 TObjArray* mdcDigiCol;
134 branch->SetAddress(&mdcDigiCol);
135 mdcDigiCol=0;
136
137 branch->GetEntry(entry);
138
139 //commonData m_common;
140
141 TIter mdcDigiIter(mdcDigiCol);
142 MdcDigiCol* mdcDigiTdsCol = new MdcDigiCol;
143 TMdcDigi *mdcDigiRoot = 0;
144
145 while ((mdcDigiRoot = (TMdcDigi*)mdcDigiIter.Next())) {
146 unsigned int id = mdcDigiRoot->getIntId();
147 unsigned int time = mdcDigiRoot->getTimeChannel();
148 unsigned int charge = mdcDigiRoot->getChargeChannel();
149 unsigned int overflow = mdcDigiRoot->getOverflow();
150 int trackIndex = mdcDigiRoot->getTrackIndex();
151
152 MdcDigi *mdcDigiTds = new MdcDigi(id);
153 //m_common.m_rootMdcDigiMap[mdcDigiRoot] = mdcDigiTds;
154 mdcDigiTds->setTimeChannel(time);
155 mdcDigiTds->setChargeChannel(charge);
156 mdcDigiTds->setOverflow(overflow);
157 mdcDigiTds->setTrackIndex(trackIndex);
158 mdcDigiTdsCol->push_back(mdcDigiTds);
159 /*std::cout<<"trackID: "<<trackIndex;
160 std::cout<<" charge: "<<charge;
161 std::cout<<" time: "<<time<<std::endl;*/
162 }
163
164 //register MDC digits collection to TDS
165 StatusCode scMdc = m_evtSvc->registerObject("/Event/Digi/MdcDigiCol", mdcDigiTdsCol);
166 if(scMdc!=StatusCode::SUCCESS)
167 std::cout<< "Could not register MDC digi collection" <<std::endl;
168
169
170 return StatusCode::SUCCESS;
171}
172
173StatusCode RootRawEvtReader::readTof(int entry)
174{
175 TBranch *branch = m_tree->GetBranch("m_tofDigiCol");
176
177 TObjArray* tofDigiCol;
178 branch->SetAddress(&tofDigiCol);
179 tofDigiCol=0;
180
181 branch->GetEntry(entry);
182
183 //commonData m_common;
184
185 TIter tofDigiIter(tofDigiCol);
186 TofDigiCol* tofDigiTdsCol = new TofDigiCol;
187 TTofDigi *tofDigiRoot = 0;
188
189 while ((tofDigiRoot = (TTofDigi*)tofDigiIter.Next())) {
190 unsigned int id = tofDigiRoot->getIntId();
191 unsigned int time = tofDigiRoot->getTimeChannel();
192 unsigned int charge = tofDigiRoot->getChargeChannel();
193 unsigned int overflow = tofDigiRoot->getOverflow();
194 int trackIndex = tofDigiRoot->getTrackIndex();
195
196 TofDigi *tofDigiTds = new TofDigi(id);
197 //m_common.m_rootTofDigiMap[tofDigiRoot] = tofDigiTds;
198 tofDigiTds->setTimeChannel(time);
199 tofDigiTds->setChargeChannel(charge);
200 tofDigiTds->setOverflow(overflow);
201 tofDigiTds->setTrackIndex(trackIndex);
202 tofDigiTdsCol->push_back(tofDigiTds);
203 }
204
205 //register TOF digits collection to TDS
206 StatusCode scTof = m_evtSvc->registerObject("/Event/Digi/TofDigiCol", tofDigiTdsCol);
207 if(scTof!=StatusCode::SUCCESS)
208 std::cout<< "Could not register TOF digi collection" <<std::endl;
209
210
211 return StatusCode::SUCCESS;
212}
213
214StatusCode RootRawEvtReader::readEmc(int entry)
215{
216 TBranch *branch = m_tree->GetBranch("m_emcDigiCol");
217
218 TObjArray* emcDigiCol;
219 branch->SetAddress(&emcDigiCol);
220 emcDigiCol=0;
221
222 branch->GetEntry(entry);
223
224 //commonData m_common;
225
226 TIter emcDigiIter(emcDigiCol);
227 EmcDigiCol* emcDigiTdsCol = new EmcDigiCol;
228 TEmcDigi *emcDigiRoot = 0;
229
230 while ((emcDigiRoot = (TEmcDigi*)emcDigiIter.Next())) {
231 unsigned int id = emcDigiRoot->getIntId();
232 unsigned int time = emcDigiRoot->getTimeChannel();
233 unsigned int charge = emcDigiRoot->getChargeChannel();
234 unsigned int measure = emcDigiRoot->getMeasure();
235 int trackIndex = emcDigiRoot->getTrackIndex();
236
237 EmcDigi *emcDigiTds = new EmcDigi(id);
238 //m_common.m_rootEmcDigiMap[emcDigiRoot] = emcDigiTds;
239 emcDigiTds->setTimeChannel(time);
240 emcDigiTds->setChargeChannel(charge);
241 emcDigiTds->setMeasure(measure);
242 emcDigiTds->setTrackIndex(trackIndex);
243 emcDigiTdsCol->push_back(emcDigiTds);
244 }
245
246 //register EMC digits collection to TDS
247 StatusCode scEmc = m_evtSvc->registerObject("/Event/Digi/EmcDigiCol", emcDigiTdsCol);
248 if(scEmc!=StatusCode::SUCCESS)
249 std::cout<< "Could not register EMC digi collection" <<std::endl;
250
251
252 return StatusCode::SUCCESS;
253}
254
255StatusCode RootRawEvtReader::readMuc(int entry)
256{
257 TBranch *branch = m_tree->GetBranch("m_mucDigiCol");
258
259 TObjArray* mucDigiCol;
260 branch->SetAddress(&mucDigiCol);
261 mucDigiCol=0;
262
263 branch->GetEntry(entry);
264
265 //commonData m_common;
266
267 TIter mucDigiIter(mucDigiCol);
268 MucDigiCol* mucDigiTdsCol = new MucDigiCol;
269 TMucDigi *mucDigiRoot = 0;
270
271 while ((mucDigiRoot = (TMucDigi*)mucDigiIter.Next())) {
272 unsigned int id = mucDigiRoot->getIntId();
273 unsigned int time = mucDigiRoot->getTimeChannel();
274 unsigned int charge = mucDigiRoot->getChargeChannel();
275 int trackIndex = mucDigiRoot->getTrackIndex();
276
277 MucDigi *mucDigiTds = new MucDigi(id);
278 //m_common.m_rootMucDigiMap[mucDigiRoot] = mucDigiTds;
279 mucDigiTds->setTimeChannel(time);
280 mucDigiTds->setChargeChannel(charge);
281 mucDigiTds->setTrackIndex(trackIndex);
282 mucDigiTdsCol->push_back(mucDigiTds);
283 }
284
285 //register MUC digits collection to TDS
286 StatusCode scMuc = m_evtSvc->registerObject("/Event/Digi/MucDigiCol", mucDigiTdsCol);
287 if(scMuc!=StatusCode::SUCCESS)
288 std::cout<< "Could not register MUC digi collection" <<std::endl;
289
290
291 return StatusCode::SUCCESS;
292}
293
294
295// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
297
298 MsgStream log(msgSvc(), name());
299 log << MSG::INFO << "in finalize()" << endreq;
300
301 return StatusCode::SUCCESS;
302}
Double_t time
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
void setMeasure(const unsigned int measure)
Definition EmcDigi.h:24
void setOverflow(const unsigned int overflow)
Definition MdcDigi.h:23
void setTrackIndex(const int trackIndex)
Definition RawData.cxx:35
void setChargeChannel(const unsigned int chargeChannel)
Definition RawData.cxx:30
void setTimeChannel(const unsigned int timeChannel)
Definition RawData.cxx:25
StatusCode initialize()
StatusCode readTof(int entry)
StatusCode readMuc(int entry)
StatusCode readEmc(int entry)
StatusCode readMdc(int entry)
UInt_t getMeasure() const
Definition TEmcDigi.cxx:37
UInt_t getOverflow() const
Definition TMdcDigi.cxx:42
UInt_t getIntId() const
Definition TRawData.cxx:50
int getTrackIndex() const
Definition TRawData.cxx:45
UInt_t getChargeChannel() const
Definition TRawData.cxx:60
UInt_t getTimeChannel() const
Definition TRawData.cxx:55
UInt_t getOverflow() const
Definition TTofDigi.cxx:42
void setOverflow(const unsigned int overflow)
Definition TofDigi.h:23
float charge