CGEM BOSS 6.6.5.g
BESIII Offline Software System
Loading...
Searching...
No Matches
RecMucTrackCnv.cxx
Go to the documentation of this file.
1#ifndef RecMucTrackCnv_CXX
2#define RecMucTrackCnv_CXX 1
3
4#include "GaudiKernel/MsgStream.h"
5#include "GaudiKernel/DataObject.h"
6#include "GaudiKernel/ObjectVector.h"
7
8#include "TClonesArray.h"
9
11
14
15//#include "RootEventData/TMucTrack.h" // standard root object
16#include "RootEventData/TRecMucTrack.h" // standard root object
17//#include "RootEventData/TDstEvent.h"
19
23
24#include <vector>
25
26using namespace std;
27
28// Instantiation of a static factory class used by clients to create
29// instances of this service
30//static CnvFactory<RecMucTrackCnv> s_factory;
31//const ICnvFactory& RecMucTrackCnvFactory = s_factory;
32
33
35: RootEventBaseCnv(classID(), svc)
36{
37
38 // Here we associate this converter with the /Event path on the TDS.
39 MsgStream log(msgSvc(), "RecMucTrackCnv");
40 //log << MSG::DEBUG << "Constructor called for " << objType() << endreq;
41 //m_rootTreename ="Rec";
42 //RecMucTrack *atrack = new RecMucTrack();
43 //RecMucTrackCol *atrackCol = new RecMucTrackCol;
44 //cout<<"in RecMucTrackCnv "<<atrack->clID()<<" "<<atrackCol->clID()<<" "<<CLID_ObjectVector<<endl;
45 m_rootBranchname ="m_recMucTrackCol";
46 //declareObject(EventModel::Recon::RecMucTrackCol, objType(), m_rootTreename, m_rootBranchname);
47 m_adresses.push_back(&m_recMucTrackCol);
48 m_recMucTrackCol=0;
49}
50
51StatusCode RecMucTrackCnv::TObjectToDataObject(DataObject*& refpObject) {
52 // creation of TDS object from root object
53
54 MsgStream log(msgSvc(), "RecMucTrackCnv");
55 log << MSG::DEBUG << "RecMucTrackCnv::TObjectToDataObject" << endreq;
56 StatusCode sc=StatusCode::SUCCESS;
57
58 // create the TDS location for the MucTrack Collection
59 RecMucTrackCol* mucTrackTdsCol = new RecMucTrackCol;
60 refpObject=mucTrackTdsCol;
61
62
63 // now convert
64 if (!m_recMucTrackCol) return sc;
65 TIter mucTrackIter(m_recMucTrackCol);
66 TRecMucTrack *mucTrackRoot = 0;
67 while ((mucTrackRoot = (TRecMucTrack*)mucTrackIter.Next())) {
68
69 int trackId = mucTrackRoot->trackId();
70 int id = mucTrackRoot-> id();
71 int st = mucTrackRoot->status();
72 int type = mucTrackRoot->type();
73
74 int startPart = mucTrackRoot->startPart();
75 int endPart = mucTrackRoot->endPart();
76 int brLastLayer = mucTrackRoot->brLastLayer();
77 int ecLastLayer = mucTrackRoot->ecLastLayer();
78 int numHits = mucTrackRoot->numHits();
79 int numLayers = mucTrackRoot->numLayers();
80 int maxHitsInLayer = mucTrackRoot->maxHitsInLayer();
81
82 double depth = mucTrackRoot->depth();
83 double chi2 = mucTrackRoot->chi2();
84 int dof = mucTrackRoot->dof();
85 double rms = mucTrackRoot->rms();
86
87
88
89 double xPos = mucTrackRoot->xPos() ;
90 double yPos = mucTrackRoot->yPos() ;
91 double zPos = mucTrackRoot->zPos() ;
92
93 double xPosSigma = mucTrackRoot->xPosSigma() ;
94 double yPosSigma = mucTrackRoot->yPosSigma() ;
95 double zPosSigma = mucTrackRoot->zPosSigma() ;
96
97 double px = mucTrackRoot->px() ;
98 double py = mucTrackRoot->py() ;
99 double pz = mucTrackRoot->pz() ;
100
101 double distance = mucTrackRoot->distance();
102 double deltaphi = mucTrackRoot->deltaPhi();
103 //cout<<"in RecMucTrackCnv distance = "<<distance<<" xpos= "<<xPos<<endl;
104
105 vector<int> vecHits = mucTrackRoot->vecHits();
106 vector<int> expHits = mucTrackRoot->expHits();
107 vector<float> distHits = mucTrackRoot->distHits();
108
109 //added by LI Chunhua
110 double krechi2 = mucTrackRoot->kalRechi2();
111 int kdof = mucTrackRoot->kaldof();
112 double kdepth = mucTrackRoot->kaldepth();
113 int kbrlay = mucTrackRoot->kalbrLastLayer();
114 int keclay = mucTrackRoot->kalecLastLayer();
115 //*********************
116 //cout<<"in RecMucTrackCnv size = "<<vecHits.size()<<" "<<expHits.size()<<" "<<distHits.size()<<endl;
117
118 RecMucTrack *mucTrackTds = new RecMucTrack();
119 m_common.m_rootRecMucTrackMap[mucTrackRoot] = mucTrackTds;
120
121 mucTrackTds->setTrackId( trackId );
122 mucTrackTds->setId( id );
123 mucTrackTds->setStatus( st );
124 mucTrackTds->setType( type );
125
126 mucTrackTds->setStartPart( startPart );
127 mucTrackTds->setEndPart( endPart );
128 mucTrackTds->setBrLastLayer( brLastLayer );
129 mucTrackTds->setEcLastLayer( ecLastLayer );
130 mucTrackTds->setNumHits( numHits );
131 mucTrackTds->setNumLayers( numLayers );
132 mucTrackTds->setMaxHitsInLayer( maxHitsInLayer );
133
134 mucTrackTds->setDepth( depth );
135 mucTrackTds->setChi2( chi2 );
136 mucTrackTds->setDof( dof );
137 mucTrackTds->setRms( rms );
138
139 mucTrackTds->setXPos( xPos );
140 mucTrackTds->setYPos( yPos );
141 mucTrackTds->setZPos( zPos );
142
143 mucTrackTds->setXPosSigma( xPosSigma );
144 mucTrackTds->setYPosSigma( yPosSigma );
145 mucTrackTds->setZPosSigma( zPosSigma );
146
147 mucTrackTds->setPx( px );
148 mucTrackTds->setPy( py );
149 mucTrackTds->setPz( pz );
150
151 mucTrackTds->setDistance(distance);
152 mucTrackTds->setDeltaPhi(deltaphi);
153 mucTrackTds->setVecHits(vecHits); //need fix
154 mucTrackTds->setExpHits(expHits);
155 mucTrackTds->setDistHits(distHits);
156
157 //added by LI Chunhua 2013/02/01
158 mucTrackTds->setkalRechi2(krechi2);
159 mucTrackTds->setkalDof(kdof);
160 mucTrackTds->setkalDepth(kdepth);
161 mucTrackTds->setkalbrLastLayer(kbrlay);
162 mucTrackTds->setkalecLastLayer(keclay);
163 //******************
164
165 //cout<<"in RecMucTrackCnv::T->D set mucpos"<<endl;
166
167 mucTrackTdsCol->push_back(mucTrackTds);
168 //delete mucTrackTds; // wensp add 2005/12/31
169 // mucTrackTds = NULL;
170 }
171
172 // m_mucTrackCol->Delete(); // wensp add 2005/12/30
173 delete m_recMucTrackCol;
174 m_recMucTrackCol = 0;
175 return StatusCode::SUCCESS;
176}
177
178StatusCode RecMucTrackCnv::DataObjectToTObject(DataObject* obj,RootAddress* rootaddr) {
179
180 MsgStream log(msgSvc(), "RecMucTrackCnv");
181 log << MSG::DEBUG << "RecMucTrackCnv::DataObjectToTObject" << endreq;
182 StatusCode sc=StatusCode::SUCCESS;
183
184 RecMucTrackCol * mucTrackColTds=dynamic_cast<RecMucTrackCol *> (obj);
185 if (!mucTrackColTds) {
186 log << MSG::ERROR << "Could not downcast to RecMucTrackCol" << endreq;
187 return StatusCode::FAILURE;
188 }
189
190 DataObject *evt;
191 m_eds->findObject(EventModel::Recon::Event,evt);
192 if (evt==NULL) {
193 log << MSG::ERROR << "Could not get RecEvent in TDS " << endreq;
194 return StatusCode::FAILURE;
195 }
196 ReconEvent * devtTds=dynamic_cast<ReconEvent *> (evt);
197 if (!devtTds) {
198 log << MSG::ERROR << "RecMucTrackCnv:Could not downcast to TDS DigiEvent" << endreq;
199 }
200 IOpaqueAddress *addr;
201
202 m_cnvSvc->getRecTrackCnv()->createRep(evt,addr);
204
205 const TObjArray *m_recMucTrackCol = recEvt->getMucTrackCol();
206 if (!m_recMucTrackCol) return sc;
207 recEvt->clearMucTrackCol(); //necessary in case there is I/O at the same time since array is static
208 RecMucTrackCol::const_iterator mucTrackTds;
209
210 for (mucTrackTds = mucTrackColTds->begin(); mucTrackTds != mucTrackColTds->end(); mucTrackTds++) {
211 Int_t trackId = (*mucTrackTds)->trackId();
212 Int_t id = (*mucTrackTds)-> id();
213 Int_t st = (*mucTrackTds)->status();
214 Int_t type = (*mucTrackTds)->type();
215
216 Int_t startPart = (*mucTrackTds)->startPart();
217 Int_t endPart = (*mucTrackTds)->endPart();
218 Int_t brLastLayer = (*mucTrackTds)->brLastLayer();
219 Int_t ecLastLayer = (*mucTrackTds)->ecLastLayer();
220 Int_t numHits = (*mucTrackTds)->numHits();
221 Int_t numLayers = (*mucTrackTds)->numLayers();
222 Int_t maxHitsInLayer = (*mucTrackTds)->maxHitsInLayer();
223
224 Double_t depth = (*mucTrackTds)->depth();
225 Double_t chi2 = (*mucTrackTds)->chi2();
226 Int_t dof = (*mucTrackTds)->dof();
227 Double_t rms = (*mucTrackTds)->rms();
228
229 Double_t xPos = (*mucTrackTds)->xPos() ;
230 Double_t yPos = (*mucTrackTds)->yPos() ;
231 Double_t zPos = (*mucTrackTds)->zPos() ;
232
233 Double_t xPosSigma = (*mucTrackTds)->xPosSigma() ;
234 Double_t yPosSigma = (*mucTrackTds)->yPosSigma() ;
235 Double_t zPosSigma = (*mucTrackTds)->zPosSigma() ;
236
237 Double_t distance = (*mucTrackTds)->distance();
238 Double_t deltaphi = (*mucTrackTds)->deltaPhi();
239
240 Double_t px = (*mucTrackTds)->px() ;
241 Double_t py = (*mucTrackTds)->py() ;
242 Double_t pz = (*mucTrackTds)->pz() ;
243
244
245 vector<Int_t> vecHits = (*mucTrackTds)->getVecHits();
246 vector<Int_t> expHits = (*mucTrackTds)->getExpHits();
247 vector<Float_t> distHits = (*mucTrackTds)->getDistHits();
248 //added by LI Chunhua
249 Double_t krechi2 = (*mucTrackTds)->kalRechi2();
250 Int_t kdof = (*mucTrackTds)->kaldof();
251 Double_t kdepth = (*mucTrackTds)->kaldepth();
252 Int_t kbrlay = (*mucTrackTds)->kalbrLastLayer();
253 Int_t keclay = (*mucTrackTds)->kalecLastLayer();
254 //*********************
255
256 /*
257 cout<<"in RecMucTrackCnv "<<vecHits.size()<<endl;
258 for(int i = 0; i < vecHits.size(); i++){
259 cout<<" vec i = "<<i<<" "<<vecHits[i]<<endl;
260 }
261
262 for(int i = 0; i < expHits.size(); i++){
263 cout<<" exp i = "<<i<<" "<<expHits[i]<<endl;
264 }
265
266 for(int i = 0; i < distHits.size(); i++){
267 cout<<" dist i = "<<i<<" "<<distHits[i]<<endl;
268 }
269 */
270
271 TRecMucTrack *mucTrackRoot = new TRecMucTrack(); //liangyt
272 //m_common.m_RecMucTrackMap[(*mucTrackTds)] = mucTrackRoot;
273
274 mucTrackRoot->setTrackId( trackId );
275 mucTrackRoot->setId( id );
276 mucTrackRoot->setStatus( st );
277 mucTrackRoot->setType( type );
278
279 mucTrackRoot->setStartPart( startPart );
280 mucTrackRoot->setEndPart( endPart );
281 mucTrackRoot->setBrLastLayer( brLastLayer );
282 mucTrackRoot->setEcLastLayer( ecLastLayer );
283 mucTrackRoot->setNumHits( numHits );
284 mucTrackRoot->setNumLayers( numLayers );
285 mucTrackRoot->setMaxHitsInLayer( maxHitsInLayer );
286
287 mucTrackRoot->setDepth( depth );
288 mucTrackRoot->setChi2( chi2 );
289 mucTrackRoot->setDof( dof );
290 mucTrackRoot->setRms( rms );
291
292 mucTrackRoot->setXPos( xPos );
293 mucTrackRoot->setYPos( yPos );
294 mucTrackRoot->setZPos( zPos );
295
296 mucTrackRoot->setXPosSigma( xPosSigma );
297 mucTrackRoot->setYPosSigma( yPosSigma );
298 mucTrackRoot->setZPosSigma( zPosSigma );
299
300 mucTrackRoot->setDistance(distance);
301 mucTrackRoot->setDeltaPhi(deltaphi);
302
303 //cout<<"in RecMucTrackCnv xyz = "<<xPos<<" "<<yPos<<" "<<zPos<<" depth= "<<depth<<" "<<maxHitsInLayer<<" "<<deltaphi<<endl;
304
305 mucTrackRoot->setPx( px );
306 mucTrackRoot->setPy( py );
307 mucTrackRoot->setPz( pz );
308
309 mucTrackRoot->setVecHits(vecHits);
310 mucTrackRoot->setExpHits(expHits);
311 mucTrackRoot->setDistHits(distHits);
312
313 //added by LI Chunhua 2013/02/01
314 mucTrackRoot->setkalRechi2(krechi2);
315 mucTrackRoot->setkalDof(kdof);
316 mucTrackRoot->setkalDepth(kdepth);
317 mucTrackRoot->setkalbrLastLayer(kbrlay);
318 mucTrackRoot->setkalecLastLayer(keclay);
319 //******************
320 recEvt->addMucTrack(mucTrackRoot);
321 }
322
323 return StatusCode::SUCCESS;
324}
325#endif
ObjectVector< RecMucTrack > RecMucTrackCol
Definition: RecMucTrack.h:394
IMessageSvc * msgSvc()
void setDistance(double dist)
Definition: DstMucTrack.h:105
void setkalbrLastLayer(int br)
Definition: DstMucTrack.h:113
void setXPos(double x)
Definition: DstMucTrack.h:93
void setMaxHitsInLayer(int maxHits)
Definition: DstMucTrack.h:86
void setEcLastLayer(int layer)
Definition: DstMucTrack.h:83
void setPz(double pz)
Definition: DstMucTrack.h:103
void setRms(double rms)
Definition: DstMucTrack.h:91
void setStatus(int st)
Definition: DstMucTrack.h:77
void setYPos(double y)
Definition: DstMucTrack.h:94
void setDof(int dof)
Definition: DstMucTrack.h:90
void setZPos(double z)
Definition: DstMucTrack.h:95
void setBrLastLayer(int layer)
Definition: DstMucTrack.h:82
void setYPosSigma(double ysigma)
Definition: DstMucTrack.h:98
void setDepth(double depth)
Definition: DstMucTrack.h:88
void setPy(double py)
Definition: DstMucTrack.h:102
void setZPosSigma(double zsigma)
Definition: DstMucTrack.h:99
void setId(int id)
Definition: DstMucTrack.h:76
void setkalecLastLayer(int ec)
Definition: DstMucTrack.h:114
void setXPosSigma(double xsigma)
Definition: DstMucTrack.h:97
void setkalDof(int f)
Definition: DstMucTrack.h:111
void setStartPart(int part)
Definition: DstMucTrack.h:80
void setDeltaPhi(double dphi)
Definition: DstMucTrack.h:106
void setNumLayers(int numLayers)
Definition: DstMucTrack.h:85
void setPx(double px)
Definition: DstMucTrack.h:101
void setType(int type)
Definition: DstMucTrack.h:78
void setNumHits(int numHits)
Definition: DstMucTrack.h:84
void setChi2(double chi2)
Definition: DstMucTrack.h:89
void setkalRechi2(double ch)
Definition: DstMucTrack.h:110
void setkalDepth(double de)
Definition: DstMucTrack.h:112
void setEndPart(int part)
Definition: DstMucTrack.h:81
RecMucTrackCnv(ISvcLocator *svc)
virtual StatusCode TObjectToDataObject(DataObject *&obj)
transformation from root
virtual StatusCode DataObjectToTObject(DataObject *obj, RootAddress *addr)
transformation to root
void setDistHits(vector< float > &disthits)
Definition: RecMucTrack.h:341
void setExpHits(vector< MucRecHit * > &pHits)
void setTrackId(const int trackId)
set the index for this track.
void setVecHits(vector< MucRecHit * > &pHits)
reload setVecHits
static TRecTrackEvent * getWriteObject()
returns object to be written (maintained here for all DIGI-converters)
Definition: RecTrackCnv.h:36
Definition of a Root address, derived from IOpaqueAddress.
Definition: RootAddress.h:21
RecTrackCnv * getRecTrackCnv()
Definition: RootCnvSvc.h:166
Base class for all Root Converters.
std::vector< void * > m_adresses
each converter knows the corresponding adresses
RootCnvSvc * m_cnvSvc
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.
Double_t zPosSigma() const
Definition: TRecMucTrack.h:49
Int_t startPart() const
Definition: TRecMucTrack.h:28
Int_t brLastLayer() const
Definition: TRecMucTrack.h:30
void setRms(Double_t rms)
Definition: TRecMucTrack.h:84
void setMaxHitsInLayer(Int_t maxHits)
Definition: TRecMucTrack.h:79
Double_t yPos() const
Definition: TRecMucTrack.h:44
Double_t zPos() const
Definition: TRecMucTrack.h:45
void setkalbrLastLayer(Int_t br)
Definition: TRecMucTrack.h:107
Int_t trackId() const
Definition: TRecMucTrack.h:23
Int_t endPart() const
Definition: TRecMucTrack.h:29
void setZPos(Double_t z)
Definition: TRecMucTrack.h:90
void setXPos(Double_t x)
Definition: TRecMucTrack.h:88
Int_t numLayers() const
Definition: TRecMucTrack.h:33
void setEcLastLayer(Int_t layer)
Definition: TRecMucTrack.h:76
void setDistHits(vector< Float_t > &distHits)
Definition: TRecMucTrack.h:102
Double_t kalRechi2() const
Definition: TRecMucTrack.h:60
void setExpHits(vector< Int_t > &expHits)
Definition: TRecMucTrack.h:101
Double_t distance() const
Definition: TRecMucTrack.h:40
void setVecHits(vector< Int_t > &vecHits)
Definition: TRecMucTrack.h:100
void setYPosSigma(Double_t y)
Definition: TRecMucTrack.h:93
void setkalDof(Int_t f)
Definition: TRecMucTrack.h:105
vector< Int_t > vecHits() const
Definition: TRecMucTrack.h:55
void setPz(Double_t pz)
Definition: TRecMucTrack.h:98
void setkalecLastLayer(Int_t ec)
Definition: TRecMucTrack.h:108
Double_t chi2() const
Definition: TRecMucTrack.h:37
Double_t xPos() const
Definition: TRecMucTrack.h:43
Int_t type() const
Definition: TRecMucTrack.h:26
Double_t rms() const
Definition: TRecMucTrack.h:39
vector< Int_t > expHits() const
Definition: TRecMucTrack.h:56
Int_t numHits() const
Definition: TRecMucTrack.h:32
Int_t maxHitsInLayer() const
Definition: TRecMucTrack.h:34
void setStartPart(Int_t part)
Definition: TRecMucTrack.h:73
Double_t xPosSigma() const
Definition: TRecMucTrack.h:47
void setNumHits(Int_t numHits)
Definition: TRecMucTrack.h:77
void setBrLastLayer(Int_t layer)
Definition: TRecMucTrack.h:75
void setPy(Double_t py)
Definition: TRecMucTrack.h:97
vector< Float_t > distHits() const
Definition: TRecMucTrack.h:57
Double_t depth() const
Definition: TRecMucTrack.h:36
void setStatus(Int_t st)
Definition: TRecMucTrack.h:70
void setDeltaPhi(Double_t dphi)
Definition: TRecMucTrack.h:86
void setEndPart(Int_t part)
Definition: TRecMucTrack.h:74
void setTrackId(Int_t trackId)
Definition: TRecMucTrack.h:68
Int_t ecLastLayer() const
Definition: TRecMucTrack.h:31
void setkalRechi2(Double_t ch)
Definition: TRecMucTrack.h:104
void setYPos(Double_t y)
Definition: TRecMucTrack.h:89
void setNumLayers(Int_t numLayers)
Definition: TRecMucTrack.h:78
void setId(Int_t id)
Definition: TRecMucTrack.h:69
Int_t status() const
Definition: TRecMucTrack.h:25
Double_t pz() const
Definition: TRecMucTrack.h:53
Double_t deltaPhi() const
Definition: TRecMucTrack.h:41
void setDepth(Double_t depth)
Definition: TRecMucTrack.h:81
void setXPosSigma(Double_t x)
Definition: TRecMucTrack.h:92
Int_t kalecLastLayer() const
Definition: TRecMucTrack.h:64
void setPx(Double_t px)
Definition: TRecMucTrack.h:96
void setChi2(Double_t chi2)
Definition: TRecMucTrack.h:82
Int_t dof() const
Definition: TRecMucTrack.h:38
Int_t kalbrLastLayer() const
Definition: TRecMucTrack.h:63
Double_t kaldepth() const
Definition: TRecMucTrack.h:62
Double_t px() const
Definition: TRecMucTrack.h:51
Double_t py() const
Definition: TRecMucTrack.h:52
void setDof(Int_t dof)
Definition: TRecMucTrack.h:83
void setZPosSigma(Double_t z)
Definition: TRecMucTrack.h:94
void setkalDepth(Double_t de)
Definition: TRecMucTrack.h:106
Int_t kaldof() const
Definition: TRecMucTrack.h:61
void setType(Int_t type)
Definition: TRecMucTrack.h:71
Double_t yPosSigma() const
Definition: TRecMucTrack.h:48
void setDistance(Double_t dist)
Definition: TRecMucTrack.h:85
void addMucTrack(TRecMucTrack *Track)
Add a MucTrack into the TOF Data collection.
void clearMucTrackCol()
clear the whole array
const TObjArray * getMucTrackCol() const
retrieve the whole TObjArray of MucTrack Data
static std::map< const TObject *, const RecMucTrack * > m_rootRecMucTrackMap
Definition: commonData.h:273
_EXTERN_ std::string Event
Definition: EventModel.h:90