CGEM BOSS 6.6.5.h
BESIII Offline Software System
Loading...
Searching...
No Matches
RootIoAlg.cxx
Go to the documentation of this file.
1#include "RootIO/RootIoAlg.h"
2#include "GaudiKernel/MsgStream.h"
3#include "GaudiKernel/AlgFactory.h"
4#include "GaudiKernel/ISvcLocator.h"
5#include "GaudiKernel/SmartDataPtr.h"
6#include "GaudiKernel/IDataProviderSvc.h"
7#include "GaudiKernel/PropertyMgr.h"
8#include "EventModel/Event.h"
10#include "MdcRawEvent/MdcDigi.h"
12#include "TofRawEvent/TofDigi.h"
13#include "EmcRawEvent/EmcDigi.h"
14#include "McTruth/McKine.h"
15
21#include "DstEvent/DstMdcDedx.h"
25
27
28#include "CLHEP/Matrix/Vector.h"
29#include "CLHEP/Matrix/SymMatrix.h"
30#include "CLHEP/Vector/ThreeVector.h"
31
32//#include "MdcGeomSvc/IMdcGeomSvc.h"
33//#include "MdcGeomSvc/MdcGeoWire.h"
34//#include "MdcGeomSvc/MdcGeoLayer.h"
36#include <vector>
37#include <iostream>
38
39using namespace std;
40
41// 2007/09/29
42//static const AlgFactory<RootIoAlg> Factory;
43//const IAlgFactory& RootIoAlgFactory = Factory;
44
45/////////////////////////////////////////////////////////////////////////////
46
47RootIoAlg::RootIoAlg(const std::string& name, ISvcLocator* pSvcLocator) :
48 Algorithm(name, pSvcLocator)
49{
50 // Declare the properties
51// declareProperty("FittingMethod", m_fittingMethod = 2);
52// declareProperty("ConfigFile", m_configFile = "MDCConfig.xml");
53}
54
55// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
57
58 MsgStream log(msgSvc(), name());
59 log << MSG::INFO << "in initialize()" << endreq;
60/*
61 IMdcGeomSvc* mdcGeomSvc;
62 StatusCode sc = service("MdcGeomSvc", mdcGeomSvc);
63 if (sc == StatusCode::SUCCESS) {
64 std::cout <<"dump"<<std::endl;
65 mdcGeomSvc->Dump();
66 std::cout<<"Hi, event routine is running"<<std::endl;
67 std::cout<<"1st wire id:"<<mdcGeomSvc->Wire(0)->Id()<<std::endl;
68 } else {
69 return StatusCode::FAILURE;
70 }
71*/
72 return StatusCode::SUCCESS;
73}
74
75// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
76StatusCode RootIoAlg::execute() {
77
78 MsgStream log(msgSvc(), name());
79 log << MSG::INFO << "in execute()" << endreq;
80
81 // Part 1: Get the event header, print out event and run number
82
83 int event, run;
84
85
86 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),"/Event/EventHeader");
87 if (!eventHeader) {
88 log << MSG::FATAL << "Could not find Event Header" << endreq;
89 return( StatusCode::FAILURE);
90 }
91 log << MSG::INFO << "RootIoAlg: retrieved event: " << eventHeader->eventNumber() << " run: " << eventHeader->runNumber() << endreq;
92
93
94 int digiId;
95
96 //Part 3: Retrieve MDC digi
97 SmartDataPtr<MdcDigiCol> mdcDigiCol(eventSvc(),"/Event/Digi/MdcDigiCol");
98 if (!mdcDigiCol) {
99 log << /*MSG::FATAL*/MSG::INFO << "Could not find MDC digi" << endreq;
100 //return( StatusCode::FAILURE);
101 }
102 else {
103 MdcDigiCol::iterator iter1 = mdcDigiCol->begin();
104 digiId = 0;
105 for (;iter1 != mdcDigiCol->end(); iter1++, digiId++) {
106 log << MSG::INFO << "MDC digit No: " << digiId << endreq;
107
108 log << MSG::INFO
109 << " time_channel = " << (*iter1)->getTimeChannel()
110 << " charge_channel = " << (*iter1)->getChargeChannel()
111 << endreq;
112 }
113 }
114
115
116 //Part 4: Retrieve TOF digi
117 SmartDataPtr<TofDigiCol> tofDigiCol(eventSvc(),"/Event/Digi/TofDigiCol");
118 if (!tofDigiCol) {
119 log <</* MSG::FATAL*/MSG::INFO << "Could not find TOF digi" << endreq;
120 // return( StatusCode::FAILURE);
121 }
122 else {
123 TofDigiCol::iterator iter2 = tofDigiCol->begin();
124 digiId = 0;
125 for (;iter2 != tofDigiCol->end(); iter2++, digiId++) {
126 log << MSG::INFO << "TOF digit No: " << digiId << endreq;
127 log << MSG::INFO
128 << " time_channel = " << (*iter2)->getTimeChannel()
129 << " charge_channel = " << (*iter2)->getChargeChannel()
130 << endreq;
131
132
133 }
134 }
135 //Part 5: Retrieve EMC digi
136 SmartDataPtr<EmcDigiCol> emcDigiCol(eventSvc(),"/Event/Digi/EmcDigiCol");
137 if (!emcDigiCol) {
138 log <</* MSG::FATAL*/MSG::INFO << "Could not find EMC digi" << endreq;
139 // return( StatusCode::FAILURE);
140 }
141 else {
142 EmcDigiCol::iterator iter3 = emcDigiCol->begin();
143 digiId = 0;
144 for (;iter3 != emcDigiCol->end(); iter3++, digiId++) {
145 log << MSG::INFO << "Emc digit No: " << digiId << endreq;
146
147 log << MSG::INFO
148 << " time_channel = " << (*iter3)->getTimeChannel()
149 << " charge_channel = " << (*iter3)->getChargeChannel()
150 << endreq;
151 }
152 }
153
154
155 //Part 6: Retrieve DST Tof Track
156 SmartDataPtr<DstTofTrackCol> dstTofTrackCol(eventSvc(),EventModel::Dst::DstTofTrackCol);
157 if (!dstTofTrackCol) {
158 log <</* MSG::FATAL*/MSG::INFO << "Could not find Dst Tof Track" << endreq;
159 // return( StatusCode::FAILURE);
160 }
161 else {
162 DstTofTrackCol::iterator iter4 = dstTofTrackCol->begin();
163 digiId = 0;
164 for (;iter4 != dstTofTrackCol->end(); iter4++, digiId++) {
165 log << MSG::INFO << "Dst Tof No: " << digiId << endreq;
166
167 log << MSG::INFO
168 <<" TrackID = " << (*iter4)->trackID()
169 <<" TofID = " <<(*iter4)->tofID()
170 <<" TofTrackID = " <<(*iter4)->tofTrackID()
171 <<" Beta = " << (*iter4)->beta()
172 << endreq;
173 }
174 }
175
176 //Part 7: Retrieve DST Emc Track
177 SmartDataPtr<DstEmcShowerCol> dstEmcShowerCol(eventSvc(),EventModel::Dst::DstEmcShowerCol);
178 if (!dstEmcShowerCol) {
179 log <</* MSG::FATAL*/MSG::INFO << "Could not find Dst Emc Track" << endreq;
180 // return( StatusCode::FAILURE);
181 }
182 else {
183 DstEmcShowerCol::iterator iter5 = dstEmcShowerCol->begin();
184 digiId = 0;
185 for (;iter5 != dstEmcShowerCol->end(); iter5++, digiId++) {
186 log << MSG::INFO << "Dst Emc No: " << digiId << endreq;
187
188 log << MSG::INFO
189 << " Track ID = " << (*iter5)->trackId()
190 <<" Cell ID = " << (*iter5)->cellId()
191 <<" Total energy observed in Emc = " << (*iter5)->energy()
192 << endreq ;
193 }
194 }
195
196//Part 8: Retrieve DST Mdc Track
197 SmartDataPtr<DstMdcTrackCol> dstMdcTrackCol(eventSvc(),EventModel::Dst::DstMdcTrackCol);
198 if (!dstMdcTrackCol) {
199 log <</* MSG::FATAL*/MSG::INFO << "Could not find Dst Mdc Track" << endreq;
200 // return( StatusCode::FAILURE);
201 }
202 else {
203 DstMdcTrackCol::iterator iter6 = dstMdcTrackCol->begin();
204 digiId = 0;
205 for (;iter6 != dstMdcTrackCol->end(); iter6++, digiId++) {
206 log << MSG::INFO << "Dst Mdc No: " << digiId << endreq;
207
208 log << MSG::INFO
209 << " Track ID = " << (*iter6)->trackId()
210 <<" number of total hits contained = " << (*iter6)->nster()
211 <<"px = "<<(*iter6)->px()
212 <<"p = "<<(*iter6)->p()
213 <<endreq;
214 }
215 }
216
217//Part 9: Retrieve DST Dedx Track
218 SmartDataPtr<DstMdcDedxCol> dstMdcDedxCol(eventSvc(),EventModel::Dst::DstMdcDedxCol);
219 if (!dstMdcDedxCol) {
220 log << /*MSG::FATAL*/MSG::INFO << "Could not find Dst Mdc Dedx " << endreq;
221 // return( StatusCode::FAILURE);
222 }
223 else {
224 DstMdcDedxCol::iterator iter7 = dstMdcDedxCol->begin();
225 digiId = 0;
226 for (;iter7 != dstMdcDedxCol->end(); iter7++, digiId++) {
227 log << MSG::INFO << "Dst Mdc Dedx No: " << digiId << endreq;
228
229 log << MSG::INFO
230 << " Track ID = " << (*iter7)->trackId()
231 <<"Chi of E = " << (*iter7)->chi(0)
232 <<"Chi of Mu = " << (*iter7)->chi(1)
233 <<"Chi of Pi = " << (*iter7)->chi(2)
234 <<endreq;
235 }
236 }
237
238//Part 9: Retrieve DST Muc Track
239 SmartDataPtr<DstMucTrackCol> dstMucTrackCol(eventSvc(),EventModel::Dst::DstMucTrackCol);
240 if (!dstMucTrackCol) {
241 log <</* MSG::FATAL*/MSG::INFO << "Could not find Muc Track " << endreq;
242 // return( StatusCode::FAILURE);
243 }
244 else {
245 DstMucTrackCol::iterator iter8 = dstMucTrackCol->begin();
246 digiId = 0;
247 for (;iter8 != dstMucTrackCol->end(); iter8++, digiId++) {
248 log << MSG::INFO << "Dst Muc Track No: " << digiId << endreq;
249
250 log << MSG::INFO
251 << " Track ID = " << (*iter8)->trackId()
252 <<" Number of hits on track = " << (*iter8)->numHits()
253 <<" maxHitsInLayer " << (*iter8)->maxHitsInLayer()
254 <<" xPos = " << (*iter8)->xPos()
255 <<" yPos = " << (*iter8)->yPos()
256 <<" zPos = " << (*iter8)->zPos()
257 << endreq;
258 }
259 }
260
261//Part 10: Retrieve DST Ext Track
262 SmartDataPtr<DstExtTrackCol> dstExtTrackCol(eventSvc(),EventModel::Dst::DstExtTrackCol);
263 if (!dstExtTrackCol) {
264 log <</* MSG::FATAL*/MSG::INFO << "Could not find DstExt Track " << endreq;
265 // return( StatusCode::FAILURE);
266 }
267 else {
268 DstExtTrackCol::iterator iter9 = dstExtTrackCol->begin();
269
270 digiId = 0;
271 for (;iter9 != dstExtTrackCol->end(); iter9++, digiId++) {
272 log << MSG::INFO << "Dst Ext Track No: " << digiId << endreq;
273 log << MSG::INFO
274 << "volume name of Tof1= "<< (*iter9)->tof1VolumeName()
275 << "volume number of Tof1 = "<< (*iter9)->tof1VolumeNumber()
276 << "Tof1 = "<< (*iter9)->tof1()
277 <<endreq;
278 log << MSG::INFO
279 << "volume name of Tof2= "<< (*iter9)->tof2VolumeName()
280 << "volume number of Tof2 = "<< (*iter9)->tof2VolumeNumber()
281 << "Tof2 = "<< (*iter9)->tof2()
282 <<endreq;
283 log << MSG::INFO
284 <<" Ext Tof1 Error Z = " << (*iter9)->tof1PosSigmaAlongZ()
285 <<" Ext Tof2 Error Z = " << (*iter9)->tof2PosSigmaAlongZ()
286 <<" Ext Emc Error theta = " << (*iter9)->emcPosSigmaAlongTheta()
287 <<" Ext Muc Error Z = " << (*iter9)->mucPosSigmaAlongZ()
288 << endreq;
289 }
290 }
291//Part 11: Retrieve MdcKal Track
292 SmartDataPtr<DstMdcKalTrackCol> dstMdcKalTrackCol(eventSvc(),EventModel::Dst::DstMdcKalTrackCol);
293 if (!dstMdcKalTrackCol) {
294 log <</* MSG::FATAL*/MSG::INFO << "Could not find DstMdcKal Track " << endreq;
295 }
296 else {
297 DstMdcKalTrackCol::iterator iter10 = dstMdcKalTrackCol->begin();
298 digiId = 0;
299 for (;iter10 != dstMdcKalTrackCol->end(); iter10++, digiId++) {
300 //log << MSG::INFO << "Dst MdcKal Track No: " << digiId << endreq;
301 //log << MSG::INFO
302 // << " stat of the fit of pid=0:" << (*iter10)->getStat(0) <<endreq;
303 //log << MSG::INFO
304 // << "mass assumption during the fit of pid =0 :" << ((*iter10)->getZHelix(0)) <<endreq;
305//
306 }
307 }
308
309 //Part 12: Retrieve CGEM digi
310 SmartDataPtr<CgemDigiCol> cgemDigiCol(eventSvc(),"/Event/Digi/CgemDigiCol");
311 if (!cgemDigiCol) {
312 log << /*MSG::FATAL*/MSG::INFO << "Could not find CGEM digi" << endreq;
313 //return( StatusCode::FAILURE);
314 }
315 else {
316 CgemDigiCol::iterator iter11 = cgemDigiCol->begin();
317 digiId = 0;
318 for (;iter11 != cgemDigiCol->end(); iter11++, digiId++) {
319 log << MSG::INFO << "CGEM digit No: " << digiId << endreq;
320
321 log << MSG::INFO
322 << " time_channel = " << (*iter11)->getTimeChannel()
323 << " charge_channel = " << (*iter11)->getChargeChannel()
324 << endreq;
325 }
326 }
327
328
329//Part 13: Retrieve DST Cgem Track
330 SmartDataPtr<DstCgemTrackCol> dstCgemTrackCol(eventSvc(),EventModel::Dst::DstCgemTrackCol);
331 if (!dstCgemTrackCol) {
332 log <</* MSG::FATAL*/MSG::INFO << "Could not find Dst Cgem Track" << endreq;
333 // return( StatusCode::FAILURE);
334 }
335 else {
336 DstCgemTrackCol::iterator iter12 = dstCgemTrackCol->begin();
337 digiId = 0;
338 for (;iter12 != dstCgemTrackCol->end(); iter12++, digiId++) {
339 log << MSG::INFO << "Dst Cgem No: " << digiId << endreq;
340
341 log << MSG::INFO
342 << " Track ID = " << (*iter12)->trackId()
343 <<"px = "<<(*iter12)->px()
344 <<"p = "<<(*iter12)->p()
345 <<endreq;
346 }
347 }
348
349//Part 14: Retrieve CgemKal Track
350 SmartDataPtr<DstCgemKalTrackCol> dstCgemKalTrackCol(eventSvc(),EventModel::Dst::DstCgemKalTrackCol);
351 if (!dstCgemKalTrackCol) {
352 log <</* MSG::FATAL*/MSG::INFO << "Could not find DstCgemKal Track " << endreq;
353 }
354 else {
355 DstCgemKalTrackCol::iterator iter13 = dstCgemKalTrackCol->begin();
356 digiId = 0;
357 for (;iter13 != dstCgemKalTrackCol->end(); iter13++, digiId++) {
358 //log << MSG::INFO << "Dst CgemKal Track No: " << digiId << endreq;
359 //log << MSG::INFO
360 // << " stat of the fit of pid=0:" << (*iter13)->getStat(0) <<endreq;
361 //log << MSG::INFO
362 // << "mass assumption during the fit of pid =0 :" << ((*iter13)->getZHelix(0)) <<endreq;
363//
364 }
365 }
366
367/*
368 // register ReconEvent Data Object to TDS;
369 //ReconEvent* recevt = new ReconEvent;
370 //StatusCode sc = eventSvc()->registerObject("/Event/Recon",recevt );
371
372 //Part 6: Retrieve Tof Track
373 // register Tof Track Data Object to TDS;
374 int trackID = 0;
375 DstTofTrackCol* dstTofTrackCol = new DstTofTrackCol();
376
377 for (trackID = 0;trackID < 10 ; trackID++) {
378 log << MSG::INFO << "Tof Track No: " << trackID << endreq;
379
380 DstTofTrack* dstTofTrack = new DstTofTrack();
381
382 dstTofTrack->setId(trackID*100);
383 dstTofTrack->setFlightTime(trackID*1.1);
384 dstTofTrack->setBeta(trackID*1.11);
385
386 log << MSG::INFO
387 <<" Counter Number = " << dstTofTrack->id()
388 <<" Time of Flight = " << dstTofTrack->flightTime()
389 <<" Beta = " << dstTofTrack->beta()
390 << endreq;
391
392 (*dstTofTrackCol).push_back(dstTofTrack);
393 }
394 StatusCode sc = eventSvc()->registerObject("/Event/Digi/DstTofTrackCol",dstTofTrackCol);
395
396 //Part 7: Retrieve Mdc Track
397 // register Mdc Track Data Object to TDS;
398 trackID = 0;
399 DstMdcTrackCol* dstMdcTrackCol = new DstMdcTrackCol();
400
401 for ( trackID = 0;trackID < 10 ; trackID++) {
402 log << MSG::INFO << "Mdc Track No: " << trackID << endreq;
403
404 DstMdcTrack* dstMdcTrack = new DstMdcTrack();
405
406 dstMdcTrack->setCharge(trackID*100);
407 dstMdcTrack->setPxy(trackID*1.1);
408 dstMdcTrack->setPx(trackID*1.11);
409
410 log << MSG::INFO
411 <<" Charge = " << dstMdcTrack->charge()
412 <<" Pxy = " << dstMdcTrack->pxy()
413 <<" Px = " << dstMdcTrack->px()
414 << endreq;
415
416 (*dstMdcTrackCol).push_back(dstMdcTrack);
417 }
418 sc = eventSvc()->registerObject("/Event/Digi/DstMdcTrackCol",dstMdcTrackCol);
419
420//Part 8: Retrieve Emc Track
421 // register Tof Track Data Object to TDS;
422 trackID = 0;
423 DstEmcShowerCol* dstEmcShowerCol = new DstEmcShowerCol();
424
425 for ( trackID = 0;trackID < 10 ; trackID++) {
426 log << MSG::INFO << "Emc Track No: " << trackID << endreq;
427
428 DstEmcShower* dstEmcShower = new DstEmcShower();
429
430 dstEmcShower->setNumHits(trackID*100);
431 dstEmcShower->setX(trackID*1.1);
432 dstEmcShower->setDx(trackID*1.11);
433
434 log << MSG::INFO
435 <<" NumHits = " << dstEmcShower->numHits()
436 <<" X = " << dstEmcShower->x()
437 <<" Dx = " << dstEmcShower->dx()
438 << endreq;
439
440 (*dstEmcShowerCol).push_back(dstEmcShower);
441 }
442 sc = eventSvc()->registerObject("/Event/Digi/DstEmcShowerCol",dstEmcShowerCol);
443
444 //Part 9: Retrieve Muc Track
445 SmartDataPtr<DstMucTrackCol> dstMucTrackCol(eventSvc(),"/Event/Digi/DstMucTrackCol");
446 if (!dstMucTrackCol) {
447 log << MSG::FATAL << "Could not find Dst Muc Track " << endreq;
448 return( StatusCode::FAILURE);
449 }
450 trackID = 0;
451 DstMucTrackCol::iterator iter9 = dstMucTrackCol->begin();
452
453 for (;iter9 != dstMucTrackCol->end(); iter9++, trackID++) {
454 log << MSG::INFO << "Dst Muc Track No.: " << trackID << endreq;
455 log << MSG::INFO
456 << " Projected x = " << (*iter9)->xProj()
457 << " Projected y = " << (*iter9)->yProj()
458 << " Projected z = " << (*iter9)->zProj()
459 << endreq;
460 }
461
462
463 //Part 10: Retrieve Dedx
464 // register Dedx Data Object to TDS;
465 trackID = 0;
466 DstDedxCol* dstDedxCol = new DstDedxCol();
467
468 for ( trackID = 0;trackID < 10 ; trackID++) {
469 log << MSG::INFO << "Dedx No: " << trackID << endreq;
470
471 DstDedx* dstDedx = new DstDedx();
472
473 dstDedx->setParticleId(trackID*100);
474 dstDedx->setNumSigmaE(trackID*1.1);
475 dstDedx->setNumSigmaMu(trackID*1.11);
476
477 log << MSG::INFO
478 <<" Particle ID from De/Dx fit = " << dstDedx->particleId()
479 <<" Number of sigama from e = " << dstDedx->numSigmaE()
480 <<" Number of sigama from muon = " << dstDedx->numSigmaMu()
481 << endreq;
482
483 (*dstDedxCol).push_back(dstDedx);
484 }
485 sc = eventSvc()->registerObject("/Event/Digi/DstDedxCol",dstDedxCol);
486*/
487 return StatusCode::SUCCESS;
488}
489
490// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
492
493 MsgStream log(msgSvc(), name());
494 log << MSG::INFO << "in finalize()" << endreq;
495
496 return StatusCode::SUCCESS;
497}
IMessageSvc * msgSvc()
RootIoAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition RootIoAlg.cxx:47
StatusCode initialize()
Definition RootIoAlg.cxx:56
StatusCode finalize()
StatusCode execute()
Definition RootIoAlg.cxx:76
_EXTERN_ std::string DstEmcShowerCol
Definition EventModel.h:152
_EXTERN_ std::string DstMdcKalTrackCol
Definition EventModel.h:148
_EXTERN_ std::string DstExtTrackCol
Definition EventModel.h:154
_EXTERN_ std::string DstMdcDedxCol
Definition EventModel.h:150
_EXTERN_ std::string DstTofTrackCol
Definition EventModel.h:151
_EXTERN_ std::string DstMdcTrackCol
Definition EventModel.h:147
_EXTERN_ std::string DstCgemTrackCol
Definition EventModel.h:158
_EXTERN_ std::string DstMucTrackCol
Definition EventModel.h:153
_EXTERN_ std::string DstCgemKalTrackCol
Definition EventModel.h:160