CGEM BOSS 6.6.5.f
BESIII Offline Software System
Loading...
Searching...
No Matches
bak_RootCnvSvc-04-01-14/src/EvtRec/EvtRecTrackCnv.cxx
Go to the documentation of this file.
1#include <algorithm>
2#include "GaudiKernel/MsgStream.h"
3
4#include "EventModel/EventModel.h"
5#include "EvtRecEvent/EvtRecObject.h"
6#include "EvtRecEvent/EvtRecTrack.h"
7
8#include "RootEventData/TEvtRecObject.h"
9#include "RootEventData/TEvtRecTrack.h"
10
11#include "RootCnvSvc/RootAddress.h"
12#include "RootCnvSvc/EvtRec/EvtRecCnv.h"
13#include "RootCnvSvc/EvtRec/EvtRecTrackCnv.h"
14
16 : RootEventBaseCnv(classID(), svc)
17{
18 m_rootBranchname = "m_evtRecTrackCol";
19 m_adresses.push_back(&m_evtRecTrackCol);
20 m_evtRecTrackCol = 0;
21}
22
23StatusCode EvtRecTrackCnv::TObjectToDataObject(DataObject*& refpObject) {
24 // creation of TDS object from root object
25 MsgStream log(msgSvc(), "EvtRecTrackCnv");
26 log << MSG::DEBUG << "EvtRecTrackCnv::TObjectToDataObject" << endreq;
27
28 // create the TDS location for the EvtRecTrack Collection
29 EvtRecTrackCol* evtRecTrackCol = new EvtRecTrackCol;
30 refpObject = evtRecTrackCol;
31
32 if ( ! m_evtRecTrackCol ) return StatusCode::SUCCESS;
33
34 IDataProviderSvc* dataSvc = 0;
35 StatusCode sc = serviceLocator()->getService("EventDataSvc",
36 IDataProviderSvc::interfaceID(), (IInterface*&)dataSvc);
37 if ( sc.isFailure() ) {
38 log << MSG::FATAL << "Could not get EventDataSvc in EvtRecTrackCnv" << endreq;
39 return sc;
40 }
41
42 /*SmartDataPtr<RecMdcTrackCol> mdcTrackCol(dataSvc, EventModel::Recon::RecMdcTrackCol);
43 if ( ! mdcTrackCol ) {
44 log << MSG::INFO << "Could not find RecMdcTrackCol" << endreq;
45 }
46
47 SmartDataPtr<RecMdcKalTrackCol> mdcKalTrackCol(dataSvc, EventModel::Recon::RecMdcKalTrackCol);
48 if ( ! mdcKalTrackCol ) {
49 log << MSG::INFO << "Could not find RecMdcKalTrackCol" << endreq;
50 }
51
52 SmartDataPtr<RecMdcDedxCol> mdcDedxCol(dataSvc, EventModel::Recon::RecMdcDedxCol);
53 if ( ! mdcDedxCol ) {
54 log << MSG::INFO << "Could not find RecMdcDedxCol" << endreq;
55 }
56
57 SmartDataPtr<RecExtTrackCol> extTrackCol(dataSvc, EventModel::Recon::RecExtTrackCol);
58 if ( ! extTrackCol ) {
59 log << MSG::INFO << "Could not find RecExtTrackCol" << endreq;
60 }
61
62 SmartDataPtr<RecTofTrackCol> tofTrackCol(dataSvc, EventModel::Recon::RecTofTrackCol);
63 if ( ! tofTrackCol ) {
64 log << MSG::INFO << "Could not find RecTofTrackCol" << endreq;
65 }
66
67 SmartDataPtr<RecEmcShowerCol> emcShowerCol(dataSvc, EventModel::Recon::RecEmcShowerCol);
68 if ( ! emcShowerCol ) {
69 log << MSG::INFO << "Could not find RecEmcShowerCol" << endreq;
70 }
71
72 SmartDataPtr<RecMucTrackCol> mucTrackCol(dataSvc, EventModel::Recon::RecMucTrackCol);
73 if ( ! mucTrackCol ) {
74 log << MSG::INFO << "Could not find RecMucTrackCol" << endreq;
75 }*/
76
77 //-----------------Dst to Rec convert in case of no Rec data in TDS
78 int trackID;
79
80 // Retrieve Mdc Track
81 SmartDataPtr<RecMdcTrackCol> mdcTrackCol(dataSvc, EventModel::Recon::RecMdcTrackCol);
82 if(!mdcTrackCol)
83 {
84 log << MSG::INFO << "Could not find RecMdcTrackCol" << endreq;
85 SmartDataPtr<DstMdcTrackCol> dstMdcTrackCol(dataSvc,"/Event/Dst/DstMdcTrackCol");
86 if (!dstMdcTrackCol) {
87 log << MSG::INFO << "Could not find DstMdcTrackCol" << endreq;
88 }
89 else {
90 RecMdcTrackCol* mdcTrackCol = new RecMdcTrackCol();
91 DstMdcTrackCol::iterator iter_mdc = dstMdcTrackCol->begin();
92 trackID = 0;
93 for (;iter_mdc != dstMdcTrackCol->end(); iter_mdc++, trackID++) {
94 RecMdcTrack* recMdcTrack = new RecMdcTrack();
95 *recMdcTrack = **iter_mdc;
96 (*mdcTrackCol).push_back(recMdcTrack);
97 log << MSG::INFO
98 << " Mdc Track ID = " << trackID
99 << " Mdc Track Nster = " << (*iter_mdc)->nster()
100 << endreq;
101 }
102 sc = dataSvc->registerObject(EventModel::Recon::RecMdcTrackCol,mdcTrackCol);
103 }
104 }
105
106 // Retrieve MdcKal track
107 SmartDataPtr<RecMdcKalTrackCol> mdcKalTrackCol(dataSvc, EventModel::Recon::RecMdcKalTrackCol);
108 if (!mdcKalTrackCol) {
109 log << MSG::INFO << "Could not find RecMdcKalTrackCol" << endreq;
110 SmartDataPtr<DstMdcKalTrackCol> dstMdcKalTrackCol(dataSvc,"/Event/Dst/DstMdcKalTrackCol");
111 if(!dstMdcKalTrackCol) {
112 log << MSG::INFO << "Could not find DstMdcKalTrackCol" << endreq;
113 }
114 else {
115 RecMdcKalTrackCol* mdcKalTrackCol = new RecMdcKalTrackCol();
116 DstMdcKalTrackCol::iterator iter_mdc = dstMdcKalTrackCol->begin();
117 trackID = 0;
118 for (;iter_mdc != dstMdcKalTrackCol->end(); iter_mdc++, trackID++) {
119 RecMdcKalTrack* recMdcKalTrack = new RecMdcKalTrack();
120 *recMdcKalTrack = **iter_mdc;
121 (*mdcKalTrackCol).push_back(recMdcKalTrack);
122 log << MSG::INFO
123 << " MdcKalTrack ID = " << trackID
124 << " MdcKalTrack Nster = " << (*iter_mdc)->nster()
125 << " MdcKalTrack poca = " << (*iter_mdc)->poca()
126 << endreq;
127 }
128 sc = dataSvc->registerObject(EventModel::Recon::RecMdcKalTrackCol, mdcKalTrackCol);
129 }
130 }
131
132 // Retrieve MdcDedx
133 SmartDataPtr<RecMdcDedxCol> mdcDedxCol(dataSvc, EventModel::Recon::RecMdcDedxCol);
134 if (!mdcDedxCol) {
135 log <<MSG::INFO << "Could not find RecMdcDedxCol" << endreq;
136 SmartDataPtr<DstMdcDedxCol> dstMdcDedxCol(dataSvc,"/Event/Dst/DstMdcDedxCol");
137 if(!dstMdcDedxCol) {
138 log <<MSG::INFO << "Could not find DstMdcDedxCol" << endreq;
139 }
140 else {
141 RecMdcDedxCol* mdcDedxCol = new RecMdcDedxCol();
142 DstMdcDedxCol::iterator iter_mdc = dstMdcDedxCol->begin();
143 trackID=0;
144 for (;iter_mdc != dstMdcDedxCol->end(); iter_mdc++, trackID++) {
145 RecMdcDedx* recMdcDedx = new RecMdcDedx();
146 *recMdcDedx= **iter_mdc;
147 (*mdcDedxCol).push_back(recMdcDedx);
148 log << MSG::INFO
149 << " MdcDedx ID = " << trackID
150 << " MdcDedx "
151 << endreq;
152 }
153 sc = dataSvc->registerObject(EventModel::Recon::RecMdcDedxCol, mdcDedxCol);
154 }
155 }
156 // Retrieve Cgem Track
157 SmartDataPtr<RecCgemTrackCol> cgemTrackCol(dataSvc, EventModel::Recon::RecCgemTrackCol);
158 if(!cgemTrackCol)
159 {
160 log << MSG::INFO << "Could not find RecCgemTrackCol" << endreq;
161 SmartDataPtr<DstCgemTrackCol> dstCgemTrackCol(dataSvc,"/Event/Dst/DstCgemTrackCol");
162 if (!dstCgemTrackCol) {
163 log << MSG::INFO << "Could not find DstCgemTrackCol" << endreq;
164 }
165 else {
166 RecCgemTrackCol* cgemTrackCol = new RecCgemTrackCol();
167 DstCgemTrackCol::iterator iter_cgem = dstCgemTrackCol->begin();
168 trackID = 0;
169 for (;iter_cgem != dstCgemTrackCol->end(); iter_cgem++, trackID++) {
170 RecCgemTrack* recCgemTrack = new RecCgemTrack();
171 *recCgemTrack = **iter_cgem;
172 (*cgemTrackCol).push_back(recCgemTrack);
173 log << MSG::INFO
174 << " Cgem Track ID = " << trackID
175 << endreq;
176 }
177 sc = dataSvc->registerObject(EventModel::Recon::RecCgemTrackCol,cgemTrackCol);
178 }
179 }
180
181 // Retrieve Cgem segment ; add by sunxh
182 SmartDataPtr<RecCgemSegmentCol> cgemSegmentCol(dataSvc, EventModel::Recon::RecCgemSegmentCol);
183 if(!cgemSegmentCol)
184 {
185 log << MSG::INFO << "Could not find RecCgemSegmentCol" << endreq;
186 SmartDataPtr<DstCgemSegmentCol> dstCgemSegmentCol(dataSvc,"/Event/Dst/DstCgemSegmentCol");
187 if (!dstCgemSegmentCol) {
188 log << MSG::INFO << "Could not find DstCgemSegmentCol" << endreq;
189 }
190 else {
191 RecCgemSegmentCol* cgemSegmentCol = new RecCgemSegmentCol();
192 DstCgemSegmentCol::iterator iter_cgem = dstCgemSegmentCol->begin();
193 trackID = 0;
194 for (;iter_cgem != dstCgemSegmentCol->end(); iter_cgem++, trackID++) {
195 RecCgemSegment* recCgemSegment = new RecCgemSegment();
196 *recCgemSegment = **iter_cgem;
197 (*cgemSegmentCol).push_back(recCgemSegment);
198 log << MSG::INFO
199 << " Cgem Track ID = " << trackID
200 << endreq;
201 }
202 sc = dataSvc->registerObject(EventModel::Recon::RecCgemSegmentCol,cgemSegmentCol);
203 }
204 }
205
206 // Retrieve CgemKal track
207 SmartDataPtr<RecCgemKalTrackCol> cgemKalTrackCol(dataSvc, EventModel::Recon::RecCgemKalTrackCol);
208 if (!cgemKalTrackCol) {
209 log << MSG::INFO << "Could not find RecCgemKalTrackCol" << endreq;
210 SmartDataPtr<DstCgemKalTrackCol> dstCgemKalTrackCol(dataSvc,"/Event/Dst/DstCgemKalTrackCol");
211 if(!dstCgemKalTrackCol) {
212 log << MSG::INFO << "Could not find DstCgemKalTrackCol" << endreq;
213 }
214 else {
215 RecCgemKalTrackCol* cgemKalTrackCol = new RecCgemKalTrackCol();
216 DstCgemKalTrackCol::iterator iter_cgem = dstCgemKalTrackCol->begin();
217 trackID = 0;
218 for (;iter_cgem != dstCgemKalTrackCol->end(); iter_cgem++, trackID++) {
219 RecCgemKalTrack* recCgemKalTrack = new RecCgemKalTrack();
220 *recCgemKalTrack = **iter_cgem;
221 (*cgemKalTrackCol).push_back(recCgemKalTrack);
222 log << MSG::INFO
223 << " CgemKalTrack ID = " << trackID
224 << " CgemKalTrack poca = " << (*iter_cgem)->poca()
225 << endreq;
226 }
227 sc = dataSvc->registerObject(EventModel::Recon::RecCgemKalTrackCol, cgemKalTrackCol);
228 }
229 }
230
231 // Retrieve CgemDedx
232 SmartDataPtr<RecCgemDedxCol> cgemDedxCol(dataSvc, EventModel::Recon::RecCgemDedxCol);
233 if (!cgemDedxCol) {
234 log <<MSG::INFO << "Could not find RecCgemDedxCol" << endreq;
235 SmartDataPtr<DstCgemDedxCol> dstCgemDedxCol(dataSvc,"/Event/Dst/DstCgemDedxCol");
236 if(!dstCgemDedxCol) {
237 log <<MSG::INFO << "Could not find DstCgemDedxCol" << endreq;
238 }
239 else {
240 RecCgemDedxCol* cgemDedxCol = new RecCgemDedxCol();
241 DstCgemDedxCol::iterator iter_cgem = dstCgemDedxCol->begin();
242 trackID=0;
243 for (;iter_cgem != dstCgemDedxCol->end(); iter_cgem++, trackID++) {
244 RecCgemDedx* recCgemDedx = new RecCgemDedx();
245 *recCgemDedx= **iter_cgem;
246 (*cgemDedxCol).push_back(recCgemDedx);
247 log << MSG::INFO
248 << " CgemDedx ID = " << trackID
249 << " CgemDedx "
250 << endreq;
251 }
252 sc = dataSvc->registerObject(EventModel::Recon::RecCgemDedxCol, cgemDedxCol);
253 }
254 }
255
256 // Retrieve Ext track
257 SmartDataPtr<RecExtTrackCol> extTrackCol(dataSvc, EventModel::Recon::RecExtTrackCol);
258 if (!extTrackCol) {
259 log <<MSG::INFO << "Could not find RecExtTrackCol" << endreq;
260 SmartDataPtr<DstExtTrackCol> dstExtTrackCol(dataSvc,"/Event/Dst/DstExtTrackCol");
261 if(!dstExtTrackCol) {
262 log <<MSG::INFO << "Could not find DstExtTrackCol" << endreq;
263 }
264 else {
265 RecExtTrackCol* extTrackCol = new RecExtTrackCol();
266 DstExtTrackCol::iterator iter_ext = dstExtTrackCol->begin();
267 trackID=0;
268 for (;iter_ext != dstExtTrackCol->end(); iter_ext++, trackID++) {
269 RecExtTrack* recExtTrack = new RecExtTrack();
270 *recExtTrack = **iter_ext;
271 (*extTrackCol).push_back(recExtTrack);
272 log << MSG::INFO
273 << " ExtTrack ID = " << trackID
274 << endreq;
275 }
276 sc = dataSvc->registerObject(EventModel::Recon::RecExtTrackCol, extTrackCol);
277 }
278 }
279
280 // Retrieve Tof Track
281 SmartDataPtr<RecTofTrackCol> tofTrackCol(dataSvc, EventModel::Recon::RecTofTrackCol);
282 if ( !tofTrackCol ) {
283 log << MSG::INFO << "Could not find TofTrackCol" << endreq;
284 SmartDataPtr<DstTofTrackCol> dstTofTrackCol(dataSvc,"/Event/Dst/DstTofTrackCol");
285 if(!dstTofTrackCol) {
286 log << MSG::INFO << "Could not find DstTofTrackCol" << endreq;
287 }
288 else {
289 RecTofTrackCol* tofTrackCol = new RecTofTrackCol();
290 DstTofTrackCol::iterator iter_tof = dstTofTrackCol->begin();
291 for (;iter_tof != dstTofTrackCol->end(); iter_tof++) {
292 RecTofTrack* recTofTrack = new RecTofTrack();
293 *recTofTrack = **iter_tof;
294 (*tofTrackCol).push_back(recTofTrack);
295 log << MSG::INFO
296 << "Tof Track ID = " << (*iter_tof)->tofTrackID()
297 << " Track ID = " << (*iter_tof)->trackID()
298 << " Tof Counter ID = "<<(*iter_tof)->tofID()
299 << " Quality = "<< (*iter_tof)->quality()
300 << endreq;
301 }
302 sc = dataSvc->registerObject(EventModel::Recon::RecTofTrackCol, tofTrackCol);
303 }
304 }
305
306
307 // Retrieve Emc shower
308 SmartDataPtr<RecEmcShowerCol> emcShowerCol(dataSvc, EventModel::Recon::RecEmcShowerCol);
309 if (!emcShowerCol) {
310 log << MSG::INFO << "Could not find RecEmcShowerCol" << endreq;
311 SmartDataPtr<DstEmcShowerCol> dstEmcShowerCol(dataSvc,"/Event/Dst/DstEmcShowerCol");
312 if(!dstEmcShowerCol) {
313 log << MSG::INFO << "Could not find DstEmcShowerCol" << endreq;
314 }
315 else {
316 RecEmcShowerCol* emcShowerCol = new RecEmcShowerCol();
317 DstEmcShowerCol::iterator iter_emc = dstEmcShowerCol->begin();
318 trackID=0;
319 for (;iter_emc != dstEmcShowerCol->end(); iter_emc++, trackID++) {
320 RecEmcShower* recEmcShower = new RecEmcShower();
321 *recEmcShower = **iter_emc;
322 (*emcShowerCol).push_back(recEmcShower);
323 log << MSG::INFO
324 << " EmcShower ID = " << trackID
325 << " EmcShower energy = " << (*iter_emc)->energy()
326 << endreq;
327 }
328 sc = dataSvc->registerObject(EventModel::Recon::RecEmcShowerCol, emcShowerCol);
329 }
330 }
331
332 // Retrieve Muc Track
333 SmartDataPtr<RecMucTrackCol> mucTrackCol(dataSvc, EventModel::Recon::RecMucTrackCol);
334 if (!mucTrackCol) {
335 log <<MSG::INFO << "Could not find RecMucTrackCol" << endreq;
336 SmartDataPtr<DstMucTrackCol> dstMucTrackCol(dataSvc,"/Event/Dst/DstMucTrackCol");
337 if(!dstMucTrackCol) {
338 log <<MSG::INFO << "Could not find DstMucTrackCol" << endreq;
339 }
340 else {
341 RecMucTrackCol* mucTrackCol = new RecMucTrackCol();
342 DstMucTrackCol::iterator iter_muc = dstMucTrackCol->begin();
343 trackID=0;
344 for (;iter_muc != dstMucTrackCol->end(); iter_muc++, trackID++) {
345 RecMucTrack* recMucTrack = new RecMucTrack();
346 *recMucTrack = **iter_muc;
347 (*mucTrackCol).push_back(recMucTrack);
348 log << MSG::INFO
349 << " MucTrack ID = "<< trackID
350 <<endreq;
351 }
352 sc = dataSvc->registerObject(EventModel::Recon::RecMucTrackCol, mucTrackCol);
353 }
354 }
355
356 // convert
357 TIter evtRecTrackIter(m_evtRecTrackCol);
358 TEvtRecTrack* evtRecTrackRoot = 0;
359 while ( (evtRecTrackRoot = (TEvtRecTrack*)evtRecTrackIter.Next() ) ) {
360 EvtRecTrack* evtRecTrack = new EvtRecTrack();
361 m_common.m_rootEvtRecTrackMap[evtRecTrackRoot] = evtRecTrack;
362 // set ....
363 evtRecTrack->setTrackId( evtRecTrackRoot->trackId() );
364 evtRecTrack->setPartId( evtRecTrackRoot->partId() );
365 evtRecTrack->setQuality( evtRecTrackRoot->quality() );
366
367 int mdcTrackId = evtRecTrackRoot->mdcTrackId();
368 if ( mdcTrackId >= 0 ) {
369 evtRecTrack->setMdcTrack(
370 dynamic_cast<RecMdcTrack*>(mdcTrackCol->containedObject(mdcTrackId))
371 );
372 }
373
374 int mdcKalTrackId = evtRecTrackRoot->mdcKalTrackId();
375 if ( mdcKalTrackId >= 0 ) {
376 evtRecTrack->setMdcKalTrack(
377 dynamic_cast<RecMdcKalTrack*>(mdcKalTrackCol->containedObject(mdcKalTrackId))
378 );
379 }
380
381 int mdcDedxId = evtRecTrackRoot->mdcDedxId();
382 if ( mdcDedxId >= 0 ) {
383 evtRecTrack->setMdcDedx(
384 dynamic_cast<RecMdcDedx*>(mdcDedxCol->containedObject(mdcDedxId))
385 );
386 }
387
388 int cgemSegmentId = evtRecTrackRoot->cgemSegmentId();
389 if ( cgemSegmentId >= 0 ) {
390 evtRecTrack->setCgemSegment(
391 dynamic_cast<RecCgemSegment*>(cgemSegmentCol->containedObject(cgemSegmentId))
392 );
393 }
394
395 int cgemTrackId = evtRecTrackRoot->cgemTrackId();
396 if ( cgemTrackId >= 0 ) {
397 evtRecTrack->setCgemTrack(
398 dynamic_cast<RecCgemTrack*>(cgemTrackCol->containedObject(cgemTrackId))
399 );
400 }
401
402 int cgemKalTrackId = evtRecTrackRoot->cgemKalTrackId();
403 if ( cgemKalTrackId >= 0 ) {
404 evtRecTrack->setCgemKalTrack(
405 dynamic_cast<RecCgemKalTrack*>(cgemKalTrackCol->containedObject(cgemKalTrackId))
406 );
407 }
408
409 int cgemDedxId = evtRecTrackRoot->cgemDedxId();
410 if ( cgemDedxId >= 0 ) {
411 evtRecTrack->setCgemDedx(
412 dynamic_cast<RecCgemDedx*>(cgemDedxCol->containedObject(cgemDedxId))
413 );
414 }
415
416 int extTrackId = evtRecTrackRoot->extTrackId();
417 if ( extTrackId >= 0 ) {
418 evtRecTrack->setExtTrack(
419 dynamic_cast<RecExtTrack*>(extTrackCol->containedObject(extTrackId))
420 );
421 }
422
423 const std::vector<int>& tofTrackIds = evtRecTrackRoot->tofTrackIds();
424 for ( unsigned int i = 0; i < tofTrackIds.size(); i++) {
425 RecTofTrack* tofTrack = dynamic_cast<RecTofTrack*>(tofTrackCol->containedObject(tofTrackIds[i]));
426 evtRecTrack->addTofTrack(tofTrack);
427 }
428
429 int emcShowerId = evtRecTrackRoot->emcShowerId();
430 if ( emcShowerId >= 0 ) {
431 evtRecTrack->setEmcShower(
432 dynamic_cast<RecEmcShower*>(emcShowerCol->containedObject(emcShowerId))
433 );
434 }
435
436 int mucTrackId = evtRecTrackRoot->mucTrackId();
437 if ( mucTrackId >= 0 ) {
438 evtRecTrack->setMucTrack(
439 dynamic_cast<RecMucTrack*>(mucTrackCol->containedObject(mucTrackId))
440 );
441 }
442
443 evtRecTrackCol->push_back(evtRecTrack);
444 }
445
446 delete m_evtRecTrackCol;
447 m_evtRecTrackCol = 0;
448 return StatusCode::SUCCESS;
449}
450
451StatusCode EvtRecTrackCnv::DataObjectToTObject(DataObject* obj, RootAddress* rootaddr) {
452 MsgStream log(msgSvc(), "EvtRecTrackCnv");
453 log << MSG::DEBUG << "EvtRecTrackCnv::DataObjectToTObject" << endreq;
454
455 EvtRecTrackCol* evtRecTrackCol = dynamic_cast<EvtRecTrackCol*> (obj);
456 if ( ! evtRecTrackCol ) {
457 log << MSG::ERROR << "Could not downcast to EvtRecTrackCol" << endreq;
458 return StatusCode::FAILURE;
459 }
460
461 DataObject* evt = NULL;
462 StatusCode sc = m_eds->findObject(EventModel::EvtRec::Event, evt);
463 if ( sc.isFailure() ) {
464 log << MSG::ERROR << "Could not get EvtRecObject in TDS" << endreq;
465 return StatusCode::FAILURE;
466 }
467 EvtRecObject* devtTds = dynamic_cast<EvtRecObject*> (evt);
468 if ( ! devtTds ) {
469 log << MSG::ERROR << "EvtRecTrackCnv: Could not downcast to TDS EvtRecObject" << endreq;
470 }
471
472 IOpaqueAddress *addr;
473 m_cnvSvc->getEvtRecCnv()->createRep(evt, addr);
475
476 const TObjArray* m_evtRecTrackCol = recEvt->getEvtRecTrackCol();
477 if ( ! m_evtRecTrackCol ) return StatusCode::SUCCESS;
478
479 IDataProviderSvc* dataSvc = 0;
480 sc = serviceLocator()->getService("EventDataSvc",
481 IDataProviderSvc::interfaceID(), (IInterface*&)dataSvc);
482 if ( sc.isFailure() ) {
483 log << MSG::FATAL << "Could not get EventDataSvc in EvtRecTrackCnv" << endreq;
484 return sc;
485 }
486
487 RecMdcTrackCol::iterator mdcTrackColbegin, mdcTrackColend;
488 RecMdcKalTrackCol::iterator mdcKalTrackColbegin, mdcKalTrackColend;
489 RecMdcDedxCol::iterator mdcDedxColbegin, mdcDedxColend;
490 RecCgemSegmentCol::iterator cgemSegmentColbegin, cgemSegmentColend;
491 RecCgemTrackCol::iterator cgemTrackColbegin, cgemTrackColend;
492 RecCgemKalTrackCol::iterator cgemKalTrackColbegin, cgemKalTrackColend;
493 RecCgemDedxCol::iterator cgemDedxColbegin, cgemDedxColend;
494 RecExtTrackCol::iterator extTrackColbegin, extTrackColend;
495 RecTofTrackCol::iterator tofTrackColbegin, tofTrackColend;
496 RecEmcShowerCol::iterator emcShowerColbegin, emcShowerColend;
497 RecMucTrackCol::iterator mucTrackColbegin, mucTrackColend;
498
499 SmartDataPtr<RecMdcTrackCol> mdcTrackCol(dataSvc, EventModel::Recon::RecMdcTrackCol);
500 if ( ! mdcTrackCol ) {
501 log << MSG::INFO << "Could not find RecMdcTrackCol" << endreq;
502 }
503 else {
504 mdcTrackColbegin = mdcTrackCol->begin();
505 mdcTrackColend = mdcTrackCol->end();
506 }
507
508 SmartDataPtr<RecMdcKalTrackCol> mdcKalTrackCol(dataSvc, EventModel::Recon::RecMdcKalTrackCol);
509 if ( ! mdcKalTrackCol ) {
510 log << MSG::INFO << "Could not find RecMdcKalTrackCol" << endreq;
511 }
512 else {
513 mdcKalTrackColbegin = mdcKalTrackCol->begin();
514 mdcKalTrackColend = mdcKalTrackCol->end();
515 }
516
517 SmartDataPtr<RecMdcDedxCol> mdcDedxCol(dataSvc, EventModel::Recon::RecMdcDedxCol);
518 if ( ! mdcDedxCol ) {
519 log << MSG::INFO << "Could not find RecMdcDedxCol" << endreq;
520 }
521 else {
522 mdcDedxColbegin = mdcDedxCol->begin();
523 mdcDedxColend = mdcDedxCol->end();
524 }
525
526 SmartDataPtr<RecCgemSegmentCol> cgemSegmentCol(dataSvc, EventModel::Recon::RecCgemSegmentCol);
527 if ( ! cgemSegmentCol ) {
528 log << MSG::INFO << "Could not find RecCgemSegmentCol" << endreq;
529 }
530 else {
531 cgemSegmentColbegin = cgemSegmentCol->begin();
532 cgemSegmentColend = cgemSegmentCol->end();
533 }
534
535 SmartDataPtr<RecCgemTrackCol> cgemTrackCol(dataSvc, EventModel::Recon::RecCgemTrackCol);
536 if ( ! cgemTrackCol ) {
537 log << MSG::INFO << "Could not find RecCgemTrackCol" << endreq;
538 }
539 else {
540 cgemTrackColbegin = cgemTrackCol->begin();
541 cgemTrackColend = cgemTrackCol->end();
542 }
543
544 SmartDataPtr<RecCgemKalTrackCol> cgemKalTrackCol(dataSvc, EventModel::Recon::RecCgemKalTrackCol);
545 if ( ! cgemKalTrackCol ) {
546 log << MSG::INFO << "Could not find RecCgemKalTrackCol" << endreq;
547 }
548 else {
549 cgemKalTrackColbegin = cgemKalTrackCol->begin();
550 cgemKalTrackColend = cgemKalTrackCol->end();
551 }
552
553 SmartDataPtr<RecCgemDedxCol> cgemDedxCol(dataSvc, EventModel::Recon::RecCgemDedxCol);
554 if ( ! cgemDedxCol ) {
555 log << MSG::INFO << "Could not find RecCgemDedxCol" << endreq;
556 }
557 else {
558 cgemDedxColbegin = cgemDedxCol->begin();
559 cgemDedxColend = cgemDedxCol->end();
560 }
561
562 SmartDataPtr<RecExtTrackCol> extTrackCol(dataSvc, EventModel::Recon::RecExtTrackCol);
563 if ( ! extTrackCol ) {
564 log << MSG::INFO << "Could not find RecExtTrackCol" << endreq;
565 }
566 else {
567 extTrackColbegin = extTrackCol->begin();
568 extTrackColend = extTrackCol->end();
569 }
570
571 SmartDataPtr<RecTofTrackCol> tofTrackCol(dataSvc, EventModel::Recon::RecTofTrackCol);
572 if ( ! tofTrackCol ) {
573 log << MSG::INFO << "Could not find RecTofTrackCol" << endreq;
574 }
575 else {
576 tofTrackColbegin = tofTrackCol->begin();
577 tofTrackColend = tofTrackCol->end();
578 }
579
580 SmartDataPtr<RecEmcShowerCol> emcShowerCol(dataSvc, EventModel::Recon::RecEmcShowerCol);
581 if ( ! emcShowerCol ) {
582 log << MSG::INFO << "Could not find RecEmcShowerCol" << endreq;
583 }
584 else {
585 emcShowerColbegin = emcShowerCol->begin();
586 emcShowerColend = emcShowerCol->end();
587 }
588
589 SmartDataPtr<RecMucTrackCol> mucTrackCol(dataSvc, EventModel::Recon::RecMucTrackCol);
590 if ( ! mucTrackCol ) {
591 log << MSG::INFO << "Could not find RecMucTrackCol" << endreq;
592 }
593 else {
594 mucTrackColbegin = mucTrackCol->begin();
595 mucTrackColend = mucTrackCol->end();
596 }
597
598 // convert
599 recEvt->clearEvtRecTrackCol();
600 EvtRecTrackCol::const_iterator evtRecTrack = evtRecTrackCol->begin();
601
602 for ( ; evtRecTrack != evtRecTrackCol->end(); evtRecTrack++) {
603 EvtRecTrack* ptr = *evtRecTrack;
604 TEvtRecTrack* evtRecTrackRoot = new TEvtRecTrack();
605 // set ...
606 evtRecTrackRoot->setTrackId( ptr->trackId() );
607 evtRecTrackRoot->setPartId( ptr->partId() );
608 evtRecTrackRoot->setQuality( ptr->quality() );
609
610 if ( ptr->isMdcTrackValid() ) {
611 RecMdcTrackCol::iterator it = find(mdcTrackColbegin, mdcTrackColend, ptr->mdcTrack());
612 evtRecTrackRoot->setMdcTrackId( it - mdcTrackColbegin );
613 }
614 if ( ptr->isMdcKalTrackValid() ) {
615 RecMdcKalTrackCol::iterator it = find(mdcKalTrackColbegin, mdcKalTrackColend, ptr->mdcKalTrack());
616 evtRecTrackRoot->setMdcKalTrackId( it - mdcKalTrackColbegin );
617 }
618 if ( ptr->isMdcDedxValid() ) {
619 RecMdcDedxCol::iterator it = find(mdcDedxColbegin, mdcDedxColend, ptr->mdcDedx());
620 evtRecTrackRoot->setMdcDedxId( it - mdcDedxColbegin );
621 }
622 if ( ptr->isCgemTrackValid() ) {
623 RecCgemTrackCol::iterator it = find(cgemTrackColbegin, cgemTrackColend, ptr->cgemTrack());
624 evtRecTrackRoot->setCgemTrackId( it - cgemTrackColbegin );
625 }
626 if ( ptr->isCgemSegmentValid() ) {
627 RecCgemSegmentCol::iterator it = find(cgemSegmentColbegin, cgemSegmentColend, ptr->cgemSegment());
628 evtRecTrackRoot->setCgemSegmentId( it - cgemSegmentColbegin );
629 }
630 if ( ptr->isCgemKalTrackValid() ) {
631 RecCgemKalTrackCol::iterator it = find(cgemKalTrackColbegin, cgemKalTrackColend, ptr->cgemKalTrack());
632 evtRecTrackRoot->setCgemKalTrackId( it - cgemKalTrackColbegin );
633 }
634 if ( ptr->isCgemDedxValid() ) {
635 RecCgemDedxCol::iterator it = find(cgemDedxColbegin, cgemDedxColend, ptr->cgemDedx());
636 evtRecTrackRoot->setCgemDedxId( it - cgemDedxColbegin );
637 }
638 if ( ptr->isExtTrackValid() ) {
639 RecExtTrackCol::iterator it = find(extTrackColbegin, extTrackColend, ptr->extTrack());
640 evtRecTrackRoot->setExtTrackId( it - extTrackColbegin );
641 }
642 if ( ptr->isTofTrackValid() ) {
643 SmartRefVector<RecTofTrack> tofTrackVec = ptr->tofTrack();
644 for ( unsigned int i = 0; i < tofTrackVec.size(); i++ ) {
645 RecTofTrackCol::iterator it = find(tofTrackColbegin, tofTrackColend, tofTrackVec[i]);
646 evtRecTrackRoot->addTofTrackId( it - tofTrackColbegin );
647 }
648 }
649 if ( ptr->isEmcShowerValid() ) {
650 RecEmcShowerCol::iterator it = find(emcShowerColbegin, emcShowerColend, ptr->emcShower());
651 evtRecTrackRoot->setEmcShowerId( it - emcShowerColbegin );
652 }
653 if ( ptr->isMucTrackValid() ) {
654 RecMucTrackCol::iterator it = find(mucTrackColbegin, mucTrackColend, ptr->mucTrack());
655 evtRecTrackRoot->setMucTrackId( it - mucTrackColbegin );
656 }
657
658 recEvt->addEvtRecTrack(evtRecTrackRoot);
659 }
660
661 return StatusCode::SUCCESS;
662}
ObjectVector< RecCgemKalTrack > RecCgemKalTrackCol
ObjectVector< RecCgemSegment > RecCgemSegmentCol
ObjectVector< RecExtTrack > RecExtTrackCol
ObjectVector< RecMdcDedx > RecMdcDedxCol
ObjectVector< RecMdcKalTrack > RecMdcKalTrackCol
ObjectVector< RecMdcTrack > RecMdcTrackCol
ObjectVector< RecMucTrack > RecMucTrackCol
ObjectVector< RecTofTrack > RecTofTrackCol
virtual StatusCode TObjectToDataObject(DataObject *&obj)
transformation from root
virtual StatusCode DataObjectToTObject(DataObject *obj, RootAddress *addr)
transformation to root
void addTofTrack(const SmartRef< RecTofTrack > trk)
Definition of a Root address, derived from IOpaqueAddress.
std::vector< void * > m_adresses
each converter knows the corresponding adresses
std::string m_rootBranchname
root branchname (may be concatenated of severals)
virtual StatusCode createRep(DataObject *pObject, IOpaqueAddress *&refpAddress)
Convert the transient object to the requested representation.
static std::map< const TObject *, const EvtRecTrack * > m_rootEvtRecTrackMap