BOSS 6.6.4.p01
BESIII Offline Software System
Loading...
Searching...
No Matches
TofTrackCnv.cxx
Go to the documentation of this file.
1#ifndef TofTrackCnv_CXX
2#define TofTrackCnv_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
12#include "DstEvent/DstEvent.h" //TDS object
13#include "DstEvent/DstTofTrack.h" //TDS object
14#include "RootEventData/TTofTrack.h" // standard root object
16
20
21#include <vector>
22
23using namespace std;
24
25// Instantiation of a static factory class used by clients to create
26// instances of this service
27//static CnvFactory<TofTrackCnv> s_factory;
28//const ICnvFactory& TofTrackCnvFactory = s_factory;
29
30TofTrackCnv::TofTrackCnv(ISvcLocator* svc)
31: RootEventBaseCnv(classID(), svc)
32{
33 // Here we associate this converter with the /Event path on the TDS.
34 MsgStream log(msgSvc(), "TofTrackCnv");
35 //log << MSG::DEBUG << "Constructor called for " << objType() << endreq;
36 m_rootBranchname ="m_tofTrackCol";
37 //declareObject(EventModel::Dst::DstTofTrackCol, objType(), m_rootTreename, m_rootBranchname);
38 m_adresses.push_back(&m_tofTrackCol);
39 m_tofTrackCol=0;
40}
41
42StatusCode TofTrackCnv::TObjectToDataObject(DataObject*& refpObject) {
43 // creation of TDS object from root object
44
45 MsgStream log(msgSvc(), "TofTrackCnv");
46 log << MSG::DEBUG << "TofTrackCnv::TObjectToDataObject" << endreq;
47 StatusCode sc=StatusCode::SUCCESS;
48 // create the TDS location for the TofTrack Collection
49 DstTofTrackCol* tofTrackTdsCol = new DstTofTrackCol;
50 refpObject=tofTrackTdsCol;
51
52
53 // now convert
54 if (!m_tofTrackCol) return sc;
55 TIter tofTrackIter(m_tofTrackCol);
56 TTofTrack *tofTrackRoot = 0;
57 while ((tofTrackRoot = (TTofTrack*)tofTrackIter.Next())) {
58
59 int tofTrackID = tofTrackRoot->tofTrackID();
60 int trackID = tofTrackRoot->trackID();
61 int tofID = tofTrackRoot->tofID();
62 unsigned int status = tofTrackRoot->status();
63 double path = tofTrackRoot->path();
64 double zrhit = tofTrackRoot->zrhit();
65 double ph = tofTrackRoot->ph();
66 double tof = tofTrackRoot->tof();
67 double errtof = tofTrackRoot->errtof();
68 double beta = tofTrackRoot->beta();
69 double texpElectron = tofTrackRoot->texpElectron();
70 double texpMuon = tofTrackRoot->texpMuon();
71 double texpPion = tofTrackRoot->texpPion();
72 double texpKaon = tofTrackRoot->texpKaon();
73 double texpProton = tofTrackRoot->texpProton();
74 double toffsetElectron = tofTrackRoot->toffsetElectron();
75 double toffsetMuon = tofTrackRoot->toffsetMuon();
76 double toffsetPion = tofTrackRoot->toffsetPion();
77 double toffsetKaon = tofTrackRoot->toffsetKaon();
78 double toffsetProton = tofTrackRoot->toffsetProton();
79 double toffsetAntiProton = tofTrackRoot->toffsetAntiProton();
80 double sigmaElectron = tofTrackRoot->sigmaElectron();
81 double sigmaMuon = tofTrackRoot->sigmaMuon();
82 double sigmaPion = tofTrackRoot->sigmaPion();
83 double sigmaKaon = tofTrackRoot->sigmaKaon();
84 double sigmaProton = tofTrackRoot->sigmaProton();
85 double sigmaAntiProton = tofTrackRoot->sigmaAntiProton();
86 int quality = tofTrackRoot->quality();
87 double t0 = tofTrackRoot->t0();
88 double errt0 = tofTrackRoot->errt0();
89 double errz = tofTrackRoot->errz();
90 double phi = tofTrackRoot->phi();
91 double errphi = tofTrackRoot->errphi();
92 double energy = tofTrackRoot->energy();
93 double errenergy = tofTrackRoot->errenergy();
94
95 DstTofTrack *tofTrackTds = new DstTofTrack();
96 m_common.m_rootTofTrackMap[tofTrackRoot] = tofTrackTds;
97
98 tofTrackTds->setTofTrackID(tofTrackID);
99 tofTrackTds->setTrackID(trackID);
100 tofTrackTds->setTofID(tofID);
101 tofTrackTds->setStatus(status);
102 tofTrackTds->setPath(path);
103 tofTrackTds->setZrHit(zrhit);
104 tofTrackTds->setPh(ph);
105 tofTrackTds->setTof(tof);
106 tofTrackTds->setErrTof(errtof);
107 tofTrackTds->setBeta(beta);
108 tofTrackTds->setTexpElectron(texpElectron);
109 tofTrackTds->setTexpMuon(texpMuon);
110 tofTrackTds->setTexpPion(texpPion);
111 tofTrackTds->setTexpKaon(texpKaon);
112 tofTrackTds->setTexpProton(texpProton);
113 tofTrackTds->setToffsetElectron(toffsetElectron);
114 tofTrackTds->setToffsetMuon(toffsetMuon);
115 tofTrackTds->setToffsetPion(toffsetPion);
116 tofTrackTds->setToffsetKaon(toffsetKaon);
117 tofTrackTds->setToffsetProton(toffsetProton);
118 tofTrackTds->setToffsetAntiProton(toffsetAntiProton);
119 tofTrackTds->setSigmaElectron(sigmaElectron);
120 tofTrackTds->setSigmaMuon(sigmaMuon);
121 tofTrackTds->setSigmaPion(sigmaPion);
122 tofTrackTds->setSigmaKaon(sigmaKaon);
123 tofTrackTds->setSigmaProton(sigmaProton);
124 tofTrackTds->setSigmaAntiProton(sigmaAntiProton);
125 tofTrackTds->setQuality(quality);
126 tofTrackTds->setT0(t0);
127 tofTrackTds->setErrT0(errt0);
128 tofTrackTds->setErrZ(errz);
129 tofTrackTds->setPhi(phi);
130 tofTrackTds->setErrPhi(errphi);
131 tofTrackTds->setEnergy(energy);
132 tofTrackTds->setErrEnergy(errenergy);
133
134 tofTrackTdsCol->push_back(tofTrackTds);
135
136 // delete tofTrackTds; // wensp add 2005/12/31
137 // tofTrackTds = NULL;
138 }
139
140 //m_tofTrackCol->Delete(); // wensp add 2005/12/30
141 delete m_tofTrackCol;
142 m_tofTrackCol = 0;
143 return StatusCode::SUCCESS;
144}
145
146StatusCode TofTrackCnv::DataObjectToTObject(DataObject* obj,RootAddress* rootaddr) {
147
148 MsgStream log(msgSvc(), "TofTrackCnv");
149 log << MSG::DEBUG << "TofTrackCnv::DataObjectToTObject" << endreq;
150 StatusCode sc=StatusCode::SUCCESS;
151
152 DstTofTrackCol * tofTrackColTds=dynamic_cast<DstTofTrackCol *> (obj);
153 if (!tofTrackColTds) {
154 log << MSG::ERROR << "Could not downcast to DstTofTrackCol" << endreq;
155 return StatusCode::FAILURE;
156 }
157
158 DataObject *evt;
159 m_eds->findObject(EventModel::Dst::Event,evt);
160 if (evt==NULL) {
161 log << MSG::ERROR << "Could not get DstEvent in TDS " << endreq;
162 return StatusCode::FAILURE;
163 }
164
165 DstEvent * devtTds=dynamic_cast<DstEvent *> (evt);
166 if (!devtTds) {
167 log << MSG::ERROR << "TofTrackCnv:Could not downcast to TDS ReconEvent" << endreq;
168 }
169 IOpaqueAddress *addr;
170
171 m_cnvSvc->getDstCnv()->createRep(evt,addr);
173
174 const TObjArray *m_tofTrackCol = recEvt->getTofTrackCol();
175 if (!m_tofTrackCol) return sc;
176 recEvt->clearTofTrackCol(); //necessary in case there is I/O at the same time since array is static
177 DstTofTrackCol::const_iterator tofTrackTds;
178
179 for (tofTrackTds = tofTrackColTds->begin(); tofTrackTds != tofTrackColTds->end(); tofTrackTds++) {
180
181 Int_t tofTrackID = (*tofTrackTds)->tofTrackID();
182 Int_t trackID = (*tofTrackTds)->trackID();
183 Int_t tofID = (*tofTrackTds)->tofID();
184 UInt_t status = (*tofTrackTds)->status();
185 Double_t path = (*tofTrackTds)->path();
186 Double_t zrhit = (*tofTrackTds)->zrhit();
187 Double_t ph = (*tofTrackTds)->ph();
188 Double_t tof = (*tofTrackTds)->tof();
189 Double_t errtof = (*tofTrackTds)->errtof();
190 Double_t beta = (*tofTrackTds)->beta();
191 Double_t texpElectron = (*tofTrackTds)->texpElectron();
192 Double_t texpMuon = (*tofTrackTds)->texpMuon();
193 Double_t texpPion = (*tofTrackTds)->texpPion();
194 Double_t texpKaon = (*tofTrackTds)->texpKaon();
195 Double_t texpProton = (*tofTrackTds)->texpProton();
196 Double_t toffsetElectron = (*tofTrackTds)->toffsetElectron();
197 Double_t toffsetMuon = (*tofTrackTds)->toffsetMuon();
198 Double_t toffsetPion = (*tofTrackTds)->toffsetPion();
199 Double_t toffsetKaon = (*tofTrackTds)->toffsetKaon();
200 Double_t toffsetProton = (*tofTrackTds)->toffsetProton();
201 Double_t toffsetAntiProton = (*tofTrackTds)->toffsetAntiProton();
202 Double_t sigmaElectron = (*tofTrackTds)->sigmaElectron();
203 Double_t sigmaMuon = (*tofTrackTds)->sigmaMuon();
204 Double_t sigmaPion = (*tofTrackTds)->sigmaPion();
205 Double_t sigmaKaon = (*tofTrackTds)->sigmaKaon();
206 Double_t sigmaProton = (*tofTrackTds)->sigmaProton();
207 Double_t sigmaAntiProton = (*tofTrackTds)->sigmaAntiProton();
208 Int_t quality = (*tofTrackTds)->quality();
209 Double_t t0 = (*tofTrackTds)->t0();
210 Double_t errt0 = (*tofTrackTds)->errt0();
211 Double_t errz = (*tofTrackTds)->errz();
212 Double_t phi = (*tofTrackTds)->phi();
213 Double_t errphi = (*tofTrackTds)->errphi();
214 Double_t energy = (*tofTrackTds)->energy();
215 Double_t errenergy = (*tofTrackTds)->errenergy();
216
217 TTofTrack *tofTrackRoot = new TTofTrack();
218
219 //m_common.m_tofTrackMap[(*tofTrackTds)] = tofTrackRoot;
220
221 tofTrackRoot->setTofTrackID(tofTrackID);
222 tofTrackRoot->setTrackID(trackID);
223 tofTrackRoot->setTofID(tofID);
224 tofTrackRoot->setStatus(status);
225 tofTrackRoot->setPath(path);
226 tofTrackRoot->setZrHit(zrhit);
227 tofTrackRoot->setPh(ph);
228 tofTrackRoot->setTof(tof);
229 tofTrackRoot->setErrTof(errtof);
230 tofTrackRoot->setBeta(beta);
231 tofTrackRoot->setTexpElectron(texpElectron);
232 tofTrackRoot->setTexpMuon(texpMuon);
233 tofTrackRoot->setTexpPion(texpPion);
234 tofTrackRoot->setTexpKaon(texpKaon);
235 tofTrackRoot->setTexpProton(texpProton);
236 tofTrackRoot->setToffsetElectron(toffsetElectron);
237 tofTrackRoot->setToffsetMuon(toffsetMuon);
238 tofTrackRoot->setToffsetPion(toffsetPion);
239 tofTrackRoot->setToffsetKaon(toffsetKaon);
240 tofTrackRoot->setToffsetProton(toffsetProton);
241 tofTrackRoot->setToffsetAntiProton(toffsetAntiProton);
242 tofTrackRoot->setSigmaElectron(sigmaElectron);
243 tofTrackRoot->setSigmaMuon(sigmaMuon);
244 tofTrackRoot->setSigmaPion(sigmaPion);
245 tofTrackRoot->setSigmaKaon(sigmaKaon);
246 tofTrackRoot->setSigmaProton(sigmaProton);
247 tofTrackRoot->setSigmaAntiProton(sigmaAntiProton);
248 tofTrackRoot->setQuality(quality);
249 tofTrackRoot->setT0(t0);
250 tofTrackRoot->setErrT0(errt0);
251 tofTrackRoot->setErrZ(errz);
252 tofTrackRoot->setPhi(phi);
253 tofTrackRoot->setErrPhi(errphi);
254 tofTrackRoot->setEnergy(energy);
255 tofTrackRoot->setErrEnergy(errenergy);
256
257 recEvt->addTofTrack(tofTrackRoot);
258 }
259
260 return StatusCode::SUCCESS;
261}
262#endif
ObjectVector< DstTofTrack > DstTofTrackCol
Definition: DstTofTrack.h:183
************Class m_ypar INTEGER m_KeyWgt INTEGER m_nphot INTEGER m_KeyGPS INTEGER m_IsBeamPolarized INTEGER m_EvtGenInterface DOUBLE PRECISION m_Emin DOUBLE PRECISION m_sphot DOUBLE PRECISION m_Xenph DOUBLE PRECISION m_q2 DOUBLE PRECISION m_PolBeam2 DOUBLE PRECISION m_xErrPb *COMMON c_KK2f $ !CMS energy average $ !Spin Polarization vector first beam $ !Spin Polarization vector second beam $ !Beam energy spread[GeV] $ !minimum hadronization energy[GeV] $ !input READ never touch them !$ !debug facility $ !maximum weight $ !inverse alfaQED $ !minimum real photon energy
Definition: KK2f.h:50
IMessageSvc * msgSvc()
static TDstEvent * getWriteObject()
returns object to be written (maintained here for all DIGI-converters)
Definition: DstCnv.h:36
void setStatus(unsigned int status)
Definition: DstTofTrack.h:92
void setTexpElectron(double texpe)
Definition: DstTofTrack.h:102
void setTexpMuon(double texpmu)
Definition: DstTofTrack.h:103
void setToffsetPion(double topi)
Definition: DstTofTrack.h:111
void setEnergy(double energy)
Definition: DstTofTrack.h:132
void setPath(double path)
Definition: DstTofTrack.h:94
void setTexpPion(double texppi)
Definition: DstTofTrack.h:104
void setTofTrackID(int tofTrackID)
Definition: DstTofTrack.h:89
void setPh(double ph)
Definition: DstTofTrack.h:96
void setSigmaMuon(double smu)
Definition: DstTofTrack.h:118
void setQuality(int quality)
Definition: DstTofTrack.h:124
void setTexpKaon(double texpk)
Definition: DstTofTrack.h:105
void setZrHit(double zrhit)
Definition: DstTofTrack.h:95
void setTof(double tof)
Definition: DstTofTrack.h:97
void setToffsetMuon(double tomu)
Definition: DstTofTrack.h:110
void setSigmaProton(double sp)
Definition: DstTofTrack.h:121
void setPhi(double phi)
Definition: DstTofTrack.h:130
void setToffsetProton(double top)
Definition: DstTofTrack.h:113
void setErrTof(double etof)
Definition: DstTofTrack.h:98
void setErrT0(double errt0)
Definition: DstTofTrack.h:127
void setTexpProton(double texpp)
Definition: DstTofTrack.h:106
void setToffsetAntiProton(double topb)
Definition: DstTofTrack.h:114
void setBeta(double beta)
Definition: DstTofTrack.h:99
void setSigmaKaon(double sk)
Definition: DstTofTrack.h:120
void setErrEnergy(double errenergy)
Definition: DstTofTrack.h:133
void setTrackID(int trackID)
Definition: DstTofTrack.h:90
void setT0(double t0)
Definition: DstTofTrack.h:126
void setErrZ(double errz)
Definition: DstTofTrack.h:129
void setSigmaAntiProton(double spb)
Definition: DstTofTrack.h:122
void setErrPhi(double errphi)
Definition: DstTofTrack.h:131
void setSigmaPion(double spi)
Definition: DstTofTrack.h:119
void setTofID(int tofID)
Definition: DstTofTrack.h:91
void setSigmaElectron(double se)
Definition: DstTofTrack.h:117
void setToffsetKaon(double tok)
Definition: DstTofTrack.h:112
void setToffsetElectron(double toe)
Definition: DstTofTrack.h:109
Definition of a Root address, derived from IOpaqueAddress.
Definition: RootAddress.h:21
DstCnv * getDstCnv()
Definition: RootCnvSvc.h:148
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.
void clearTofTrackCol()
clear the whole array
Definition: TDstEvent.h:69
const TObjArray * getTofTrackCol() const
retrieve the whole TObjArray of TofTrack Data
Definition: TDstEvent.h:60
void addTofTrack(TTofTrack *Track)
Add a TofTrack into the TOF Data collection.
Definition: TDstEvent.cxx:141
Double_t errt0() const
Definition: TTofTrack.h:98
Double_t ph() const
Definition: TTofTrack.h:67
Double_t toffsetPion() const
Definition: TTofTrack.h:82
void setSigmaElectron(Double_t se)
Definition: TTofTrack.h:41
void setSigmaKaon(Double_t sk)
Definition: TTofTrack.h:44
Double_t energy() const
Definition: TTofTrack.h:103
void setSigmaMuon(Double_t smu)
Definition: TTofTrack.h:42
void setToffsetMuon(Double_t tomu)
Definition: TTofTrack.h:35
Double_t sigmaMuon() const
Definition: TTofTrack.h:89
void setToffsetPion(Double_t topi)
Definition: TTofTrack.h:36
Double_t toffsetMuon() const
Definition: TTofTrack.h:81
void setPhi(Double_t phi)
Definition: TTofTrack.h:54
void setPh(Double_t ph)
Definition: TTofTrack.h:23
Double_t texpKaon() const
Definition: TTofTrack.h:76
Double_t phi() const
Definition: TTofTrack.h:101
void setEnergy(Double_t energy)
Definition: TTofTrack.h:56
void setT0(Double_t t0)
Definition: TTofTrack.h:50
Double_t sigmaElectron() const
Definition: TTofTrack.h:88
void setToffsetProton(Double_t top)
Definition: TTofTrack.h:38
void setToffsetAntiProton(Double_t topb)
Definition: TTofTrack.h:39
void setTexpKaon(Double_t texpk)
Definition: TTofTrack.h:31
Double_t toffsetAntiProton() const
Definition: TTofTrack.h:85
Double_t sigmaPion() const
Definition: TTofTrack.h:90
void setTof(Double_t tof)
Definition: TTofTrack.h:24
void setBeta(Double_t beta)
Definition: TTofTrack.h:26
void setToffsetKaon(Double_t tok)
Definition: TTofTrack.h:37
void setTexpProton(Double_t texpp)
Definition: TTofTrack.h:32
Int_t tofID() const
Definition: TTofTrack.h:61
Double_t errenergy() const
Definition: TTofTrack.h:104
Double_t sigmaAntiProton() const
Definition: TTofTrack.h:93
Double_t path() const
Definition: TTofTrack.h:65
Double_t sigmaKaon() const
Definition: TTofTrack.h:91
void setSigmaPion(Double_t spi)
Definition: TTofTrack.h:43
void setTexpMuon(Double_t texpmu)
Definition: TTofTrack.h:29
Double_t beta() const
Definition: TTofTrack.h:70
void setSigmaProton(Double_t sp)
Definition: TTofTrack.h:45
void setZrHit(Double_t zrhit)
Definition: TTofTrack.h:22
void setTofTrackID(Int_t tofTrackID)
Definition: TTofTrack.h:17
void setErrT0(Double_t errt0)
Definition: TTofTrack.h:51
void setErrZ(Double_t errz)
Definition: TTofTrack.h:53
Double_t errphi() const
Definition: TTofTrack.h:102
void setQuality(Int_t quality)
Definition: TTofTrack.h:48
Double_t texpProton() const
Definition: TTofTrack.h:77
void setStatus(UInt_t status)
Definition: TTofTrack.h:20
void setTrackID(Int_t trackID)
Definition: TTofTrack.h:18
Double_t zrhit() const
Definition: TTofTrack.h:66
void setTexpPion(Double_t texppi)
Definition: TTofTrack.h:30
Double_t toffsetProton() const
Definition: TTofTrack.h:84
Int_t quality() const
Definition: TTofTrack.h:95
void setToffsetElectron(Double_t toe)
Definition: TTofTrack.h:34
Double_t texpPion() const
Definition: TTofTrack.h:75
Int_t tofTrackID() const
Definition: TTofTrack.h:59
void setTofID(Int_t tofID)
Definition: TTofTrack.h:19
Double_t texpElectron() const
Definition: TTofTrack.h:73
Double_t t0() const
Definition: TTofTrack.h:97
Double_t sigmaProton() const
Definition: TTofTrack.h:92
void setTexpElectron(Double_t texpe)
Definition: TTofTrack.h:28
Double_t tof() const
Definition: TTofTrack.h:68
void setSigmaAntiProton(Double_t spb)
Definition: TTofTrack.h:46
void setErrPhi(Double_t errphi)
Definition: TTofTrack.h:55
void setErrTof(Double_t etof)
Definition: TTofTrack.h:25
Double_t errz() const
Definition: TTofTrack.h:100
UInt_t status() const
Definition: TTofTrack.h:63
Double_t toffsetElectron() const
Definition: TTofTrack.h:80
Double_t texpMuon() const
Definition: TTofTrack.h:74
void setPath(Double_t path)
Definition: TTofTrack.h:21
Double_t toffsetKaon() const
Definition: TTofTrack.h:83
Double_t errtof() const
Definition: TTofTrack.h:69
Int_t trackID() const
Definition: TTofTrack.h:60
void setErrEnergy(Double_t errenergy)
Definition: TTofTrack.h:57
virtual StatusCode DataObjectToTObject(DataObject *obj, RootAddress *addr)
transformation to root
virtual StatusCode TObjectToDataObject(DataObject *&obj)
transformation from root
Definition: TofTrackCnv.cxx:42
TofTrackCnv(ISvcLocator *svc)
Definition: TofTrackCnv.cxx:30
static std::map< const TObject *, const DstTofTrack * > m_rootTofTrackMap
Definition: commonData.h:151
_EXTERN_ std::string Event
Definition: EventModel.h:123