CGEM BOSS 6.6.5.h
BESIII Offline Software System
Loading...
Searching...
No Matches
RecCgemTrackCnv Class Reference

#include <RecCgemTrackCnv.h>

+ Inheritance diagram for RecCgemTrackCnv:

Public Member Functions

virtual ~RecCgemTrackCnv ()
 
- Public Member Functions inherited from RootEventBaseCnv
 RootEventBaseCnv (const CLID &clid, ISvcLocator *svc)
 
virtual ~RootEventBaseCnv ()
 
virtual long repSvcType () const
 
virtual StatusCode initialize ()
 
virtual StatusCode finalize ()
 
void declareObject (const std::string &fullPath, const CLID &clid, const std::string &treename, const std::string &branchname)
 Store TDS path to link a particular converter to an object on the TDS.
 
virtual StatusCode createObj (IOpaqueAddress *addr, DataObject *&dat)
 Convert the persistent object to transient.
 
virtual StatusCode createRep (DataObject *pObject, IOpaqueAddress *&refpAddress)
 Convert the transient object to the requested representation.
 
virtual StatusCode fillRepRefs (IOpaqueAddress *pAddress, DataObject *pObject)
 Resolve the references of the converted object.
 
virtual StatusCode fillObjRefs (IOpaqueAddress *pAddress, DataObject *pObject)
 Resolve the references of the converted object.
 
TObject * getReadObject () const
 get the object to be read
 
- Public Member Functions inherited from Converter< Ty1, Ty2 >
destinationoperator (const source &) const
 

Static Public Member Functions

static const CLID & classID ()
 
- Static Public Member Functions inherited from RootEventBaseCnv
static const unsigned char storageType ()
 Storage type and class ID.
 

Protected Member Functions

 RecCgemTrackCnv (ISvcLocator *svc)
 
virtual StatusCode DataObjectToTObject (DataObject *obj, RootAddress *addr)
 transformation to root
 
virtual StatusCode TObjectToDataObject (DataObject *&obj)
 transformation from root
 
- Protected Member Functions inherited from Converter< Ty1, Ty2 >
virtual destinationconvert (const source &) const =0
 

Friends

class CnvFactory< RecCgemTrackCnv >
 

Additional Inherited Members

- Public Types inherited from Converter< Ty1, Ty2 >
typedef Ty1 source
 
typedef Ty2 destination
 
- Protected Attributes inherited from RootEventBaseCnv
RootCnvSvcm_cnvSvc
 
std::vector< RootCnvSvc::Leafm_leaves
 
RootInterfacem_rootInterface
 pointer to the RootInterface
 
IDataProviderSvc * m_eds
 pointer to eventdataservice
 
int m_branchNr
 the branchNr of this converter for writing
 
int m_branchNrDst
 
int m_branchNrMc
 
int m_branchNrRecon
 
int m_branchNrEvtRec
 
int m_branchNrEvtHeader
 
int m_branchNrEvtNavigator
 
TObject * m_objRead
 the object that was read
 
CLID CLID_top
 the CLID of the upper converter if any
 
TArrayS * m_branchNumbers
 array with number of branches for reading
 
std::string m_rootBranchname
 root branchname (may be concatenated of severals)
 
std::string m_rootTreename
 each converter knows it's treename
 
std::string m_currentFileName
 
std::vector< void * > m_adresses
 each converter knows the corresponding adresses
 
RootEvtSelectorm_evtsel
 

Detailed Description

Definition at line 15 of file RecCgemTrackCnv.h.

Constructor & Destructor Documentation

◆ ~RecCgemTrackCnv()

virtual RecCgemTrackCnv::~RecCgemTrackCnv ( )
inlinevirtual

Definition at line 25 of file RecCgemTrackCnv.h.

25{ };

◆ RecCgemTrackCnv()

RecCgemTrackCnv::RecCgemTrackCnv ( ISvcLocator * svc)
protected

Definition at line 33 of file RecCgemTrackCnv.cxx.

35{
36 // Here we associate this converter with the /Event path on the TDS.
37 MsgStream log(msgSvc(), "RecCgemTrackCnv");
38 //m_rootTreename ="Rec";
39 m_rootBranchname ="m_recCgemTrackCol";
40 //declareObject(EventModel::Recon::RecCgemTrackCol, objType(), m_rootTreename, m_rootBranchname);
41 m_adresses.push_back(&m_recCgemTrackCol);
42 m_recCgemTrackCol=0;
43}
IMessageSvc * msgSvc()
static const CLID & classID()
std::vector< void * > m_adresses
each converter knows the corresponding adresses
std::string m_rootBranchname
root branchname (may be concatenated of severals)
RootEventBaseCnv(const CLID &clid, ISvcLocator *svc)

Member Function Documentation

◆ classID()

static const CLID & RecCgemTrackCnv::classID ( )
inlinestatic

Definition at line 20 of file RecCgemTrackCnv.h.

21 {
23 }
const CLID & CLID_RecCgemTrackCol

◆ DataObjectToTObject()

StatusCode RecCgemTrackCnv::DataObjectToTObject ( DataObject * obj,
RootAddress * addr )
protectedvirtual

transformation to root

Implements RootEventBaseCnv.

Definition at line 183 of file RecCgemTrackCnv.cxx.

183 {
184
185 MsgStream log(msgSvc(), "RecCgemTrackCnv");
186 log << MSG::DEBUG << "RecCgemTrackCnv::DataObjectToTObject" << endreq;
187
188 RecCgemTrackCol * cgemTrackColTds=dynamic_cast<RecCgemTrackCol *> (obj);
189 if (!cgemTrackColTds) {
190 log << MSG::ERROR << "Could not downcast to CgemTrackCol" << endreq;
191 return StatusCode::FAILURE;
192 }
193 DataObject *evt;
194 StatusCode sc = m_eds->findObject(EventModel::Recon::Event,evt);
195 if (!sc.isSuccess()) {
196 log << MSG::ERROR << "Could not get ReconEvent in TDS " << endreq;
197 return StatusCode::FAILURE;
198 }
199 ReconEvent * devtTds=dynamic_cast<ReconEvent *> (evt);
200 if (!devtTds) {
201 log << MSG::ERROR << "RecCgemTrackCnv:Could not downcast to TDS ReconEvent" << endreq;
202 }
203
204 IOpaqueAddress *addr;
205
206 m_cnvSvc->getRecTrackCnv()->createRep(evt,addr);
208
209 const TObjArray *m_recCgemTrackCol = recEvt->getRecCgemTrackCol();
210 if (!m_recCgemTrackCol) return StatusCode::SUCCESS;
211 //necessary in case there is I/O at the same time since array is static
212 recEvt->clearRecCgemTrackCol();
213
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);
221 }
222
223 Int_t stat = (*recCgemTrack)->stat();
224 Double_t chi = (*recCgemTrack)->chi2();
225 Int_t ndof = (*recCgemTrack)->ndof();
226
227 Double_t er[15];
228 for (Int_t i=0; i<15; i++){
229 er[i] = (*recCgemTrack)->err(i);
230 }
231 Int_t nh = (*recCgemTrack)->getNhits();
232 // vector<Int_t> vecHits = (*recCgemTrack)->vecHits();
233 Double_t vx0 = (*recCgemTrack)->getVX0();
234 Double_t vy0 = (*recCgemTrack)->getVY0();
235 Double_t vz0 = (*recCgemTrack)->getVZ0();
236 Double_t fiterm =(*recCgemTrack)->getFiTerm();
237
238 TRecCgemTrack *recCgemTrackRoot = new TRecCgemTrack();
239 //m_common.m_recCgemTrackMap[(*recCgemTrack)] = recCgemTrackRoot;
240
241 recCgemTrackRoot->setTrackId( trackId );
242 recCgemTrackRoot->setHelix(cgemHelix);
243 log<<MSG::INFO<<" test,recCgemTrackRoot.px: "<<recCgemTrackRoot->px()
244 <<" recCgemTrackRoot.py: "<<recCgemTrackRoot->py()
245 <<" recCgemTrackRoot.pz: "<<recCgemTrackRoot->pz()
246 <<endreq;
247
248 recCgemTrackRoot->setStat( stat );
249 recCgemTrackRoot->setChi2( chi );
250 recCgemTrackRoot->setNdof( ndof );
251 recCgemTrackRoot->setErr( er );
252 recCgemTrackRoot->setNhits( nh );
253 // recCgemTrackRoot->setVecHits(vecHits);
254 recCgemTrackRoot->setVX0( vx0 );
255 recCgemTrackRoot->setVY0( vy0 );
256 recCgemTrackRoot->setVZ0( vz0 );
257 recCgemTrackRoot->setFiTerm( fiterm );
258
259 recEvt->addRecCgemTrack(recCgemTrackRoot);
260 }
261
262
263 return StatusCode::SUCCESS;
264}
ObjectVector< RecCgemTrack > RecCgemTrackCol
static TRecTrackEvent * getWriteObject()
returns object to be written (maintained here for all DIGI-converters)
Definition RecTrackCnv.h:36
RecTrackCnv * getRecTrackCnv()
Definition RootCnvSvc.h:166
RootCnvSvc * m_cnvSvc
IDataProviderSvc * m_eds
pointer to eventdataservice
virtual StatusCode createRep(DataObject *pObject, IOpaqueAddress *&refpAddress)
Convert the transient object to the requested representation.
void setVY0(Double_t vy0)
void setChi2(const Double_t chi)
void setNdof(const Int_t ndof)
void setHelix(const Double_t helix[5])
void setErr(const Double_t er[15])
const Double_t pz() const
const Double_t py() const
const Double_t px() const
void setTrackId(const Int_t trackId)
void setVX0(Double_t vx0)
void setFiTerm(Double_t fiterm)
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)
_EXTERN_ std::string Event
Definition EventModel.h:90

◆ TObjectToDataObject()

StatusCode RecCgemTrackCnv::TObjectToDataObject ( DataObject *& obj)
protectedvirtual

transformation from root

Implements RootEventBaseCnv.

Definition at line 45 of file RecCgemTrackCnv.cxx.

45 {
46 // creation of TDS object from root object
47 MsgStream log(msgSvc(), "RecCgemTrackCnv");
48 log << MSG::DEBUG << "RecCgemTrackCnv::TObjectToDataObject" << endreq;
49
50 // create the TDS location for the RecCgemTrack Collection
51 RecCgemTrackCol* recCgemTrackCol = new RecCgemTrackCol;
52 refpObject = recCgemTrackCol;
53 // now convert
54 if (!m_recCgemTrackCol) return StatusCode::SUCCESS;
55 TIter cgemTrackIter(m_recCgemTrackCol);
56
57 //----------get hit smartRefVector--------
58 //HitRefVec *hitRefVec;
59 //int nTk=0;
60 //while (cgemTrackIter.Next()){ nTk++; }
61 //hitRefVec = new HitRefVec[nTk];
62
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);
69 }
70 SmartDataPtr<RecCgemHitCol> recCgemHitCol(dataSvc,"/Event/Recon/RecCgemHitCol");
71 if (!recCgemHitCol) {
72 log << MSG::FATAL << "Could not find RecCgemHitCol" << endreq;
73 return( StatusCode::FAILURE);
74 }
75 //RecCgemHitCol::iterator iter = recCgemHitCol->begin();
76 //for (;iter != recCgemHitCol->end(); iter++ ) {
77 // int tkId = (*iter)->getTrkId();
78 // hitRefVec[tkId].push_back(*iter);
79 //}
80
81 //---------------------------------------
82 cgemTrackIter = m_recCgemTrackCol;
83 TRecCgemTrack *recCgemTrackRoot = 0;
84 while ((recCgemTrackRoot = (TRecCgemTrack*)cgemTrackIter.Next())) {
85 int trackId = recCgemTrackRoot->trackId();
86 int charge = recCgemTrackRoot->charge();
87 double cgemHelix[5];
88 for(int i=0;i<5; i++){
89 cgemHelix[i] = recCgemTrackRoot->helix(i);
90 }
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();
105 double err[15];
106 for (int i=0; i<15; i++){
107 err[i] = recCgemTrackRoot->err(i);
108 }
109 int nh = recCgemTrackRoot->nhits();
110 // vector<int> vecHits = recCgemTrackRoot->vecHits();
111 double vx0 = recCgemTrackRoot->vx0();
112 double vy0 = recCgemTrackRoot->vy0();
113 double vz0 = recCgemTrackRoot->vz0();
114 double fiterm = recCgemTrackRoot->fiTerm();
115 RecCgemTrack *recCgemTrack = new RecCgemTrack();
116 m_common.m_rootRecCgemTrackMap[recCgemTrackRoot] = recCgemTrack;
117
118 recCgemTrack->setTrackId( trackId );
119 recCgemTrack->setCharge( charge );
120 recCgemTrack->setHelix( cgemHelix );
121 recCgemTrack->setPxy( pxy );
122 recCgemTrack->setPx( px );
123 recCgemTrack->setPy( py );
124 recCgemTrack->setPz( pz );
125 recCgemTrack->setP( p );
126 recCgemTrack->setTheta( theta );
127 recCgemTrack->setPhi( phi );
128 recCgemTrack->setX( x );
129 recCgemTrack->setY( y );
130 recCgemTrack->setZ( z );
131 recCgemTrack->setR( r );
132 recCgemTrack->setStat( stat );
133 recCgemTrack->setChi2( chi );
134 recCgemTrack->setNdof( ndof );
135 recCgemTrack->setError( err );
136 recCgemTrack->setNhits( nh );
137 // recCgemTrack->setVecHits( vecHits );
138 //rec
139 recCgemTrack->setVX0( vx0 );
140 recCgemTrack->setVY0( vy0 );
141 recCgemTrack->setVZ0( vz0 );
142 recCgemTrack->setFiTerm( fiterm );
143
144 RecCgemHitRefVec theHitRefVec;
145
146 RecCgemHitCol::iterator iter = recCgemHitCol->begin();
147 for (;iter != recCgemHitCol->end(); iter++){
148
149 //cout<<" (*iter)->getTrkId(): "<<(*iter)->getTrkId()<<endl;
150 if((*iter)->getTrkId() == trackId){
151 SmartRef<RecCgemHit> refhit(*iter);
152 theHitRefVec.push_back(refhit);
153 }
154 }
155
156 recCgemTrack->setVecHits(theHitRefVec);
157
158 int nhits = recCgemTrack->getVecHits().size();
159
160 //std::cout<<" cgem hits: "<<nhits<< std::endl;
161
162 for(int ii=0; ii <nhits ; ii++){
163
164 //cout<<"ddl: "<<(recCgemTrack->getVecHits()[ii])->getDriftDistLeft()<<endl;
165 //cout<<"erddl: "<<(recCgemTrack->getVecHits()[ii])->getErrDriftDistLeft()<<endl;
166 Identifier id(recCgemTrack->getVecHits()[ii]->getCgemId());
167 int layer = CgemID::layer(id);
168 int sheet = CgemID::sheet(id);
169 int strip = CgemID::strip(id);
170 //cout<<"layer: "<<layer<<" wire: "<<wire<<endl;
171 }
172 recCgemTrackCol->push_back(recCgemTrack);
173 }
174
175 delete m_recCgemTrackCol;
176 m_recCgemTrackCol = 0;
177 return StatusCode::SUCCESS;
178}
Double_t x[10]
EvtStreamInputIterator< typename Generator::result_type > iter(Generator gen, int N=0)
SmartRefVector< RecCgemHit > RecCgemHitRefVec
static int strip(const Identifier &id)
Definition CgemID.cxx:83
static int sheet(const Identifier &id)
Definition CgemID.cxx:77
static int layer(const Identifier &id)
Definition CgemID.cxx:71
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)
const RecCgemHitRefVec getVecHits(void) const
void setVecHits(RecCgemHitRefVec vechits)
void setVX0(double x0)
void setNhits(int nhits)
void setVZ0(double z0)
void setFiTerm(double fiterm)
void setVY0(double y0)
const Double_t phi() const
const Double_t chi2() const
const Int_t ndof() const
const Int_t nhits() const
const Int_t trackId() const
const Double_t vy0(void) const
const Int_t stat() const
const Double_t y() const
const Double_t x() const
const Double_t r() const
const Double_t pxy() const
const Double_t p() const
const Double_t vx0(void) const
const Double_t helix(Int_t i) const
const Double_t z() const
const Int_t charge() const
const Double_t vz0(void) const
const Double_t theta() const
const Double_t fiTerm(void) const
const Double_t err(Int_t i) const
static std::map< const TObject *, const RecCgemTrack * > m_rootRecCgemTrackMap
Definition commonData.h:244

Friends And Related Symbol Documentation

◆ CnvFactory< RecCgemTrackCnv >

friend class CnvFactory< RecCgemTrackCnv >
friend

Definition at line 9 of file RecCgemTrackCnv.h.


The documentation for this class was generated from the following files: