1#ifndef CgemTrackCnv_CXX
2#define CgemTrackCnv_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/DstCgemTrack.h"
11#include "RootEventData/TCgemTrack.h"
12#include "RootEventData/TDstEvent.h"
13#include "RootCnvSvc/Dst/DstCnv.h"
14#include "RootCnvSvc/Dst/CgemTrackCnv.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(),
"CgemTrackCnv");
29 m_rootBranchname =
"m_cgemTrackCol";
30 m_adresses.push_back(&m_cgemTrackCol);
36 MsgStream log(
msgSvc(),
"CgemTrackCnv");
38 log << MSG::INFO <<
"My Message::CgemTrackCnv::TObjectToDataObject()"<<endreq;
40 log << MSG::DEBUG <<
"CgemTrackCnv::TObjectToDataObject" << endreq;
41 StatusCode sc=StatusCode::SUCCESS;
45 refpObject=cgemTrackTdsCol;
48 if (!m_cgemTrackCol)
return sc;
49 TIter cgemTrackIter(m_cgemTrackCol);
51 while ((cgemTrackRoot = (
TCgemTrack*)cgemTrackIter.Next())) {
53 int trackId = cgemTrackRoot->
trackId();
54 int charge = cgemTrackRoot->
charge();
56 for(
int i=0; i<5; i++){
57 helix[i] = cgemTrackRoot->
helix(i);
58 log<<MSG::INFO<<
"in CgemTrackCnv, helix["<<i<<
"]: "<<helix[i]<<endreq;
60 double pxy = cgemTrackRoot->
pxy();
61 double px = cgemTrackRoot->
px();
62 double py = cgemTrackRoot->
py();
63 double pz = cgemTrackRoot->
pz();
64 double p = cgemTrackRoot->
p();
65 double theta = cgemTrackRoot->
theta();
66 double phi = cgemTrackRoot->
phi();
67 double x = cgemTrackRoot->
x();
68 double y = cgemTrackRoot->
y();
69 double z = cgemTrackRoot->
z();
70 double r = cgemTrackRoot->
r();
71 int stat = cgemTrackRoot->
stat();
72 double chi = cgemTrackRoot->
chi2();
73 int ndof = cgemTrackRoot->
ndof();
76 for (
int i=0; i<15; i++){
77 err[i] = cgemTrackRoot->
err(i);
86 log << MSG::INFO <<
"My Message::CgemTrackCnv::TObjectToDataObject::charge:"<<charge<<
",p:"<<p<<
",r:"<<r<<
",z:"<<z<<endreq;
92 log<<MSG::INFO<<
" dstCgemTrack trkid: "<<cgemTrackTds->
trackId()<<endreq;
98 log<<MSG::INFO<<
"dstCgemTrack helix: "<<cgemTrackTds->
helix()<<endreq;
100 cgemTrackTds->
setPxy( pxy );
101 cgemTrackTds->
setPx( px );
102 cgemTrackTds->
setPy( py );
103 cgemTrackTds->
setPz( pz );
104 cgemTrackTds->
setP( p );
106 cgemTrackTds->
setPhi( phi );
107 cgemTrackTds->
setX( x );
108 cgemTrackTds->
setY( y );
109 cgemTrackTds->
setZ( z );
110 cgemTrackTds->
setR( r );
116 cgemTrackTdsCol->push_back(cgemTrackTds);
119 delete m_cgemTrackCol;
122 log << MSG::INFO <<
"My Message::CgemTrackCnv::TObjectToDataObject()-finished"<<endreq;
124 return StatusCode::SUCCESS;
129 MsgStream log(
msgSvc(),
"CgemTrackCnv");
131 log << MSG::INFO <<
"My Message::CgemTrackCnv::DataObjectToTObject("<<rootaddr->
getTreename()<<
")"<<endreq;
133 log << MSG::DEBUG <<
"CgemTrackCnv::DataObjectToTObject" << endreq;
134 StatusCode sc=StatusCode::SUCCESS;
137 if (!cgemTrackColTds) {
138 log << MSG::ERROR <<
"Could not downcast to CgemTrackCol" << endreq;
140 log << MSG::INFO <<
"My Message::CgemTrackCnv::DataObjectToTObject("<<rootaddr->
getTreename()<<
")-finished"<<endreq;
142 return StatusCode::FAILURE;
148 log << MSG::ERROR <<
"Could not get DstEvent in TDS " << endreq;
150 log << MSG::INFO <<
"My Message::CgemTrackCnv::DataObjectToTObject("<<rootaddr->
getTreename()<<
")-finished"<<endreq;
152 return StatusCode::FAILURE;
156 log << MSG::ERROR <<
"CgemTrackCnv:Could not downcast to TDS DstEvent" << endreq;
158 IOpaqueAddress *addr;
161 log << MSG::INFO <<
"My Message::CgemTrackCnv::DataObjectToTObject("<<rootaddr->
getTreename()<<
")::DstCnv"<<endreq;
167 if (!m_cgemTrackCol)
return sc;
169 DstCgemTrackCol::const_iterator cgemTrackTds;
171 for (cgemTrackTds = cgemTrackColTds->begin(); cgemTrackTds != cgemTrackColTds->end(); cgemTrackTds++) {
172 Int_t trackId =(*cgemTrackTds)->
trackId();
174 for(
int i=0;i<5;i++){
175 helix[i] = (*cgemTrackTds)->helix(i) ;
177 Int_t stat = (*cgemTrackTds)->stat();
178 Double_t chi = (*cgemTrackTds)->chi2();
179 Int_t ndof = (*cgemTrackTds)->ndof();
181 for (Int_t i=0; i<15; i++){
182 err[i] = (*cgemTrackTds)->err(i);
184 Int_t fL = (*cgemTrackTds)->firstLayer();
185 Int_t lL = (*cgemTrackTds)->lastLayer();
192 log<<MSG::INFO<<
"test,trackId: "<<cgemTrackRoot->
trackId()<<endreq;
193 log<<MSG::INFO<<
"test,px: "<<cgemTrackRoot->
px()
194 <<
"test,py: "<<cgemTrackRoot->
py()
195 <<
"test,pz: "<<cgemTrackRoot->
pz()<<endreq;
197 cgemTrackRoot->
setStat( stat );
199 cgemTrackRoot->
setNdof( ndof );
200 cgemTrackRoot->
setErr( err );
208 log << MSG::INFO <<
"My Message::CgemTrackCnv::DataObjectToTObject("<<rootaddr->
getTreename()<<
")-finished"<<endreq;
210 return StatusCode::SUCCESS;
ObjectVector< DstCgemTrack > DstCgemTrackCol
virtual StatusCode DataObjectToTObject(DataObject *obj, RootAddress *addr)
transformation to root
CgemTrackCnv(ISvcLocator *svc)
virtual StatusCode TObjectToDataObject(DataObject *&obj)
transformation from root
void setStat(const int stat)
void setPx(const double px)
void setPhi(const double phi)
void setTheta(const double theta)
void setCharge(const int charge)
void setHelix(double helix[5])
void setZ(const double z)
void setP(const double p)
const int trackId() const
void setTrackId(const int trackId)
void setError(double err[15])
void setPxy(const double pxy)
void setPy(const double py)
void setY(const double y)
void setPoca(double poca[3])
void setX(const double x)
void setNdof(const int ndof)
void setR(const double r)
void setPz(const double pz)
void setChi2(const double chi)
const HepVector helix() const
......
static TDstEvent * getWriteObject()
returns object to be written (maintained here for all DIGI-converters)
Definition of a Root address, derived from IOpaqueAddress.
std::string getTreename() const
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 setLastLayer(const Int_t lL)
void setTrackId(const Int_t trackId)
const Int_t trackId() const
void setStat(const Int_t stat)
void setErr(const Double_t err[15])
void setHelix(const Double_t helix[5])
const Double_t theta() const
const Int_t charge() const
const Double_t pz() const
void setFirstLayer(const Int_t fL)
const Double_t phi() const
const Double_t helix(Int_t i) const
const Double_t chi2() const
const Double_t err(Int_t i) const
const Double_t px() const
const Double_t py() const
const Double_t pxy() const
void setNdof(const Int_t ndof)
void setChi2(const Double_t chi)
const TObjArray * getCgemTrackCol() const
retrieve the whole TObjArray of CgemTrack Data
void addCgemTrack(TCgemTrack *Track)
Add a tkrtrack into the Cgem data collection.
void clearCgemTrackCol()
clear the whole array (necessary because of the consts-s)
static std::map< const TObject *, const DstCgemTrack * > m_rootCgemTrackMap
_EXTERN_ std::string Event