1#ifndef RecCgemTrackCnv_CXX
2#define RecCgemTrackCnv_CXX 1
4#include "GaudiKernel/MsgStream.h"
5#include "GaudiKernel/DataObject.h"
6#include "GaudiKernel/ObjectVector.h"
8#include "TClonesArray.h"
9#include "Identifier/CgemID.h"
10#include "Identifier/Identifier.h"
12#include "EventModel/EventModel.h"
14#include "ReconEvent/ReconEvent.h"
15#include "CgemRecEvent/RecCgemTrack.h"
16#include "CgemRecEvent/RecCgemHit.h"
17#include "RootEventData/TRecCgemTrack.h"
18#include "RootEventData/TRecTrackEvent.h"
20#include "RootCnvSvc/Rec/RecTrackCnv.h"
21#include "RootCnvSvc/Rec/RecCgemTrackCnv.h"
22#include "RootCnvSvc/RootAddress.h"
37 MsgStream log(
msgSvc(),
"RecCgemTrackCnv");
47 MsgStream log(
msgSvc(),
"RecCgemTrackCnv");
48 log << MSG::DEBUG <<
"RecCgemTrackCnv::TObjectToDataObject" << endreq;
52 refpObject = recCgemTrackCol;
54 if (!m_recCgemTrackCol)
return StatusCode::SUCCESS;
55 TIter cgemTrackIter(m_recCgemTrackCol);
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 RecCgemTrackCnv" << endreq;
68 return( StatusCode::FAILURE);
70 SmartDataPtr<RecCgemHitCol> recCgemHitCol(dataSvc,
"/Event/Recon/RecCgemHitCol");
72 log << MSG::FATAL <<
"Could not find RecCgemHitCol" << endreq;
73 return( StatusCode::FAILURE);
82 cgemTrackIter = m_recCgemTrackCol;
84 while ((recCgemTrackRoot = (
TRecCgemTrack*)cgemTrackIter.Next())) {
85 int trackId = recCgemTrackRoot->
trackId();
86 int charge = recCgemTrackRoot->
charge();
88 for(
int i=0;i<5; i++){
89 cgemHelix[i] = recCgemTrackRoot->
helix(i);
91 double pxy = recCgemTrackRoot->
pxy();
92 double px = recCgemTrackRoot->
px();
93 double py = recCgemTrackRoot->
py();
94 double pz = recCgemTrackRoot->
pz();
95 double p = recCgemTrackRoot->
p();
96 double theta = recCgemTrackRoot->
theta();
97 double phi = recCgemTrackRoot->
phi();
98 double x = recCgemTrackRoot->
x();
99 double y = recCgemTrackRoot->
y();
100 double z = recCgemTrackRoot->
z();
101 double r = recCgemTrackRoot->
r();
102 int stat = recCgemTrackRoot->
stat();
103 double chi = recCgemTrackRoot->
chi2();
104 int ndof = recCgemTrackRoot->
ndof();
106 for (
int i=0; i<15; i++){
107 err[i] = recCgemTrackRoot->
err(i);
109 int nh = recCgemTrackRoot->
nhits();
111 double vx0 = recCgemTrackRoot->
vx0();
112 double vy0 = recCgemTrackRoot->
vy0();
113 double vz0 = recCgemTrackRoot->
vz0();
114 double fiterm = recCgemTrackRoot->
fiTerm();
120 recCgemTrack->
setHelix( cgemHelix );
121 recCgemTrack->
setPxy( pxy );
122 recCgemTrack->
setPx( px );
123 recCgemTrack->
setPy( py );
124 recCgemTrack->
setPz( pz );
125 recCgemTrack->
setP( p );
127 recCgemTrack->
setPhi( phi );
128 recCgemTrack->
setX(
x );
129 recCgemTrack->
setY( y );
130 recCgemTrack->
setZ( z );
131 recCgemTrack->
setR( r );
139 recCgemTrack->
setVX0( vx0 );
140 recCgemTrack->
setVY0( vy0 );
141 recCgemTrack->
setVZ0( vz0 );
146 RecCgemHitCol::iterator
iter = recCgemHitCol->begin();
147 for (;
iter != recCgemHitCol->end();
iter++){
150 if((*iter)->getTrkId() == trackId){
151 SmartRef<RecCgemHit> refhit(*
iter);
152 theHitRefVec.push_back(refhit);
158 int nhits = recCgemTrack->
getVecHits().size();
162 for(
int ii=0; ii <nhits ; ii++){
172 recCgemTrackCol->push_back(recCgemTrack);
175 delete m_recCgemTrackCol;
176 m_recCgemTrackCol = 0;
177 return StatusCode::SUCCESS;
185 MsgStream log(
msgSvc(),
"RecCgemTrackCnv");
186 log << MSG::DEBUG <<
"RecCgemTrackCnv::DataObjectToTObject" << endreq;
189 if (!cgemTrackColTds) {
190 log << MSG::ERROR <<
"Could not downcast to CgemTrackCol" << endreq;
191 return StatusCode::FAILURE;
195 if (!sc.isSuccess()) {
196 log << MSG::ERROR <<
"Could not get ReconEvent in TDS " << endreq;
197 return StatusCode::FAILURE;
201 log << MSG::ERROR <<
"RecCgemTrackCnv:Could not downcast to TDS ReconEvent" << endreq;
204 IOpaqueAddress *addr;
210 if (!m_recCgemTrackCol)
return StatusCode::SUCCESS;
214 RecCgemTrackCol::const_iterator recCgemTrack;
215 for (recCgemTrack = cgemTrackColTds->begin(); recCgemTrack != cgemTrackColTds->end(); recCgemTrack++) {
216 Int_t trackId =(*recCgemTrack)->trackId();
217 Double_t cgemHelix[5];
218 for(
int i=0;i<5;i++){
219 log<<MSG::INFO<<
" recCgemTrack.cgemHelix("<<i<<
"): "<<(*recCgemTrack)->helix(i)<<endreq;
220 cgemHelix[i] = (*recCgemTrack)->helix(i);
223 Int_t stat = (*recCgemTrack)->stat();
224 Double_t chi = (*recCgemTrack)->chi2();
225 Int_t ndof = (*recCgemTrack)->ndof();
228 for (Int_t i=0; i<15; i++){
229 er[i] = (*recCgemTrack)->err(i);
231 Int_t nh = (*recCgemTrack)->getNhits();
233 Double_t vx0 = (*recCgemTrack)->getVX0();
234 Double_t vy0 = (*recCgemTrack)->getVY0();
235 Double_t vz0 = (*recCgemTrack)->getVZ0();
236 Double_t fiterm =(*recCgemTrack)->getFiTerm();
242 recCgemTrackRoot->
setHelix(cgemHelix);
243 log<<MSG::INFO<<
" test,recCgemTrackRoot.px: "<<recCgemTrackRoot->
px()
244 <<
" recCgemTrackRoot.py: "<<recCgemTrackRoot->
py()
245 <<
" recCgemTrackRoot.pz: "<<recCgemTrackRoot->
pz()
248 recCgemTrackRoot->
setStat( stat );
249 recCgemTrackRoot->
setChi2( chi );
250 recCgemTrackRoot->
setNdof( ndof );
251 recCgemTrackRoot->
setErr( er );
254 recCgemTrackRoot->
setVX0( vx0 );
255 recCgemTrackRoot->
setVY0( vy0 );
256 recCgemTrackRoot->
setVZ0( vz0 );
263 return StatusCode::SUCCESS;
SmartRefVector< RecCgemHit > RecCgemHitRefVec
ObjectVector< RecCgemTrack > RecCgemTrackCol
static int strip(const Identifier &id)
static int sheet(const Identifier &id)
static int layer(const Identifier &id)
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)
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 setX(const double x)
void setNdof(const int ndof)
void setR(const double r)
void setPz(const double pz)
void setChi2(const double chi)
virtual StatusCode DataObjectToTObject(DataObject *obj, RootAddress *addr)
transformation to root
RecCgemTrackCnv(ISvcLocator *svc)
virtual StatusCode TObjectToDataObject(DataObject *&obj)
transformation from root
const RecCgemHitRefVec getVecHits(void) const
void setVecHits(RecCgemHitRefVec 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.
const Double_t phi() const
const Double_t chi2() const
void setVY0(Double_t vy0)
const Int_t nhits() const
void setChi2(const Double_t chi)
void setNdof(const Int_t ndof)
void setHelix(const Double_t helix[5])
const Int_t trackId() const
const Double_t vy0(void) const
void setErr(const Double_t er[15])
const Double_t pz() const
const Double_t py() const
const Double_t pxy() const
const Double_t px() const
const Double_t vx0(void) const
void setTrackId(const Int_t trackId)
void setVX0(Double_t vx0)
const Double_t helix(Int_t i) const
const Int_t charge() const
const Double_t vz0(void) const
void setFiTerm(Double_t fiterm)
const Double_t theta() const
const Double_t fiTerm(void) const
const Double_t err(Int_t i) const
void setVZ0(Double_t vz0)
void setNhits(const Int_t nh)
void setStat(const Int_t stat)
void addRecCgemTrack(TRecCgemTrack *Track)
Add a TkrTrack into the Cgem data collection.
const TObjArray * getRecCgemTrackCol() const
retrieve the whole TObjArray of RecCgemTrack Data
void clearRecCgemTrackCol()
clear the whole array (necessary because of the consts-s)
static std::map< const TObject *, const RecCgemTrack * > m_rootRecCgemTrackMap
_EXTERN_ std::string Event