2#include "GaudiKernel/MsgStream.h"
4#include "EventModel/EventModel.h"
5#include "EvtRecEvent/EvtRecObject.h"
6#include "EvtRecEvent/EvtRecDTag.h"
8#include "RootEventData/TEvtRecObject.h"
9#include "RootEventData/TEvtRecDTag.h"
11#include "RootCnvSvc/RootAddress.h"
12#include "RootCnvSvc/EvtRec/EvtRecCnv.h"
13#include "RootCnvSvc/EvtRec/EvtRecDTagCnv.h"
15#include "CLHEP/Matrix/Vector.h"
16#include "CLHEP/Matrix/SymMatrix.h"
21using CLHEP::HepVector;
22using CLHEP::HepSymMatrix;
34 MsgStream log(
msgSvc(),
"EvtRecDTagCnv");
35 log << MSG::DEBUG <<
"EvtRecDTagCnv::TObjectToDataObject" << endreq;
39 refpObject = evtRecDTagCol;
41 if ( ! m_evtRecDTagCol )
return StatusCode::SUCCESS;
43 IDataProviderSvc* dataSvc = 0;
44 StatusCode sc = serviceLocator()->getService(
"EventDataSvc",
45 IDataProviderSvc::interfaceID(), (IInterface*&)dataSvc);
46 if ( sc.isFailure() ) {
47 log << MSG::FATAL <<
"Could not get EventDataSvc in EvtRecDTagCnv" << endreq;
52 if ( ! evtRecTrackCol) {
53 log << MSG::INFO <<
"Could not find EvtRecTrackCol" << endreq;
57 TIter evtRecDTagIter(m_evtRecDTagCol);
59 while ( (evtRecDTagRoot = (
TEvtRecDTag*)evtRecDTagIter.Next() ) ) {
68 evtRecDTag->
setmBC( evtRecDTagRoot->
mBC() );
74 HepLorentzVector p4(evtRecDTagRoot->
px(),evtRecDTagRoot->
py(),evtRecDTagRoot->
pz(),evtRecDTagRoot->
pe());
75 evtRecDTag->
setp4(p4);
78 const std::vector<int>& tracks=evtRecDTagRoot->
tracks();
79 const std::vector<int>& showers=evtRecDTagRoot->
showers();
80 const std::vector<int>& otherTracks=evtRecDTagRoot->
otherTracks();
81 const std::vector<int>& otherShowers=evtRecDTagRoot->
otherShowers();
82 const std::vector<int>& pionId=evtRecDTagRoot->
pionId();
83 const std::vector<int>& kaonId=evtRecDTagRoot->
kaonId();
85 for(
unsigned int i=0; i<tracks.size();i++)
87 dynamic_cast<EvtRecTrack*
>(evtRecTrackCol->containedObject(tracks[i]))
90 for(
unsigned int i=0; i<showers.size();i++)
92 dynamic_cast<EvtRecTrack*
>(evtRecTrackCol->containedObject(showers[i]))
96 for(
unsigned int i=0; i<otherTracks.size();i++)
98 dynamic_cast<EvtRecTrack*
>(evtRecTrackCol->containedObject(otherTracks[i]))
102 for(
unsigned int i=0; i<otherShowers.size();i++)
104 dynamic_cast<EvtRecTrack*
>(evtRecTrackCol->containedObject(otherShowers[i]))
107 for(
unsigned int i=0; i<pionId.size();i++)
109 dynamic_cast<EvtRecTrack*
>(evtRecTrackCol->containedObject(pionId[i]))
112 for(
unsigned int i=0; i<kaonId.size();i++)
114 dynamic_cast<EvtRecTrack*
>(evtRecTrackCol->containedObject(kaonId[i]))
119 evtRecDTagCol->push_back(evtRecDTag);
122 delete m_evtRecDTagCol;
124 return StatusCode::SUCCESS;
128 MsgStream log(
msgSvc(),
"EvtRecDTagCnv");
129 log << MSG::DEBUG <<
"EvtRecDTagCnv::DataObjectToTObject" << endreq;
132 if ( ! evtRecDTagCol ) {
133 log << MSG::ERROR <<
"Could not downcast to EvtRecDTagCol" << endreq;
134 return StatusCode::FAILURE;
140 log << MSG::ERROR <<
"Could not get EvtRecObject in TDS" << endreq;
141 return StatusCode::FAILURE;
145 log << MSG::ERROR <<
"EvtRecDTagCnv: Could not downcast to TDS EvtRecObject" << endreq;
148 IOpaqueAddress *addr;
153 if ( ! m_evtRecDTagCol )
return StatusCode::SUCCESS;
155 IDataProviderSvc* dataSvc = 0;
156 StatusCode sc = serviceLocator()->getService(
"EventDataSvc",
157 IDataProviderSvc::interfaceID(), (IInterface*&)dataSvc);
158 if ( sc.isFailure() ) {
159 log << MSG::FATAL <<
"Could not get EventDataSvc in EvtRecDTagCnv" << endreq;
163 EvtRecTrackCol::iterator evtRecTrackColbegin, evtRecTrackColend;
166 if ( ! evtRecTrackCol) {
167 log << MSG::INFO <<
"Could not find EvtRecTrackCol" << endreq;
170 evtRecTrackColbegin = evtRecTrackCol->begin();
171 evtRecTrackColend = evtRecTrackCol->end();
176 EvtRecDTagCol::const_iterator evtRecDTag = evtRecDTagCol->begin();
178 for ( ; evtRecDTag != evtRecDTagCol->end(); evtRecDTag++) {
193 HepLorentzVector p4=ptr->
p4();
194 evtRecDTagRoot->
setpx(p4.x());
195 evtRecDTagRoot->
setpy(p4.y());
196 evtRecDTagRoot->
setpz(p4.z());
197 evtRecDTagRoot->
setpe(p4.t());
201 SmartRefVector<EvtRecTrack> tracks=ptr->
tracks();
203 for(
unsigned int i=0; i<tracks.size();i++){
204 EvtRecTrackCol::iterator it = find(evtRecTrackColbegin,
205 evtRecTrackColend, tracks[i]);
207 evtRecDTagRoot->
addTrack(it - evtRecTrackColbegin );
211 SmartRefVector<EvtRecTrack> showers=ptr->
showers();
213 for(
unsigned int i=0; i<showers.size();i++){
214 EvtRecTrackCol::iterator it = find(evtRecTrackColbegin,
215 evtRecTrackColend, showers[i]);
217 evtRecDTagRoot->
addShower(it - evtRecTrackColbegin );
221 SmartRefVector<EvtRecTrack> otherTracks=ptr->
otherTracks();
223 for(
unsigned int i=0; i<otherTracks.size();i++){
224 EvtRecTrackCol::iterator it = find(evtRecTrackColbegin,
225 evtRecTrackColend, otherTracks[i]);
230 SmartRefVector<EvtRecTrack> otherShowers=ptr->
otherShowers();
232 for(
unsigned int i=0; i<otherShowers.size();i++){
233 EvtRecTrackCol::iterator it = find(evtRecTrackColbegin,
234 evtRecTrackColend, otherShowers[i]);
239 SmartRefVector<EvtRecTrack> pionId=ptr->
pionId();
241 for(
unsigned int i=0; i<pionId.size();i++){
242 EvtRecTrackCol::iterator it = find(evtRecTrackColbegin,
243 evtRecTrackColend, pionId[i]);
245 evtRecDTagRoot->
addPionId(it - evtRecTrackColbegin );
248 SmartRefVector<EvtRecTrack> kaonId=ptr->
kaonId();
250 for(
unsigned int i=0; i<kaonId.size();i++){
251 EvtRecTrackCol::iterator it = find(evtRecTrackColbegin,
252 evtRecTrackColend, kaonId[i]);
254 evtRecDTagRoot->
addKaonId(it - evtRecTrackColbegin );
261 return StatusCode::SUCCESS;
ObjectVector< EvtRecDTag > EvtRecDTagCol
static TEvtRecObject * getWriteObject()
virtual StatusCode TObjectToDataObject(DataObject *&obj)
transformation from root
EvtRecDTagCnv(ISvcLocator *svc)
virtual StatusCode DataObjectToTObject(DataObject *obj, RootAddress *addr)
transformation to root
SmartRefVector< EvtRecTrack > tracks()
SmartRefVector< EvtRecTrack > showers()
void addOtherTrack(const SmartRef< EvtRecTrack > track)
SmartRefVector< EvtRecTrack > otherShowers()
void settype(SelType type)
SmartRefVector< EvtRecTrack > kaonId()
void setdecayMode(DecayMode decayMode)
HepLorentzVector p4() const
void setp4(HepLorentzVector p4)
SmartRefVector< EvtRecTrack > otherTracks()
void setmass(double mass)
void addOtherShower(const SmartRef< EvtRecTrack > shower)
void addKaonId(const SmartRef< EvtRecTrack > kaonId)
void setdeltaE(double deltaE)
void setcharge(int charge)
SmartRefVector< EvtRecTrack > pionId()
void addPionId(const SmartRef< EvtRecTrack > pionId)
void setbeamE(double beamE)
int numOfChildren() const
DecayMode decayMode() const
void addShower(const SmartRef< EvtRecTrack > shower)
void setnumOfChildren(int numOfChildren)
void addTrack(const SmartRef< EvtRecTrack > track)
Definition of a Root address, derived from IOpaqueAddress.
EvtRecCnv * getEvtRecCnv()
Base class for all Root Converters.
IDataProviderSvc * m_eds
pointer to eventdataservice
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.
const std::vector< Int_t > & otherShowers() const
void setnumOfChildren(Int_t numOfChildren)
void addTrack(Int_t track)
void setbeamE(Double_t beamE)
void addOtherTrack(Int_t track)
void addOtherShower(Int_t shower)
void setmass(Double_t mass)
void addPionId(Int_t pionId)
const std::vector< Int_t > & showers() const
void setcharge(Int_t charge)
void addShower(Int_t shower)
void setdeltaE(Double_t deltaE)
Int_t numOfChildren() const
void setcharm(Int_t charm)
const std::vector< Int_t > & otherTracks() const
void addKaonId(Int_t kaonId)
void setmBC(Double_t mBC)
const std::vector< Int_t > & kaonId() const
void setdecayMode(Int_t decayMode)
const std::vector< Int_t > & tracks() const
const std::vector< Int_t > & pionId() const
void clearEvtRecDTagCol()
const TObjArray * getEvtRecDTagCol() const
void addEvtRecDTag(TEvtRecDTag *dtag)
static std::map< const TObject *, const EvtRecDTag * > m_rootEvtRecDTagMap
_EXTERN_ std::string Event
_EXTERN_ std::string EvtRecTrackCol