2#include "GaudiKernel/MsgStream.h"
4#include "EventModel/EventModel.h"
5#include "EvtRecEvent/EvtRecObject.h"
6#include "EvtRecEvent/EvtRecTrack.h"
8#include "RootEventData/TEvtRecObject.h"
9#include "RootEventData/TEvtRecTrack.h"
11#include "RootCnvSvc/RootAddress.h"
12#include "RootCnvSvc/EvtRec/EvtRecCnv.h"
13#include "RootCnvSvc/EvtRec/EvtRecTrackCnv.h"
18 m_rootBranchname =
"m_evtRecTrackCol";
19 m_adresses.push_back(&m_evtRecTrackCol);
25 MsgStream log(
msgSvc(),
"EvtRecTrackCnv");
26 log << MSG::DEBUG <<
"EvtRecTrackCnv::TObjectToDataObject" << endreq;
30 refpObject = evtRecTrackCol;
32 if ( ! m_evtRecTrackCol )
return StatusCode::SUCCESS;
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;
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;
91 DstMdcTrackCol::iterator iter_mdc = dstMdcTrackCol->begin();
93 for (;iter_mdc != dstMdcTrackCol->end(); iter_mdc++, trackID++) {
95 *recMdcTrack = **iter_mdc;
96 (*mdcTrackCol).push_back(recMdcTrack);
98 <<
" Mdc Track ID = " << trackID
99 <<
" Mdc Track Nster = " << (*iter_mdc)->
nster()
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;
116 DstMdcKalTrackCol::iterator iter_mdc = dstMdcKalTrackCol->begin();
118 for (;iter_mdc != dstMdcKalTrackCol->end(); iter_mdc++, trackID++) {
120 *recMdcKalTrack = **iter_mdc;
121 (*mdcKalTrackCol).push_back(recMdcKalTrack);
123 <<
" MdcKalTrack ID = " << trackID
124 <<
" MdcKalTrack Nster = " << (*iter_mdc)->
nster()
125 <<
" MdcKalTrack poca = " << (*iter_mdc)->poca()
135 log <<MSG::INFO <<
"Could not find RecMdcDedxCol" << endreq;
136 SmartDataPtr<DstMdcDedxCol> dstMdcDedxCol(dataSvc,
"/Event/Dst/DstMdcDedxCol");
138 log <<MSG::INFO <<
"Could not find DstMdcDedxCol" << endreq;
142 DstMdcDedxCol::iterator iter_mdc = dstMdcDedxCol->begin();
144 for (;iter_mdc != dstMdcDedxCol->end(); iter_mdc++, trackID++) {
146 *recMdcDedx= **iter_mdc;
147 (*mdcDedxCol).push_back(recMdcDedx);
149 <<
" MdcDedx ID = " << trackID
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;
167 DstCgemTrackCol::iterator iter_cgem = dstCgemTrackCol->begin();
169 for (;iter_cgem != dstCgemTrackCol->end(); iter_cgem++, trackID++) {
171 *recCgemTrack = **iter_cgem;
172 (*cgemTrackCol).push_back(recCgemTrack);
174 <<
" Cgem Track ID = " << trackID
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;
192 DstCgemSegmentCol::iterator iter_cgem = dstCgemSegmentCol->begin();
194 for (;iter_cgem != dstCgemSegmentCol->end(); iter_cgem++, trackID++) {
196 *recCgemSegment = **iter_cgem;
197 (*cgemSegmentCol).push_back(recCgemSegment);
199 <<
" Cgem Track ID = " << trackID
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;
216 DstCgemKalTrackCol::iterator iter_cgem = dstCgemKalTrackCol->begin();
218 for (;iter_cgem != dstCgemKalTrackCol->end(); iter_cgem++, trackID++) {
220 *recCgemKalTrack = **iter_cgem;
221 (*cgemKalTrackCol).push_back(recCgemKalTrack);
223 <<
" CgemKalTrack ID = " << trackID
224 <<
" CgemKalTrack poca = " << (*iter_cgem)->
poca()
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;
241 DstCgemDedxCol::iterator iter_cgem = dstCgemDedxCol->begin();
243 for (;iter_cgem != dstCgemDedxCol->end(); iter_cgem++, trackID++) {
245 *recCgemDedx= **iter_cgem;
246 (*cgemDedxCol).push_back(recCgemDedx);
248 <<
" CgemDedx ID = " << trackID
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;
266 DstExtTrackCol::iterator iter_ext = dstExtTrackCol->begin();
268 for (;iter_ext != dstExtTrackCol->end(); iter_ext++, trackID++) {
270 *recExtTrack = **iter_ext;
271 (*extTrackCol).push_back(recExtTrack);
273 <<
" ExtTrack ID = " << trackID
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;
290 DstTofTrackCol::iterator iter_tof = dstTofTrackCol->begin();
291 for (;iter_tof != dstTofTrackCol->end(); iter_tof++) {
293 *recTofTrack = **iter_tof;
294 (*tofTrackCol).push_back(recTofTrack);
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()
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;
317 DstEmcShowerCol::iterator iter_emc = dstEmcShowerCol->begin();
319 for (;iter_emc != dstEmcShowerCol->end(); iter_emc++, trackID++) {
321 *recEmcShower = **iter_emc;
322 (*emcShowerCol).push_back(recEmcShower);
324 <<
" EmcShower ID = " << trackID
325 <<
" EmcShower energy = " << (*iter_emc)->
energy()
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;
342 DstMucTrackCol::iterator iter_muc = dstMucTrackCol->begin();
344 for (;iter_muc != dstMucTrackCol->end(); iter_muc++, trackID++) {
346 *recMucTrack = **iter_muc;
347 (*mucTrackCol).push_back(recMucTrack);
349 <<
" MucTrack ID = "<< trackID
357 TIter evtRecTrackIter(m_evtRecTrackCol);
359 while ( (evtRecTrackRoot = (
TEvtRecTrack*)evtRecTrackIter.Next() ) ) {
367 int mdcTrackId = evtRecTrackRoot->
mdcTrackId();
368 if ( mdcTrackId >= 0 ) {
370 dynamic_cast<RecMdcTrack*
>(mdcTrackCol->containedObject(mdcTrackId))
375 if ( mdcKalTrackId >= 0 ) {
377 dynamic_cast<RecMdcKalTrack*
>(mdcKalTrackCol->containedObject(mdcKalTrackId))
381 int mdcDedxId = evtRecTrackRoot->
mdcDedxId();
382 if ( mdcDedxId >= 0 ) {
384 dynamic_cast<RecMdcDedx*
>(mdcDedxCol->containedObject(mdcDedxId))
389 if ( cgemSegmentId >= 0 ) {
391 dynamic_cast<RecCgemSegment*
>(cgemSegmentCol->containedObject(cgemSegmentId))
396 if ( cgemTrackId >= 0 ) {
398 dynamic_cast<RecCgemTrack*
>(cgemTrackCol->containedObject(cgemTrackId))
403 if ( cgemKalTrackId >= 0 ) {
405 dynamic_cast<RecCgemKalTrack*
>(cgemKalTrackCol->containedObject(cgemKalTrackId))
409 int cgemDedxId = evtRecTrackRoot->
cgemDedxId();
410 if ( cgemDedxId >= 0 ) {
412 dynamic_cast<RecCgemDedx*
>(cgemDedxCol->containedObject(cgemDedxId))
416 int extTrackId = evtRecTrackRoot->
extTrackId();
417 if ( extTrackId >= 0 ) {
419 dynamic_cast<RecExtTrack*
>(extTrackCol->containedObject(extTrackId))
423 const std::vector<int>& tofTrackIds = evtRecTrackRoot->
tofTrackIds();
424 for (
unsigned int i = 0; i < tofTrackIds.size(); i++) {
430 if ( emcShowerId >= 0 ) {
432 dynamic_cast<RecEmcShower*
>(emcShowerCol->containedObject(emcShowerId))
436 int mucTrackId = evtRecTrackRoot->
mucTrackId();
437 if ( mucTrackId >= 0 ) {
439 dynamic_cast<RecMucTrack*
>(mucTrackCol->containedObject(mucTrackId))
443 evtRecTrackCol->push_back(evtRecTrack);
446 delete m_evtRecTrackCol;
447 m_evtRecTrackCol = 0;
448 return StatusCode::SUCCESS;
452 MsgStream log(
msgSvc(),
"EvtRecTrackCnv");
453 log << MSG::DEBUG <<
"EvtRecTrackCnv::DataObjectToTObject" << endreq;
456 if ( ! evtRecTrackCol ) {
457 log << MSG::ERROR <<
"Could not downcast to EvtRecTrackCol" << endreq;
458 return StatusCode::FAILURE;
461 DataObject* evt = NULL;
463 if ( sc.isFailure() ) {
464 log << MSG::ERROR <<
"Could not get EvtRecObject in TDS" << endreq;
465 return StatusCode::FAILURE;
469 log << MSG::ERROR <<
"EvtRecTrackCnv: Could not downcast to TDS EvtRecObject" << endreq;
472 IOpaqueAddress *addr;
477 if ( ! m_evtRecTrackCol )
return StatusCode::SUCCESS;
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;
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;
500 if ( ! mdcTrackCol ) {
501 log << MSG::INFO <<
"Could not find RecMdcTrackCol" << endreq;
504 mdcTrackColbegin = mdcTrackCol->begin();
505 mdcTrackColend = mdcTrackCol->end();
509 if ( ! mdcKalTrackCol ) {
510 log << MSG::INFO <<
"Could not find RecMdcKalTrackCol" << endreq;
513 mdcKalTrackColbegin = mdcKalTrackCol->begin();
514 mdcKalTrackColend = mdcKalTrackCol->end();
518 if ( ! mdcDedxCol ) {
519 log << MSG::INFO <<
"Could not find RecMdcDedxCol" << endreq;
522 mdcDedxColbegin = mdcDedxCol->begin();
523 mdcDedxColend = mdcDedxCol->end();
527 if ( ! cgemSegmentCol ) {
528 log << MSG::INFO <<
"Could not find RecCgemSegmentCol" << endreq;
531 cgemSegmentColbegin = cgemSegmentCol->begin();
532 cgemSegmentColend = cgemSegmentCol->end();
536 if ( ! cgemTrackCol ) {
537 log << MSG::INFO <<
"Could not find RecCgemTrackCol" << endreq;
540 cgemTrackColbegin = cgemTrackCol->begin();
541 cgemTrackColend = cgemTrackCol->end();
545 if ( ! cgemKalTrackCol ) {
546 log << MSG::INFO <<
"Could not find RecCgemKalTrackCol" << endreq;
549 cgemKalTrackColbegin = cgemKalTrackCol->begin();
550 cgemKalTrackColend = cgemKalTrackCol->end();
554 if ( ! cgemDedxCol ) {
555 log << MSG::INFO <<
"Could not find RecCgemDedxCol" << endreq;
558 cgemDedxColbegin = cgemDedxCol->begin();
559 cgemDedxColend = cgemDedxCol->end();
563 if ( ! extTrackCol ) {
564 log << MSG::INFO <<
"Could not find RecExtTrackCol" << endreq;
567 extTrackColbegin = extTrackCol->begin();
568 extTrackColend = extTrackCol->end();
572 if ( ! tofTrackCol ) {
573 log << MSG::INFO <<
"Could not find RecTofTrackCol" << endreq;
576 tofTrackColbegin = tofTrackCol->begin();
577 tofTrackColend = tofTrackCol->end();
581 if ( ! emcShowerCol ) {
582 log << MSG::INFO <<
"Could not find RecEmcShowerCol" << endreq;
585 emcShowerColbegin = emcShowerCol->begin();
586 emcShowerColend = emcShowerCol->end();
590 if ( ! mucTrackCol ) {
591 log << MSG::INFO <<
"Could not find RecMucTrackCol" << endreq;
594 mucTrackColbegin = mucTrackCol->begin();
595 mucTrackColend = mucTrackCol->end();
600 EvtRecTrackCol::const_iterator evtRecTrack = evtRecTrackCol->begin();
602 for ( ; evtRecTrack != evtRecTrackCol->end(); evtRecTrack++) {
611 RecMdcTrackCol::iterator it = find(mdcTrackColbegin, mdcTrackColend, ptr->
mdcTrack());
615 RecMdcKalTrackCol::iterator it = find(mdcKalTrackColbegin, mdcKalTrackColend, ptr->
mdcKalTrack());
619 RecMdcDedxCol::iterator it = find(mdcDedxColbegin, mdcDedxColend, ptr->
mdcDedx());
623 RecCgemTrackCol::iterator it = find(cgemTrackColbegin, cgemTrackColend, ptr->
cgemTrack());
627 RecCgemSegmentCol::iterator it = find(cgemSegmentColbegin, cgemSegmentColend, ptr->
cgemSegment());
631 RecCgemKalTrackCol::iterator it = find(cgemKalTrackColbegin, cgemKalTrackColend, ptr->
cgemKalTrack());
635 RecCgemDedxCol::iterator it = find(cgemDedxColbegin, cgemDedxColend, ptr->
cgemDedx());
639 RecExtTrackCol::iterator it = find(extTrackColbegin, extTrackColend, ptr->
extTrack());
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]);
650 RecEmcShowerCol::iterator it = find(emcShowerColbegin, emcShowerColend, ptr->
emcShower());
654 RecMucTrackCol::iterator it = find(mucTrackColbegin, mucTrackColend, ptr->
mucTrack());
661 return StatusCode::SUCCESS;
ObjectVector< RecCgemDedx > RecCgemDedxCol
ObjectVector< RecCgemKalTrack > RecCgemKalTrackCol
ObjectVector< RecCgemSegment > RecCgemSegmentCol
ObjectVector< RecCgemTrack > RecCgemTrackCol
ObjectVector< RecEmcShower > RecEmcShowerCol
ObjectVector< EvtRecTrack > EvtRecTrackCol
ObjectVector< RecExtTrack > RecExtTrackCol
ObjectVector< RecMdcDedx > RecMdcDedxCol
ObjectVector< RecMdcKalTrack > RecMdcKalTrackCol
ObjectVector< RecMdcTrack > RecMdcTrackCol
ObjectVector< RecMucTrack > RecMucTrackCol
ObjectVector< RecTofTrack > RecTofTrackCol
const HepPoint3D poca() const
static TEvtRecObject * getWriteObject()
EvtRecTrackCnv(ISvcLocator *svc)
virtual StatusCode TObjectToDataObject(DataObject *&obj)
transformation from root
virtual StatusCode DataObjectToTObject(DataObject *obj, RootAddress *addr)
transformation to root
void setCgemTrack(const RecCgemTrack *trk)
void setCgemDedx(const RecCgemDedx *trk)
void setMucTrack(const RecMucTrack *trk)
void setQuality(const int quality)
void setPartId(const int partId)
RecCgemSegment * cgemSegment()
void setMdcTrack(const RecMdcTrack *trk)
void setCgemSegment(const RecCgemSegment *trk)
void setTrackId(const int trkId)
RecCgemKalTrack * cgemKalTrack()
void setMdcKalTrack(const RecMdcKalTrack *trk)
void setCgemKalTrack(const RecCgemKalTrack *trk)
bool isCgemSegmentValid()
void setMdcDedx(const RecMdcDedx *trk)
bool isMdcKalTrackValid()
SmartRefVector< RecTofTrack > tofTrack()
void setEmcShower(const RecEmcShower *shower)
void addTofTrack(const SmartRef< RecTofTrack > trk)
RecEmcShower * emcShower()
RecCgemTrack * cgemTrack()
bool isCgemKalTrackValid()
RecMdcKalTrack * mdcKalTrack()
void setExtTrack(const RecExtTrack *trk)
Definition of a Root address, derived from IOpaqueAddress.
EvtRecCnv * getEvtRecCnv()
Base class for all Root Converters.
IDataProviderSvc * m_eds
pointer to eventdataservice
virtual StatusCode createRep(DataObject *pObject, IOpaqueAddress *&refpAddress)
Convert the transient object to the requested representation.
void clearEvtRecTrackCol()
void addEvtRecTrack(TEvtRecTrack *track)
const TObjArray * getEvtRecTrackCol() const
void addTofTrackId(const int tofTrackId)
void setTrackId(const int trackId)
void setCgemTrackId(const int cgemTrackId)
void setMdcTrackId(const int mdcTrackId)
Int_t cgemTrackId() const
Int_t cgemSegmentId() const
void setCgemKalTrackId(const int cgemKalTrackId)
void setMdcDedxId(const int mdcDedxId)
void setMucTrackId(const int mucTrackId)
void setCgemSegmentId(const int cgemSegmentId)
void setMdcKalTrackId(const int mdcKalTrackId)
void setEmcShowerId(const int emcShowerId)
void setPartId(const int partId)
void setExtTrackId(const int extTrackId)
void setCgemDedxId(const int cgemDedxId)
Int_t emcShowerId() const
void setQuality(const int quality)
Int_t mdcKalTrackId() const
const std::vector< Int_t > & tofTrackIds() const
Int_t cgemKalTrackId() const
static std::map< const TObject *, const EvtRecTrack * > m_rootEvtRecTrackMap
_EXTERN_ std::string Event
_EXTERN_ std::string RecCgemTrackCol
_EXTERN_ std::string RecExtTrackCol
_EXTERN_ std::string RecCgemDedxCol
_EXTERN_ std::string RecMdcDedxCol
_EXTERN_ std::string RecTofTrackCol
_EXTERN_ std::string RecCgemKalTrackCol
_EXTERN_ std::string RecCgemSegmentCol
_EXTERN_ std::string RecMdcTrackCol
_EXTERN_ std::string RecMdcKalTrackCol
_EXTERN_ std::string RecMucTrackCol
_EXTERN_ std::string RecEmcShowerCol