1#ifndef RecMdcTrackCnv_CXX
2#define RecMdcTrackCnv_CXX 1
4#include "GaudiKernel/MsgStream.h"
5#include "GaudiKernel/DataObject.h"
6#include "GaudiKernel/ObjectVector.h"
8#include "TClonesArray.h"
9#include "Identifier/MdcID.h"
10#include "Identifier/Identifier.h"
12#include "EventModel/EventModel.h"
14#include "ReconEvent/ReconEvent.h"
15#include "MdcRecEvent/RecMdcTrack.h"
16#include "MdcRecEvent/RecMdcHit.h"
17#include "RootEventData/TRecMdcTrack.h"
18#include "RootEventData/TRecTrackEvent.h"
20#include "RootCnvSvc/Rec/RecTrackCnv.h"
21#include "RootCnvSvc/Rec/RecMdcTrackCnv.h"
22#include "RootCnvSvc/RootAddress.h"
37 MsgStream log(
msgSvc(),
"RecMdcTrackCnv");
47 MsgStream log(
msgSvc(),
"RecMdcTrackCnv");
48 log << MSG::DEBUG <<
"RecMdcTrackCnv::TObjectToDataObject" << endreq;
52 refpObject = recMdcTrackCol;
54 if (!m_recMdcTrackCol)
return StatusCode::SUCCESS;
55 TIter mdcTrackIter(m_recMdcTrackCol);
63 IDataProviderSvc* dataSvc = 0;
64 StatusCode sc = serviceLocator()->getService (
"EventDataSvc",
65 IDataProviderSvc::interfaceID(), (IInterface*&)dataSvc);
66 if (!sc.isSuccess()) {
67 log << MSG::FATAL <<
"Could not get EventDataSvc in RecMdcTrackCnv" << endreq;
68 return( StatusCode::FAILURE);
70 SmartDataPtr<RecMdcHitCol> recMdcHitCol(dataSvc,
"/Event/Recon/RecMdcHitCol");
72 log << MSG::FATAL <<
"Could not find RecMdcHitCol" << endreq;
73 return( StatusCode::FAILURE);
82 mdcTrackIter = m_recMdcTrackCol;
84 while ((recMdcTrackRoot = (
TRecMdcTrack*)mdcTrackIter.Next())) {
85 int trackId = recMdcTrackRoot->
trackId();
88 for(
int i=0;i<5; i++){
89 helix[i] = recMdcTrackRoot->
helix(i);
91 double pxy = recMdcTrackRoot->
pxy();
92 double px = recMdcTrackRoot->
px();
93 double py = recMdcTrackRoot->
py();
94 double pz = recMdcTrackRoot->
pz();
95 double p = recMdcTrackRoot->
p();
96 double theta = recMdcTrackRoot->
theta();
97 double phi = recMdcTrackRoot->
phi();
98 double x = recMdcTrackRoot->
x();
99 double y = recMdcTrackRoot->
y();
100 double z = recMdcTrackRoot->
z();
101 double r = recMdcTrackRoot->
r();
102 int stat = recMdcTrackRoot->
stat();
103 double chi = recMdcTrackRoot->
chi2();
104 int ndof = recMdcTrackRoot->
ndof();
105 int nlayer= recMdcTrackRoot->
nlayer();
107 for (
int i=0; i<15; i++){
108 err[i] = recMdcTrackRoot->
err(i);
110 int nh = recMdcTrackRoot->
nhits();
111 int ns = recMdcTrackRoot->
nster();
113 double vx0 = recMdcTrackRoot->
vx0();
114 double vy0 = recMdcTrackRoot->
vy0();
115 double vz0 = recMdcTrackRoot->
vz0();
116 double fiterm = recMdcTrackRoot->
fiTerm();
123 recMdcTrack->
setPxy( pxy );
124 recMdcTrack->
setPx( px );
125 recMdcTrack->
setPy( py );
126 recMdcTrack->
setPz( pz );
127 recMdcTrack->
setP( p );
129 recMdcTrack->
setPhi( phi );
130 recMdcTrack->
setX(
x );
131 recMdcTrack->
setY(
y );
132 recMdcTrack->
setZ( z );
133 recMdcTrack->
setR( r );
143 recMdcTrack->
setVX0( vx0 );
144 recMdcTrack->
setVY0( vy0 );
145 recMdcTrack->
setVZ0( vz0 );
150 RecMdcHitCol::iterator
iter = recMdcHitCol->begin();
151 for (;
iter != recMdcHitCol->end();
iter++){
154 if((*iter)->getTrkId() == trackId){
155 SmartRef<RecMdcHit> refhit(*
iter);
156 theHitRefVec.push_back(refhit);
166 for(
int ii=0; ii <
nhits ; ii++){
175 recMdcTrackCol->push_back(recMdcTrack);
178 delete m_recMdcTrackCol;
179 m_recMdcTrackCol = 0;
180 return StatusCode::SUCCESS;
188 MsgStream log(
msgSvc(),
"RecMdcTrackCnv");
189 log << MSG::DEBUG <<
"RecMdcTrackCnv::DataObjectToTObject" << endreq;
192 if (!mdcTrackColTds) {
193 log << MSG::ERROR <<
"Could not downcast to MdcTrackCol" << endreq;
194 return StatusCode::FAILURE;
198 if (!sc.isSuccess()) {
199 log << MSG::ERROR <<
"Could not get ReconEvent in TDS " << endreq;
200 return StatusCode::FAILURE;
204 log << MSG::ERROR <<
"RecMdcTrackCnv:Could not downcast to TDS ReconEvent" << endreq;
207 IOpaqueAddress *addr;
213 if (!m_recMdcTrackCol)
return StatusCode::SUCCESS;
217 RecMdcTrackCol::const_iterator recMdcTrack;
218 for (recMdcTrack = mdcTrackColTds->begin(); recMdcTrack != mdcTrackColTds->end(); recMdcTrack++) {
219 Int_t trackId =(*recMdcTrack)->trackId();
221 for(
int i=0;i<5;i++){
222 log<<MSG::INFO<<
" recMdcTrack.helix("<<i<<
"): "<<(*recMdcTrack)->helix(i)<<endreq;
223 helix[i] = (*recMdcTrack)->helix(i);
226 Int_t stat = (*recMdcTrack)->stat();
227 Double_t chi = (*recMdcTrack)->chi2();
228 Int_t ndof = (*recMdcTrack)->ndof();
229 Int_t
ns = (*recMdcTrack)->nster();
230 Int_t nlayer =(*recMdcTrack)->nlayer();
233 for (Int_t i=0; i<15; i++){
234 er[i] = (*recMdcTrack)->err(i);
236 Int_t nh = (*recMdcTrack)->getNhits();
238 Double_t vx0 = (*recMdcTrack)->getVX0();
239 Double_t vy0 = (*recMdcTrack)->getVY0();
240 Double_t vz0 = (*recMdcTrack)->getVZ0();
241 Double_t fiterm =(*recMdcTrack)->getFiTerm();
248 log<<MSG::INFO<<
" test,recMdcTrackRoot.px: "<<recMdcTrackRoot->
px()
249 <<
" recMdcTrackRoot.py: "<<recMdcTrackRoot->
py()
250 <<
" recMdcTrackRoot.pz: "<<recMdcTrackRoot->
pz()
253 recMdcTrackRoot->
setStat( stat );
254 recMdcTrackRoot->
setChi2( chi );
255 recMdcTrackRoot->
setNdof( ndof );
257 recMdcTrackRoot->
setErr( er );
261 recMdcTrackRoot->
setVX0( vx0 );
262 recMdcTrackRoot->
setVY0( vy0 );
263 recMdcTrackRoot->
setVZ0( vz0 );
270 return StatusCode::SUCCESS;
ObjectVector< RecMdcTrack > RecMdcTrackCol
SmartRefVector< RecMdcHit > HitRefVec
void setPxy(const double pxy)
void setTrackId(const int trackId)
void setPy(const double py)
void setZ(const double z)
void setNster(const int ns)
void setX(const double x)
void setError(double err[15])
void setNdof(const int ndof)
void setTheta(const double theta)
void setStat(const int stat)
void setNlayer(const int nlayer)
void setP(const double p)
void setHelix(double helix[5])
void setR(const double r)
void setCharge(const int charge)
void setY(const double y)
void setChi2(const double chi)
void setPhi(const double phi)
void setPz(const double pz)
void setPx(const double px)
static int layer(const Identifier &id)
Values of different levels (failure returns 0)
static int wire(const Identifier &id)
RecMdcTrackCnv(ISvcLocator *svc)
virtual StatusCode TObjectToDataObject(DataObject *&obj)
transformation from root
virtual StatusCode DataObjectToTObject(DataObject *obj, RootAddress *addr)
transformation to root
const HitRefVec getVecHits(void) const
void setVecHits(HitRefVec vechits)
void setFiTerm(double fiterm)
static TRecTrackEvent * getWriteObject()
returns object to be written (maintained here for all DIGI-converters)
Definition of a Root address, derived from IOpaqueAddress.
RecTrackCnv * getRecTrackCnv()
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.
void setVZ0(Double_t vz0)
const Double_t phi() const
const Double_t pz() const
void setStat(const Int_t stat)
void setVX0(Double_t vx0)
void setNdof(const Int_t ndof)
const Int_t nster() const
const Double_t vz0(void) const
void setErr(const Double_t er[15])
void setHelix(const Double_t helix[5])
const Double_t px() const
const Int_t nhits() const
const Double_t chi2() const
void setNhits(const Int_t nh)
const Int_t trackId() const
void setNster(const Int_t ns)
void setNlayer(const Int_t nlayer)
void setChi2(const Double_t chi)
const Double_t vy0(void) const
const Double_t fiTerm(void) const
void setTrackId(const Int_t trackId)
const Double_t pxy() const
const Double_t err(Int_t i) const
const Double_t theta() const
void setFiTerm(Double_t fiterm)
const Int_t nlayer() const
void setVY0(Double_t vy0)
const Int_t charge() const
const Double_t vx0(void) const
const Double_t py() const
const Double_t helix(Int_t i) const
void addRecMdcTrack(TRecMdcTrack *Track)
Add a TkrTrack into the Mdc data collection.
void clearRecMdcTrackCol()
clear the whole array (necessary because of the consts-s)
const TObjArray * getRecMdcTrackCol() const
retrieve the whole TObjArray of RecMdcTrack Data
static std::map< const TObject *, const RecMdcTrack * > m_rootRecMdcTrackMap
_EXTERN_ std::string Event