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

#include <RecMdcTrackCnv.h>

+ Inheritance diagram for RecMdcTrackCnv:

Public Member Functions

virtual ~RecMdcTrackCnv ()
 
- 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

 RecMdcTrackCnv (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< RecMdcTrackCnv >
 

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 RecMdcTrackCnv.h.

Constructor & Destructor Documentation

◆ ~RecMdcTrackCnv()

virtual RecMdcTrackCnv::~RecMdcTrackCnv ( )
inlinevirtual

Definition at line 25 of file RecMdcTrackCnv.h.

25{ };

◆ RecMdcTrackCnv()

RecMdcTrackCnv::RecMdcTrackCnv ( ISvcLocator * svc)
protected

Definition at line 33 of file RecMdcTrackCnv.cxx.

35{
36 // Here we associate this converter with the /Event path on the TDS.
37 MsgStream log(msgSvc(), "RecMdcTrackCnv");
38 //m_rootTreename ="Rec";
39 m_rootBranchname ="m_recMdcTrackCol";
40 //declareObject(EventModel::Recon::RecMdcTrackCol, objType(), m_rootTreename, m_rootBranchname);
41 m_adresses.push_back(&m_recMdcTrackCol);
42 m_recMdcTrackCol=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 & RecMdcTrackCnv::classID ( )
inlinestatic

Definition at line 20 of file RecMdcTrackCnv.h.

21 {
22 return CLID_RecMdcTrackCol;
23 }
const CLID & CLID_RecMdcTrackCol

◆ DataObjectToTObject()

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

transformation to root

Implements RootEventBaseCnv.

Definition at line 220 of file RecMdcTrackCnv.cxx.

220 {
221
222 MsgStream log(msgSvc(), "RecMdcTrackCnv");
223 log << MSG::DEBUG << "RecMdcTrackCnv::DataObjectToTObject" << endreq;
224
225 RecMdcTrackCol * mdcTrackColTds=dynamic_cast<RecMdcTrackCol *> (obj);
226 if (!mdcTrackColTds) {
227 log << MSG::ERROR << "Could not downcast to MdcTrackCol" << endreq;
228 return StatusCode::FAILURE;
229 }
230 DataObject *evt;
231 StatusCode sc = m_eds->findObject(EventModel::Recon::Event,evt);
232 if (!sc.isSuccess()) {
233 log << MSG::ERROR << "Could not get ReconEvent in TDS " << endreq;
234 return StatusCode::FAILURE;
235 }
236 ReconEvent * devtTds=dynamic_cast<ReconEvent *> (evt);
237 if (!devtTds) {
238 log << MSG::ERROR << "RecMdcTrackCnv:Could not downcast to TDS ReconEvent" << endreq;
239 }
240
241 IOpaqueAddress *addr;
242
243 m_cnvSvc->getRecTrackCnv()->createRep(evt,addr);
245
246 const TObjArray *m_recMdcTrackCol = recEvt->getRecMdcTrackCol();
247 if (!m_recMdcTrackCol) return StatusCode::SUCCESS;
248 //necessary in case there is I/O at the same time since array is static
249 recEvt->clearRecMdcTrackCol();
250
251 RecMdcTrackCol::const_iterator recMdcTrack;
252 for (recMdcTrack = mdcTrackColTds->begin(); recMdcTrack != mdcTrackColTds->end(); recMdcTrack++) {
253 Int_t trackId =(*recMdcTrack)->trackId();
254 Double_t helix[5];
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);
258 }
259
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();
265 //Int_t nCgemXCluster = (*recMdcTrack)->nCgemXCluster();
266 //Int_t nCgemVCluster = (*recMdcTrack)->nCgemVCluster();
267
268 Double_t er[15];
269 for (Int_t i=0; i<15; i++){
270 er[i] = (*recMdcTrack)->err(i);
271 }
272 Int_t nh = (*recMdcTrack)->getNhits();
273 // vector<Int_t> vecHits = (*recMdcTrack)->vecHits();
274 Double_t vx0 = (*recMdcTrack)->getVX0();
275 Double_t vy0 = (*recMdcTrack)->getVY0();
276 Double_t vz0 = (*recMdcTrack)->getVZ0();
277 Double_t fiterm =(*recMdcTrack)->getFiTerm();
278
279 TRecMdcTrack *recMdcTrackRoot = new TRecMdcTrack();
280 //m_common.m_recMdcTrackMap[(*recMdcTrack)] = recMdcTrackRoot;
281
282 recMdcTrackRoot->setTrackId( trackId );
283 recMdcTrackRoot->setHelix(helix);
284 log<<MSG::INFO<<" test,recMdcTrackRoot.px: "<<recMdcTrackRoot->px()
285 <<" recMdcTrackRoot.py: "<<recMdcTrackRoot->py()
286 <<" recMdcTrackRoot.pz: "<<recMdcTrackRoot->pz()
287 <<endreq;
288
289 recMdcTrackRoot->setStat( stat );
290 recMdcTrackRoot->setChi2( chi );
291 recMdcTrackRoot->setNdof( ndof );
292 recMdcTrackRoot->setNlayer( nlayer );
293 //recMdcTrackRoot->setNCgemXClusters(nCgemXCluster);
294 //recMdcTrackRoot->setNCgemVClusters(nCgemVCluster);
295 recMdcTrackRoot->setErr( er );
296 recMdcTrackRoot->setNhits( nh );
297 recMdcTrackRoot->setNster( ns );
298 // recMdcTrackRoot->setVecHits(vecHits);
299 recMdcTrackRoot->setVX0( vx0 );
300 recMdcTrackRoot->setVY0( vy0 );
301 recMdcTrackRoot->setVZ0( vz0 );
302 recMdcTrackRoot->setFiTerm( fiterm );
303
304 vector<Int_t> vecClusterId;
305 ClusterRefVec clusterRefVec = (*recMdcTrack)->getVecClusters();
306 ClusterRefVec::iterator itCluster=clusterRefVec.begin();
307 for(; itCluster!=clusterRefVec.end(); itCluster++)
308 {
309 Int_t clusterId= (*itCluster)->getclusterid();
310 vecClusterId.push_back(clusterId);
311 }
312 recMdcTrackRoot->setVecClusterId(vecClusterId);
313 //cout<<"recMdcTrackRoot set a vecClusterId with size "<<vecClusterId.size()<<endl;
314
315 recEvt->addRecMdcTrack(recMdcTrackRoot);
316 }
317
318
319 return StatusCode::SUCCESS;
320}
SmartRefVector< RecCgemCluster > ClusterRefVec
Definition RecMdcTrack.h:28
ObjectVector< RecMdcTrack > RecMdcTrackCol
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 setVZ0(Double_t vz0)
const Double_t pz() const
void setStat(const Int_t stat)
void setVX0(Double_t vx0)
void setNdof(const Int_t ndof)
void setErr(const Double_t er[15])
void setHelix(const Double_t helix[5])
const Double_t px() const
void setNhits(const Int_t nh)
void setNster(const Int_t ns)
void setNlayer(const Int_t nlayer)
void setChi2(const Double_t chi)
void setVecClusterId(vector< Int_t > &vecCluId)
void setTrackId(const Int_t trackId)
void setFiTerm(Double_t fiterm)
void setVY0(Double_t vy0)
const Double_t py() 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
_EXTERN_ std::string Event
Definition EventModel.h:90
#define ns(x)
Definition xmltok.c:1504

◆ TObjectToDataObject()

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

transformation from root

Implements RootEventBaseCnv.

Definition at line 45 of file RecMdcTrackCnv.cxx.

45 {
46 // creation of TDS object from root object
47 MsgStream log(msgSvc(), "RecMdcTrackCnv");
48 log << MSG::DEBUG << "RecMdcTrackCnv::TObjectToDataObject" << endreq;
49
50 // create the TDS location for the RecMdcTrack Collection
51 RecMdcTrackCol* recMdcTrackCol = new RecMdcTrackCol;
52 refpObject = recMdcTrackCol;
53 // now convert
54 if (!m_recMdcTrackCol) return StatusCode::SUCCESS;
55 TIter mdcTrackIter(m_recMdcTrackCol);
56
57 //----------get hit smartRefVector--------
58 //HitRefVec *hitRefVec;
59 //int nTk=0;
60 //while (mdcTrackIter.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 RecMdcTrackCnv" << endreq;
68 return( StatusCode::FAILURE);
69 }
70 SmartDataPtr<RecMdcHitCol> recMdcHitCol(dataSvc,"/Event/Recon/RecMdcHitCol");
71 if (!recMdcHitCol) {
72 log << MSG::FATAL << "Could not find RecMdcHitCol" << endreq;
73 return( StatusCode::FAILURE);
74 }
75 //RecMdcHitCol::iterator iter = recMdcHitCol->begin();
76 //for (;iter != recMdcHitCol->end(); iter++ ) {
77 // int tkId = (*iter)->getTrkId();
78 // hitRefVec[tkId].push_back(*iter);
79 //}
80
81 SmartDataPtr<RecCgemClusterCol> aCgemClusterCol(dataSvc,"/Event/Recon/RecCgemClusterCol");
82 if(!aCgemClusterCol) {
83 log << MSG::FATAL << "Could not find RecCgemClusterCol" << endreq;
84 return( StatusCode::FAILURE);
85 }
86 //---------------------------------------
87 mdcTrackIter = m_recMdcTrackCol;
88 TRecMdcTrack *recMdcTrackRoot = 0;
89 while ((recMdcTrackRoot = (TRecMdcTrack*)mdcTrackIter.Next())) {
90 int trackId = recMdcTrackRoot->trackId();
91 int charge = recMdcTrackRoot->charge();
92 double helix[5];
93 for(int i=0;i<5; i++){
94 helix[i] = recMdcTrackRoot->helix(i);
95 }
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();
111 //int nCgemXClusters=recMdcTrackRoot->nCgemXClusters();
112 //int nCgemVClusters=recMdcTrackRoot->nCgemVClusters();
113 double err[15];
114 for (int i=0; i<15; i++){
115 err[i] = recMdcTrackRoot->err(i);
116 }
117 int nh = recMdcTrackRoot->nhits();
118 int ns = recMdcTrackRoot->nster();
119 // vector<int> vecHits = recMdcTrackRoot->vecHits();
120 double vx0 = recMdcTrackRoot->vx0();
121 double vy0 = recMdcTrackRoot->vy0();
122 double vz0 = recMdcTrackRoot->vz0();
123 double fiterm = recMdcTrackRoot->fiTerm();
124 RecMdcTrack *recMdcTrack = new RecMdcTrack();
125 m_common.m_rootRecMdcTrackMap[recMdcTrackRoot] = recMdcTrack;
126
127 recMdcTrack->setTrackId( trackId );
128 recMdcTrack->setCharge( charge );
129 recMdcTrack->setHelix( helix );
130 recMdcTrack->setPxy( pxy );
131 recMdcTrack->setPx( px );
132 recMdcTrack->setPy( py );
133 recMdcTrack->setPz( pz );
134 recMdcTrack->setP( p );
135 recMdcTrack->setTheta( theta );
136 recMdcTrack->setPhi( phi );
137 recMdcTrack->setX( x );
138 recMdcTrack->setY( y );
139 recMdcTrack->setZ( z );
140 recMdcTrack->setR( r );
141 recMdcTrack->setStat( stat );
142 recMdcTrack->setChi2( chi );
143 recMdcTrack->setNdof( ndof );
144 recMdcTrack->setError( err );
145 recMdcTrack->setNhits( nh );
146 recMdcTrack->setNster( ns );
147 recMdcTrack->setNlayer( nlayer );
148 // recMdcTrack->setVecHits( vecHits );
149 //rec
150 recMdcTrack->setVX0( vx0 );
151 recMdcTrack->setVY0( vy0 );
152 recMdcTrack->setVZ0( vz0 );
153 recMdcTrack->setFiTerm( fiterm );
154 //recMdcTrack->setNCgemXCluster( nCgemXClusters );
155 //recMdcTrack->setNCgemVCluster( nCgemVClusters );
156
157 HitRefVec theHitRefVec;
158
159 RecMdcHitCol::iterator iter = recMdcHitCol->begin();
160 for (;iter != recMdcHitCol->end(); iter++){
161
162 //cout<<" (*iter)->getTrkId(): "<<(*iter)->getTrkId()<<endl;
163 if((*iter)->getTrkId() == trackId){
164 SmartRef<RecMdcHit> refhit(*iter);
165 theHitRefVec.push_back(refhit);
166 }
167 }
168
169 recMdcTrack->setVecHits(theHitRefVec);
170
171 int nhits = recMdcTrack->getVecHits().size();
172
173 //std::cout<<" mdc hits: "<<nhits<< std::endl;
174
175 for(int ii=0; ii <nhits ; ii++){
176
177 //cout<<"ddl: "<<(recMdcTrack->getVecHits()[ii])->getDriftDistLeft()<<endl;
178 //cout<<"erddl: "<<(recMdcTrack->getVecHits()[ii])->getErrDriftDistLeft()<<endl;
179 Identifier id(recMdcTrack->getVecHits()[ii]->getMdcId());
180 int layer = MdcID::layer(id);
181 int wire = MdcID::wire(id);
182 //cout<<"layer: "<<layer<<" wire: "<<wire<<endl;
183 }
184
185 // --- CGEM clusters (added on 6 Apr, 2021, L.L. Wang)
186 ClusterRefVec clusterRefVec;
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();
192 //for(; iter_cluster!=aCgemClusterCol->end(); iter_cluster++)
193 for(; it_clusterId!=vecClusterId.end(); it_clusterId++)
194 {
195 //if(trackId==(*iter_cluster)->getTrkId())
196 iter_cluster=aCgemClusterCol->begin()+(*it_clusterId);
197 if((*iter_cluster)->getclusterid()==(*it_clusterId))
198 {
199 const RecCgemCluster* recCgemCluster = (*iter_cluster);
200 clusterRefVec.push_back(recCgemCluster);
201 int clusterid = recCgemCluster->getclusterid();
202 clusterFitStat[clusterid] = 1;
203 }
204 else cout<<"wrong clusterRefVec assignment in RecMdcTrackCnv"<<endl;
205 }
206 //cout<<"recMdcTrack set a clusterRefVec with size "<<clusterRefVec.size()<<endl;
207 recMdcTrack->setVecClusters(clusterRefVec,clusterFitStat);
208
209 recMdcTrackCol->push_back(recMdcTrack);
210 }
211
212 delete m_recMdcTrackCol;
213 m_recMdcTrackCol = 0;
214 return StatusCode::SUCCESS;
215}
Double_t x[10]
EvtStreamInputIterator< typename Generator::result_type > iter(Generator gen, int N=0)
SmartRefVector< RecMdcHit > HitRefVec
Definition RecMdcTrack.h:26
void setPxy(const double pxy)
Definition DstMdcTrack.h:86
void setTrackId(const int trackId)
Definition DstMdcTrack.h:84
void setPy(const double py)
Definition DstMdcTrack.h:88
void setZ(const double z)
Definition DstMdcTrack.h:95
void setNster(const int ns)
void setX(const double x)
Definition DstMdcTrack.h:93
void setError(double err[15])
void setNdof(const int ndof)
Definition DstMdcTrack.h:99
void setTheta(const double theta)
Definition DstMdcTrack.h:91
void setStat(const int stat)
Definition DstMdcTrack.h:97
void setNlayer(const int nlayer)
void setP(const double p)
Definition DstMdcTrack.h:90
void setHelix(double helix[5])
void setR(const double r)
Definition DstMdcTrack.h:96
void setCharge(const int charge)
Definition DstMdcTrack.h:85
void setY(const double y)
Definition DstMdcTrack.h:94
void setChi2(const double chi)
Definition DstMdcTrack.h:98
void setPhi(const double phi)
Definition DstMdcTrack.h:92
void setPz(const double pz)
Definition DstMdcTrack.h:89
void setPx(const double px)
Definition DstMdcTrack.h:87
static int layer(const Identifier &id)
Values of different levels (failure returns 0)
Definition MdcID.cxx:49
static int wire(const Identifier &id)
Definition MdcID.cxx:54
int getclusterid(void) const
const HitRefVec getVecHits(void) const
Definition RecMdcTrack.h:67
void setVecClusters(ClusterRefVec vecclusters)
void setVZ0(double z0)
Definition RecMdcTrack.h:76
void setVY0(double y0)
Definition RecMdcTrack.h:75
void setVecHits(HitRefVec vechits)
void setNhits(int nhits)
Definition RecMdcTrack.h:78
void setFiTerm(double fiterm)
Definition RecMdcTrack.h:77
void setVX0(double x0)
Definition RecMdcTrack.h:74
const Double_t x() const
const Double_t phi() const
const Double_t z() const
const Int_t nster() const
const Double_t vz0(void) const
const Double_t p() const
const Int_t nhits() const
const Double_t chi2() const
const Int_t trackId() const
const Double_t y() const
const Int_t stat() const
const Double_t vy0(void) const
const Double_t fiTerm(void) const
const Double_t pxy() const
const Double_t err(Int_t i) const
const Int_t ndof() const
const Double_t theta() const
vector< Int_t > vecClusterId() const
const Double_t r() const
const Int_t nlayer() const
const Int_t charge() const
const Double_t vx0(void) const
const Double_t helix(Int_t i) const
static std::map< const TObject *, const RecMdcTrack * > m_rootRecMdcTrackMap
Definition commonData.h:238

Friends And Related Symbol Documentation

◆ CnvFactory< RecMdcTrackCnv >

friend class CnvFactory< RecMdcTrackCnv >
friend

Definition at line 9 of file RecMdcTrackCnv.h.


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