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