31 MsgStream log(
msgSvc(),
"EvtRecDTagCnv" );
32 log << MSG::DEBUG <<
"EvtRecDTagCnv::TObjectToDataObject" << endmsg;
36 refpObject = evtRecDTagCol;
38 if ( !m_evtRecDTagCol )
return StatusCode::SUCCESS;
40 IDataProviderSvc* dataSvc = 0;
41 StatusCode sc = serviceLocator()->getService(
42 "EventDataSvc", IDataProviderSvc::interfaceID(), (IInterface*&)dataSvc );
45 log << MSG::FATAL <<
"Could not get EventDataSvc in EvtRecDTagCnv" << endmsg;
50 if ( !evtRecTrackCol ) { log << MSG::INFO <<
"Could not find EvtRecTrackCol" << endmsg; }
53 TIter evtRecDTagIter( m_evtRecDTagCol );
55 while ( ( evtRecDTagRoot = (
TEvtRecDTag*)evtRecDTagIter.Next() ) )
58 m_common.m_rootEvtRecDTagMap[evtRecDTagRoot] = evtRecDTag;
65 evtRecDTag->
setmBC( evtRecDTagRoot->
mBC() );
71 HepLorentzVector p4( evtRecDTagRoot->
px(), evtRecDTagRoot->
py(), evtRecDTagRoot->
pz(),
72 evtRecDTagRoot->
pe() );
73 evtRecDTag->
setp4( p4 );
75 const std::vector<int>& tracks = evtRecDTagRoot->
tracks();
76 const std::vector<int>& showers = evtRecDTagRoot->
showers();
77 const std::vector<int>& otherTracks = evtRecDTagRoot->
otherTracks();
78 const std::vector<int>& otherShowers = evtRecDTagRoot->
otherShowers();
79 const std::vector<int>& pionId = evtRecDTagRoot->
pionId();
80 const std::vector<int>& kaonId = evtRecDTagRoot->
kaonId();
82 for (
unsigned int i = 0; i < tracks.size(); i++ )
84 dynamic_cast<EvtRecTrack*
>( evtRecTrackCol->containedObject( tracks[i] ) ) );
86 for (
unsigned int i = 0; i < showers.size(); i++ )
88 dynamic_cast<EvtRecTrack*
>( evtRecTrackCol->containedObject( showers[i] ) ) );
90 for (
unsigned int i = 0; i < otherTracks.size(); i++ )
92 dynamic_cast<EvtRecTrack*
>( evtRecTrackCol->containedObject( otherTracks[i] ) ) );
94 for (
unsigned int i = 0; i < otherShowers.size(); i++ )
96 dynamic_cast<EvtRecTrack*
>( evtRecTrackCol->containedObject( otherShowers[i] ) ) );
98 for (
unsigned int i = 0; i < pionId.size(); i++ )
100 dynamic_cast<EvtRecTrack*
>( evtRecTrackCol->containedObject( pionId[i] ) ) );
102 for (
unsigned int i = 0; i < kaonId.size(); i++ )
104 dynamic_cast<EvtRecTrack*
>( evtRecTrackCol->containedObject( kaonId[i] ) ) );
106 evtRecDTagCol->push_back( evtRecDTag );
109 delete m_evtRecDTagCol;
111 return StatusCode::SUCCESS;
115 MsgStream log(
msgSvc(),
"EvtRecDTagCnv" );
116 log << MSG::DEBUG <<
"EvtRecDTagCnv::DataObjectToTObject" << endmsg;
119 if ( !evtRecDTagCol )
121 log << MSG::ERROR <<
"Could not downcast to EvtRecDTagCol" << endmsg;
122 return StatusCode::FAILURE;
129 log << MSG::ERROR <<
"Could not get EvtRecObject in TDS" << endmsg;
130 return StatusCode::FAILURE;
134 { log << MSG::ERROR <<
"EvtRecDTagCnv: Could not downcast to TDS EvtRecObject" << endmsg; }
136 IOpaqueAddress* addr;
137 m_cnvSvc->getEvtRecCnv()->createRep( evt, addr );
141 if ( !m_evtRecDTagCol )
return StatusCode::SUCCESS;
143 IDataProviderSvc* dataSvc = 0;
144 StatusCode sc = serviceLocator()->getService(
145 "EventDataSvc", IDataProviderSvc::interfaceID(), (IInterface*&)dataSvc );
146 if ( sc.isFailure() )
148 log << MSG::FATAL <<
"Could not get EventDataSvc in EvtRecDTagCnv" << endmsg;
152 EvtRecTrackCol::iterator evtRecTrackColbegin, evtRecTrackColend;
155 if ( !evtRecTrackCol ) { log << MSG::INFO <<
"Could not find EvtRecTrackCol" << endmsg; }
158 evtRecTrackColbegin = evtRecTrackCol->begin();
159 evtRecTrackColend = evtRecTrackCol->end();
164 EvtRecDTagCol::const_iterator evtRecDTag = evtRecDTagCol->begin();
166 for ( ; evtRecDTag != evtRecDTagCol->end(); evtRecDTag++ )
182 HepLorentzVector p4 = ptr->
p4();
183 evtRecDTagRoot->
setpx( p4.x() );
184 evtRecDTagRoot->
setpy( p4.y() );
185 evtRecDTagRoot->
setpz( p4.z() );
186 evtRecDTagRoot->
setpe( p4.t() );
188 SmartRefVector<EvtRecTrack> tracks = ptr->
tracks();
190 for (
unsigned int i = 0; i < tracks.size(); i++ )
192 EvtRecTrackCol::iterator it = find( evtRecTrackColbegin, evtRecTrackColend, tracks[i] );
194 evtRecDTagRoot->
addTrack( it - evtRecTrackColbegin );
197 SmartRefVector<EvtRecTrack> showers = ptr->
showers();
199 for (
unsigned int i = 0; i < showers.size(); i++ )
201 EvtRecTrackCol::iterator it = find( evtRecTrackColbegin, evtRecTrackColend, showers[i] );
203 evtRecDTagRoot->
addShower( it - evtRecTrackColbegin );
206 SmartRefVector<EvtRecTrack> otherTracks = ptr->
otherTracks();
208 for (
unsigned int i = 0; i < otherTracks.size(); i++ )
210 EvtRecTrackCol::iterator it =
211 find( evtRecTrackColbegin, evtRecTrackColend, otherTracks[i] );
216 SmartRefVector<EvtRecTrack> otherShowers = ptr->
otherShowers();
218 for (
unsigned int i = 0; i < otherShowers.size(); i++ )
220 EvtRecTrackCol::iterator it =
221 find( evtRecTrackColbegin, evtRecTrackColend, otherShowers[i] );
226 SmartRefVector<EvtRecTrack> pionId = ptr->
pionId();
228 for (
unsigned int i = 0; i < pionId.size(); i++ )
230 EvtRecTrackCol::iterator it = find( evtRecTrackColbegin, evtRecTrackColend, pionId[i] );
232 evtRecDTagRoot->
addPionId( it - evtRecTrackColbegin );
235 SmartRefVector<EvtRecTrack> kaonId = ptr->
kaonId();
237 for (
unsigned int i = 0; i < kaonId.size(); i++ )
239 EvtRecTrackCol::iterator it = find( evtRecTrackColbegin, evtRecTrackColend, kaonId[i] );
241 evtRecDTagRoot->
addKaonId( it - evtRecTrackColbegin );
247 return StatusCode::SUCCESS;