97 {
98
99
100
101
102
103
104
105 MsgStream log(
msgSvc(), name());
106 log << MSG::INFO << "in execute()" << endreq;
107
108 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),"/Event/EventHeader");
109 int run = eventHeader->runNumber();
110 int event = eventHeader->eventNumber();
111 if(m_event%1000==0) {
112 std::cout << m_event << "-------------TofEnergyCalib run,event: " << run << "," << event << std::endl;
113 }
114 m_event++;
115
118
119 log << MSG::DEBUG <<"ncharg, nneu, tottks = "
120 << evtRecEvent->totalCharged() << " , "
121 << evtRecEvent->totalNeutral() << " , "
122 << evtRecEvent->totalTracks() <<endreq;
123
124 if(evtRecEvent->totalCharged() != 2) {
125 return StatusCode::SUCCESS;
126 }
127
128
130 StatusCode sc = service(
"RawDataProviderSvc",
tofDigiSvc);
131 if (sc != StatusCode::SUCCESS) {
132 log << MSG::ERROR << "TofRec Get Tof Raw Data Service Failed !! " << endreq;
133 return StatusCode::SUCCESS;
134 }
135
136
138 StatusCode scc = service(
"TofCaliSvc",
tofCaliSvc);
139 if (scc != StatusCode::SUCCESS) {
140 log << MSG::ERROR << "TofRec Get Calibration Service Failed !! " << endreq;
141 return StatusCode::SUCCESS;
142 }
143
144
147 if (sc != StatusCode::SUCCESS) {
148 log << MSG::ERROR << "TofRec Get QCorr Service Failed !! " << endreq;
149 return StatusCode::SUCCESS;
150 }
151
154 if (sc != StatusCode::SUCCESS) {
155 log << MSG::ERROR << "TofRec Get QElec Service Failed !! " << endreq;
156 return StatusCode::SUCCESS;
157 }
158
159
160 std::vector<TofData*> tofDataVec;
162 const unsigned int ADC_MASK = 0x00001FFF;
163
164 for(int i = 0; i < evtRecEvent->totalCharged(); i++) {
166
167 if(!(*itTrk)->isExtTrackValid()) continue;
169
170 if(!(*itTrk)->isTofTrackValid()) continue;
171
172
173 int npart, tof1, tof2;
174 Hep3Vector pos1, pos2;
175 Hep3Vector p1, p2;
176
179
180
181
182 if(tof1>=0 && tof1<88 && tof2>=88 && tof2<176) {
183 npart = 1;
184 } else if(tof1>=176 && tof1<224) {
185 tof1 -= 176;
186 npart = 2;
187 } else if(tof1>=224 && tof1<272) {
188 tof1 -= 224;
189 npart = 0;
190 } else {
191 continue;
192 }
193
196
199
200 double zpos1=0, zpos2=0, l1=0, l2=0, lext=0;
201 double z1, xy1, z2, xy2;
202
203 if(npart==1) {
204
205 const double tofDPhi = CLHEP::twopi / 88.;
206 double tofPhi1 = tof1*tofDPhi + tofDPhi/2;
207 double tofPhi2 = (tof2-88)*tofDPhi;
208
209
210 double extTheta1, extTheta2, extPhi1, extPhi2;
211 extTheta1 = pos1.theta();
212 extTheta2 = pos2.theta();
213 extPhi1 = pos1.phi();
214 extPhi2 = pos2.phi();
215
216
217
218 z1 = 5/
tan(extTheta1);
219 xy1 = 5/
cos(extPhi1-tofPhi1);
220 l1 = sqrt(z1*z1+xy1*xy1);
221 z2 = 5/
tan(extTheta2);
222 xy2 = 5/
cos(extPhi2-tofPhi2);
223 l2 = sqrt(z2*z2+xy2*xy2);
224 zpos1 = (pos1.z()+z1/2)/100;
225 zpos2 = (pos2.z()+z2/2)/100;
226
227
229 }
230
231 else {
232
233 double extTheta1 = pos1.theta();
234
235
236
237 l1 = 5./fabs(
cos(extTheta1));
238 zpos1 = (sqrt(pos1.x()*pos1.x()+pos1.y()*pos1.y())+5.*
tan(extTheta1)/2)/100;
239 }
240
241 vector<TofData*>::iterator it;
242
243
244 for(it=tofDataVec.begin();
245 it!=tofDataVec.end();
246 it++) {
247
251 if(im+layer*88==tof1-1 || im+layer*88==tof1+1 ||
252 im+layer*88==tof1-2 || im+layer*88==tof1+2) {
253
254 return StatusCode::SUCCESS;
255 }
256 }
257
258 for(it=tofDataVec.begin();
259 it!=tofDataVec.end();
260 it++) {
261
265
266 double adc1,adc2,tdc1,tdc2,ztdc,tofq;
267 if((*it)->barrel()) {
269 tdc1 = bTofData->
tdc1();
270 tdc2 = bTofData->
tdc2();
271 adc1 = bTofData->
adc1();
272 adc2 = bTofData->
adc2();
273
276 if(tofq<100||tofq>10000) continue;
277
278 npart = 1;
279
280 } else {
282
283 adc1 = eTofData->
adc();
284 tdc1 = eTofData->
tdc();
285 npart = 2;
286 }
287
288
289 if(im+layer*88==tof1) {
290 m_adc1 = adc1;
291 m_adc2 = adc2;
292 m_tdc1 = tdc1;
293 m_tdc2 = tdc2;
294 m_ztdc = ztdc;
295 m_q = tofq;
296 m_npart = npart;
297 m_number = tof1;
298 m_zpos = zpos1;
299 m_length = l1;
300 m_length_ext = lext;
301
302 m_energy = l1*10.25/5.;
303 m_energy_ext = lext*10.25/5.;
304
305 m_tuple->write();
306 } else if((*it)->barrel() && im+layer*88 == tof2) {
307 m_adc1 = adc1;
308 m_adc2 = adc2;
309 m_tdc1 = tdc1;
310 m_tdc2 = tdc2;
311 m_ztdc = ztdc;
312 m_q = tofq;
313 m_npart = npart;
314 m_number = tof2;
315 m_zpos = zpos2;
316 m_length = l2;
317 m_length_ext = lext;
318
319 m_energy = l2*10.25/5.;
320 m_energy_ext = lext*10.25/5.;
321
322 m_tuple->write();
323 }
324 }
325
326 }
327
328 return sc;
329}
EvtRecTrackCol::iterator EvtRecTrackIterator
double tan(const BesAngle a)
double cos(const BesAngle a)
ITofQElecSvc * tofQElecSvc
ITofQCorrSvc * tofQCorrSvc
IRawDataProviderSvc * tofDigiSvc
const double tof1Path() const
const Hep3Vector tof1Position() const
const int tof1VolumeNumber() const
const Hep3Vector tof2Momentum() const
const Hep3Vector tof1Momentum() const
const double tof2Path() const
const int tof2VolumeNumber() const
const Hep3Vector tof2Position() const
virtual TofDataVector & tofDataVectorTof(double estime=0)=0
virtual const double BPh(double ADC1, double ADC2, double zHit, unsigned int id)=0
virtual const double ZTDC(double tleft, double tright, unsigned id)=0
static int phi_module(const Identifier &id)
static int layer(const Identifier &id)
_EXTERN_ std::string EvtRecEvent
_EXTERN_ std::string EvtRecTrackCol