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"
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);
81 SmartDataPtr<RecCgemClusterCol> aCgemClusterCol(dataSvc,
"/Event/Recon/RecCgemClusterCol");
82 if(!aCgemClusterCol) {
83 log << MSG::FATAL <<
"Could not find RecCgemClusterCol" << endreq;
84 return( StatusCode::FAILURE);
87 mdcTrackIter = m_recMdcTrackCol;
89 while ((recMdcTrackRoot = (
TRecMdcTrack*)mdcTrackIter.Next())) {
90 int trackId = recMdcTrackRoot->
trackId();
91 int charge = recMdcTrackRoot->
charge();
93 for(
int i=0;i<5; i++){
94 helix[i] = recMdcTrackRoot->
helix(i);
96 double pxy = recMdcTrackRoot->
pxy();
97 double px = recMdcTrackRoot->
px();
98 double py = recMdcTrackRoot->
py();
99 double pz = recMdcTrackRoot->
pz();
100 double p = recMdcTrackRoot->
p();
101 double theta = recMdcTrackRoot->
theta();
102 double phi = recMdcTrackRoot->
phi();
103 double x = recMdcTrackRoot->
x();
104 double y = recMdcTrackRoot->
y();
105 double z = recMdcTrackRoot->
z();
106 double r = recMdcTrackRoot->
r();
107 int stat = recMdcTrackRoot->
stat();
108 double chi = recMdcTrackRoot->
chi2();
109 int ndof = recMdcTrackRoot->
ndof();
110 int nlayer= recMdcTrackRoot->
nlayer();
114 for (
int i=0; i<15; i++){
115 err[i] = recMdcTrackRoot->
err(i);
117 int nh = recMdcTrackRoot->
nhits();
118 int ns = recMdcTrackRoot->
nster();
120 double vx0 = recMdcTrackRoot->
vx0();
121 double vy0 = recMdcTrackRoot->
vy0();
122 double vz0 = recMdcTrackRoot->
vz0();
123 double fiterm = recMdcTrackRoot->
fiTerm();
130 recMdcTrack->
setPxy( pxy );
131 recMdcTrack->
setPx( px );
132 recMdcTrack->
setPy( py );
133 recMdcTrack->
setPz( pz );
134 recMdcTrack->
setP( p );
136 recMdcTrack->
setPhi( phi );
137 recMdcTrack->
setX(
x );
138 recMdcTrack->
setY( y );
139 recMdcTrack->
setZ( z );
140 recMdcTrack->
setR( r );
150 recMdcTrack->
setVX0( vx0 );
151 recMdcTrack->
setVY0( vy0 );
152 recMdcTrack->
setVZ0( vz0 );
159 RecMdcHitCol::iterator
iter = recMdcHitCol->begin();
160 for (;
iter != recMdcHitCol->end();
iter++){
163 if((*iter)->getTrkId() == trackId){
164 SmartRef<RecMdcHit> refhit(*
iter);
165 theHitRefVec.push_back(refhit);
175 for(
int ii=0; ii <nhits ; ii++){
187 map<int,int> clusterFitStat;
188 vector<Int_t> vecClusterId = recMdcTrackRoot->
vecClusterId();
189 cout<<
"recMdcTrackRoot gets a vecClusterId with size "<<vecClusterId.size()<<endl;
190 vector<Int_t>::iterator it_clusterId = vecClusterId.begin();
191 RecCgemClusterCol::iterator iter_cluster=aCgemClusterCol->begin();
193 for(; it_clusterId!=vecClusterId.end(); it_clusterId++)
196 iter_cluster=aCgemClusterCol->begin()+(*it_clusterId);
197 if((*iter_cluster)->getclusterid()==(*it_clusterId))
200 clusterRefVec.push_back(recCgemCluster);
202 clusterFitStat[clusterid] = 1;
204 else cout<<
"wrong clusterRefVec assignment in RecMdcTrackCnv"<<endl;
209 recMdcTrackCol->push_back(recMdcTrack);
212 delete m_recMdcTrackCol;
213 m_recMdcTrackCol = 0;
214 return StatusCode::SUCCESS;
222 MsgStream log(
msgSvc(),
"RecMdcTrackCnv");
223 log << MSG::DEBUG <<
"RecMdcTrackCnv::DataObjectToTObject" << endreq;
226 if (!mdcTrackColTds) {
227 log << MSG::ERROR <<
"Could not downcast to MdcTrackCol" << endreq;
228 return StatusCode::FAILURE;
232 if (!sc.isSuccess()) {
233 log << MSG::ERROR <<
"Could not get ReconEvent in TDS " << endreq;
234 return StatusCode::FAILURE;
238 log << MSG::ERROR <<
"RecMdcTrackCnv:Could not downcast to TDS ReconEvent" << endreq;
241 IOpaqueAddress *addr;
247 if (!m_recMdcTrackCol)
return StatusCode::SUCCESS;
251 RecMdcTrackCol::const_iterator recMdcTrack;
252 for (recMdcTrack = mdcTrackColTds->begin(); recMdcTrack != mdcTrackColTds->end(); recMdcTrack++) {
253 Int_t trackId =(*recMdcTrack)->trackId();
255 for(
int i=0;i<5;i++){
256 log<<MSG::INFO<<
" recMdcTrack.helix("<<i<<
"): "<<(*recMdcTrack)->helix(i)<<endreq;
257 helix[i] = (*recMdcTrack)->helix(i);
260 Int_t stat = (*recMdcTrack)->stat();
261 Double_t chi = (*recMdcTrack)->chi2();
262 Int_t ndof = (*recMdcTrack)->ndof();
263 Int_t
ns = (*recMdcTrack)->nster();
264 Int_t nlayer =(*recMdcTrack)->nlayer();
269 for (Int_t i=0; i<15; i++){
270 er[i] = (*recMdcTrack)->err(i);
272 Int_t nh = (*recMdcTrack)->getNhits();
274 Double_t vx0 = (*recMdcTrack)->getVX0();
275 Double_t vy0 = (*recMdcTrack)->getVY0();
276 Double_t vz0 = (*recMdcTrack)->getVZ0();
277 Double_t fiterm =(*recMdcTrack)->getFiTerm();
284 log<<MSG::INFO<<
" test,recMdcTrackRoot.px: "<<recMdcTrackRoot->
px()
285 <<
" recMdcTrackRoot.py: "<<recMdcTrackRoot->
py()
286 <<
" recMdcTrackRoot.pz: "<<recMdcTrackRoot->
pz()
289 recMdcTrackRoot->
setStat( stat );
290 recMdcTrackRoot->
setChi2( chi );
291 recMdcTrackRoot->
setNdof( ndof );
295 recMdcTrackRoot->
setErr( er );
299 recMdcTrackRoot->
setVX0( vx0 );
300 recMdcTrackRoot->
setVY0( vy0 );
301 recMdcTrackRoot->
setVZ0( vz0 );
304 vector<Int_t> vecClusterId;
305 ClusterRefVec clusterRefVec = (*recMdcTrack)->getVecClusters();
306 ClusterRefVec::iterator itCluster=clusterRefVec.begin();
307 for(; itCluster!=clusterRefVec.end(); itCluster++)
309 Int_t clusterId= (*itCluster)->getclusterid();
310 vecClusterId.push_back(clusterId);
319 return StatusCode::SUCCESS;
SmartRefVector< RecCgemCluster > ClusterRefVec
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)
int getclusterid(void) const
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 setVecClusters(ClusterRefVec vecclusters)
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.
std::vector< void * > m_adresses
each converter knows the corresponding adresses
IDataProviderSvc * m_eds
pointer to eventdataservice
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)
void setVecClusterId(vector< Int_t > &vecCluId)
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)
vector< Int_t > vecClusterId() const
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