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