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