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