2#define MdcTrackCnv_CXX 1
4#include "GaudiKernel/MsgStream.h"
5#include "GaudiKernel/DataObject.h"
6#include "GaudiKernel/ObjectVector.h"
7#include "TClonesArray.h"
8#include "EventModel/EventModel.h"
9#include "DstEvent/DstEvent.h"
10#include "DstEvent/DstMdcTrack.h"
11#include "RootEventData/TMdcTrack.h"
12#include "RootEventData/TDstEvent.h"
13#include "RootCnvSvc/Dst/DstCnv.h"
14#include "RootCnvSvc/Dst/MdcTrackCnv.h"
15#include "RootCnvSvc/RootAddress.h"
17#include "CLHEP/Matrix/Vector.h"
18#include "CLHEP/Matrix/SymMatrix.h"
19#include "CLHEP/Geometry/Point3D.h"
28 MsgStream log(
msgSvc(),
"MdcTrackCnv");
29 m_rootBranchname =
"m_mdcTrackCol";
30 m_adresses.push_back(&m_mdcTrackCol);
36 MsgStream log(
msgSvc(),
"MdcTrackCnv");
37 log << MSG::DEBUG <<
"MdcTrackCnv::TObjectToDataObject" << endreq;
38 StatusCode sc=StatusCode::SUCCESS;
42 refpObject=mdcTrackTdsCol;
45 if (!m_mdcTrackCol)
return sc;
46 TIter mdcTrackIter(m_mdcTrackCol);
48 while ((mdcTrackRoot = (
TMdcTrack*)mdcTrackIter.Next())) {
50 int trackId = mdcTrackRoot->
trackId();
51 int charge = mdcTrackRoot->
charge();
53 for(
int i=0; i<5; i++){
54 helix[i] = mdcTrackRoot->
helix(i);
55 log<<MSG::INFO<<
"in MdcTrackCnv, helix["<<i<<
"]: "<<helix[i]<<endreq;
57 double pxy = mdcTrackRoot->
pxy();
58 double px = mdcTrackRoot->
px();
59 double py = mdcTrackRoot->
py();
60 double pz = mdcTrackRoot->
pz();
61 double p = mdcTrackRoot->
p();
62 double theta = mdcTrackRoot->
theta();
63 double phi = mdcTrackRoot->
phi();
64 double x = mdcTrackRoot->
x();
65 double y = mdcTrackRoot->
y();
66 double z = mdcTrackRoot->
z();
67 double r = mdcTrackRoot->
r();
68 int stat = mdcTrackRoot->
stat();
69 double chi = mdcTrackRoot->
chi2();
70 int ndof = mdcTrackRoot->
ndof();
72 int nlayer = mdcTrackRoot->
nlayer();
77 for (
int i=0; i<15; i++){
78 err[i] = mdcTrackRoot->
err(i);
86 log<<MSG::INFO<<
"in MdcTrackCnv, mdcTrackRoot.nster "<<
ns<<endreq;
92 log<<MSG::INFO<<
" dstMdcTrack trkid: "<<mdcTrackTds->
trackId()<<endreq;
98 log<<MSG::INFO<<
"dstMdcTrack helix: "<<mdcTrackTds->
helix()<<endreq;
100 mdcTrackTds->
setPxy( pxy );
101 mdcTrackTds->
setPx( px );
102 mdcTrackTds->
setPy( py );
103 mdcTrackTds->
setPz( pz );
104 mdcTrackTds->
setP( p );
106 mdcTrackTds->
setPhi( phi );
107 mdcTrackTds->
setX( x );
108 mdcTrackTds->
setY( y );
109 mdcTrackTds->
setZ( z );
110 mdcTrackTds->
setR( r );
120 log<<MSG::INFO<<
" dstMdcTrack nster: "<<mdcTrackTds->
nster()<<endreq;
122 mdcTrackTdsCol->push_back(mdcTrackTds);
125 delete m_mdcTrackCol;
127 return StatusCode::SUCCESS;
132 MsgStream log(
msgSvc(),
"MdcTrackCnv");
133 log << MSG::DEBUG <<
"MdcTrackCnv::DataObjectToTObject" << endreq;
134 StatusCode sc=StatusCode::SUCCESS;
137 if (!mdcTrackColTds) {
138 log << MSG::ERROR <<
"Could not downcast to MdcTrackCol" << endreq;
139 return StatusCode::FAILURE;
145 log << MSG::ERROR <<
"Could not get DstEvent in TDS " << endreq;
146 return StatusCode::FAILURE;
150 log << MSG::ERROR <<
"MdcTrackCnv:Could not downcast to TDS DstEvent" << endreq;
152 IOpaqueAddress *addr;
158 if (!m_mdcTrackCol)
return sc;
160 DstMdcTrackCol::const_iterator mdcTrackTds;
162 for (mdcTrackTds = mdcTrackColTds->begin(); mdcTrackTds != mdcTrackColTds->end(); mdcTrackTds++) {
163 Int_t trackId =(*mdcTrackTds)->
trackId();
165 for(
int i=0;i<5;i++){
166 helix[i] = (*mdcTrackTds)->helix(i) ;
168 Int_t stat = (*mdcTrackTds)->stat();
169 Double_t chi = (*mdcTrackTds)->chi2();
170 Int_t ndof = (*mdcTrackTds)->ndof();
172 for (Int_t i=0; i<15; i++){
173 err[i] = (*mdcTrackTds)->err(i);
175 Int_t
ns = (*mdcTrackTds)->nster();
176 Int_t fL = (*mdcTrackTds)->firstLayer();
177 Int_t lL = (*mdcTrackTds)->lastLayer();
178 Int_t nlayer = (*mdcTrackTds)->nlayer();
179 Int_t nCgemXCluster = (*mdcTrackTds)->nCgemXCluster();
180 Int_t nCgemVCluster = (*mdcTrackTds)->nCgemVCluster();
187 log<<MSG::INFO<<
"test,trackId: "<<mdcTrackRoot->
trackId()<<endreq;
188 log<<MSG::INFO<<
"test,px: "<<mdcTrackRoot->
px()
189 <<
"test,py: "<<mdcTrackRoot->
py()
190 <<
"test,pz: "<<mdcTrackRoot->
pz()<<endreq;
195 mdcTrackRoot->
setErr( err );
206 return StatusCode::SUCCESS;
ObjectVector< DstMdcTrack > DstMdcTrackCol
static TDstEvent * getWriteObject()
returns object to be written (maintained here for all DIGI-converters)
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 setNCgemXCluster(const int n)
void setNdof(const int ndof)
void setTheta(const double theta)
void setStat(const int stat)
const int trackId() const
void setNlayer(const int nlayer)
void setP(const double p)
void setHelix(double helix[5])
void setPoca(double poca[3])
void setR(const double r)
void setCharge(const int charge)
const HepVector helix() const
......
void setY(const double y)
void setChi2(const double chi)
void setPhi(const double phi)
void setNCgemVCluster(const int n)
void setPz(const double pz)
void setPx(const double px)
virtual StatusCode DataObjectToTObject(DataObject *obj, RootAddress *addr)
transformation to root
virtual StatusCode TObjectToDataObject(DataObject *&obj)
transformation from root
MdcTrackCnv(ISvcLocator *svc)
Definition of a Root address, derived from IOpaqueAddress.
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 addMdcTrack(TMdcTrack *Track)
Add a Tkrtrack into the Mdc data collection.
void clearMdcTrackCol()
clear the whole array (necessary because of the consts-s)
const TObjArray * getMdcTrackCol() const
retrieve the whole TObjArray of MdcTrack Data
const Double_t py() const
const Int_t charge() const
void setNCgemVClusters(const Int_t n)
const Double_t pz() const
const Double_t helix(Int_t i) const
const Double_t chi2() const
const Double_t phi() const
void setLastLayer(const Int_t lL)
Int_t nCgemVClusters() const
const Double_t px() const
void setNster(const Int_t ns)
void setChi2(const Double_t chi)
Int_t nCgemXClusters() const
const Double_t theta() const
const Double_t pxy() const
void setNlayer(const Int_t nlayer)
const Int_t nster() const
const Double_t err(Int_t i) const
const Int_t trackId() const
void setNdof(const Int_t ndof)
void setTrackId(const Int_t trackId)
void setFirstLayer(const Int_t fL)
const Int_t nlayer() const
void setErr(const Double_t err[15])
void setStat(const Int_t stat)
void setNCgemXClusters(const Int_t n)
void setHelix(const Double_t helix[5])
static std::map< const TObject *, const DstMdcTrack * > m_rootMdcTrackMap
_EXTERN_ std::string Event