BOSS 7.1.0
BESIII Offline Software System
Loading...
Searching...
No Matches
TofTrack.cxx
Go to the documentation of this file.
2#include "Identifier/TofID.h"
6#include "TofRec/TofTrack.h"
7
9
10TofTrack::TofTrack( int run, int event ) {
11 m_run = run;
12 m_event = event;
13 m_trackId = -1;
14 m_tofTrackId = -1;
15 m_id1 = -9;
16 m_id2 = -9;
17 m_istrip1 = -9;
18 m_istrip2 = -9;
19 m_hitCase = NoHit;
20 m_momentum = -99.0;
21 m_path = 0.0;
22 m_path1 = 0.0;
23 m_path2 = 0.0;
24 m_zrhit1 = 99.0;
25 m_errzr1 = 99.0;
26 m_zrhit2 = 99.0;
27 m_errzr2 = 99.0;
28 m_xhit1 = 99.0;
29 m_yhit1 = 99.0;
30 m_xhit2 = 99.0;
31 m_yhit2 = 99.0;
32 for( unsigned int i=0; i<5; i++ ) {
33 m_kal[i] = -1;
34 m_zr1[i] = 99.0;
35 m_zr2[i] = 99.0;
36 m_ezr1[i] = 99.0;
37 m_ezr2[i] = 99.0;
38 }
39 if( m_tofData1.size()>0 ) {
40 m_tofData1.clear();
41 }
42 if( m_tofData2.size()>0 ) {
43 m_tofData2.clear();
44 }
45 if( m_tofData3.size()>0 ) {
46 m_tofData3.clear();
47 }
48 if( m_tofData4.size()>0 ) {
49 m_tofData4.clear();
50 }
51 if( m_tofData5.size()>0 ) {
52 m_tofData5.clear();
53 }
54 if( m_tofData6.size()>0 ) {
55 m_tofData6.clear();
56 }
57 m_quality1 = 0;
58 m_quality2 = 0;
59 m_quality = 10;
60
61 m_delStrip1 = 20;
62 m_delStrip2 = 20;
63
64 m_tofId1 = -9;
65 m_tofId2 = -9;
66 m_strip1 = -9;
67 m_strip2 = -9;
68
69 m_ph11 = -99.0;
70 m_ph12 = -99.0;
71 m_ph21 = -99.0;
72 m_ph22 = -99.0;
73 m_ph1 = -99.0;
74 m_ph2 = -99.0;
75 m_ph = -99.0;
76
77 for( unsigned int i=0; i<5; i++ ) {
78 m_tof11[i] = 0.0;
79 m_tof12[i] = 0.0;
80 m_tof21[i] = 0.0;
81 m_tof22[i] = 0.0;
82 m_tof1[i] = 0.0;
83 m_tof2[i] = 0.0;
84 m_tof[i] = 0.0;
85 }
86
87 m_sigma11 = -99.0;
88 m_sigma12 = -99.0;
89 m_sigma21 = -99.0;
90 m_sigma22 = -99.0;
91 m_sigma1 = -99.0;
92 m_sigma2 = -99.0;
93 m_sigma = -99.0;
94
95 m_qch1 = -99.0;
96 m_qch2 = -99.0;
97 m_qch3 = -99.0;
98 m_qch4 = -99.0;
99 m_adc1 = -99.0;
100 m_adc2 = -99.0;
101 m_adc3 = -99.0;
102 m_adc4 = -99.0;
103 m_tdc1 = -99.0;
104 m_tdc2 = -99.0;
105 m_tdc3 = -99.0;
106 m_tdc4 = -99.0;
107
108 for( unsigned int i=0; i<5; i++ ) {
109 m_texpInner[i] = -99.0;
110 m_texpOuter[i] = -99.0;
111 m_texp[i] = -99.0;
112 }
113
114 m_ztdc1 = -99.0;
115 m_ztdc2 = -99.0;
116 m_zadc1 = -99.0;
117 m_zadc2 = -99.0;
118
119 m_estime = -99.0;
120 m_tdiff1 = -99.0;
121 m_tdiff2 = -99.0;
122
123 m_flag = 0;
124
125 return;
126}
127
128
130 if( m_tofData1.size()>0 ) {
131 m_tofData1.clear();
132 }
133 if( m_tofData2.size()>0 ) {
134 m_tofData2.clear();
135 }
136 if( m_tofData3.size()>0 ) {
137 m_tofData3.clear();
138 }
139 if( m_tofData4.size()>0 ) {
140 m_tofData4.clear();
141 }
142 if( m_tofData5.size()>0 ) {
143 m_tofData5.clear();
144 }
145 if( m_tofData6.size()>0 ) {
146 m_tofData6.clear();
147 }
148 return;
149}
150
151//------- setExtTrack ----------------------------------------------
152// get information from RecExtTrackCol
153// tofId1(), tofId2(), hitCase(),
154// p(), path1(), path2(), zrhit1(), zrhit2(), errz1(), errz2()
155// quality() = 3 ( no hit )
156//
157void TofTrack::setExtTrack( RecExtTrack* extTrack, double costheta, double p[5], int kal[5], double t0, int t0Stat ) {
158
159 m_estime = t0;
160 m_t0Stat = t0Stat;
161
162 int tofId1 = extTrack->tof1VolumeNumber();
163 int tofId2 = extTrack->tof2VolumeNumber();
164
165 int iExist1 = -1;
166 int iExist2 = -1;
167 if( tofId1<0 ) {
168 if( extTrack->tof1VolumeNumber(3)>-1 ) {
169 iExist1 = 3;
170 }
171 else if( extTrack->tof1VolumeNumber(1)>-1 ) {
172 iExist1 = 1;
173 }
174 else if( extTrack->tof1VolumeNumber(4)>-1 ) {
175 iExist1 = 4;
176 }
177 else if( extTrack->tof1VolumeNumber(0)>-1 ) {
178 iExist1 = 0;
179 }
180 if( iExist1!=-1 ) {
181 tofId1 = extTrack->tof1VolumeNumber(iExist1);
182 }
183 }
184 if( tofId2<0 ) {
185 if( extTrack->tof2VolumeNumber(3)>-1 ) {
186 iExist2 = 3;
187 }
188 else if( extTrack->tof2VolumeNumber(1)>-1 ) {
189 iExist2 = 1;
190 }
191 else if( extTrack->tof2VolumeNumber(4)>-1 ) {
192 iExist2 = 4;
193 }
194 else if( extTrack->tof2VolumeNumber(0)>-1 ) {
195 iExist2 = 0;
196 }
197 if( iExist2!=-1 ) {
198 tofId2 = extTrack->tof2VolumeNumber(iExist2);
199 }
200 }
201 if( iExist1 == -1 ) { iExist1 = 2; }
202 if( iExist2 == -1 ) { iExist2 = 2; }
203
204 m_barrel = 3;
205 if( tofId1>=0 && tofId1<=87 ) {
206 m_id1 = tofId1;
207 m_barrel = 1;
208 m_hitCase = InnerLayer;
209 }
210 else if( tofId1>=176 && tofId1<=223 ) {
211 m_id1 = tofId1 - 176 + 48;
212 m_barrel = 2;
213 m_hitCase = WestEndcap;
214 if( costheta>0.0 ) {
215 m_id1 = -9;
216 m_barrel = 3;
217 m_hitCase = NoHit;
218 }
219 }
220 else if( tofId1>=224 && tofId1<=271 ) {
221 m_id1 = tofId1 - 176 - 48;
222 m_barrel = 0;
223 m_hitCase = EastEndcap;
224 if( costheta<0.0 ) {
225 m_id1 = -9;
226 m_barrel = 3;
227 m_hitCase = NoHit;
228 }
229 }
230 else if( tofId1>=272 && tofId1<=1135 ) {
231 m_id1 = tofId1 - 176 - 96;
232 m_istrip1 = m_id1%12;
233 m_id1 = m_id1/12;
234 if( tofId1>=272 && tofId1<=703 ) {
235 if( costheta>0.0 ) {
236 m_barrel = 4;
237 m_hitCase = EastEndcapMRPC;
238 }
239 else {
240 m_id1 = -9;
241 m_istrip1 = -9;
242 }
243 }
244 else if( tofId1>=704 && tofId1<=1135 ) {
245 if( costheta<0.0 ) {
246 m_barrel = 5;
247 m_hitCase = WestEndcapMRPC;
248 }
249 else {
250 m_id1 = -9;
251 m_istrip1 = -9;
252 }
253 }
254 }
255 else {
256 m_barrel = 3;
257 m_hitCase = NoHit;
258 }
259
260 if( tofId2>=88 && tofId2<=175 ) {
261 m_id2 = tofId2;
262 m_barrel = 1;
263 if( m_hitCase == InnerLayer ) {
264 m_hitCase = DoubleLayer;
265 }
266 else if( m_hitCase==NoHit ) {
267 m_hitCase = OuterLayer;
268 }
269 }
270 else if( tofId2>=272 && tofId2<=1135 ) {
271 m_id2 = tofId2 - 176 - 96;
272 m_istrip2 = m_id2%12;
273 m_id2 = m_id2/12;
274 if( m_hitCase==EastEndcapMRPC || m_hitCase==WestEndcapMRPC || m_hitCase==NoHit ) {
275 if( tofId2>=272 && tofId2<=703 ) {
276 if( costheta>0.0 ) {
277 m_barrel = 4;
278 m_hitCase = EastEndcapMRPC;
279 }
280 else {
281 m_id2 = -9;
282 m_istrip2 = -9;
283 }
284 }
285 else if( tofId2>=704 && tofId2<=1135 ) {
286 if( costheta<0.0 ) {
287 m_barrel = 5;
288 m_hitCase = WestEndcapMRPC;
289 }
290 else {
291 m_id2 = -9;
292 m_istrip2 = -9;
293 }
294 }
295 }
296 }
297
298 m_trackId = extTrack->trackId();
299
300 m_momentum = extTrack->tof1Momentum().r();
301 if( !( tofId1>=272 && tofId1<=1135 ) && ( m_hitCase == EastEndcapMRPC || m_hitCase == WestEndcapMRPC ) ){
302 m_momentum = extTrack->tof2Momentum().r();
303 }
304
305 if( m_hitCase == InnerLayer || m_hitCase == DoubleLayer || m_hitCase == EastEndcap || m_hitCase == WestEndcap || ( ( m_hitCase == EastEndcapMRPC || m_hitCase == WestEndcapMRPC ) && ( tofId1>=272 && tofId1<=1135 ) ) ) {
306 m_path1 = extTrack->tof1Path(iExist1);
307 m_theta1 = extTrack->tof1Momentum(iExist1).rho()/extTrack->tof1Momentum(iExist1).r();
308 m_phi1 = extTrack->tof1Position(iExist1).phi();
309 for( unsigned int i=0; i<5; i++ ) {
310 m_texpInner[i] = extTrack->tof1(i);
311 if( fabs(m_texpInner[i]+99.0)<1.0e-6 ) {
312 double beta = p[iExist1]/sqrt(p[iExist1]*p[iExist1]+mass[iExist1]*mass[iExist1]);
313 double betaNew = p[i]/sqrt(p[i]*p[i]+mass[i]*mass[i]);
314 m_texpInner[i] = beta*extTrack->tof1(iExist1)/betaNew;
315 }
316 }
317 if( m_hitCase == InnerLayer || m_hitCase == DoubleLayer ) {
318 m_xhit1 = extTrack->tof1Position(iExist1).x();
319 m_yhit1 = extTrack->tof1Position(iExist1).y();
320 m_zrhit1 = extTrack->tof1Position(iExist1).z();
321 m_errzr1 = extTrack->tof1PosSigmaAlongZ(iExist1);
322 for( unsigned int i=0; i<5; i++ ) {
323 m_zr1[i] = extTrack->tof1Position(i).z();
324 m_ezr1[i] = extTrack->tof1PosSigmaAlongZ(i);
325 if( fabs(m_zr1[i]+99.0)<1.0e-6 ) {
326 m_zr1[i] = m_zrhit1;
327 m_ezr1[i] = m_errzr1;
328 }
329 }
330 }
331 else if( m_hitCase == EastEndcap || m_hitCase == WestEndcap ) {
332 m_xhit1 = extTrack->tof1Position(iExist1).x();
333 m_yhit1 = extTrack->tof1Position(iExist1).y();
334 m_zrhit1 = extTrack->tof1Position(iExist1).rho();
335 m_errzr1 = sqrt( extTrack->tof1PosSigmaAlongX(iExist1)*extTrack->tof1PosSigmaAlongX(iExist1) + extTrack->tof1PosSigmaAlongY(iExist1)*extTrack->tof1PosSigmaAlongY(iExist1) );
336 for( unsigned int i=0; i<5; i++ ) {
337 m_zr1[i] = extTrack->tof1Position(i).rho();
338 m_ezr1[i] = sqrt( extTrack->tof1PosSigmaAlongX(i)*extTrack->tof1PosSigmaAlongX(i) + extTrack->tof1PosSigmaAlongY(i)*extTrack->tof1PosSigmaAlongY(i) );
339 if( fabs(m_zr1[i]+99.0)<1.0e-6 ) {
340 m_zr1[i] = m_zrhit1;
341 m_ezr1[i] = m_errzr1;
342 }
343 }
344 }
345 else if( ( m_hitCase == EastEndcapMRPC || m_hitCase == WestEndcapMRPC ) && ( tofId1>=272 && tofId1<=1135 ) ) {
346 m_xhit1 = extTrack->tof1Position(iExist1).x();
347 m_yhit1 = extTrack->tof1Position(iExist1).z();
348 m_zrhit1 = extTrack->tof1Position(iExist1).x();
349 m_errzr1 = extTrack->tof1PosSigmaAlongX(iExist1);
350 for( unsigned int i=0; i<5; i++ ) {
351 m_zr1[i] = extTrack->tof1Position(i).x();
352 m_ezr1[i] = extTrack->tof1PosSigmaAlongX(i);
353 if( fabs(m_zr1[i]+99.0)<1.0e-6 ) {
354 m_zr1[i] = m_zrhit1;
355 m_ezr1[i] = m_errzr1;
356 }
357 }
358 if( !( tofId2>=272 && tofId2<=1135 ) ) {
359 for( unsigned int i=0; i<5; i++ ) {
360 m_texpOuter[i] = m_texpInner[i] * 136.573/133.673;
361 }
362 }
363 }
364 }
365
366 if( m_hitCase == OuterLayer || m_hitCase == DoubleLayer || ( ( m_hitCase == EastEndcapMRPC || m_hitCase == WestEndcapMRPC ) && ( tofId2>=272 && tofId2<=1135 ) ) ) {
367 m_path2 = extTrack->tof2Path(iExist2);
368 m_theta2 = extTrack->tof2Momentum(iExist2).rho()/extTrack->tof2Momentum(iExist2).r();
369 m_phi2 = extTrack->tof2Position(iExist2).phi();
370 for( unsigned int i=0; i<5; i++ ) {
371 m_texpOuter[i] = extTrack->tof2(i);
372 if( fabs(m_texpOuter[i]+99.0)<1.0e-6 ) {
373 double beta = p[iExist2]/sqrt(p[iExist2]*p[iExist2]+mass[iExist2]*mass[iExist2]);
374 double betaNew = p[i]/sqrt(p[i]*p[i]+mass[i]*mass[i]);
375 m_texpOuter[i] = beta*extTrack->tof2(iExist2)/betaNew;
376 }
377 }
378 if( m_hitCase == OuterLayer || m_hitCase == DoubleLayer ) {
379 m_xhit2 = extTrack->tof2Position(iExist2).x();
380 m_yhit2 = extTrack->tof2Position(iExist2).y();
381 m_zrhit2 = extTrack->tof2Position(iExist2).z();
382 m_errzr2 = extTrack->tof2PosSigmaAlongZ(iExist2);
383 for( unsigned int i=0; i<5; i++ ) {
384 m_zr2[i] = extTrack->tof2Position(i).z();
385 m_ezr2[i] = extTrack->tof2PosSigmaAlongZ(i);
386 if( fabs(m_zr2[i]+99.0)<1.0e-6 ) {
387 m_zr2[i] = m_zrhit2;
388 m_ezr2[i] = m_errzr2;
389 }
390 }
391 }
392 else if( ( m_hitCase == EastEndcapMRPC || m_hitCase == WestEndcapMRPC ) && ( tofId2>=272 && tofId2<=1135 ) ) {
393 m_xhit2 = extTrack->tof2Position(iExist2).x();
394 m_yhit2 = extTrack->tof2Position(iExist2).z();
395 m_zrhit2 = extTrack->tof2Position(iExist2).x();
396 m_errzr2 = extTrack->tof2PosSigmaAlongX(iExist2);
397 for( unsigned int i=0; i<5; i++ ) {
398 m_zr2[i] = extTrack->tof2Position(i).x();
399 m_ezr2[i] = extTrack->tof2PosSigmaAlongX(i);
400 if( fabs(m_zr2[i]+99.0)<1.0e-6 ) {
401 m_zr2[i] = m_zrhit2;
402 m_ezr2[i] = m_errzr2;
403 }
404 }
405 if( !( tofId1>=272 && tofId1<=1135 ) ) {
406 for( unsigned int i=0; i<5; i++ ) {
407 m_texpInner[i] = m_texpOuter[i] * 133.673/136.573;
408 }
409 }
410 }
411 }
412
413 if( m_hitCase == NoHit ) { m_quality = 11; }
414
415 for( unsigned int i=0; i<5; i++ ) {
416 m_kal[i] = kal[i];
417 }
418
419 return;
420}
421
422
423//------- get Multi hit ----------------------------------------------
424// get Multi-hit of one TOF Counter
425//
427 if( m_hitCase == InnerLayer || m_hitCase == OuterLayer || m_hitCase == DoubleLayer ) {
428
429 if( ( m_hitCase==InnerLayer || m_hitCase==DoubleLayer ) && ( track->hitCase()==InnerLayer || track->hitCase()==DoubleLayer ) ) {
430 if( ( abs(m_id1-track->id1())<=1 ) || ( m_id1==0 && track->id1()==87 ) || ( m_id1==87 && track->id1()==0 ) ) {
431 track->setQuality1( ( track->quality1() | 0x400 ) );
432 m_quality1 = ( m_quality1 | 0x400 );
433 }
434 }
435
436 if( ( m_hitCase==OuterLayer || m_hitCase==DoubleLayer ) && ( track->hitCase()==OuterLayer || track->hitCase()==DoubleLayer ) ) {
437 if( ( abs(m_id2-track->id2())<=1 ) || ( m_id2==88 && track->id2()==175 ) || ( m_id2==175 && track->id2()==88 ) ) {
438 track->setQuality2( ( track->quality2() | 0x400 ) );
439 m_quality2 = ( m_quality2 | 0x400 );
440 }
441 }
442
443 }
444 else if( m_hitCase == EastEndcap ) {
445 if( track->hitCase()==EastEndcap ) {
446 if( ( abs(m_id1-track->id1())<=1 ) || ( m_id1==0 && track->id1()==47 ) || ( m_id1==47 && track->id1()==0 ) ) {
447 track->setQuality1( ( track->quality1() | 0x400 ) );
448 m_quality1 = ( m_quality1 | 0x400 );
449 }
450 }
451 }
452 else if( m_hitCase == WestEndcap ) {
453 if( track->hitCase()==WestEndcap ) {
454 if( ( abs(m_id1-track->id1())<=1 ) || ( m_id1==48 && track->id1()==95 ) || ( m_id1==95 && track->id1()==48 ) ) {
455 track->setQuality1( ( track->quality1() | 0x400 ) );
456 m_quality1 = ( m_quality1 | 0x400 );
457 }
458 }
459 }
460 if( m_hitCase == EastEndcapMRPC || m_hitCase == WestEndcapMRPC ) {
461 if( ( m_hitCase==EastEndcapMRPC && track->hitCase()==EastEndcapMRPC ) || ( m_hitCase==WestEndcapMRPC && track->hitCase()==WestEndcapMRPC ) ) {
462 if( m_id1>=0 ) {
463 if( ( m_id1==track->id1() ) && abs(m_istrip1-track->strip1())<=1 ) {
464 track->setQuality1( ( track->quality1() | 0x400 ) );
465 m_quality1 = ( m_quality1 | 0x400 );
466 }
467 }
468 if( m_id2>=0 ) {
469 if( ( m_id2==track->id2() ) && abs(m_istrip2-track->strip2())<=1 ) {
470 track->setQuality1( ( track->quality1() | 0x400 ) );
471 m_quality1 = ( m_quality1 | 0x400 );
472 }
473 }
474 }
475 }
476
477 return;
478}
479
480
481//------- setTofData --------------------------------------------
482// do TOF hits and extrapolated track match
483// tofTrackId(), tofMod1(), tofMod2()
484// quality() = 3 ( no hit )
485//
487
488 if( m_hitCase == NoHit ) return;
489
490 unsigned int identify[11];
491 unsigned int count[11];
492 for( unsigned int i=0; i<11; i++ ) {
493 identify[i] = 0x0000c000;
494 count[i] = 0;
495 }
496 unsigned int countTot1 = 0;
497 unsigned int countTot2 = 0;
498
499 if( ( ( m_hitCase == InnerLayer ) || ( m_hitCase == DoubleLayer ) ) && ( m_id1 > -1 ) ) {
500 int tofid0 = m_id1;
501 identify[0] = TofID::getIntID( 1, 0, tofid0, 0 );
502 count[0] = tofDataMap.count( identify[0] );
503 int tofid1 = tofid0 - 1;
504 if( tofid1 == -1 ) { tofid1 = 87; }
505 identify[1] = TofID::getIntID( 1, 0, tofid1, 0 );
506 count[1] = tofDataMap.count( identify[1] );
507 int tofid2 = tofid0 + 1;
508 if( tofid2 == 88 ) { tofid2 = 0; }
509 identify[2] = TofID::getIntID( 1, 0, tofid2, 0 );
510 count[2] = tofDataMap.count( identify[2] );
511 }
512
513 if( ( ( m_hitCase == EastEndcap ) || ( m_hitCase == WestEndcap ) )&& ( m_id1 > -1 ) ) {
514 unsigned int whichEndcap = 0;
515 int tofid0 = m_id1;
516 if( m_hitCase == WestEndcap ) {
517 whichEndcap = 2;
518 tofid0 = m_id1 - 48;
519 }
520 identify[0] = TofID::getIntID( whichEndcap, 0, tofid0, 0 );
521 count[0] = tofDataMap.count( identify[0] );
522 int tofid1 = tofid0 - 1;
523 if( tofid1 == -1 ) { tofid1 = 47; }
524 identify[1] = TofID::getIntID( whichEndcap, 0, tofid1, 0 );
525 count[1] = tofDataMap.count( identify[1] );
526 int tofid2 = tofid0 + 1;
527 if( tofid2 == 48 ) { tofid2 = 0; }
528 identify[2] = TofID::getIntID( whichEndcap, 0, tofid2, 0 );
529 count[2] = tofDataMap.count( identify[2] );
530 }
531
532 if( ( ( m_hitCase == EastEndcapMRPC ) || ( m_hitCase == WestEndcapMRPC ) ) && ( ( m_id1 > -1 ) && ( m_istrip1 > -1 ) ) ) {
533 IterTofDataMap iter = tofDataMap.begin();
534 for( ; iter != tofDataMap.end(); iter++ ) {
535 Identifier iden = TofID::cell_id( (*iter).first );
536 if( TofID::is_mrpc( iden ) ) {
537 TofData* tof = (*iter).second;
538 if( m_id1 == tof->tofId() && abs( m_istrip1 - tof->strip() )<=abs(m_delStrip1) ) {
539 m_delStrip1 = m_istrip1 - tof->strip();
540 }
541 if( ( abs( m_id1 - tof->tofId() )==1 || ( m_id1==0 && tof->tofId()==35 ) || ( m_id1==35 && tof->tofId()==0 ) || ( m_id1==36 && tof->tofId()==71 ) || ( m_id1==71 && tof->tofId()==36 ) ) && abs( m_istrip1 - tof->strip() )<=abs(m_delStrip1) ) {
542 m_delStrip2 = m_istrip1 - tof->strip();
543 }
544 }
545 }
546
547 unsigned int whichEndcap = 0;
548 int tofid0 = m_id1;
549 if( m_hitCase == WestEndcapMRPC ) {
550 whichEndcap = 1;
551 tofid0 = m_id1 - 36;
552 }
553 int strip0 = m_istrip1;
554 int strip1 = strip0 - 1;
555 int strip2 = strip0 + 1;
556 int strip3 = strip0 - 2;
557 int strip4 = strip0 + 2;
558 int tofid1 = tofid0 - 1;
559 if( tofid1 == -1 ) { tofid1 = 35; }
560 int tofid2 = tofid0 + 1;
561 if( tofid2 == 36 ) { tofid2 = 0; }
562
563 identify[0] = TofID::getIntID( 3, whichEndcap, tofid0, strip0, 0 );
564 count[0] = tofDataMap.count( identify[0] );
565 identify[5] = TofID::getIntID( 3, whichEndcap, tofid1, strip0, 0 );
566 count[5] = tofDataMap.count( identify[5] );
567 identify[6] = TofID::getIntID( 3, whichEndcap, tofid2, strip0, 0 );
568 count[6] = tofDataMap.count( identify[6] );
569
570 if( strip1 == -1 ) {
571 count[1] = 0;
572 count[7] = 0;
573 count[9] = 0;
574 }
575 else {
576 identify[1] = TofID::getIntID( 3, whichEndcap, tofid0, strip1, 0 );
577 count[1] = tofDataMap.count( identify[1] );
578 identify[7] = TofID::getIntID( 3, whichEndcap, tofid1, strip1, 0 );
579 count[7] = tofDataMap.count( identify[7] );
580 identify[9] = TofID::getIntID( 3, whichEndcap, tofid2, strip1, 0 );
581 count[9] = tofDataMap.count( identify[9] );
582 }
583
584 if( strip2 == 12 ) {
585 count[2] = 0;
586 count[8] = 0;
587 count[10] = 0;
588 }
589 else {
590 identify[2] = TofID::getIntID( 3, whichEndcap, tofid0, strip2, 0 );
591 count[2] = tofDataMap.count( identify[2] );
592 identify[8] = TofID::getIntID( 3, whichEndcap, tofid1, strip2, 0 );
593 count[8] = tofDataMap.count( identify[8] );
594 identify[10] = TofID::getIntID( 3, whichEndcap, tofid2, strip2, 0 );
595 count[10] = tofDataMap.count( identify[10] );
596 }
597 if( strip3 == -1 || strip3 == -2 ) { count[3] = 0; }
598 else {
599 identify[3] = TofID::getIntID( 3, whichEndcap, tofid0, strip3, 0 );
600 count[3] = tofDataMap.count( identify[3] );
601 }
602 if( strip4 == 12 || strip4 == 13 ) { count[4] = 0; }
603 else {
604 identify[4] = TofID::getIntID( 3, whichEndcap, tofid0, strip4, 0 );
605 count[4] = tofDataMap.count( identify[4] );
606 }
607 }
608
609 for( unsigned int i=0; i<11; i++ ) {
610 if( count[i] > 0 ) {
611 pair< IterTofDataMap, IterTofDataMap > range = tofDataMap.equal_range( identify[i] );
612 IterTofDataMap iter = range.first;
613 for( unsigned int j=0; j<count[i]; j++,iter++ ) {
614 if( i==0 ) {
615 tofDataAnalysis( (*iter).second, 1 );
616 }
617 else if( i==1 || i==2 ) {
618 tofDataAnalysis( (*iter).second, 2 );
619 }
620 else {
621 tofDataAnalysis( (*iter).second, 3 );
622 }
623 }
624 }
625 countTot1 = countTot1 + count[i];
626 }
627
628 if( countTot1 == 0 ) {
629 if( m_hitCase == DoubleLayer ) {
630 m_hitCase = OuterLayer;
631 }
632 else if( ( m_hitCase == EastEndcapMRPC ) || ( m_hitCase == WestEndcapMRPC ) ) {
633 }
634 else {
635 m_hitCase = NoHit;
636 m_quality = 12;
637 }
638 }
639
640
641 for( unsigned int i=0; i<11; i++ ) {
642 identify[i] = 0x0000c000;
643 count[i] = 0;
644 }
645 if( ( ( m_hitCase == OuterLayer ) || ( m_hitCase == DoubleLayer ) ) && ( m_id2 > 87 ) ) {
646 int tofid0 = m_id2 - 88;
647 identify[0] = TofID::getIntID( 1, 1, tofid0, 0 );
648 count[0] = tofDataMap.count( identify[0] );
649 int tofid1 = tofid0 - 1;
650 if( tofid1 == -1 ) { tofid1 = 87; }
651 identify[1] = TofID::getIntID( 1, 1, tofid1, 0 );
652 count[1] = tofDataMap.count( identify[1] );
653 int tofid2 = tofid0 + 1;
654 if( tofid2 == 88 ) { tofid2 = 0; }
655 identify[2] = TofID::getIntID( 1, 1, tofid2, 0 );
656 count[2] = tofDataMap.count( identify[2] );
657
658 for( unsigned int i=0; i<3; i++ ) {
659 if( count[i] > 0 ) {
660 pair< IterTofDataMap, IterTofDataMap > range = tofDataMap.equal_range( identify[i] );
661 IterTofDataMap iter = range.first;
662 for( unsigned int j=0; j<count[i]; j++,iter++ ) {
663 if( i==0 ) {
664 tofDataAnalysis( (*iter).second, 3 );
665 }
666 else {
667 tofDataAnalysis( (*iter).second, 4 );
668 }
669 }
670 }
671 countTot2 = countTot2 + count[i];
672 }
673
674 if( countTot2 == 0 ) {
675 if( m_hitCase != DoubleLayer ) {
676 m_hitCase = NoHit;
677 m_quality = 12;
678 }
679 else {
680 m_hitCase = InnerLayer;
681 }
682 }
683 }
684
685 if( ( ( m_hitCase == EastEndcapMRPC ) || ( m_hitCase == WestEndcapMRPC ) ) && ( ( m_id2 > -1 ) && ( m_istrip2 > -1 ) ) ) {
686 IterTofDataMap iter = tofDataMap.begin();
687 for( ; iter != tofDataMap.end(); iter++ ) {
688 Identifier iden = TofID::cell_id( (*iter).first );
689 if( TofID::is_mrpc( iden ) ) {
690 TofData* tof = (*iter).second;
691 if( m_id2 == tof->tofId() && abs( m_istrip2 - tof->strip() )<=abs(m_delStrip1) ) {
692 m_delStrip1 = m_istrip2 - tof->strip();
693 }
694 if( ( abs( m_id2 - tof->tofId() )==1 || ( m_id2==0 && tof->tofId()==35 ) || ( m_id2==35 && tof->tofId()==0 ) || ( m_id2==36 && tof->tofId()==71 ) || ( m_id2==71 && tof->tofId()==36 ) ) && abs( m_istrip2 - tof->strip() )<=abs(m_delStrip2) ) {
695 m_delStrip2 = m_istrip2 - tof->strip();
696 }
697 }
698 }
699
700 unsigned int whichEndcap = 0;
701 int tofid0 = m_id2;
702 if( m_hitCase == WestEndcapMRPC ) {
703 whichEndcap = 1;
704 tofid0 = m_id2 - 36;
705 }
706 int strip0 = m_istrip2;
707 int strip1 = strip0 - 1;
708 int strip2 = strip0 + 1;
709 int strip3 = strip0 - 2;
710 int strip4 = strip0 + 2;
711 int tofid1 = tofid0 - 1;
712 if( tofid1 == -1 ) { tofid1 = 35; }
713 int tofid2 = tofid0 + 1;
714 if( tofid2 == 36 ) { tofid2 = 0; }
715
716 identify[0] = TofID::getIntID( 3, whichEndcap, tofid0, strip0, 0 );
717 count[0] = tofDataMap.count( identify[0] );
718 identify[5] = TofID::getIntID( 3, whichEndcap, tofid1, strip0, 0 );
719 count[5] = tofDataMap.count( identify[5] );
720 identify[6] = TofID::getIntID( 3, whichEndcap, tofid2, strip0, 0 );
721 count[6] = tofDataMap.count( identify[6] );
722
723 if( strip1 == -1 ) {
724 count[1] = 0;
725 count[7] = 0;
726 count[9] = 0;
727 }
728 else {
729 identify[1] = TofID::getIntID( 3, whichEndcap, tofid0, strip1, 0 );
730 count[1] = tofDataMap.count( identify[1] );
731 identify[7] = TofID::getIntID( 3, whichEndcap, tofid1, strip1, 0 );
732 count[7] = tofDataMap.count( identify[7] );
733 identify[9] = TofID::getIntID( 3, whichEndcap, tofid2, strip1, 0 );
734 count[9] = tofDataMap.count( identify[9] );
735 }
736
737 if( strip2 == 12 ) {
738 count[2] = 0;
739 count[8] = 0;
740 count[10] = 0;
741 }
742 else {
743 identify[2] = TofID::getIntID( 3, whichEndcap, tofid0, strip2, 0 );
744 count[2] = tofDataMap.count( identify[2] );
745 identify[8] = TofID::getIntID( 3, whichEndcap, tofid1, strip2, 0 );
746 count[8] = tofDataMap.count( identify[8] );
747 identify[10] = TofID::getIntID( 3, whichEndcap, tofid2, strip2, 0 );
748 count[10] = tofDataMap.count( identify[10] );
749 }
750 if( strip3 == -1 || strip3 == -2 ) { count[3] = 0; }
751 else {
752 identify[3] = TofID::getIntID( 3, whichEndcap, tofid0, strip3, 0 );
753 count[3] = tofDataMap.count( identify[3] );
754 }
755 if( strip4 == 12 || strip4 == 13 ) { count[4] = 0; }
756 else {
757 identify[4] = TofID::getIntID( 3, whichEndcap, tofid0, strip4, 0 );
758 count[4] = tofDataMap.count( identify[4] );
759 }
760
761 for( unsigned int i=0; i<11; i++ ) {
762 if( count[i] > 0 ) {
763 pair< IterTofDataMap, IterTofDataMap > range = tofDataMap.equal_range( identify[i] );
764 IterTofDataMap iter = range.first;
765 for( unsigned int j=0; j<count[i]; j++,iter++ ) {
766 if( i==0 ) {
767 tofDataAnalysis( (*iter).second, 4 );
768 }
769 else if( i==1 || i==2 ) {
770 tofDataAnalysis( (*iter).second, 5 );
771 }
772 else {
773 tofDataAnalysis( (*iter).second, 6 );
774 }
775 }
776 }
777 countTot2 = countTot2 + count[i];
778 }
779 }
780
781 if( countTot1==0 && countTot2==0 ) {
782 m_hitCase = NoHit;
783 m_quality = 12;
784 }
785
786 return;
787}
788
789
790//------- tofDataAnalysis ----------------------------------------
791// analysis tof data
792//
793void TofTrack::tofDataAnalysis( TofData* tof, unsigned int iflag ) {
794
795 unsigned int qual = tof->quality();
796
797 if( ( qual & 0x10 ) == 0 ) {
798 qual = ( qual | 0x10 ); // zadc, ztdc unmatched, and track matched
799 if( tof->barrel() || tof->is_mrpc() ) { // Barrel, Endcap has been done
800 if( ( tof->quality() == 0x7 ) || ( tof->quality() == 0xd ) ) {
801 qual = ( qual | 0x20 ); // lost one Q
802 }
803
804 if( ( tof->quality() == 0xb ) || ( tof->quality() == 0xe ) ) {
805 qual = ( qual | 0x40 ); // lost one T
806 }
807
808 if( ( tof->quality() == 0x3 ) || ( tof->quality() == 0xc ) ) {
809 qual = ( qual | 0x80 ); // single end
810 }
811 }
812 if( tof->barrel() ) {
813 if( ( tof->quality() & 0x5 ) == 0x5 ) {
814 double ztdc = tofCaliSvc->ZTDC( tof->tdc1(), tof->tdc2(), tof->tofId() );
815 tof->setZTdc( ztdc );
816 }
817
818 if( ( tof->quality() & 0xa ) == 0xa ) {
819 double zadc = tofCaliSvc->ZADC( tof->adc1(), tof->adc2(), tof->tofId() );
820 tof->setZAdc( zadc );
821 }
822 }
823 if( tof->is_mrpc() ) {
824 if( ( tof->quality() & 0x5 ) == 0x5 ) {
825 double ztdc = tofCaliSvc->EtfZTDC( tof->tdc1(), tof->tdc2(), tof->tofId(), tof->strip() );
826 tof->setZTdc( ztdc );
827 }
828 }
829 tof->setQuality( qual );
830 }
831
832 if( iflag == 1 ) { m_tofData1.push_back( tof ); }
833 else if( iflag == 2 ) { m_tofData2.push_back( tof ); }
834 else if( iflag == 3 ) { m_tofData3.push_back( tof ); }
835 else if( iflag == 4 ) { m_tofData4.push_back( tof ); }
836 else if( iflag == 5 ) { m_tofData5.push_back( tof ); }
837 else if( iflag == 6 ) { m_tofData6.push_back( tof ); }
838 else {
839 cout << "TofRec::TofTrack::TofDataAnalylsis: the Flag should be 1-4, out of the Range!" << endl;
840 }
841
842 return;
843}
844
845
846//------- match --------------------------------------------------
847// Tof Data - Extrapolated Track Match
848//
849void TofTrack::match( bool forCalibration, std::vector<int> deadId, std::vector<TofTrack*>*& tofTrackVec ) {
850
851 if( m_hitCase == NoHit ) return;
852
853 if( m_hitCase == InnerLayer ) {
854 findTofDataBarrel( m_tofData1, m_tofData2, m_zrhit1, 1, tofTrackVec );
855 if( ( m_quality1 & 0x10 ) == 0 ) { m_hitCase = NoHit; }
856 }
857 else if( m_hitCase == OuterLayer ) {
858 findTofDataBarrel( m_tofData3, m_tofData4, m_zrhit2, 2, tofTrackVec );
859 if( ( m_quality2 & 0x10 ) == 0 ) { m_hitCase = NoHit; }
860 }
861 else if( m_hitCase == DoubleLayer ) {
862 findTofDataBarrel( m_tofData1, m_tofData2, m_zrhit1, 1, tofTrackVec );
863 if( ( m_quality1 & 0x10 ) == 0 ) { m_hitCase = OuterLayer; }
864 findTofDataBarrel( m_tofData3, m_tofData4, m_zrhit2, 2, tofTrackVec );
865 if( ( m_quality2 & 0x10 ) == 0 ) {
866 if( m_hitCase == DoubleLayer ) {
867 m_hitCase = InnerLayer;
868 }
869 else if( m_hitCase == OuterLayer ) {
870 m_hitCase = NoHit;
871 }
872 else {
873 cout << "TofRec::TofTrack::match: 2- Impossible!" << endl;
874 }
875 }
876 }
877 else if( ( m_hitCase == EastEndcap ) || ( m_hitCase == WestEndcap ) ) {
878 findTofDataEndcap( m_tofData1, m_tofData2, m_zr1 );
879 }
880 else if( ( m_hitCase == EastEndcapMRPC ) || ( m_hitCase == WestEndcapMRPC ) ) {
881 findEtfData( m_tofData1, m_tofData2, m_tofData3, m_zrhit1, 1 );
882 findEtfData( m_tofData4, m_tofData5, m_tofData6, m_zrhit2, 2 );
883 }
884 else {
885 cout << "TofRec::TofTrack::match: 1- Impossible!" << endl;
886 }
887
888 if( forCalibration ) {
889 // set Data Sample for Calibration, double layer, only one hit for counter, T and Q.
890 if( m_hitCase == DoubleLayer ) {
891 if( ( ( m_quality1 & 0xf ) == 0xf ) && ( ( m_quality2 & 0xf ) == 0xf ) ) {
892 m_quality1 = ( m_quality1 | 0x800 ); // Calibration Sample
893 m_quality2 = ( m_quality2 | 0x800 ); // Calibration Sample
894 }
895 else {
896 std::vector<int>::iterator iter = deadId.begin();
897 for( ; iter != deadId.end(); iter++ ) {
898 Identifier iden = Identifier(*iter);
899 int barrel = TofID::barrel_ec(iden);
900 int layer = TofID::layer(iden);
901 int tofId = TofID::phi_module(iden);
902 int east = TofID::end(iden);
903 if( barrel == 1 ) {
904 if( layer==0 ) {
905 if( m_tofId1 == tofId ) {
906 if( ( m_quality2 & 0xf ) == 0xf ) {
907 if( ( ( east == 0 ) && ( ( ( m_quality1 & 0xf ) == 0x3 ) || ( ( m_quality1 & 0xf ) == 0x7 ) || ( ( m_quality1 & 0xf ) == 0xb ) ) ) || ( ( east == 1 ) && ( ( ( m_quality1 & 0xf ) == 0xc ) || ( ( m_quality1 & 0xf ) == 0xd ) || ( ( m_quality1 & 0xf ) == 0xe ) ) ) ) {
908 m_quality1 = ( m_quality1 | 0x800 );
909 m_quality2 = ( m_quality2 | 0x800 );
910
911 }
912 }
913 }
914 }
915 else if( layer == 1 ) {
916 if( m_tofId2 == (tofId+88) ) {
917 if( ( m_quality1 & 0xf ) == 0xf ) {
918 if( ( ( east == 0 ) && ( ( ( m_quality2 & 0xf ) == 0x3 ) || ( ( m_quality2 & 0xf ) == 0x7 ) || ( ( m_quality2 & 0xf ) == 0xb ) ) ) || ( ( east == 1 ) && ( ( ( m_quality2 & 0xf ) == 0xc ) || ( ( m_quality2 & 0xf ) == 0xd ) || ( ( m_quality2 & 0xf ) == 0xe ) ) ) ) {
919 m_quality1 = ( m_quality1 | 0x800 );
920 m_quality2 = ( m_quality2 | 0x800 );
921 }
922 }
923 }
924 }
925 }
926 }
927 }
928 }
929 // set Data Sample for Calibration, only one hit for counter, T and Q.
930 else if( m_hitCase == InnerLayer ) {
931 if( ( m_quality1 & 0xf ) == 0xf ) {
932 m_quality1 = ( m_quality1 | 0x800 ); // Calibration Sample
933 }
934 else {
935 std::vector<int>::iterator iter = deadId.begin();
936 for( ; iter != deadId.end(); iter++ ) {
937 Identifier iden = Identifier(*iter);
938 int barrel = TofID::barrel_ec(iden);
939 int layer = TofID::layer(iden);
940 int tofId = TofID::phi_module(iden);
941 int east = TofID::end(iden);
942 if( barrel == 1 ) {
943 if( layer==0 ) {
944 if( m_tofId1 == tofId ) {
945 if( ( ( east == 0 ) && ( ( ( m_quality1 & 0xf ) == 0x3 ) || ( ( m_quality1 & 0xf ) == 0x7 ) || ( ( m_quality1 & 0xf ) == 0xb ) ) ) || ( ( east == 1 ) && ( ( ( m_quality1 & 0xf ) == 0xc ) || ( ( m_quality1 & 0xf ) == 0xd ) || ( ( m_quality1 & 0xf ) == 0xe ) ) ) ) {
946 m_quality1 = ( m_quality1 | 0x800 );
947 }
948 }
949 }
950 }
951 }
952 }
953 }
954
955 // set Data Sample for Calibration, only one hit for counter, T and Q.
956 if( ( ( m_hitCase == EastEndcap ) || ( m_hitCase == WestEndcap ) ) && ( ( m_quality1 & 0xf ) == 0xc ) ) {
957 m_quality1 = ( m_quality1 | 0x800 ); // Calibration Sample
958 }
959
960 // set Data Sample for Calibration.
961 if( ( m_hitCase == EastEndcapMRPC ) || ( m_hitCase == WestEndcapMRPC ) ) {
962 if( ( ( m_quality1 & 0xf000 ) == 0x1000 ) || ( ( m_quality1 & 0xf000 ) == 0x2000 ) ) {
963 if( ( m_quality1 & 0xf ) == 0xf ) {
964 m_quality1 = ( m_quality1 | 0x800 ); // Calibration Sample
965 }
966 }
967 else if( ( ( m_quality1 & 0xf000 ) == 0x4000 ) ) {
968 std::vector<int>::iterator iter = deadId.begin();
969 for( ; iter != deadId.end(); iter++ ) {
970 if( (*iter)==1 ) {
971 if( ( m_tofId1==3 && ( m_strip1==1 || m_strip1==3 || ( m_strip1>=5 && m_strip1<=11 ) ) ) || ( m_tofId1==13 && m_strip1==7 ) ) {
972 if( ( m_quality1 & 0xf ) == 0xc ) {
973 m_quality1 = ( m_quality1 | 0x800 );
974 }
975 }
976 if( m_tofId1==13 && m_strip1==5 ) {
977 if( ( m_quality1 & 0xf ) == 0x3 ) {
978 m_quality1 = ( m_quality1 | 0x800 );
979 }
980 }
981 }
982 else {
983 Identifier iden = Identifier(*iter);
984 int barrel = TofID::barrel_ec( iden );
985 if( barrel == 3 ) {
986 int endcap = TofID::endcap( iden );
987 int tofid = TofID::module( iden );
988 int strip = TofID::strip( iden );
989 int east = TofID::end( iden );
990 if( ( m_tofId1 == ( endcap*36 + tofid ) ) && ( m_strip1 == strip ) ) {
991 if( ( ( east == 0 ) && ( ( ( m_quality1 & 0xf ) == 0x3 ) || ( ( m_quality1 & 0xf ) == 0x7 ) || ( ( m_quality1 & 0xf ) == 0xb ) ) ) || ( ( east == 1 ) && ( ( ( m_quality1 & 0xf ) == 0xc ) || ( ( m_quality1 & 0xf ) == 0xd ) || ( ( m_quality1 & 0xf ) == 0xe ) ) ) ) {
992 m_quality1 = ( m_quality1 | 0x800 );
993 }
994 }
995 }
996 }
997 }
998 }
999
1000 if( ( ( m_quality2 & 0xf000 ) == 0x1000 ) || ( ( m_quality2 & 0xf000 ) == 0x2000 ) ) {
1001 if( ( m_quality2 & 0xf ) == 0xf ) {
1002 m_quality2 = ( m_quality2 | 0x800 ); // Calibration Sample
1003 }
1004 }
1005 else if( ( m_quality2 & 0xf000 ) == 0x4000 ) {
1006 std::vector<int>::iterator iter = deadId.begin();
1007 for( ; iter != deadId.end(); iter++ ) {
1008 if( (*iter)==2 ) {
1009 if( m_tofId2==34 && ( m_strip2>=0 && m_strip1<=5 ) ) {
1010 if( ( m_quality2 & 0xf ) == 0x3 ) {
1011 m_quality2 = ( m_quality2 | 0x800 );
1012 }
1013 }
1014 }
1015 else {
1016 Identifier iden = Identifier(*iter);
1017 int barrel = TofID::barrel_ec( iden );
1018 if( barrel == 3 ) {
1019 int endcap = TofID::endcap( iden );
1020 int tofid = TofID::module( iden );
1021 int strip = TofID::strip( iden );
1022 int east = TofID::end( iden );
1023 if( ( m_tofId2 == ( endcap*36 + tofid ) ) && ( m_strip2 == strip ) ) {
1024 if( ( ( east == 0 ) && ( ( ( m_quality2 & 0xf ) == 0x3 ) || ( ( m_quality2 & 0xf ) == 0x7 ) || ( ( m_quality2 & 0xf ) == 0xb ) ) ) || ( ( east == 1 ) && ( ( ( m_quality2 & 0xf ) == 0xc ) || ( ( m_quality2 & 0xf ) == 0xd ) || ( ( m_quality2 & 0xf ) == 0xe ) ) ) ) {
1025 m_quality2 = ( m_quality2 | 0x800 );
1026 }
1027 }
1028 }
1029 }
1030 }
1031 }
1032 }
1033 }
1034
1035 return;
1036}
1037
1038
1039//------- findTofDataBarrel ----------------------------------------
1040// find the right TOF information in TOF data vector
1041// of the exact TOF ID and of the neighbor
1042//
1043void TofTrack::findTofDataBarrel( std::vector<TofData*> tofDataVec1, std::vector<TofData*> tofDataVec2, double zrhit, unsigned int iflag, std::vector<TofTrack*>*& tofTrackVec ) {
1044
1045 unsigned int qual = 0xf;
1046 TofData* tof = 0;
1047 if( tofDataVec2.size() == 0 ) {
1048 if( tofDataVec1.size() == 0 ) {
1049 qual = 0;
1050 }
1051 else if( tofDataVec1.size() == 1 ) {
1052 std::vector<TofData*>::iterator iter1 = tofDataVec1.begin();
1053 tof = (*iter1);
1054 qual = 0x1;
1055 }
1056 else if( tofDataVec1.size() > 1 ) {
1057 tof= chooseTofData( tofDataVec1, zrhit );
1058 qual = 0x2;
1059 }
1060 else {
1061 cout << "TofRec::TofTrack::findTofDataBarrel: 1- Impossible!" << endl;
1062 }
1063 }
1064 else if( ( tofDataVec2.size() == 1 ) ) {
1065 if( tofDataVec1.size() == 0 ) {
1066 std::vector<TofData*>::iterator iter2 = tofDataVec2.begin();
1067 tof = (*iter2);
1068 qual = 0x4;
1069 }
1070 else if( tofDataVec1.size() == 1 ) {
1071 std::vector<TofData*>::iterator iter1 = tofDataVec1.begin();
1072 if( ((*iter1)->quality()&0x1ff)==0x01f && abs((*iter1)->ztdc()-zrhit)<ztdc_Cut ) {
1073 tof = (*iter1);
1074 }
1075 else {
1076 std::vector<TofData*>::iterator iter2 = tofDataVec2.begin();
1077 tof = compareTofData( (*iter1), (*iter2), zrhit );
1078 }
1079 qual = 0x5;
1080 }
1081 else if( tofDataVec1.size() > 1 ) {
1082 TofData* tofData1 = chooseTofData( tofDataVec1, zrhit );
1083 if( (tofData1->quality()&0x1ff)==0x01f && abs(tofData1->ztdc()-zrhit)<ztdc_Cut ) {
1084 tof = tofData1;
1085 }
1086 else {
1087 std::vector<TofData*>::iterator iter2 = tofDataVec2.begin();
1088 tof = compareTofData( tofData1, (*iter2), zrhit );
1089 }
1090 qual = 0x6;
1091 }
1092 else {
1093 cout << "TofRec::TofTrack::findTofDataBarrel: 2- Impossible!" << endl;
1094 }
1095 }
1096 else if( ( tofDataVec2.size() > 1 ) ) {
1097 if( tofDataVec1.size() == 0 ) {
1098 tof = chooseTofData( tofDataVec2, zrhit );
1099 qual = 0x8;
1100 }
1101 else if( tofDataVec1.size() == 1 ) {
1102 std::vector<TofData*>::iterator iter1 = tofDataVec1.begin();
1103 if( ((*iter1)->quality()&0x1ff)==0x01f && abs((*iter1)->ztdc()-zrhit)<ztdc_Cut ) {
1104 tof = (*iter1);
1105 }
1106 else {
1107 TofData* tofData2 = chooseTofData( tofDataVec2, zrhit );
1108 tof = compareTofData( (*iter1), tofData2, zrhit );
1109 }
1110 qual = 0x9;
1111 }
1112 else if( tofDataVec1.size() > 1 ) {
1113 TofData* tofData1 = chooseTofData( tofDataVec1, zrhit );
1114 if( (tofData1->quality()&0x1ff)==0x01f && abs(tofData1->ztdc()-zrhit)<ztdc_Cut ) {
1115 tof = tofData1;
1116 }
1117 else {
1118 TofData* tofData2 = chooseTofData( tofDataVec2, zrhit );
1119 tof = compareTofData( tofData1, tofData2, zrhit );
1120 }
1121 qual = 0xa;
1122 }
1123 else {
1124 cout << "TofRec::TofTrack::findTofDataBarrel: 3- Impossible!" << endl;
1125 }
1126 }
1127
1128 if( qual != 0 ) {
1129 if( !(tof->used()) ) {
1130 getTofData( tof, iflag );
1131 }
1132 else {
1133 bool z1=false, z2=false;
1134 bool zc1=false, zc2=false;
1135 TofTrack* track=0;
1136 if( iflag==1 ) {
1137 z1 = ( abs( m_zrhit1 - tof->ztdc() ) < ztdc_Cut );
1138 zc1 = ( m_zrhit1 > tof->ztdc() );
1139 std::vector<TofTrack*>::iterator iter = tofTrackVec->begin();
1140 for( ; iter!=tofTrackVec->end(); iter++ ) {
1141 if( (*iter)->hitCase()!=InnerLayer && (*iter)->hitCase()!=DoubleLayer ) continue;
1142 if( tof->tofId()==(*iter)->tofId1() ) {
1143 track = (*iter);
1144 z2 = ( abs( (*iter)->zrhit1() - tof->ztdc() ) < ztdc_Cut );
1145 zc2 = ( (*iter)->zrhit1() > tof->ztdc() );
1146 }
1147 }
1148 }
1149 else if( iflag==2 ) {
1150 z1 = ( abs( m_zrhit2 - tof->ztdc() ) < ztdc_Cut );
1151 zc1 = ( m_zrhit2 > tof->ztdc() );
1152 std::vector<TofTrack*>::iterator iter = tofTrackVec->begin();
1153 for( ; iter!=tofTrackVec->end(); iter++ ) {
1154 if( (*iter)->hitCase()!=OuterLayer && (*iter)->hitCase()!=DoubleLayer ) continue;
1155 if( tof->tofId()==(*iter)->tofId2() ) {
1156 track = (*iter);
1157 z2 = ( abs( (*iter)->zrhit2() - tof->ztdc() ) < ztdc_Cut );
1158 zc2 = ( (*iter)->zrhit2() > tof->ztdc() );
1159 }
1160 }
1161 }
1162
1163 if( ( z1 && z2 )||( (!z1) && (!z2) ) ) {
1164 if( zc1 && !zc2 ) {
1165 getTofDataEast( tof, iflag );
1166 track->getTofDataWest( tof, iflag );
1167 }
1168 else if( !zc1 && zc2 ) {
1169 getTofDataWest( tof, iflag );
1170 track->getTofDataEast( tof, iflag );
1171 }
1172 }
1173 else if( z1 && !z2 ) {
1174 getTofData( tof, iflag );
1175 track->getTofDataNohit( iflag );
1176 }
1177 else if( !z1 && z2 ) {
1178 qual = 0;
1179 }
1180 }
1181 }
1182
1183 if( qual == 0 ) {
1184 if( ( iflag == 1 ) || ( iflag == 3 ) ) {
1185 m_quality1 = ( m_quality1 | 0x300 );
1186 }
1187 else if( iflag == 2 ) {
1188 m_quality2 = ( m_quality2 | 0x300 );
1189 }
1190 else {
1191 cout << "TofRec::TofTrack::findTofDataBarrel: the 1- IFLAG is Out of Range!" << endl;
1192 }
1193 }
1194 else {
1195 qual = ( qual << 12 );
1196 if( ( iflag == 1 ) || ( iflag == 3 ) ) {
1197 m_quality1 = ( m_quality1 | qual );
1198 }
1199 else if( iflag == 2 ) {
1200 m_quality2 = ( m_quality2 | qual );
1201 }
1202 else {
1203 cout << "TofRec::TofTrack::findTofDataBarrel: the 2- IFLAG is Out of Range!" << endl;
1204 }
1205 }
1206
1207 return;
1208}
1209
1210
1211//------- chooseTofData -------------------------------------------
1212// choose the most possible TofData from TofDataVector
1213// ZTDC, ZADC, SingleEnd/NoQ/NoT are jugded.
1214//
1215TofData* TofTrack::chooseTofData( std::vector<TofData*> tofDataVec, double zrhit ) {
1216 if( tofDataVec.size() == 0 ) {
1217 cout << "TofRec::TofTrack::ChooseTofData: Size of TofData Vector is Zero!" << endl;
1218 return 0;
1219 }
1220 std::vector<TofData*>::iterator igood = tofDataVec.begin();
1221 if( tofDataVec.size() > 1 ) {
1222 double deltaZ = 1000.0;
1223 std::vector<TofData*>::iterator iter = tofDataVec.begin();
1224 // ZTDC compare
1225 for( ; iter != tofDataVec.end(); iter++ ) {
1226 if( ( (*iter)->quality() & 0x5 ) == 0x5 ) {
1227 if( abs( (*iter)->ztdc() - zrhit ) < deltaZ ) {
1228 deltaZ = abs( (*iter)->ztdc() - zrhit );
1229 igood = iter;
1230 }
1231 }
1232 }
1233 // ZADC compare
1234 if( deltaZ > 999.0 ) {
1235 iter = tofDataVec.begin();
1236 for( ; iter != tofDataVec.end(); iter++ ) {
1237 if( ( (*iter)->quality() & 0xa ) == 0xa ) {
1238 if( abs( (*iter)->zadc() - zrhit ) < deltaZ ) {
1239 deltaZ = abs( (*iter)->zadc() - zrhit );
1240 igood = iter;
1241 }
1242 }
1243 }
1244 }
1245 // Max Q
1246 if( deltaZ > 999.0 ) {
1247 unsigned int ibad = 0xf0;
1248 iter = tofDataVec.begin();
1249 for( ; iter != tofDataVec.end(); iter++ ) {
1250 if( ( (*iter)->quality() & 0xf0 ) < ibad ) {
1251 igood = iter;
1252 ibad = ( (*iter)->quality() & 0xf0 );
1253 }
1254 else if( ( (*iter)->quality() & 0xf0 ) == ibad ) {
1255 if( ( (*iter)->adc1() + (*iter)->adc2() ) > ( (*igood)->adc1() + (*igood)->adc2() ) ) {
1256 igood = iter;
1257 ibad = ( (*iter)->quality() & 0xf0 );
1258 }
1259 }
1260 }
1261 }
1262 }
1263
1264 return (*igood);
1265}
1266
1267
1268//------- compareTofData -------------------------------------------
1269// choose the most possible TofData from TofDataVector
1270// ZTDC, ZADC, SingleEnd/NoQ/NoT are jugded.
1271//
1272TofData* TofTrack::compareTofData( TofData* tofData1, TofData* tofData2, double zrhit ) {
1273 TofData* tof = tofData1;
1274 // ZTDC compare
1275 if( abs(tofData1->ztdc() - zrhit ) > abs(tofData2->ztdc() - zrhit ) ) {
1276 // SingleEnd/NoT/NoQ compare
1277 if( ( tofData1->quality() & 0xf0 ) >= ( tofData1->quality() & 0xf0 ) ) {
1278 // QDC compare
1279 // if( ( tofData1->adc1() + tofData1->adc2() ) < ( tofData2->adc1() + tofData2->adc2() ) ) {
1280 tof = tofData2;
1281 // }
1282 }
1283 // }
1284 }
1285
1286 return tof;
1287}
1288
1289
1290//------- findTofDataEndcap --------------------------------------
1291// find the right TOF information in TOF data vector
1292// of the exact TOF ID and of the neighbor
1293//
1294void TofTrack::findTofDataEndcap( std::vector<TofData*> tofDataVec1, std::vector<TofData*> tofDataVec2, double zr1[5] ) {
1295
1296 unsigned int iflag = 3;
1297 unsigned int qual = 0xf;
1298
1299 if( tofDataVec2.size() == 0 ) {
1300 if( tofDataVec1.size() == 0 ) {
1301 qual = 0;
1302 }
1303 else if( tofDataVec1.size() == 1 ) {
1304 std::vector<TofData*>::iterator iter1 = tofDataVec1.begin();
1305 getTofData( (*iter1), iflag );
1306 qual = 0x1;
1307 }
1308 else if( tofDataVec1.size() > 1 ) {
1309 getTofData( chooseTofDataEndcap( tofDataVec1, zr1 ), iflag );
1310 qual = 0x2;
1311 }
1312 else {
1313 cout << "TofRec::TofTrack::findTofDataEndcap: 1- Impossible!" << endl;
1314 }
1315 }
1316 else if( ( tofDataVec2.size() == 1 ) ) {
1317 if( tofDataVec1.size() == 0 ) {
1318 std::vector<TofData*>::iterator iter2 = tofDataVec2.begin();
1319 getTofData( (*iter2), iflag );
1320 qual = 0x4;
1321 }
1322 else if( tofDataVec1.size() == 1 ) {
1323 std::vector<TofData*>::iterator iter1 = tofDataVec1.begin();
1324 std::vector<TofData*>::iterator iter2 = tofDataVec2.begin();
1325 getTofData( compareTofDataEndcap( (*iter1), (*iter2) ), iflag );
1326 qual = 0x5;
1327 }
1328 else if( tofDataVec1.size() > 1 ) {
1329 TofData* tofData1 = chooseTofDataEndcap( tofDataVec1, zr1 );
1330 std::vector<TofData*>::iterator iter2 = tofDataVec2.begin();
1331 getTofData( compareTofDataEndcap( tofData1, (*iter2) ), iflag );
1332 qual = 0x6;
1333 }
1334 else {
1335 cout << "TofRec::TofTrack::findTofDataBarrel: 2- Impossible!" << endl;
1336 }
1337 }
1338 else if( ( tofDataVec2.size() > 1 ) ) {
1339 if( tofDataVec1.size() == 0 ) {
1340 getTofData( chooseTofDataEndcap( tofDataVec2, zr1 ), iflag );
1341 qual = 0x8;
1342 }
1343 else if( tofDataVec1.size() == 1 ) {
1344 std::vector<TofData*>::iterator iter1 = tofDataVec1.begin();
1345 TofData* tofData2 = chooseTofDataEndcap( tofDataVec2, zr1 );
1346 getTofData( compareTofDataEndcap( (*iter1), tofData2 ), iflag );
1347 qual = 0x9;
1348 }
1349 else if( tofDataVec1.size() > 1 ) {
1350 TofData* tofData1 = chooseTofDataEndcap( tofDataVec1, zr1 );
1351 TofData* tofData2 = chooseTofDataEndcap( tofDataVec2, zr1 );
1353 qual = 0xa;
1354 }
1355 else {
1356 cout << "TofRec::TofTrack::findTofDataBarrel: 3- Impossible!" << endl;
1357 }
1358 }
1359
1360 if( qual == 0 ) {
1361 m_quality1 = ( m_quality1 | 0x300 );
1362 }
1363 else {
1364 qual = ( qual << 12 );
1365 m_quality1 = ( m_quality1 | qual );
1366 }
1367
1368 return;
1369}
1370
1371
1372//------- chooseTofDataEndcap --------------------------------
1373// choose the most possible TofData from TofDataVector
1374//
1375TofData* TofTrack::chooseTofDataEndcap( std::vector<TofData*> tofDataVec, double zr1[5] ) {
1376 if( tofDataVec.size() == 0 ) {
1377 cout << "TofRec::TofTrack::ChooseTofData: Size of TofData Vector is Zero!" << endl;
1378 return 0;
1379 }
1380 std::vector<TofData*>::iterator igood = tofDataVec.begin();
1381 if( tofDataVec.size() > 1 ) {
1382 bool multihit = false;
1383 std::vector<TofData*>::iterator iter = tofDataVec.begin();
1384 for( ; iter != tofDataVec.end(); iter++ ) {
1385 if( (*iter)->qtimes1()>1 ) { multihit = true; }
1386 }
1387 iter = tofDataVec.begin();
1388 if( multihit ) {
1389 double tcorr = -999.0;
1390 double deltaTMin = 999.0;
1391 for( ; iter != tofDataVec.end(); iter++ ) {
1392 tcorr = tofCaliSvc->ETime( (*iter)->adc(), (*iter)->tdc()-m_estime, zr1[2], (*iter)->tofId() );
1393 for( unsigned int i=0; i<5; i++ ) {
1394 if( abs(tcorr-m_texpInner[i]) < deltaTMin ) {
1395 deltaTMin = abs(tcorr-m_texpInner[i]);
1396 igood = iter;
1397 }
1398 }
1399 }
1400 }
1401 else {
1402 double maxQ = 0.0;
1403 for( ; iter != tofDataVec.end(); iter++ ) {
1404 if( (*iter)->adc() > maxQ ) {
1405 maxQ = (*iter)->adc();
1406 igood = iter;
1407 }
1408 }
1409 }
1410 }
1411 return (*igood);
1412}
1413
1414
1415//------- compareTofDataEndcap -------------------------------
1416// choose the most possible TofData from TofDataVector
1417//
1419 TofData* tof = tofData1;
1420 if( tof->adc() < tofData2->adc() ) {
1421 tof = tofData2;
1422 }
1423 return tof;
1424}
1425
1426
1427//------- findTofDataEtf --------------------------------------
1428// find the right TOF information in TOF data vector
1429// of the exact TOF ID and of the neighbor
1430//
1431void TofTrack::findEtfData( std::vector<TofData*> tofDataVec1, std::vector<TofData*> tofDataVec2, std::vector<TofData*> tofDataVec3, double zrhit, unsigned int iflag ) {
1432
1433 TofData *tof1 = 0;
1434 TofData *tof2 = 0;
1435 TofData *tof3 = 0;
1436
1437 bool findSignal = false;
1438
1439 if( tofDataVec1.size()==0 && tofDataVec2.size()==0 && tofDataVec3.size()==0 ) {
1440 if( iflag == 1 ) {
1441 m_quality1 = ( m_quality1 | 0x300 );
1442 }
1443 else if( iflag == 2 ) {
1444 m_quality2 = ( m_quality2 | 0x300 );
1445 }
1446 }
1447 else {
1448 if( tofDataVec1.size()>0 ) {
1449 tof1 = chooseEtfData1( tofDataVec1, zrhit );
1450 if( ( tof1->quality() & 0xf ) == 0xf ) {
1451 getEtfData( tof1, iflag, 1 );
1452 findSignal = true;
1453 }
1454 }
1455 if( !findSignal && tofDataVec2.size() > 0 ) {
1456 tof2 = chooseEtfData1( tofDataVec2, zrhit );
1457 if( ( tof2->quality() & 0xf ) == 0xf ) {
1458 getEtfData( tof2, iflag, 2 );
1459 findSignal = true;
1460 }
1461 }
1462 if( !findSignal && tofDataVec3.size() > 0 ) {
1463 tof3 = chooseEtfData2( tofDataVec3, zrhit );
1464 if( ( tof3->quality() & 0xf ) == 0xf ) {
1465 getEtfData( tof3, iflag, 3 );
1466 findSignal = true;
1467 }
1468 }
1469 if( !findSignal && tofDataVec1.size()>0 ) {
1470 if( ( ( tof1->quality() & 0xf ) == 0xc ) || ( ( tof1->quality() & 0xf ) == 0x3 ) ) {
1471 getEtfData( tof1, iflag, 4 );
1472 findSignal = true;
1473 }
1474 }
1475 if( !findSignal && tofDataVec2.size() > 0 ) {
1476 if( ( ( tof2->quality() & 0xf ) == 0xc ) || ( ( tof2->quality() & 0xf ) == 0x3 ) ) {
1477 getEtfData( tof2, iflag, 5 );
1478 findSignal = true;
1479 }
1480 }
1481 if( !findSignal && tofDataVec3.size() > 0 ) {
1482 if( ( ( tof3->quality() & 0xf ) == 0xc ) || ( ( tof3->quality() & 0xf ) == 0x3 ) ) {
1483 getEtfData( tof3, iflag, 6 );
1484 findSignal = true;
1485 }
1486 }
1487 if( findSignal ) {
1488 if( iflag == 1 ) {
1489 m_quality1 = ( m_quality1 | 0x300 );
1490 }
1491 else if( iflag == 2 ) {
1492 m_quality2 = ( m_quality2 | 0x300 );
1493 }
1494 }
1495 }
1496
1497 return;
1498}
1499
1500//------- chooseEtfData -------------------------------
1501// choose the most possible TofData from TofDataVector
1502//
1503TofData* TofTrack::chooseEtfData1( std::vector<TofData*> tofDataVec, double zrhit ) {
1504 if( tofDataVec.size() == 0 ) {
1505 return 0;
1506 }
1507 std::vector<TofData*>::iterator igood = tofDataVec.begin();
1508 if( tofDataVec.size() == 1 ) {
1509 return (*igood);
1510 }
1511 else if( tofDataVec.size() > 1 ) {
1512 double deltaZ = 1000.0;
1513 std::vector<TofData*>::iterator iter = tofDataVec.begin();
1514 for( ; iter != tofDataVec.end(); iter++ ) {
1515 if( ( (*iter)->quality() & 0xf ) == 0xf ) {
1516 if( abs( (*iter)->ztdc() - zrhit ) < deltaZ ) {
1517 deltaZ = abs( (*iter)->ztdc() - zrhit );
1518 igood = iter;
1519 }
1520 }
1521 }
1522 // Max Q
1523 if( deltaZ > 999.0 ) {
1524 double maxQ = -1;
1525 iter = tofDataVec.begin();
1526 for( ; iter != tofDataVec.end(); iter++ ) {
1527 if( ( (*iter)->quality() & 0xc ) == 0xc ) {
1528 if( (*iter)->adc1() > maxQ ) {
1529 maxQ = (*iter)->adc1();
1530 igood = iter;
1531 }
1532 }
1533 else if( ( (*iter)->quality() & 0x3 ) == 0x3 ) {
1534 if( (*iter)->adc2() > maxQ ) {
1535 maxQ = (*iter)->adc2();
1536 igood = iter;
1537 }
1538 }
1539 }
1540 }
1541 }
1542
1543 return (*igood);
1544}
1545
1546//------- chooseEtfData -------------------------------
1547// choose the most possible TofData from TofDataVector
1548//
1549TofData* TofTrack::chooseEtfData2( std::vector<TofData*> tofDataVec, double zrhit ) {
1550 if( tofDataVec.size() == 0 ) {
1551 return 0;
1552 }
1553 std::vector<TofData*>::iterator igood = tofDataVec.begin();
1554 if( tofDataVec.size() == 1 ) {
1555 return (*igood);
1556 }
1557 else if( tofDataVec.size() > 1 ) {
1558 double maxQ = -1;
1559 std::vector<TofData*>::iterator iter = tofDataVec.begin();
1560 for( ; iter != tofDataVec.end(); iter++ ) {
1561 if( ( (*iter)->quality() & 0xc ) == 0xc ) {
1562 if( (*iter)->adc1() > maxQ ) {
1563 maxQ = (*iter)->adc1();
1564 igood = iter;
1565 }
1566 }
1567 else if( ( (*iter)->quality() & 0x3 ) == 0x3 ) {
1568 if( (*iter)->adc2() > maxQ ) {
1569 maxQ = (*iter)->adc2();
1570 igood = iter;
1571 }
1572 }
1573 }
1574 }
1575
1576 return (*igood);
1577}
1578
1579//------- getTofData -----------------------------------------
1580// set Tof Data of Inner / Outer Layer Barrel TOF and Endcap TOF
1581//
1582void TofTrack::getTofData( TofData* tof, unsigned int iflag ) {
1583
1584 if( iflag == 1 ) {
1585 m_tofId1 = tof->tofId();
1586 m_strip1 = tof->strip();
1587 if( tofCaliSvc->QElec() ) {
1588 m_qch1 = tof->qtc1();
1589 }
1590 else {
1591 m_qch1 = tof->adcChannelEast();
1592 }
1593 m_adc1 = tof->adc1();
1594 m_tdc1 = tof->tdc1();
1595 if( tofCaliSvc->QElec() ) {
1596 m_qch2 = tof->qtc2();
1597 }
1598 else {
1599 m_qch2 = tof->adcChannelWest();
1600 }
1601 m_adc2 = tof->adc2();
1602 m_tdc2 = tof->tdc2();
1603 m_ztdc1 = tof->ztdc();
1604 m_zadc1 = tof->zadc();
1605 m_quality1 = ( m_quality1 | ( 0x1f & tof->quality() ) );
1606 if( ( ( tof->quality() & 0x5 ) != 0x5 ) || ( ( ( tof->quality() & 0x5 ) == 0x5 ) && ( abs( tof->ztdc() - m_zrhit1 ) > ztdc_Cut ) ) ) {
1607 m_quality1 = ( m_quality1 | 0x100 );
1608 }
1609 if( ( ( tof->quality() & 0xa ) != 0xa ) || ( ( ( tof->quality() & 0xa ) == 0xa ) && ( abs( tof->zadc() - m_zrhit1 ) > zadc_Cut ) ) ) {
1610 m_quality1 = ( m_quality1 | 0x200 );
1611 }
1612 }
1613 else if( iflag == 2 ) {
1614 m_tofId2 = tof->tofId();
1615 m_strip2 = tof->strip();
1616 if( tofCaliSvc->QElec() ) {
1617 m_qch3 = tof->qtc1();
1618 }
1619 else {
1620 m_qch3 = tof->adcChannelEast();
1621 }
1622 m_adc3 = tof->adc1();
1623 m_tdc3 = tof->tdc1();
1624 if( tofCaliSvc->QElec() ) {
1625 m_qch4 = tof->qtc2();
1626 }
1627 else {
1628 m_qch4 = tof->adcChannelWest();
1629 }
1630 m_adc4 = tof->adc2();
1631 m_tdc4 = tof->tdc2();
1632 m_ztdc2 = tof->ztdc();
1633 m_zadc2 = tof->zadc();
1634 m_quality2 = ( m_quality2 | ( 0x1f & tof->quality() ) );
1635 if( ( ( tof->quality() & 0x5 ) != 0x5 ) || ( ( ( tof->quality() & 0x5 ) == 0x5 ) && ( abs( tof->ztdc() - m_zrhit2 ) > ztdc_Cut ) ) ) {
1636 m_quality2 = ( m_quality2 | 0x100 );
1637 }
1638 if( ( ( tof->quality() & 0xa ) != 0xa ) || ( ( ( tof->quality() & 0xa ) == 0xa ) && ( abs( tof->zadc() - m_zrhit2 ) > zadc_Cut ) ) ) {
1639 m_quality2 = ( m_quality2 | 0x200 );
1640 }
1641 }
1642 else if( iflag == 3 ) {
1643 m_tofId1 = tof->tofId();
1644 if( tofCaliSvc->QElec() ) {
1645 m_qch1 = tof->qtc();
1646 }
1647 else {
1648 m_qch1 = tof->adcChannel();
1649 }
1650 m_adc1 = tof->adc();
1651 m_tdc1 = tof->tdc();
1652 m_quality1 = ( m_quality1 | ( 0x1f & tof->quality() ) );
1653 m_quality1 = ( m_quality1 | 0x300 );
1654 }
1655 else {
1656 cout << "TofRec::TofTrack::getTofData: Flag which sign the Barrel/Endcap or Inner/Outer is wrong! Please check it!" << endl;
1657 }
1658 tof->setUsed();
1659 return;
1660}
1661
1662
1663//------- getTofDataEast ------------------------------------
1664// set Tof Data of Inner / Outer Layer Barrel TOF and Endcap TOF
1665//
1666void TofTrack::getTofDataEast( TofData* tof, unsigned int iflag ) {
1667
1668 if( iflag == 1 ) {
1669 m_tofId1 = tof->tofId();
1670 m_strip1 = tof->strip();
1671 if( tofCaliSvc->QElec() ) {
1672 m_qch1 = tof->qtc1();
1673 }
1674 else {
1675 m_qch1 = tof->adcChannelEast();
1676 }
1677 m_adc1 = tof->adc1();
1678 m_tdc1 = tof->tdc1();
1679 m_qch2 = -999.0;
1680 m_adc2 = -999.0;
1681 m_tdc2 = -999.0;
1682 m_ztdc1 = tof->ztdc();
1683 m_zadc1 = tof->zadc();
1684 m_quality1 = ( ( m_quality1 & 0xfffffff0 ) | ( 0x1c & tof->quality() ) );
1685 if( ( ( tof->quality() & 0x5 ) != 0x5 ) || ( ( ( tof->quality() & 0x5 ) == 0x5 ) && ( abs( tof->ztdc() - m_zrhit1 ) > ztdc_Cut ) ) ) {
1686 m_quality1 = ( m_quality1 | 0x100 );
1687 }
1688 if( ( ( tof->quality() & 0xa ) != 0xa ) || ( ( ( tof->quality() & 0xa ) == 0xa ) && ( abs( tof->zadc() - m_zrhit1 ) > zadc_Cut ) ) ) {
1689 m_quality1 = ( m_quality1 | 0x200 );
1690 }
1691 }
1692 else if( iflag == 2 ) {
1693 m_tofId2 = tof->tofId();
1694 if( tofCaliSvc->QElec() ) {
1695 m_qch3 = tof->qtc1();
1696 }
1697 else {
1698 m_qch3 = tof->adcChannelEast();
1699 }
1700 m_adc3 = tof->adc1();
1701 m_tdc3 = tof->tdc1();
1702 m_qch4 = -999.0;
1703 m_adc4 = -999.0;
1704 m_tdc4 = -999.0;
1705 m_ztdc2 = tof->ztdc();
1706 m_zadc2 = tof->zadc();
1707 m_quality2 = ( ( m_quality2 & 0xfffffff0 ) | ( 0x1c & tof->quality() ) );
1708 if( ( ( tof->quality() & 0x5 ) != 0x5 ) || ( ( ( tof->quality() & 0x5 ) == 0x5 ) && ( abs( tof->ztdc() - m_zrhit2 ) > ztdc_Cut ) ) ) {
1709 m_quality2 = ( m_quality2 | 0x100 );
1710 }
1711 if( ( ( tof->quality() & 0xa ) != 0xa ) || ( ( ( tof->quality() & 0xa ) == 0xa ) && ( abs( tof->zadc() - m_zrhit2 ) > zadc_Cut ) ) ) {
1712 m_quality2 = ( m_quality2 | 0x200 );
1713 }
1714 }
1715 else {
1716 cout << "TofRec::TofTrack::getTofDataEast: Flag which sign the Barrel/Endcap or Inner/Outer is wrong! Please check it!" << endl;
1717 }
1718 tof->setUsed();
1719 return;
1720}
1721
1722
1723//------- getTofDataWest ------------------------------------
1724// set Tof Data of Inner / Outer Layer Barrel TOF and Endcap TOF
1725//
1726void TofTrack::getTofDataWest( TofData* tof, unsigned int iflag ) {
1727
1728 if( iflag == 1 ) {
1729 m_tofId1 = tof->tofId();
1730 m_strip1 = tof->strip();
1731 m_qch1 = -999.0;
1732 m_adc1 = -999.0;
1733 m_tdc1 = -999.0;
1734 if( tofCaliSvc->QElec() ) {
1735 m_qch2 = tof->qtc2();
1736 }
1737 else {
1738 m_qch2 = tof->adcChannelWest();
1739 }
1740 m_adc2 = tof->adc2();
1741 m_tdc2 = tof->tdc2();
1742 m_ztdc1 = tof->ztdc();
1743 m_zadc1 = tof->zadc();
1744 m_quality1 = ( ( m_quality1 & 0xfffffff0 ) | ( 0x13 & tof->quality() ) );
1745 if( ( ( tof->quality() & 0x5 ) != 0x5 ) || ( ( ( tof->quality() & 0x5 ) == 0x5 ) && ( abs( tof->ztdc() - m_zrhit1 ) > ztdc_Cut ) ) ) {
1746 m_quality1 = ( m_quality1 | 0x100 );
1747 }
1748 if( ( ( tof->quality() & 0xa ) != 0xa ) || ( ( ( tof->quality() & 0xa ) == 0xa ) && ( abs( tof->zadc() - m_zrhit1 ) > zadc_Cut ) ) ) {
1749 m_quality1 = ( m_quality1 | 0x200 );
1750 }
1751 }
1752 else if( iflag == 2 ) {
1753 m_tofId2 = tof->tofId();
1754 m_qch3 = -999.0;
1755 m_adc3 = -999.0;
1756 m_tdc3 = -999.0;
1757 if( tofCaliSvc->QElec() ) {
1758 m_qch4 = tof->qtc2();
1759 }
1760 else {
1761 m_qch4 = tof->adcChannelWest();
1762 }
1763 m_adc4 = tof->adc2();
1764 m_tdc4 = tof->tdc2();
1765 m_ztdc2 = tof->ztdc();
1766 m_zadc2 = tof->zadc();
1767 m_quality2 = ( ( m_quality2 & 0xfffffff0 ) | ( 0x13 & tof->quality() ) );
1768 if( ( ( tof->quality() & 0x5 ) != 0x5 ) || ( ( ( tof->quality() & 0x5 ) == 0x5 ) && ( abs( tof->ztdc() - m_zrhit2 ) > ztdc_Cut ) ) ) {
1769 m_quality2 = ( m_quality2 | 0x100 );
1770 }
1771 if( ( ( tof->quality() & 0xa ) != 0xa ) || ( ( ( tof->quality() & 0xa ) == 0xa ) && ( abs( tof->zadc() - m_zrhit2 ) > zadc_Cut ) ) ) {
1772 m_quality2 = ( m_quality2 | 0x200 );
1773 }
1774 }
1775 else {
1776 cout << "TofRec::TofTrack::getTofDataWest: Flag which sign the Barrel/Endcap or Inner/Outer is wrong! Please check it!" << endl;
1777 }
1778 tof->setUsed();
1779 return;
1780}
1781
1782
1783//------- getTofData -----------------------------------------
1784// set Tof Data of Inner / Outer Layer Barrel TOF and Endcap TOF
1785//
1786void TofTrack::getTofDataNohit( unsigned int iflag ) {
1787
1788 if( iflag == 1 ) {
1789 m_tofId1 = -99;
1790 m_strip1 = -99;
1791 m_qch1 = -999.0;
1792 m_adc1 = -999.0;
1793 m_tdc1 = -999.0;
1794 m_qch2 = -999.0;
1795 m_adc2 = -999.0;
1796 m_tdc2 = -999.0;
1797 m_ztdc1 = -999.0;
1798 m_zadc1 = -999.0;
1799 m_quality1 = ( m_quality1 & 0x700 );
1800 if( m_hitCase == InnerLayer ) { m_hitCase = NoHit; }
1801 else if( m_hitCase == DoubleLayer ) { m_hitCase = OuterLayer; }
1802 }
1803 else if( iflag == 2 ) {
1804 m_tofId2 = -99;
1805 m_qch3 = -999.0;
1806 m_adc3 = -999.0;
1807 m_tdc3 = -999.0;
1808 m_qch4 = -999.0;
1809 m_adc4 = -999.0;
1810 m_tdc4 = -999.0;
1811 m_ztdc2 = -999.0;
1812 m_zadc2 = -999.0;
1813 m_quality2 = ( m_quality2 & 0x700 );
1814 if( m_hitCase == OuterLayer ) { m_hitCase = NoHit; }
1815 else if( m_hitCase == DoubleLayer ) { m_hitCase = InnerLayer; }
1816 }
1817 else {
1818 cout << "TofRec::TofTrack::getTofData: Flag which sign the Barrel/Endcap or Inner/Outer is wrong! Please check it!" << endl;
1819 }
1820
1821 return;
1822}
1823
1824
1825//------- getTofData -----------------------------------------
1826// set Tof Data of MRPC Endcap TOF
1827//
1828void TofTrack::getEtfData( TofData* tof, unsigned int iflag, unsigned int qual ) {
1829
1830 if( iflag == 1 && tof->tofId() != m_id2 ) {
1831 m_tofId1 = tof->tofId();
1832 m_strip1 = tof->strip();
1833 m_qch1 = tof->adcChannelEast();
1834 m_adc1 = tof->adc1();
1835 m_tdc1 = tof->tdc1();
1836 m_qch2 = tof->adcChannelWest();
1837 m_adc2 = tof->adc2();
1838 m_tdc2 = tof->tdc2();
1839 m_ztdc1 = tof->ztdc();
1840 m_zadc1 = tof->zadc();
1841 m_quality1 = ( m_quality1 | ( 0x1f & tof->quality() ) );
1842 if( ( ( tof->quality() & 0x5 ) != 0x5 ) || ( ( ( tof->quality() & 0x5 ) == 0x5 ) && ( abs( tof->ztdc() - m_zrhit1 ) > ztdc_Cut ) ) ) {
1843 m_quality1 = ( m_quality1 | 0x100 );
1844 }
1845 if( ( ( tof->quality() & 0xa ) != 0xa ) || ( ( ( tof->quality() & 0xa ) == 0xa ) && ( abs( tof->zadc() - m_zrhit1 ) > zadc_Cut ) ) ) {
1846 m_quality1 = ( m_quality1 | 0x200 );
1847 }
1848 m_quality1 = ( m_quality1 | ( qual << 12 ) );
1849 tof->setUsed();
1850 if( abs(tof->tofId()-m_id1)== 1 || ( tof->tofId()==0 && m_id1==35 ) || ( tof->tofId()==35 && m_id1==0 ) || ( tof->tofId()==36 && m_id1==71 ) || ( tof->tofId()==71 && m_id1==36 ) ) {
1851 for( unsigned int i=0; i<5; i++ ) {
1852 m_texpInner[i] = m_texpOuter[i];
1853 }
1854 }
1855 }
1856 else if( iflag == 2 && tof->tofId() != m_id1 ) {
1857 m_tofId2 = tof->tofId();
1858 m_strip2 = tof->strip();
1859 m_qch3 = tof->adcChannelEast();
1860 m_adc3 = tof->adc1();
1861 m_tdc3 = tof->tdc1();
1862 m_qch4 = tof->adcChannelWest();
1863 m_adc4 = tof->adc2();
1864 m_tdc4 = tof->tdc2();
1865 m_ztdc2 = tof->ztdc();
1866 m_zadc2 = tof->zadc();
1867 m_quality2 = ( m_quality2 | ( 0x1f & tof->quality() ) );
1868 if( ( ( tof->quality() & 0x5 ) != 0x5 ) || ( ( ( tof->quality() & 0x5 ) == 0x5 ) && ( abs( tof->ztdc() - m_zrhit2 ) > ztdc_Cut ) ) ) {
1869 m_quality2 = ( m_quality2 | 0x100 );
1870 }
1871 if( ( ( tof->quality() & 0xa ) != 0xa ) || ( ( ( tof->quality() & 0xa ) == 0xa ) && ( abs( tof->zadc() - m_zrhit2 ) > zadc_Cut ) ) ) {
1872 m_quality2 = ( m_quality2 | 0x200 );
1873 }
1874 m_quality2 = ( m_quality2 | ( qual << 12 ) );
1875 tof->setUsed();
1876 if( abs(tof->tofId()-m_id2)== 1 || ( tof->tofId()==0 && m_id2==35 ) || ( tof->tofId()==35 && m_id2==0 ) || ( tof->tofId()==36 && m_id2==71 ) || ( tof->tofId()==71 && m_id2==36 ) ) {
1877 for( unsigned int i=0; i<5; i++ ) {
1878 m_texpOuter[i] = m_texpInner[i];
1879 }
1880 }
1881 }
1882
1883 return;
1884}
1885
1886
1887//------- setCalibration() ----------------------------------------
1888// get calibration constants
1889// ph11() - ph22(), tof11() -- tof22()
1890// ph1() ph2() ph(), tof1() tof2() tof()
1891//
1893
1894 bool barrel = ( ( m_hitCase == InnerLayer ) || ( m_hitCase == OuterLayer ) || ( m_hitCase == DoubleLayer ) );
1895 bool endcap = ( ( m_hitCase == EastEndcap ) || ( m_hitCase == WestEndcap ) );
1896 bool endcapMRPC = ( ( m_hitCase == EastEndcapMRPC ) || ( m_hitCase == WestEndcapMRPC ) );
1897
1898 bool innerEast = ( ( m_quality1 & 0xc ) == 0xc );
1899 bool innerWest = ( ( m_quality1 & 0x3 ) == 0x3 );
1900 bool outerEast = ( ( m_quality2 & 0xc ) == 0xc );
1901 bool outerWest = ( ( m_quality2 & 0x3 ) == 0x3 );
1902 bool innerLayer = ( ( m_quality1 & 0xf ) == 0xf );
1903 bool outerLayer = ( ( m_quality2 & 0xf ) == 0xf );
1904
1905 bool endcapData = ( ( m_quality1 & 0xc ) == 0xc );
1906
1907 if( m_hitCase == DoubleLayer ) {
1908 for( unsigned int i=0; i<5; i++ ) {
1909 m_texp[i] = tofCaliSvc->BTimeCluster( m_texpInner[i], m_texpOuter[i], m_zr1[i], m_zr2[i], m_tofId1, m_tofId2 );
1910 }
1911 m_path = tofCaliSvc->BTimeCluster( m_path1, m_path2, m_zrhit1, m_zrhit2, m_tofId1, m_tofId2 );
1912 }
1913
1914 if( barrel ) {
1915 if( innerEast ) {
1916 for( unsigned int i=0; i<5; i++ ) {
1917 m_tof11[i] = tofCaliSvc->BTime1( m_adc1, m_tdc1-m_estime, m_zr1[i], m_tofId1, m_estime );
1918 }
1919 m_sigma11 = tofCaliSvc->BSigma1( m_zrhit1, m_tofId1 );
1920 m_ph11 = m_adc1;
1921 }
1922
1923 if( innerWest ) {
1924 for( unsigned int i=0; i<5; i++ ) {
1925 m_tof12[i] = tofCaliSvc->BTime2( m_adc2, m_tdc2-m_estime, m_zr1[i], m_tofId1, m_estime );
1926 }
1927 m_sigma12 = tofCaliSvc->BSigma2( m_zrhit1, m_tofId1 );
1928 m_ph12 = m_adc2;
1929 }
1930
1931 if( innerLayer ) {
1932 for( unsigned int i=0; i<5; i++ ) {
1933 m_tof1[i] = tofCaliSvc->BTimeCounter( m_tof11[i], m_tof12[i], m_zr1[i], m_tofId1 );
1934 }
1935 m_sigma1 = tofCaliSvc->BSigmaCounter( m_zrhit1, m_tofId1 );
1936 m_ph1 = tofCaliSvc->BPulseHeight( m_adc1, m_adc2, m_zrhit1, m_theta1, m_tofId1 );
1937 }
1938
1939 if( outerEast ) {
1940 for( unsigned int i=0; i<5; i++ ) {
1941 m_tof21[i] = tofCaliSvc->BTime1( m_adc3, m_tdc3-m_estime, m_zr2[i], m_tofId2, m_estime );
1942 }
1943 m_sigma21 = tofCaliSvc->BSigma1( m_zrhit2, m_tofId2 );
1944 m_ph21 = m_adc3;
1945 }
1946
1947 if( outerWest ) {
1948 for( unsigned int i=0; i<5; i++ ) {
1949 m_tof22[i] = tofCaliSvc->BTime2( m_adc4, m_tdc4-m_estime, m_zr2[i], m_tofId2, m_estime );
1950 }
1951 m_sigma22 = tofCaliSvc->BSigma2( m_zrhit2, m_tofId2 );
1952 m_ph22 = m_adc4;
1953 }
1954
1955 if( outerLayer ) {
1956 for( unsigned int i=0; i<5; i++ ) {
1957 m_tof2[i] = tofCaliSvc->BTimeCounter( m_tof21[i], m_tof22[i], m_zr2[i], m_tofId2 );
1958 }
1959 m_sigma2 = tofCaliSvc->BSigmaCounter( m_zrhit2, m_tofId2 );
1960 m_ph2 = tofCaliSvc->BPulseHeight( m_adc3, m_adc4, m_zrhit2, m_theta2, m_tofId2 );
1961 }
1962
1963 if( innerLayer && outerLayer ) {
1964 for( unsigned int i=0; i<5; i++ ) {
1965 m_tof[i] = tofCaliSvc->BTimeCluster( m_tof1[i], m_tof2[i], m_zr1[i], m_zr2[i], m_tofId1, m_tofId2 );
1966 }
1967 m_sigma = tofCaliSvc->BSigmaCluster( m_zrhit1, m_zrhit2, m_tofId1, m_tofId2 );
1968 m_ph = tofCaliSvc->BTimeCluster( m_ph1, m_ph2, m_zrhit1, m_zrhit2, m_tofId1, m_tofId2 );
1969 }
1970 }
1971
1972 if( endcap ) {
1973 if( endcapData ) {
1974 for( unsigned int i=0; i<5; i++ ) {
1975 m_tof11[i] = tofCaliSvc->ETime( m_adc1, m_tdc1-m_estime, m_zr1[i], m_tofId1 );
1976 }
1977 m_sigma11 = tofCaliSvc->ESigma( m_zrhit1, m_tofId1 );
1978 m_ph11 = tofCaliSvc->EPulseHeight( m_adc1, m_zrhit1, m_theta1, m_tofId1 );
1979 m_quality = 1;
1980 if( (m_quality1&0xa000)!=0 ) { m_quality = 4; }
1981 }
1982 }
1983
1984 if( endcapMRPC ) {
1985 if( innerEast ) {
1986 if( m_tofId1>-1 ) {
1987 for( unsigned int i=0; i<5; i++ ) {
1988 if( m_run > 0 ) {
1989 m_tof11[i] = tofCaliSvc->EtfTime1( m_adc1, m_tdc1-m_estime, m_zr1[i], m_tofId1, m_strip1, m_estime );
1990 }
1991 else {
1992 m_tof11[i] = tofCaliSvc->EtfTimeMC1( m_adc1, m_tdc1-m_estime, m_zr1[i], m_tofId1, m_strip1, m_estime );
1993 }
1994 }
1995 m_ph11 = m_adc1;
1996 }
1997 }
1998 if( innerWest ) {
1999 if( m_tofId1>-1 ) {
2000 for( unsigned int i=0; i<5; i++ ) {
2001 if( m_run > 0 ) {
2002 m_tof12[i] = tofCaliSvc->EtfTime2( m_adc2, m_tdc2-m_estime, m_zr1[i], m_tofId1, m_strip1, m_estime );
2003 }
2004 else {
2005 m_tof12[i] = tofCaliSvc->EtfTimeMC2( m_adc2, m_tdc2-m_estime, m_zr1[i], m_tofId1, m_strip1, m_estime );
2006 }
2007 }
2008 m_ph12 = m_adc2;
2009 }
2010 }
2011 if( outerEast ) {
2012 if( m_tofId2>-1 ) {
2013 for( unsigned int i=0; i<5; i++ ) {
2014 if( m_run > 0 ) {
2015 m_tof21[i] = tofCaliSvc->EtfTime1( m_adc3, m_tdc3-m_estime, m_zr2[i], m_tofId2, m_strip2, m_estime );
2016 }
2017 else {
2018 m_tof21[i] = tofCaliSvc->EtfTimeMC1( m_adc3, m_tdc3-m_estime, m_zr2[i], m_tofId2, m_strip2, m_estime );
2019 }
2020 }
2021 m_ph21 = m_adc3;
2022 }
2023 }
2024 if( outerWest ) {
2025 if( m_tofId2>-1 ) {
2026 for( unsigned int i=0; i<5; i++ ) {
2027 if( m_run > 0 ) {
2028 m_tof22[i] = tofCaliSvc->EtfTime2( m_adc4, m_tdc4-m_estime, m_zr2[i], m_tofId2, m_strip2, m_estime );
2029 }
2030 else {
2031 m_tof22[i] = tofCaliSvc->EtfTimeMC2( m_adc4, m_tdc4-m_estime, m_zr2[i], m_tofId2, m_strip2, m_estime );
2032 }
2033 }
2034 m_ph22 = m_adc4;
2035 }
2036 }
2037 if( innerLayer ) {
2038 if( m_tofId1>-1 ) {
2039 m_tof1[0] = tofCaliSvc->EtfTime( m_tof11[0], m_tof12[0] );
2040 // if( m_run > 0 ) {
2041 // m_tof1[0] = tofCaliSvc->EtfTime( m_adc1, m_adc2, m_tdc1-m_estime, m_tdc2-m_estime, m_tofId1, m_strip1, m_estime );
2042 // }
2043 // else {
2044 // m_tof1[0] = tofCaliSvc->EtfTimeMC( m_adc1, m_adc2, m_tdc1-m_estime, m_tdc2-m_estime, m_tofId1, m_strip1, m_estime );
2045 // m_tof1[0] = tofCaliSvc->EtfTime( m_tof11[0], m_tof12[0] );
2046 // }
2047 for( unsigned int i=1; i<5; i++ ) {
2048 m_tof1[i] = m_tof1[0];
2049 }
2050 m_ph1 = ( m_adc1 + m_adc2 )/2.0;
2051 }
2052 }
2053 if( outerLayer ) {
2054 if( m_tofId2>-1 ) {
2055 m_tof2[0] = tofCaliSvc->EtfTime( m_tof21[0], m_tof22[0] );
2056 // if( m_run > 0 ) {
2057 // m_tof2[0] = tofCaliSvc->EtfTime( m_adc3, m_adc4, m_tdc3-m_estime, m_tdc4-m_estime, m_tofId2, m_strip2, m_estime );
2058 // }
2059 // else {
2060 // m_tof2[0] = tofCaliSvc->EtfTimeMC( m_adc3, m_adc4, m_tdc3-m_estime, m_tdc4-m_estime, m_tofId2, m_strip2, m_estime );
2061 // }
2062 for( unsigned int i=1; i<5; i++ ) {
2063 m_tof2[i] = m_tof2[0];
2064 }
2065 m_ph2 = ( m_adc3 + m_adc4 )/2.0;
2066 }
2067 }
2068 }
2069
2070 // set Quality of Barrel TOF
2071 if( barrel ) {
2072
2073 // double layer
2074 if( innerLayer && outerLayer ) {
2075 m_quality = 1;
2076 }
2077 else {
2078 // single layer
2079 if( innerLayer || outerLayer ) {
2080 m_quality = 2;
2081 }
2082 else {
2083 // single-end of one layer
2084 if( innerEast || innerWest || outerEast || outerWest ) {
2085 m_quality = 3;
2086 }
2087 }
2088 }
2089
2090 // multi-hit
2091 if( ( (m_quality1&0xa000)!=0 ) || ( (m_quality2&0xa000)!=0 ) ) {
2092 m_quality = m_quality + 3;
2093 }
2094
2095 // ztdc and extrapolated zhit is not matched
2096 if( ( (m_quality1&0x100)==0x100 ) || ( (m_quality2&0x100)==0x100 ) ) {
2097 if( ( m_quality == 1 ) || ( m_quality == 4 ) ) { m_quality = 7; }
2098 else if( ( m_quality == 2 ) || ( m_quality == 5 ) ) { m_quality = 8; }
2099 else if( ( m_quality == 3 ) || ( m_quality == 6 ) ) { m_quality = 9; }
2100 else {
2101 cout << "TofRec::TofTrack::setCalibration: Impossible!" << endl;
2102 }
2103 }
2104
2105 }
2106
2107 return;
2108}
2109
2110
2111//------- convert2RecTofTrackCol() -----------------------------------
2112// generate RecTofTrackCol
2113//
2115
2116 bool barrel = ( ( m_hitCase == InnerLayer ) || ( m_hitCase == OuterLayer ) || ( m_hitCase == DoubleLayer ) );
2117
2118 bool innerEast = ( ( m_quality1 & 0xc ) == 0xc );
2119 bool innerWest = ( ( m_quality1 & 0x3 ) == 0x3 );
2120 bool outerEast = ( ( m_quality2 & 0xc ) == 0xc );
2121 bool outerWest = ( ( m_quality2 & 0x3 ) == 0x3 );
2122
2123 if( barrel ) {
2124
2125 if( innerEast ) {
2126 RecTofTrack* atrack11 = new RecTofTrack;
2127 buildRecTofTrack( atrack11, 11 ); // innerlayer east readout
2128 TofHitStatus* hitStatus11 = new TofHitStatus;
2129 if( innerWest ) {
2130 hitStatus11->setBarrelReadout( 1, true ); // innerlayer east readout
2131 }
2132 else {
2133 if( m_hitCase == InnerLayer ) {
2134 hitStatus11->setBarrelCluster( 11 ); // innerlayer east cluster
2135 }
2136 else if( m_hitCase == DoubleLayer ) {
2137 if( outerEast && outerWest ) {
2138 hitStatus11->setBarrelCounter( 11 ); // innerlayer east counter
2139 }
2140 else {
2141 hitStatus11->setBarrelCluster( 11 ); // innerlayer east cluster
2142 }
2143 }
2144 else {
2145 cout << "TofRec::TofTrack:convert2RecTofTrackCol: 11- Impossible!" << endl;
2146 }
2147 }
2148 atrack11->setStatus( hitStatus11->value() );
2149 delete hitStatus11;
2150 recTofTrackCol->push_back( atrack11 );
2151 }
2152
2153 if( innerWest ) {
2154 RecTofTrack* atrack12 = new RecTofTrack;
2155 buildRecTofTrack( atrack12, 12 ); // innerlayer west readout
2156 TofHitStatus* hitStatus12 = new TofHitStatus;
2157 if( innerEast ) {
2158 hitStatus12->setBarrelReadout( 1, false ); // innerlayer west
2159 }
2160 else {
2161 if( m_hitCase == InnerLayer ) {
2162 hitStatus12->setBarrelCluster( 12 ); // innerlayer west cluster
2163 }
2164 else if( m_hitCase == DoubleLayer ) {
2165 if( outerEast && outerWest ) {
2166 hitStatus12->setBarrelCounter( 12 ); // innerlayer west counter
2167 }
2168 else {
2169 hitStatus12->setBarrelCluster( 12 ); // innerlayer west cluster
2170 }
2171 }
2172 else {
2173 cout << "TofRec::TofTrack:convert2RecTofTrackCol: 12- Impossible!" << endl;
2174 }
2175 }
2176 atrack12->setStatus( hitStatus12->value() );
2177 delete hitStatus12;
2178 recTofTrackCol->push_back( atrack12 );
2179 }
2180
2181 if( innerEast && innerWest ) {
2182 RecTofTrack* atrack1 = new RecTofTrack;
2183 buildRecTofTrack( atrack1, 1 ); // innerlayer counter
2184 TofHitStatus* hitStatus1 = new TofHitStatus;
2185 if( m_hitCase == InnerLayer ) {
2186 hitStatus1->setBarrelCluster( 1 ); // innerlayer cluster and counter
2187 }
2188 else if( m_hitCase == DoubleLayer ) {
2189 if( outerEast && outerWest ) {
2190 hitStatus1->setBarrelCounter( 1 ); // innerlayer counter
2191 }
2192 else {
2193 hitStatus1->setBarrelCluster( 1 ); // innerlayer cluster and counter
2194 }
2195 }
2196 else {
2197 cout << "TofRec::TofTrack:convert2RecTofTrackCol: 1- Impossible!" << endl;
2198 }
2199 atrack1->setStatus( hitStatus1->value() );
2200 delete hitStatus1;
2201 recTofTrackCol->push_back( atrack1 );
2202 }
2203
2204 if( outerEast ) {
2205 RecTofTrack* atrack21 = new RecTofTrack;
2206 buildRecTofTrack( atrack21, 21 ); // outerlayer east readout
2207 TofHitStatus* hitStatus21 = new TofHitStatus;
2208 if( outerWest ) {
2209 hitStatus21->setBarrelReadout( 2, true ); // outerlayer east readout
2210 }
2211 else {
2212 if( m_hitCase == OuterLayer ) {
2213 hitStatus21->setBarrelCluster( 21 ); // outerlayer east cluster
2214 }
2215 else if( m_hitCase == DoubleLayer ) {
2216 if( innerEast || innerWest ) {
2217 hitStatus21->setBarrelCounter( 21 ); // outerlayer east counter
2218 }
2219 // else {
2220 // hitStatus21->setBarrelCluster( 21 ); // outerlayer east cluster
2221 // }
2222 }
2223 else {
2224 cout << "TofRec::TofTrack:convert2RecTofTrackCol: 21- Impossible!" << endl;
2225 }
2226 }
2227 atrack21->setStatus( hitStatus21->value() );
2228 delete hitStatus21;
2229 recTofTrackCol->push_back( atrack21 );
2230 }
2231
2232 if( outerWest ) {
2233 RecTofTrack* atrack22 = new RecTofTrack;
2234 buildRecTofTrack( atrack22, 22 ); // outerlayer west readout
2235 TofHitStatus* hitStatus22 = new TofHitStatus;
2236 if( outerEast ) {
2237 hitStatus22->setBarrelReadout( 2, false ); // outerlayer west readout
2238 }
2239 else {
2240 if( m_hitCase == OuterLayer ) {
2241 hitStatus22->setBarrelCluster( 22 ); // outerlayer west cluster
2242 }
2243 else if( m_hitCase == DoubleLayer ) {
2244 if( innerEast || innerWest ) {
2245 hitStatus22->setBarrelCounter( 22 ); // outerlayer west counter
2246 }
2247 // else {
2248 // hitStatus22->setBarrelCluster( 22 ); // outerlayer west cluster
2249 // }
2250 }
2251 else {
2252 cout << "TofRec::TofTrack:convert2RecTofTrackCol: 22- Impossible!" << endl;
2253 }
2254 }
2255 atrack22->setStatus( hitStatus22->value() );
2256 delete hitStatus22;
2257 recTofTrackCol->push_back( atrack22 );
2258 }
2259
2260 if( outerEast && outerWest ) {
2261 RecTofTrack* atrack2 = new RecTofTrack;
2262 buildRecTofTrack( atrack2, 2 ); // outerlayer counter
2263 TofHitStatus* hitStatus2 = new TofHitStatus;
2264 if( m_hitCase == OuterLayer ) {
2265 hitStatus2->setBarrelCluster( 2 ); // outerlayer cluster and counter
2266 }
2267 else if( m_hitCase == DoubleLayer ) {
2268 if( innerEast && innerWest ) {
2269 hitStatus2->setBarrelCounter( 2 ); // outerlayer counter
2270 }
2271 else {
2272 hitStatus2->setBarrelCluster( 2 ); // outerlayer cluster and counter
2273 }
2274 }
2275 else {
2276 cout << "TofRec::TofTrack:convert2RecTofTrackCol: 2- Impossible!" << endl;
2277 }
2278 atrack2->setStatus( hitStatus2->value() );
2279 delete hitStatus2;
2280 recTofTrackCol->push_back( atrack2 );
2281 }
2282
2283 if( innerEast && innerWest && outerEast && outerWest ) {
2284 RecTofTrack* atrack = new RecTofTrack;
2285 buildRecTofTrack( atrack, 0 ); // doublelayer cluster
2286 TofHitStatus* hitStatus = new TofHitStatus;
2287 hitStatus->setBarrelCluster( 3 ); // doublelayer cluster
2288 atrack->setStatus( hitStatus->value() );
2289 delete hitStatus;
2290 recTofTrackCol->push_back( atrack );
2291 }
2292
2293 }
2294
2295 if( ( m_hitCase == EastEndcap ) || ( m_hitCase == WestEndcap ) ) {
2296 RecTofTrack* atrack = new RecTofTrack;
2297 buildRecTofTrack( atrack, 11 ); // eastendcap counter
2298 TofHitStatus* hitStatus = new TofHitStatus;
2299 if( m_hitCase == EastEndcap ) {
2300 hitStatus->setEndcapCluster( true ); // east endcap cluster counter readout
2301 }
2302 else if( m_hitCase == WestEndcap ) {
2303 hitStatus->setEndcapCluster( false ); // west endcap cluster counter readout
2304 }
2305 else {
2306 cout << "TofRec::TofTrack:convert2RecTofTrackCol: endcap- Impossible!" << endl;
2307 }
2308 atrack->setStatus( hitStatus->value() );
2309 delete hitStatus;
2310 recTofTrackCol->push_back( atrack );
2311 }
2312
2313 if( ( m_hitCase == EastEndcapMRPC ) || ( m_hitCase == WestEndcapMRPC ) ) {
2314
2315 if( innerEast || innerWest ) {
2316
2317 if( innerEast ) {
2318 RecTofTrack* atrack1 = new RecTofTrack;
2319 buildRecTofTrack( atrack1, 11 ); // mrpc east readout
2320 TofHitStatus* hitStatus1 = new TofHitStatus;
2321 if( innerWest ) {
2322 hitStatus1->setMRPCReadout( true ); // mrpc east readout
2323 }
2324 else {
2325 hitStatus1->setMRPCCluster( false, true ); // mrpc east cluster
2326 }
2327 atrack1->setStatus( hitStatus1->value() );
2328 delete hitStatus1;
2329 recTofTrackCol->push_back( atrack1 );
2330 }
2331
2332 if( innerWest ) {
2333 RecTofTrack* atrack2 = new RecTofTrack;
2334 buildRecTofTrack( atrack2, 12 ); // mrpc west readout
2335 TofHitStatus* hitStatus2 = new TofHitStatus;
2336 if( innerEast ) {
2337 hitStatus2->setMRPCReadout( false ); // mrpc west readout
2338 }
2339 else {
2340 hitStatus2->setMRPCCluster( false, false ); // mrpc east cluster
2341 }
2342 atrack2->setStatus( hitStatus2->value() );
2343 delete hitStatus2;
2344 recTofTrackCol->push_back( atrack2 );
2345 }
2346
2347 if( innerEast && innerWest ) {
2348 RecTofTrack* atrack = new RecTofTrack;
2349 buildRecTofTrack( atrack, 1 ); // mrpc east readout
2350 TofHitStatus* hitStatus = new TofHitStatus;
2351 if( m_hitCase == EastEndcapMRPC ) {
2352 hitStatus->setMRPCCluster( true, true ); // mrpc east cluster
2353 }
2354 else {
2355 hitStatus->setMRPCCluster( true, false );// mrpc west cluster
2356 }
2357 atrack->setStatus( hitStatus->value() );
2358 delete hitStatus;
2359 recTofTrackCol->push_back( atrack );
2360 }
2361
2362 }
2363 else {
2364
2365 if( outerEast ) {
2366 RecTofTrack* atrack1 = new RecTofTrack;
2367 buildRecTofTrack( atrack1, 21 ); // mrpc east readout
2368 TofHitStatus* hitStatus1 = new TofHitStatus;
2369 if( outerWest ) {
2370 hitStatus1->setMRPCReadout( true ); // mrpc east readout
2371 }
2372 else {
2373 hitStatus1->setMRPCCluster( false, true ); // mrpc east cluster
2374 }
2375 atrack1->setStatus( hitStatus1->value() );
2376 delete hitStatus1;
2377 recTofTrackCol->push_back( atrack1 );
2378 }
2379
2380 if( outerWest ) {
2381 RecTofTrack* atrack2 = new RecTofTrack;
2382 buildRecTofTrack( atrack2, 22 ); // mrpc west readout
2383 TofHitStatus* hitStatus2 = new TofHitStatus;
2384 if( outerEast ) {
2385 hitStatus2->setMRPCReadout( false ); // mrpc west readout
2386 }
2387 else {
2388 hitStatus2->setMRPCCluster( false, false ); // mrpc east cluster
2389 }
2390 atrack2->setStatus( hitStatus2->value() );
2391 delete hitStatus2;
2392 recTofTrackCol->push_back( atrack2 );
2393 }
2394
2395 if( outerEast && outerWest ) {
2396 RecTofTrack* atrack = new RecTofTrack;
2397 buildRecTofTrack( atrack, 2 ); // mrpc east readout
2398 TofHitStatus* hitStatus = new TofHitStatus;
2399 if( m_hitCase == EastEndcapMRPC ) {
2400 hitStatus->setMRPCCluster( true, true ); // mrpc east cluster
2401 }
2402 else {
2403 hitStatus->setMRPCCluster( true, false );// mrpc west cluster
2404 }
2405 atrack->setStatus( hitStatus->value() );
2406 delete hitStatus;
2407 recTofTrackCol->push_back( atrack );
2408 }
2409
2410 }
2411
2412 }
2413
2414 if( m_hitCase == NoHit ) {
2415 RecTofTrack* atrack = new RecTofTrack;
2416 buildRecTofTrack( atrack, 3 ); // no hit
2417 TofHitStatus* hitStatus = new TofHitStatus;
2418 hitStatus->setNoHit(); // no hit
2419 atrack->setStatus( hitStatus->value() );
2420 delete hitStatus;
2421 recTofTrackCol->push_back( atrack );
2422 }
2423
2424 return;
2425}
2426
2427
2428
2429void TofTrack::buildRecTofTrack( RecTofTrack* track, int layerorend ) {
2430
2431 track->setTofTrackID( m_tofTrackId );
2432 track->setTrackID( m_trackId );
2433
2434 track->setErrTof( 0.0 );
2435 track->setBeta( 0.0 );
2436
2437 double sigma[6];
2438 for( int i=0; i<6; i++ ) {
2439 sigma[i] = 0.0;
2440 }
2441 track->setSigma( sigma );
2442 track->setQuality( m_quality );
2443 track->setT0( m_estime );
2444 track->setErrT0( 0.0 );
2445 track->setPhi( 9999.0 );
2446 track->setErrPhi( 9999.0 );
2447 track->setEnergy( 9999.0 );
2448 track->setErrEnergy( 9999.0 );
2449
2450 if( ( layerorend == 11 ) || ( layerorend == 12 ) || ( layerorend == 1 ) ) {
2451 if( m_strip1<0 ) {
2452 track->setTofID( m_tofId1 ); // scintillator
2453 }
2454 else {
2455 track->setTofID( 12*m_tofId1+m_strip1 ); // MRPC
2456 }
2457 track->setPath( m_path1 );
2458 track->setZrHit( m_zrhit1 );
2459 track->setErrZ( m_errzr1 );
2460 track->setTexp( m_texpInner );
2461
2462 setRecTofTrack( track, layerorend );
2463 }
2464
2465 if( ( layerorend==21 ) || ( layerorend==22 ) || ( layerorend==2 ) ) {
2466 if( m_strip2<0 ) {
2467 track->setTofID( m_tofId2 ); // scintillator
2468 }
2469 else {
2470 track->setTofID( 12*m_tofId2+m_strip2 ); // MRPC
2471 }
2472 track->setPath( m_path2 );
2473 track->setZrHit( m_zrhit2 );
2474 track->setErrZ( m_errzr2 );
2475 track->setTexp( m_texpOuter );
2476
2477 setRecTofTrack( track, layerorend );
2478 }
2479
2480 if( layerorend==0 ) {
2481 track->setTofID( m_tofId1 );
2482 track->setPath( m_path2 );
2483 track->setZrHit( m_zrhit2 );
2484 track->setErrZ( m_errzr2 );
2485 track->setTexp( m_texp );
2486
2487 setRecTofTrack( track, layerorend );
2488 }
2489
2490 if( layerorend == 3 ) {
2491 if( m_strip1<0 ) {
2492 track->setTofID( m_id1 ); // scintillator
2493 }
2494 else {
2495 track->setTofID( 12*m_id1 + m_strip1 ); // mrpc
2496 }
2497 track->setPath( m_path1 );
2498 track->setZrHit( m_zrhit1 );
2499 track->setErrZ( m_errzr1 );
2500 track->setTexp( m_texpInner );
2501 }
2502
2503 return;
2504}
2505
2506
2507void TofTrack::setRecTofTrack( RecTofTrack* track, int layerorend ) {
2508
2509 double toffset[6];
2510 for( unsigned int i=0; i<6; i++ ) {
2511 toffset[i] = 0.0;
2512 }
2513
2514 if( layerorend == 0 ) { // cluster or double layer hit
2515 track->setPh( m_ph );
2516 track->setTof( m_tof[0] );
2517 track->setSigmaElectron( m_sigma );
2518 for( unsigned int i=0; i<5; i++ ) {
2519 toffset[i] = m_tof[0] - m_tof[i];
2520 }
2521 track->setToffset( toffset );
2522 track->setBeta( m_path/m_tof[0]/30.0 );
2523 }
2524 else if( layerorend == 1 ) { // inner layer
2525 track->setPh( m_ph1 );
2526 track->setTof( m_tof1[0] );
2527 track->setSigmaElectron( m_sigma1 );
2528 for( unsigned int i=0; i<5; i++ ) {
2529 toffset[i] = m_tof1[0] - m_tof1[i];
2530 }
2531 track->setToffset( toffset );
2532 track->setBeta( m_path1/m_tof1[0]/30.0 );
2533 }
2534 else if( layerorend == 2 ) { // outer layer
2535 track->setPh( m_ph2 );
2536 track->setTof( m_tof2[0] );
2537 track->setSigmaElectron( m_sigma2 );
2538 for( unsigned int i=0; i<5; i++ ) {
2539 toffset[i] = m_tof2[0] - m_tof2[i];
2540 }
2541 track->setToffset( toffset );
2542 track->setBeta( m_path2/m_tof2[0]/30.0 );
2543 }
2544 else if( layerorend == 11 ) { // inner layer east end readout
2545 track->setPh( m_ph11 );
2546 track->setTof( m_tof11[0] );
2547 track->setSigmaElectron( m_sigma11 );
2548 for( unsigned int i=0; i<5; i++ ) {
2549 toffset[i] = m_tof11[0] - m_tof11[i];
2550 }
2551 track->setToffset( toffset );
2552 track->setBeta( m_path1/m_tof11[0]/30.0 );
2553 }
2554 else if( layerorend == 12 ) { // inner layer west end readout
2555 track->setPh( m_ph12 );
2556 track->setTof( m_tof12[0] );
2557 track->setSigmaElectron( m_sigma12 );
2558 for( unsigned int i=0; i<5; i++ ) {
2559 toffset[i] = m_tof12[0] - m_tof12[i];
2560 }
2561 track->setToffset( toffset );
2562 track->setBeta( m_path1/m_tof12[0]/30.0 );
2563 }
2564 else if( layerorend == 21 ) { // outer layer east end readout
2565 track->setPh( m_ph21 );
2566 track->setTof( m_tof21[0] );
2567 track->setSigmaElectron( m_sigma21 );
2568 for( unsigned int i=0; i<5; i++ ) {
2569 toffset[i] = m_tof21[0] - m_tof21[i];
2570 }
2571 track->setToffset( toffset );
2572 track->setBeta( m_path2/m_tof21[0]/30.0 );
2573 }
2574 else if( layerorend == 22 ) { // outer layer west end readout
2575 track->setPh( m_ph22 );
2576 track->setTof( m_tof22[0] );
2577 track->setSigmaElectron( m_sigma22 );
2578 for( unsigned int i=0; i<5; i++ ) {
2579 toffset[i] = m_tof22[0] - m_tof22[i];
2580 }
2581 track->setToffset( toffset );
2582 track->setBeta( m_path2/m_tof22[0]/30.0 );
2583 }
2584 else{
2585 cout << "TofRec TofTrack::SetRecTofTrack layerorend = " << layerorend << endl;
2586 }
2587 return;
2588}
2589
2590
2591void TofTrack::convert2RecBTofCalHitColBarrel( int runNumber, int eventNumber, RecBTofCalHitCol* btofCalHitCol, std::string calibData ) {
2592
2593 if( ( m_quality1 & 0x800 ) == 0x800 ) {
2594
2595 RecBTofCalHit* ahit = new RecBTofCalHit;
2596 ahit->setRun( runNumber );
2597 ahit->setEvent( eventNumber );
2598 ahit->setMod( m_tofId1 );
2599 ahit->setQual( m_hitCase );
2600 ahit->setdZHit( 1 );
2601
2602 for( int i=0; i<5; i++ ) {
2603 ahit->setTpred( i, m_texpInner[i] );
2604 }
2605 if( calibData == "Dimu" ) {
2606 ahit->setTpred( m_texpInner[1] );
2607 ahit->setZHit( m_zr1[1] );
2608 // ahit->setdZHit( m_ezr1[1] );
2609 }
2610 else {
2611 ahit->setTpred( m_texpInner[0] );
2612 ahit->setZHit( m_zr1[0] );
2613 // ahit->setdZHit( m_ezr1[0] );
2614 }
2615
2616 ahit->setTdc1( m_tdc1-m_estime );
2617 ahit->setTdc2( m_tdc2-m_estime );
2618 ahit->setAdc1( m_adc1 );
2619 ahit->setAdc2( m_adc2 );
2620 // ahit->setZHit( m_zrhit1 );
2621 // ahit->setdZHit( m_errzr1 );
2622 ahit->setDeltaPhi( m_estime );
2623 ahit->setsinTheta( m_theta1 );
2624 ahit->setP( m_momentum );
2625 ahit->setQ( m_ph1 );
2626 ahit->setPath( m_path1 );
2627
2628 btofCalHitCol->push_back( ahit );
2629
2630 if( ( m_quality2 & 0x800 ) == 0x800 ) {
2631
2632 RecBTofCalHit* bhit = new RecBTofCalHit;
2633 bhit->setRun( runNumber );
2634 bhit->setEvent( eventNumber );
2635 bhit->setMod( m_tofId2 );
2636 bhit->setQual( m_hitCase );
2637 bhit->setdZHit( 1 );
2638
2639 for( int i=0; i<5; i++ ) {
2640 bhit->setTpred( i, m_texpOuter[i] );
2641 }
2642 if( calibData == "Dimu" ) {
2643 bhit->setTpred( m_texpOuter[1] );
2644 bhit->setZHit( m_zr2[1] );
2645 // bhit->setdZHit( m_ezr2[1] );
2646 }
2647 else {
2648 bhit->setTpred( m_texpOuter[0] );
2649 bhit->setZHit( m_zr2[0] );
2650 // bhit->setdZHit( m_ezr2[0] );
2651 }
2652
2653 bhit->setTdc1( m_tdc3-m_estime );
2654 bhit->setTdc2( m_tdc4-m_estime );
2655 bhit->setAdc1( m_adc3 );
2656 bhit->setAdc2( m_adc4 );
2657 // bhit->setZHit( m_zrhit2 );
2658 // bhit->setdZHit( m_errzr2 );
2659 bhit->setDeltaPhi( m_estime );
2660 bhit->setsinTheta( m_theta2 );
2661 bhit->setP( m_momentum );
2662 bhit->setQ( m_ph2 );
2663 bhit->setPath( m_path2 );
2664
2665 ahit->setnext(bhit);
2666
2667 btofCalHitCol->push_back( bhit );
2668
2669 }
2670 }
2671
2672 return;
2673}
2674
2675
2676void TofTrack::convert2RecETofCalHitCol( int runNumber, int eventNumber, RecETofCalHitCol* etofCalHitCol, std::string calibData ) {
2677
2678 if( ( m_quality1 & 0x800 ) != 0x800 ) return;
2679
2680 RecETofCalHit* chit = new RecETofCalHit;
2681 chit->setRun( runNumber );
2682 chit->setEvent( eventNumber );
2683 chit->setMod( m_tofId1 );
2684 chit->setQual( m_hitCase );
2685
2686 for( int i=0; i<5; i++ ) {
2687 chit->setTpred( i, m_texpInner[i] );
2688 }
2689 if( calibData == "Dimu" ) {
2690 chit->setTpred( m_texpInner[1] );
2691 chit->setRHit( m_zr1[1] );
2692 chit->setdRHit( m_ezr1[1] );
2693 }
2694 else {
2695 chit->setTpred( m_texpInner[0] );
2696 chit->setRHit( m_zr1[0] );
2697 chit->setdRHit( m_ezr1[0] );
2698 }
2699
2700 chit->setTdc( m_tdc1-m_estime );
2701 chit->setAdc( m_adc1 );
2702 // chit->setRHit( m_zrhit1 );
2703 // chit->setdRHit( m_errzr1 );
2704 chit->setDeltaPhi( m_estime );
2705 chit->setcosTheta( m_theta1 );
2706 chit->setQ( m_ph1 );
2707 chit->setP( m_momentum );
2708 chit->setPath( m_path1 );
2709
2710 etofCalHitCol->push_back( chit );
2711
2712 return;
2713}
2714
2715
2716void TofTrack::convert2RecBTofCalHitColETF( int runNumber, int eventNumber, RecBTofCalHitCol* btofCalHitCol, std::string calibData ) {
2717
2718 if( ( m_quality1 & 0x800 ) == 0x800 ) {
2719
2720 RecBTofCalHit* ahit = new RecBTofCalHit;
2721 ahit->setRun( runNumber );
2722 ahit->setEvent( eventNumber );
2723 ahit->setMod( m_tofId1 );
2724 ahit->setQual( m_hitCase );
2725 ahit->setdZHit( 0 );
2726
2727 for( int i=0; i<5; i++ ) {
2728 ahit->setTpred( i, m_texpInner[i] );
2729 }
2730 if( calibData == "Dimu" ) {
2731 ahit->setTpred( m_texpInner[1] );
2732 ahit->setZHit( m_zr1[1] );
2733 }
2734 else {
2735 ahit->setTpred( m_texpInner[0] );
2736 ahit->setZHit( m_zr1[0] );
2737 }
2738
2739 ahit->setTdc1( m_tdc1-m_estime );
2740 ahit->setTdc2( m_tdc2-m_estime );
2741 ahit->setAdc1( m_adc1 );
2742 ahit->setAdc2( m_adc2 );
2743 ahit->setDeltaPhi( m_estime );
2744 ahit->setsinTheta( m_strip1 );
2745 ahit->setP( m_momentum );
2746 ahit->setQ( m_ph1 );
2747 ahit->setPath( m_path1 );
2748
2749 btofCalHitCol->push_back( ahit );
2750 }
2751
2752 if( ( m_quality2 & 0x800 ) == 0x800 ) {
2753
2754 RecBTofCalHit* bhit = new RecBTofCalHit;
2755 bhit->setRun( runNumber );
2756 bhit->setEvent( eventNumber );
2757 bhit->setMod( m_tofId2 );
2758 bhit->setQual( m_hitCase );
2759 bhit->setdZHit( 0 );
2760
2761 for( int i=0; i<5; i++ ) {
2762 bhit->setTpred( i, m_texpOuter[i] );
2763 }
2764 if( calibData == "Dimu" ) {
2765 bhit->setTpred( m_texpOuter[1] );
2766 bhit->setZHit( m_zr2[1] );
2767 }
2768 else {
2769 bhit->setTpred( m_texpOuter[0] );
2770 bhit->setZHit( m_zr2[0] );
2771 }
2772
2773 bhit->setTdc1( m_tdc3-m_estime );
2774 bhit->setTdc2( m_tdc4-m_estime );
2775 bhit->setAdc1( m_adc3 );
2776 bhit->setAdc2( m_adc4 );
2777 bhit->setDeltaPhi( m_estime );
2778 bhit->setsinTheta( m_strip2 );
2779 bhit->setP( m_momentum );
2780 bhit->setQ( m_ph2 );
2781 bhit->setPath( m_path2 );
2782
2783 btofCalHitCol->push_back( bhit );
2784 }
2785
2786 return;
2787}
2788
2789
2790// set Quality using quality1 and quality2
2792
2793 return;
2794}
TTree * sigma
DOUBLE_PRECISION count[3]
EvtStreamInputIterator< typename Generator::result_type > iter(Generator gen, int N=0)
ObjectVector< RecBTofCalHit > RecBTofCalHitCol
Definition: RecBTofCalHit.h:94
ObjectVector< RecETofCalHit > RecETofCalHitCol
Definition: RecETofCalHit.h:82
ObjectVector< RecTofTrack > RecTofTrackCol
Definition: RecTofTrack.h:33
std::multimap< unsigned int, TofData * > TofDataMap
Definition: TofData.h:244
std::multimap< unsignedint, TofData * >::iterator IterTofDataMap
Definition: TofData.h:245
ITofCaliSvc * tofCaliSvc
ITofCaliSvc * tofCaliSvc
void qualityAnalysis()
Definition: TofTrack.cxx:2791
const double zadc_Cut
Definition: TofTrack.h:15
const double mass[5]
Definition: TofTrack.h:17
@ WestEndcap
Definition: TofTrack.h:20
@ OuterLayer
Definition: TofTrack.h:20
@ EastEndcapMRPC
Definition: TofTrack.h:20
@ InnerLayer
Definition: TofTrack.h:20
@ EastEndcap
Definition: TofTrack.h:20
@ DoubleLayer
Definition: TofTrack.h:20
@ WestEndcapMRPC
Definition: TofTrack.h:20
@ NoHit
Definition: TofTrack.h:20
const double ztdc_Cut
Definition: TofTrack.h:12
const double tof1Path() const
Definition: DstExtTrack.h:68
const Hep3Vector tof1Position() const
Definition: DstExtTrack.h:58
const int tof1VolumeNumber() const
Definition: DstExtTrack.h:64
const double tof1() const
Definition: DstExtTrack.h:66
const Hep3Vector tof2Momentum() const
Definition: DstExtTrack.h:96
const Hep3Vector tof1Momentum() const
Definition: DstExtTrack.h:60
const double tof2() const
Definition: DstExtTrack.h:102
const double tof2PosSigmaAlongZ() const
Definition: DstExtTrack.h:106
const double tof1PosSigmaAlongX() const
Definition: DstExtTrack.h:74
const double tof2Path() const
Definition: DstExtTrack.h:104
const int trackId() const
Definition: DstExtTrack.h:43
const double tof1PosSigmaAlongY() const
Definition: DstExtTrack.h:76
const double tof2PosSigmaAlongX() const
Definition: DstExtTrack.h:110
const double tof1PosSigmaAlongZ() const
Definition: DstExtTrack.h:70
const int tof2VolumeNumber() const
Definition: DstExtTrack.h:100
const Hep3Vector tof2Position() const
Definition: DstExtTrack.h:94
void setStatus(unsigned int status)
Definition: DstTofTrack.h:93
void setSigma(double sigma[6])
Definition: DstTofTrack.h:117
void setToffset(double toffset[6])
Definition: DstTofTrack.h:109
void setEnergy(double energy)
Definition: DstTofTrack.h:133
void setPath(double path)
Definition: DstTofTrack.h:95
void setTofTrackID(int tofTrackID)
Definition: DstTofTrack.h:90
void setPh(double ph)
Definition: DstTofTrack.h:97
void setQuality(int quality)
Definition: DstTofTrack.h:125
void setZrHit(double zrhit)
Definition: DstTofTrack.h:96
void setTof(double tof)
Definition: DstTofTrack.h:98
void setPhi(double phi)
Definition: DstTofTrack.h:131
void setErrTof(double etof)
Definition: DstTofTrack.h:99
void setErrT0(double errt0)
Definition: DstTofTrack.h:128
void setTexp(double texp[5])
Definition: DstTofTrack.h:102
void setBeta(double beta)
Definition: DstTofTrack.h:100
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 setErrPhi(double errphi)
Definition: DstTofTrack.h:132
void setTofID(int tofID)
Definition: DstTofTrack.h:92
void setSigmaElectron(double se)
Definition: DstTofTrack.h:118
virtual const double BSigmaCounter(double zHit, unsigned id)=0
virtual const double BSigma2(double zHit, unsigned id)=0
virtual const double BTimeCluster(double tlayer1, double tlayer2, double z1, double z2, unsigned id1, unsigned int id2)=0
virtual const double EPulseHeight(double ADC, double rHit, double cost, unsigned int id)=0
virtual const double BTime2(double ADC, double TDC, double zHit, unsigned id, double t0)=0
virtual const double BTime1(double ADC, double TDC, double zHit, unsigned id, double t0)=0
virtual const int QElec()=0
virtual const double EtfTime1(double ADC, double TDC, double zHit, unsigned id, unsigned strip, double t0)=0
virtual const double EtfTime2(double ADC, double TDC, double zHit, unsigned id, unsigned strip, double t0)=0
virtual const double BTimeCounter(double tleft, double tright, double z, unsigned id)=0
virtual const double ZTDC(double tleft, double tright, unsigned id)=0
virtual const double EtfTimeMC2(double ADC, double TDC, double zHit, unsigned id, unsigned strip, double t0)=0
virtual const double BSigmaCluster(double zHit1, double zHit2, unsigned id1, unsigned id2)=0
virtual const double EtfTime(double ADC1, double ADC2, double TDC1, double TDC2, unsigned int id, unsigned int strip, double t0)=0
virtual const double BPulseHeight(double ADC1, double ADC2, double zHit, double sint, unsigned int id)=0
virtual const double BSigma1(double zHit, unsigned id)=0
virtual const double ESigma(double rHit, unsigned id)=0
virtual const double ZADC(double qleft, double qright, unsigned id)=0
virtual const double EtfZTDC(double tleft, double tright, unsigned int id, unsigned int strip)=0
virtual const double EtfTimeMC1(double ADC, double TDC, double zHit, unsigned id, unsigned strip, double t0)=0
virtual const double ETime(double ADC, double TDC, double rHit, unsigned id)=0
void setsinTheta(double sint)
Definition: RecBTofCalHit.h:66
void setnext(RecBTofCalHit *n)
Definition: RecBTofCalHit.h:89
void setTdc2(double tdc2)
Definition: RecBTofCalHit.h:60
void setRun(int run)
Definition: RecBTofCalHit.h:54
void setP(double p)
Definition: RecBTofCalHit.h:67
void setQ(double q)
Definition: RecBTofCalHit.h:68
void setdZHit(double dzHit)
Definition: RecBTofCalHit.h:64
void setPath(double l)
Definition: RecBTofCalHit.h:69
void setAdc2(double adc2)
Definition: RecBTofCalHit.h:62
void setTdc1(double tdc1)
Definition: RecBTofCalHit.h:59
void setMod(int imod)
Definition: RecBTofCalHit.h:56
void setZHit(double zHit)
Definition: RecBTofCalHit.h:63
void setQual(int qual)
Definition: RecBTofCalHit.h:57
void setDeltaPhi(double deltaPhi)
Definition: RecBTofCalHit.h:65
void setEvent(int event)
Definition: RecBTofCalHit.h:55
void setTpred(int idx, double t)
Definition: RecBTofCalHit.h:49
void setAdc1(double adc1)
Definition: RecBTofCalHit.h:61
void setEvent(int event)
Definition: RecETofCalHit.h:52
void setdRHit(double drHit)
Definition: RecETofCalHit.h:59
void setDeltaPhi(double deltaPhi)
Definition: RecETofCalHit.h:60
void setTdc(double tdc)
Definition: RecETofCalHit.h:56
void setRHit(double rHit)
Definition: RecETofCalHit.h:58
void setRun(int run)
Definition: RecETofCalHit.h:51
void setPath(double l)
Definition: RecETofCalHit.h:64
void setMod(int imod)
Definition: RecETofCalHit.h:53
void setP(double p)
Definition: RecETofCalHit.h:62
void setAdc(double adc)
Definition: RecETofCalHit.h:57
void setcosTheta(double cost)
Definition: RecETofCalHit.h:61
void setQ(double q)
Definition: RecETofCalHit.h:63
void setQual(int qual)
Definition: RecETofCalHit.h:54
void setTpred(int idx, double t)
Definition: RecETofCalHit.h:46
unsigned int quality() const
Definition: TofData.h:168
void setMRPCReadout(bool east)
unsigned int value() const
Definition: TofHitStatus.h:20
void setMRPCCluster(bool cluster, bool east)
void setBarrelReadout(unsigned int layer, bool east)
void setEndcapCluster(bool east)
void setBarrelCounter(unsigned int layer)
void setBarrelCluster(unsigned int layer)
static int endcap(const Identifier &id)
Definition: TofID.cxx:124
static int strip(const Identifier &id)
Definition: TofID.cxx:136
static Identifier cell_id(int barrel_ec, int layer, int phi_module, int end)
For a single crystal.
Definition: TofID.cxx:143
static int end(const Identifier &id)
Definition: TofID.cxx:79
static bool is_mrpc(const Identifier &id)
Definition: TofID.cxx:113
static int phi_module(const Identifier &id)
Definition: TofID.cxx:73
static int barrel_ec(const Identifier &id)
Values of different levels (failure returns 0)
Definition: TofID.cxx:61
static value_type getIntID(int barrel_ec, int layer, int phi_module, int end)
Definition: TofID.cxx:178
static int layer(const Identifier &id)
Definition: TofID.cxx:66
static int module(const Identifier &id)
Definition: TofID.cxx:130
void setTofData(TofDataMap tofDataMap)
Definition: TofTrack.cxx:486
double tof2(unsigned int i) const
Definition: TofTrack.h:86
std::vector< TofData * > tofData1() const
Definition: TofTrack.h:54
TofData * chooseTofDataEndcap(std::vector< TofData * > tofDataVec, double zr1[5])
Definition: TofTrack.cxx:1375
ExtTrackCase hitCase() const
Definition: TofTrack.h:36
int strip1() const
Definition: TofTrack.h:70
double zr1(unsigned int i) const
Definition: TofTrack.h:50
int t0Stat() const
Definition: TofTrack.h:115
int kal(unsigned int i) const
Definition: TofTrack.h:49
void getEtfData(TofData *tof, unsigned int iflag, unsigned int qual)
Definition: TofTrack.cxx:1828
unsigned int quality1() const
Definition: TofTrack.h:64
double tof(unsigned int i) const
Definition: TofTrack.h:87
void convert2RecTofTrackCol(RecTofTrackCol *recTofTrackCol)
Definition: TofTrack.cxx:2114
int id2() const
Definition: TofTrack.h:30
void tofDataAnalysis(TofData *tof, unsigned int iflag)
Definition: TofTrack.cxx:793
void findEtfData(std::vector< TofData * > tofDataVec1, std::vector< TofData * > tofDataVec2, std::vector< TofData * > tofDataVec3, double zrhit, unsigned int iflag)
Definition: TofTrack.cxx:1431
void buildRecTofTrack(RecTofTrack *track, int layerorend)
Definition: TofTrack.cxx:2429
void getTofData(TofData *tof, unsigned int iflag)
Definition: TofTrack.cxx:1582
void match(bool forCalibration, std::vector< int > deadId, std::vector< TofTrack * > *&tofTrackVec)
Definition: TofTrack.cxx:849
void findTofDataEndcap(std::vector< TofData * > tofDataVec1, std::vector< TofData * > tofDataVec2, double zr1[5])
Definition: TofTrack.cxx:1294
int strip2() const
Definition: TofTrack.h:71
TofData * chooseEtfData2(std::vector< TofData * > tofDataVec, double zrhit)
Definition: TofTrack.cxx:1549
int tofId1() const
Definition: TofTrack.h:68
double tof1(unsigned int i) const
Definition: TofTrack.h:85
void setQuality1(int qual1)
Definition: TofTrack.h:122
double p() const
Definition: TofTrack.h:37
void setCalibration()
Definition: TofTrack.cxx:1892
TofTrack(int run, int event)
Definition: TofTrack.cxx:10
void setRecTofTrack(RecTofTrack *track, int layerorend)
Definition: TofTrack.cxx:2507
void convert2RecBTofCalHitColBarrel(int runNumber, int eventNumber, RecBTofCalHitCol *btofCalHitCol, std::string calibData)
Definition: TofTrack.cxx:2591
void convert2RecETofCalHitCol(int runNumber, int eventNumber, RecETofCalHitCol *etofCalHitCol, std::string calibData)
Definition: TofTrack.cxx:2676
void convert2RecBTofCalHitColETF(int runNumber, int eventNumber, RecBTofCalHitCol *btofCalHitCol, std::string calibData)
Definition: TofTrack.cxx:2716
TofData * compareTofData(TofData *tofData1, TofData *tofData2, double zrhit)
Definition: TofTrack.cxx:1272
void getTofDataNohit(unsigned int iflag)
Definition: TofTrack.cxx:1786
TofData * chooseTofData(std::vector< TofData * > tofDataVec, double zrhit)
Definition: TofTrack.cxx:1215
void getTofDataWest(TofData *tof, unsigned int iflag)
Definition: TofTrack.cxx:1726
TofData * chooseEtfData1(std::vector< TofData * > tofDataVec, double zrhit)
Definition: TofTrack.cxx:1503
void getMultiHit(TofTrack *&)
Definition: TofTrack.cxx:426
int tofId2() const
Definition: TofTrack.h:69
void setQuality2(int qual2)
Definition: TofTrack.h:123
TofData * compareTofDataEndcap(TofData *tofData1, TofData *tofData2)
Definition: TofTrack.cxx:1418
std::vector< TofData * > tofData2() const
Definition: TofTrack.h:55
unsigned int barrel() const
Definition: TofTrack.h:35
void setExtTrack(RecExtTrack *extTrack, double costheta, double p[5], int kal[5], double t0, int t0Stat)
Definition: TofTrack.cxx:157
void getTofDataEast(TofData *tof, unsigned int iflag)
Definition: TofTrack.cxx:1666
void findTofDataBarrel(std::vector< TofData * > tofDataVec1, std::vector< TofData * > tofDataVec2, double zrhit, unsigned int iflag, std::vector< TofTrack * > *&tofTrackVec)
Definition: TofTrack.cxx:1043
unsigned int quality2() const
Definition: TofTrack.h:65
int id1() const
Definition: TofTrack.h:29
float costheta