199 {
200
201 MsgStream log(
msgSvc(), name() );
202 log << MSG::INFO << "TofRec in execute()!" << endmsg;
203
204 SmartDataPtr<Event::EventHeader> eventHeader( eventSvc(), "/Event/EventHeader" );
205 if ( !eventHeader )
206 {
207 log << MSG::FATAL << "TofRec could not find Event Header!" << endmsg;
208 return StatusCode::FAILURE;
209 }
210 int run = eventHeader->runNumber();
211 int event = eventHeader->eventNumber();
212 if ( ( event % 1000 == 0 ) && m_printOutInfo )
213 { std::cout << "run:" << run << " event: " << event << std::endl; }
214 log << MSG::INFO << "run= " << run << " event= " << event << endmsg;
216 { return StatusCode::FAILURE; }
217
218 TofRecTDS tds;
220
221
222 if ( m_acceleratorStatus == "Colliding" )
223 {
224
225 SmartDataPtr<RecEsTimeCol> estimeCol( eventSvc(), "/Event/Recon/RecEsTimeCol" );
226 if ( !estimeCol || ( estimeCol->size() == 0 ) )
227 {
228 log << MSG::WARNING << "TofRec Could not find RecEsTimeCol! Run = " << run
229 << " Event = " << event << endmsg;
230 return StatusCode::SUCCESS;
231 }
232 RecEsTimeCol::iterator iter_ESTime = estimeCol->begin();
233 double t0 = ( *iter_ESTime )->getTest();
234 int t0Stat = ( *iter_ESTime )->getStat();
235 log << MSG::INFO << "t0= " << t0 << " t0Stat= " << t0Stat << endmsg;
236
237
238 IDataProviderSvc* m_pCalibDataSvc;
239 StatusCode sc = service( "CalibDataSvc", m_pCalibDataSvc, true );
240 std::string fullpath = "/Calib/EsTimeCal";
241 SmartDataPtr<CalibData::EsTimeCalibData> Est( m_pCalibDataSvc, fullpath );
242
243 if ( ( event % 1000 == 0 ) && m_printOutInfo )
244 {
245 if ( !Est )
246 { std::cout << " t0 = " << t0 << " t0stat = " << t0Stat << std::endl; }
247 else
248 {
249 std::cout << " t0 = " << t0 << " t0stat = " << t0Stat
250 << " bunch = " << Est->getBunchTime()
251 << " offset_b = " << Est->getToffsetb()
252 << " offset_e = " << Est->getToffsete() << std::endl;
253 }
254 }
255
256
257 SmartDataPtr<RecMdcKalTrackCol> mdcKalTrackCol( eventSvc(),
258 "/Event/Recon/RecMdcKalTrackCol" );
259 if ( !mdcKalTrackCol )
260 {
261 log << MSG::WARNING << "No MdcKalTrackCol in TDS! Run = " << run
262 << " Event = " << event << endmsg;
263 return StatusCode::SUCCESS;
264 }
265 SmartDataPtr<RecMdcTrackCol> mdcTrackCol( eventSvc(), "/Event/Recon/RecMdcTrackCol" );
266 if ( !mdcTrackCol )
267 {
268 log << MSG::FATAL << "Could NOT find RecMdcTrackCol in TDS! Run = " << run
269 << " Event = " << event << endmsg;
270 return StatusCode::SUCCESS;
271 }
272
273
274 SmartDataPtr<RecExtTrackCol> extTrackCol( eventSvc(), "/Event/Recon/RecExtTrackCol" );
275 if ( !extTrackCol )
276 {
277 log << MSG::WARNING << "No ExtTrackCol in TDS! Run = " << run << " Event = " << event
278 << endmsg;
279 return StatusCode::SUCCESS;
280 }
281 else
282 {
283 if ( m_printOutInfo ) { m_printOut->setExtTrackNum( extTrackCol->size() ); }
284 if ( m_checkDigi && m_checkDigiExt )
285 { m_checkdigi_tuple->FillCol( *eventHeader, mdcTrackCol, mdcKalTrackCol, extTrackCol ); }
286 }
287
288
289 if ( m_forCalibration )
290 {
291 if ( m_printOutInfo ) { m_printOut->addNumber( 0 ); }
292
293 if ( t0Stat % 10 != 1 ) return StatusCode::SUCCESS;
294 if ( m_printOutInfo ) { m_printOut->addNumber( 1 ); }
295
296 if ( extTrackCol->size() != 2 ) return StatusCode::SUCCESS;
297 if ( m_printOutInfo ) { m_printOut->addNumber( 2 ); }
298
299 if ( mdcTrackCol->size() != 2 ) return StatusCode::SUCCESS;
300 if ( m_printOutInfo ) { m_printOut->addNumber( 3 ); }
301
302 SmartDataPtr<RecEmcShowerCol> emcShowerCol( eventSvc(), "/Event/Recon/RecEmcShowerCol" );
303 if ( !emcShowerCol )
304 {
305 log << MSG::FATAL << "Could NOT find EmcRecShowerCol in TDS! Run = " << run
306 << " Event = " << event << endmsg;
307 return StatusCode::SUCCESS;
308 }
309
310 if ( m_printOutInfo ) { m_printOut->addNumber( 4 ); }
311
312 if ( emcShowerCol->size() < 2 ) return StatusCode::SUCCESS;
313 if ( m_printOutInfo ) { m_printOut->addNumber( 5 ); }
314
315 RecMdcTrackCol::iterator iter_mdc1 = mdcTrackCol->begin();
316 RecMdcTrackCol::iterator iter_mdc2 = mdcTrackCol->begin() + 1;
317
318 RecMdcKalTrackCol::iterator iter_kal1 = mdcKalTrackCol->begin();
319 RecMdcKalTrackCol::iterator iter_kal2 = mdcKalTrackCol->begin() + 1;
320
321 RecExtTrackCol::iterator iter_ext1 = extTrackCol->begin();
322 RecExtTrackCol::iterator iter_ext2 = extTrackCol->begin() + 1;
323 Hep3Vector extPos1 = ( *iter_ext1 )->emcPosition();
324 Hep3Vector extPos2 = ( *iter_ext2 )->emcPosition();
325
326 RecEmcShowerCol::iterator iter_emc1 = emcShowerCol->begin();
327 RecEmcShowerCol::iterator iter_emc2 = emcShowerCol->begin() + 1;
328 Hep3Vector emcPos1( ( *iter_emc1 )->x(), ( *iter_emc1 )->y(), ( *iter_emc1 )->z() );
329 Hep3Vector emcPos2( ( *iter_emc2 )->x(), ( *iter_emc2 )->y(), ( *iter_emc2 )->z() );
330
331 Hep3Vector pep = ( *iter_mdc1 )->p3();
332 Hep3Vector pem = ( *iter_mdc2 )->p3();
333 double delta_angle = 180.0 - pep.angle( pem.unit() ) * 180.0 /
pi;
334 double delta_phi =
abs( ( *iter_mdc1 )->phi() - ( *iter_mdc2 )->phi() ) * 180.0 /
pi;
335
336 Hep3Vector distant1 = extPos1 - emcPos1;
337 Hep3Vector distant2 = extPos2 - emcPos1;
338 if ( distant1.r() > distant2.r() )
339 {
340 RecEmcShowerCol::iterator iter_tmp = iter_emc1;
341 iter_emc1 = iter_emc2;
342 iter_emc2 = iter_tmp;
343 Hep3Vector emc_tmp = emcPos1;
344 emcPos1 = emcPos2;
345 emcPos2 = emc_tmp;
346 }
347 distant1 = extPos1 - emcPos1;
348 distant2 = extPos2 - emcPos2;
349
350 double p1 = ( *iter_mdc1 )->p();
351 double p2 = ( *iter_mdc2 )->p();
352 double e1 = ( *iter_emc1 )->energy();
353 double e2 = ( *iter_emc2 )->energy();
355 RecEmcShowerCol::iterator iter_emc = emcShowerCol->begin();
356 for ( ; iter_emc != emcShowerCol->end(); iter_emc++ )
357 {
etot += ( *iter_emc )->energy(); }
358
359 if ( m_checkDigi )
360 {
361 m_checkdigi_tuple->FillCol( *eventHeader, extTrackCol, mdcTrackCol, emcShowerCol,
362 mdcKalTrackCol );
363 }
364
365 if ( ( ( *iter_mdc1 )->charge() + ( *iter_mdc2 )->charge() ) != 0 )
366 return StatusCode::SUCCESS;
367 if ( m_printOutInfo ) { m_printOut->addNumber( 6 ); }
368
369 if ( delta_angle > 10.0 ) return StatusCode::SUCCESS;
370 if ( m_printOutInfo ) { m_printOut->addNumber( 7 ); }
371
372 if ( ( *iter_kal1 )->getStat( 1, 0 ) != 0 || ( *iter_kal2 )->getStat( 1, 0 ) != 0 )
373 return StatusCode::SUCCESS;
374 if ( m_printOutInfo ) { m_printOut->addNumber( 8 ); }
375
376 if ( distant1.r() > 6.0 || distant2.r() > 6.0 ) return StatusCode::SUCCESS;
377 if ( m_printOutInfo ) { m_printOut->addNumber( 9 ); }
378
379
380 if ( m_data == "jpsi09" )
381 {
382 if ( ( *iter_mdc1 )->x() < -0.2 || ( *iter_mdc1 )->x() > 0.4 ||
383 ( *iter_mdc1 )->y() < -0.5 || ( *iter_mdc1 )->y() > 0.1 ||
384 abs( ( *iter_mdc1 )->z() ) > 4.0 )
385 return StatusCode::SUCCESS;
386 if ( m_printOutInfo ) { m_printOut->addNumber( 10 ); }
387 if ( ( *iter_mdc2 )->x() < -0.2 || ( *iter_mdc2 )->x() > 0.4 ||
388 ( *iter_mdc2 )->y() < -0.5 || ( *iter_mdc2 )->y() > 0.1 ||
389 abs( ( *iter_mdc2 )->z() ) > 4.0 )
390 return StatusCode::SUCCESS;
391 if ( m_printOutInfo ) { m_printOut->addNumber( 11 ); }
392 if ( delta_phi < 174.0 || delta_phi > 186.0 ) return StatusCode::SUCCESS;
393 if ( m_printOutInfo ) { m_printOut->addNumber( 12 ); }
394 if ( m_calibData == "Bhabha" )
395 {
396 if (
e1 < 1.1 ||
e2 < 1.1 )
return StatusCode::SUCCESS;
397 if ( m_printOutInfo ) { m_printOut->addNumber( 13 ); }
398 }
399 }
400
401 else if ( m_data == "psip09" )
402 {
403 if ( ( *iter_mdc1 )->x() < -0.2 || ( *iter_mdc1 )->x() > 0.4 ||
404 ( *iter_mdc1 )->y() < -0.5 || ( *iter_mdc1 )->y() > 0.1 ||
405 abs( ( *iter_mdc1 )->z() ) > 4.0 )
406 return StatusCode::SUCCESS;
407 if ( m_printOutInfo ) { m_printOut->addNumber( 10 ); }
408 if ( ( *iter_mdc2 )->x() < -0.2 || ( *iter_mdc2 )->x() > 0.4 ||
409 ( *iter_mdc2 )->y() < -0.5 || ( *iter_mdc2 )->y() > 0.1 ||
410 abs( ( *iter_mdc2 )->z() ) > 4.0 )
411 return StatusCode::SUCCESS;
412 if ( m_printOutInfo ) { m_printOut->addNumber( 11 ); }
413 if ( delta_phi < 174.0 || delta_phi > 183.0 ) return StatusCode::SUCCESS;
414 if ( m_printOutInfo ) { m_printOut->addNumber( 12 ); }
415 if ( m_calibData == "Bhabha" )
416 {
417 if (
e1 < 1.4 ||
e2 < 1.4 )
return StatusCode::SUCCESS;
418 if ( m_printOutInfo ) { m_printOut->addNumber( 13 ); }
419 }
420 }
421
422 else if ( m_data == "psipp10" )
423 {
424 if ( ( *iter_mdc1 )->x() < -0.2 || ( *iter_mdc1 )->x() > 1.2 ||
425 ( *iter_mdc1 )->y() < -0.9 || ( *iter_mdc1 )->y() > 0.5 ||
426 abs( ( *iter_mdc1 )->z() ) > 6.0 )
427 return StatusCode::SUCCESS;
428 if ( m_printOutInfo ) { m_printOut->addNumber( 10 ); }
429 if ( ( *iter_mdc2 )->x() < -0.2 || ( *iter_mdc2 )->x() > 1.2 ||
430 ( *iter_mdc2 )->y() < -0.9 || ( *iter_mdc2 )->y() > 0.5 ||
431 abs( ( *iter_mdc2 )->z() ) > 6.0 )
432 return StatusCode::SUCCESS;
433 if ( m_printOutInfo ) { m_printOut->addNumber( 11 ); }
434 if ( delta_phi < 174.0 || delta_phi > 186.0 ) return StatusCode::SUCCESS;
435 if ( m_printOutInfo ) { m_printOut->addNumber( 12 ); }
436 if ( m_calibData == "Bhabha" )
437 {
438 if (
e1 < 1.4 ||
e2 < 1.4 )
return StatusCode::SUCCESS;
439 if ( m_printOutInfo ) { m_printOut->addNumber( 13 ); }
440 }
441 }
442
443 else if ( m_data == "psipp11" )
444 {
445 if ( ( *iter_mdc1 )->x() < -0.15 || ( *iter_mdc1 )->x() > 0.3 ||
446 ( *iter_mdc1 )->y() < -0.3 || ( *iter_mdc1 )->y() > 0.15 ||
447 abs( ( *iter_mdc1 )->z() ) > 6.0 )
448 return StatusCode::SUCCESS;
449 if ( m_printOutInfo ) { m_printOut->addNumber( 10 ); }
450 if ( ( *iter_mdc2 )->x() < -0.15 || ( *iter_mdc2 )->x() > 0.3 ||
451 ( *iter_mdc2 )->y() < -0.3 || ( *iter_mdc2 )->y() > 0.15 ||
452 abs( ( *iter_mdc2 )->z() ) > 6.0 )
453 return StatusCode::SUCCESS;
454 if ( m_printOutInfo ) { m_printOut->addNumber( 11 ); }
455 if ( delta_phi < 174.0 || delta_phi > 184.0 ) return StatusCode::SUCCESS;
456 if ( m_printOutInfo ) { m_printOut->addNumber( 12 ); }
457 if ( m_calibData == "Bhabha" )
458 {
459 if (
e1 < 1.4 ||
e2 < 1.4 )
return StatusCode::SUCCESS;
460 if ( m_printOutInfo ) { m_printOut->addNumber( 13 ); }
461 }
462 }
463
464 else if ( m_data == "psip12" )
465 {
466 if ( ( *iter_mdc1 )->x() < -0.25 || ( *iter_mdc1 )->x() > 0.3 ||
467 ( *iter_mdc1 )->y() < -0.3 || ( *iter_mdc1 )->y() > 0.15 ||
468 abs( ( *iter_mdc1 )->z() ) > 6.0 )
469 return StatusCode::SUCCESS;
470 if ( m_printOutInfo ) { m_printOut->addNumber( 10 ); }
471 if ( ( *iter_mdc2 )->x() < -0.25 || ( *iter_mdc2 )->x() > 0.3 ||
472 ( *iter_mdc2 )->y() < -0.3 || ( *iter_mdc2 )->y() > 0.15 ||
473 abs( ( *iter_mdc2 )->z() ) > 6.0 )
474 return StatusCode::SUCCESS;
475 if ( m_printOutInfo ) { m_printOut->addNumber( 11 ); }
476 if ( delta_phi < 172.0 || delta_phi > 188.0 ) return StatusCode::SUCCESS;
477 if ( m_printOutInfo ) { m_printOut->addNumber( 12 ); }
478 if ( m_calibData == "Bhabha" )
479 {
480 if (
e1 < 1.4 ||
e2 < 1.4 )
return StatusCode::SUCCESS;
481 if ( m_printOutInfo ) { m_printOut->addNumber( 13 ); }
482 }
483 }
484
485 else if ( m_data == "jpsi12" )
486 {
487 if ( ( *iter_mdc1 )->x() < -0.2 || ( *iter_mdc1 )->x() > 0.4 ||
488 ( *iter_mdc1 )->y() < -0.4 || ( *iter_mdc1 )->y() > 0.2 ||
489 abs( ( *iter_mdc1 )->z() ) > 4.0 )
490 return StatusCode::SUCCESS;
491 if ( m_printOutInfo ) { m_printOut->addNumber( 10 ); }
492 if ( ( *iter_mdc2 )->x() < -0.2 || ( *iter_mdc2 )->x() > 0.4 ||
493 ( *iter_mdc2 )->y() < -0.4 || ( *iter_mdc2 )->y() > 0.2 ||
494 abs( ( *iter_mdc2 )->z() ) > 4.0 )
495 return StatusCode::SUCCESS;
496 if ( m_printOutInfo ) { m_printOut->addNumber( 11 ); }
497 if ( delta_phi < 172.0 || delta_phi > 188.0 ) return StatusCode::SUCCESS;
498 if ( m_printOutInfo ) { m_printOut->addNumber( 12 ); }
499 if ( m_calibData == "Bhabha" )
500 {
501 if (
e1 < 1.1 ||
e2 < 1.1 )
return StatusCode::SUCCESS;
502 if ( m_printOutInfo ) { m_printOut->addNumber( 13 ); }
503 }
504 }
505
506 else if ( m_data == "psi13" )
507 {
508 if ( ( *iter_mdc1 )->x() < -0.15 || ( *iter_mdc1 )->x() > 0.35 ||
509 ( *iter_mdc1 )->y() < -0.35 || ( *iter_mdc1 )->y() > 0.15 ||
510 abs( ( *iter_mdc1 )->z() ) > 4.0 )
511 return StatusCode::SUCCESS;
512 if ( m_printOutInfo ) { m_printOut->addNumber( 10 ); }
513 if ( ( *iter_mdc2 )->x() < -0.15 || ( *iter_mdc2 )->x() > 0.35 ||
514 ( *iter_mdc2 )->y() < -0.35 || ( *iter_mdc2 )->y() > 0.15 ||
515 abs( ( *iter_mdc2 )->z() ) > 4.0 )
516 return StatusCode::SUCCESS;
517 if ( m_printOutInfo ) { m_printOut->addNumber( 11 ); }
518 if ( delta_phi < 172.0 || delta_phi > 188.0 ) return StatusCode::SUCCESS;
519 if ( m_printOutInfo ) { m_printOut->addNumber( 12 ); }
520 if ( m_calibData == "Bhabha" )
521 {
522 if (
e1 < 1.5 ||
e2 < 1.5 )
return StatusCode::SUCCESS;
523 if ( m_printOutInfo ) { m_printOut->addNumber( 13 ); }
524 }
525 }
526 else if ( m_data == "rxyz14" )
527 {
528 if ( ( *iter_mdc1 )->x() < -0.15 || ( *iter_mdc1 )->x() > 0.35 ||
529 ( *iter_mdc1 )->y() < -0.35 || ( *iter_mdc1 )->y() > 0.15 ||
530 abs( ( *iter_mdc1 )->z() ) > 4.0 )
531 return StatusCode::SUCCESS;
532 if ( m_printOutInfo ) { m_printOut->addNumber( 10 ); }
533 if ( ( *iter_mdc2 )->x() < -0.15 || ( *iter_mdc2 )->x() > 0.35 ||
534 ( *iter_mdc2 )->y() < -0.35 || ( *iter_mdc2 )->y() > 0.15 ||
535 abs( ( *iter_mdc2 )->z() ) > 4.0 )
536 return StatusCode::SUCCESS;
537 if ( m_printOutInfo ) { m_printOut->addNumber( 11 ); }
538 if ( delta_phi < 175.0 || delta_phi > 185.0 ) return StatusCode::SUCCESS;
539 if ( m_printOutInfo ) { m_printOut->addNumber( 12 ); }
540 if ( m_calibData == "Bhabha" )
541 {
542 if (
e1 /
p1 < 0.75 ||
e2 /
p2 < 0.75 )
return StatusCode::SUCCESS;
543 if ( m_printOutInfo ) { m_printOut->addNumber( 13 ); }
544 }
545 }
546 else if ( m_data == "r15" )
547 {
548 if ( ( *iter_mdc1 )->x() < -0.15 || ( *iter_mdc1 )->x() > 0.35 ||
549 ( *iter_mdc1 )->y() < -0.35 || ( *iter_mdc1 )->y() > 0.15 ||
550 abs( ( *iter_mdc1 )->z() ) > 4.0 )
551 return StatusCode::SUCCESS;
552 if ( m_printOutInfo ) { m_printOut->addNumber( 10 ); }
553 if ( ( *iter_mdc2 )->x() < -0.15 || ( *iter_mdc2 )->x() > 0.35 ||
554 ( *iter_mdc2 )->y() < -0.35 || ( *iter_mdc2 )->y() > 0.15 ||
555 abs( ( *iter_mdc2 )->z() ) > 4.0 )
556 return StatusCode::SUCCESS;
557 if ( m_printOutInfo ) { m_printOut->addNumber( 11 ); }
558 if ( delta_phi < 175.0 || delta_phi > 185.0 ) return StatusCode::SUCCESS;
559 if ( m_printOutInfo ) { m_printOut->addNumber( 12 ); }
560 if ( m_calibData == "Bhabha" )
561 {
562 if (
e1 /
p1 < 0.75 ||
e2 /
p2 < 0.75 )
return StatusCode::SUCCESS;
563 if ( m_printOutInfo ) { m_printOut->addNumber( 13 ); }
564 }
565 }
566 else if ( m_data == "data16" )
567 {
568 if ( ( *iter_mdc1 )->x() < -0.15 || ( *iter_mdc1 )->x() > 0.35 ||
569 ( *iter_mdc1 )->y() < -0.35 || ( *iter_mdc1 )->y() > 0.2 ||
570 abs( ( *iter_mdc1 )->z() ) > 4.0 )
571 return StatusCode::SUCCESS;
572 if ( m_printOutInfo ) { m_printOut->addNumber( 10 ); }
573 if ( ( *iter_mdc2 )->x() < -0.15 || ( *iter_mdc2 )->x() > 0.35 ||
574 ( *iter_mdc2 )->y() < -0.35 || ( *iter_mdc2 )->y() > 0.2 ||
575 abs( ( *iter_mdc2 )->z() ) > 4.0 )
576 return StatusCode::SUCCESS;
577 if ( m_printOutInfo ) { m_printOut->addNumber( 11 ); }
578 if ( delta_phi < 170.0 || delta_phi > 190.0 ) return StatusCode::SUCCESS;
579 if ( m_printOutInfo ) { m_printOut->addNumber( 12 ); }
580 if ( m_calibData == "Bhabha" )
581 {
582 if (
e1 /
p1 < 0.75 ||
e2 /
p2 < 0.75 )
return StatusCode::SUCCESS;
583 if ( m_printOutInfo ) { m_printOut->addNumber( 13 ); }
584 }
585 }
586 else if ( m_data == "data17" )
587 {
588 if ( ( *iter_mdc1 )->x() < -0.15 || ( *iter_mdc1 )->x() > 0.35 ||
589 ( *iter_mdc1 )->y() < -0.3 || ( *iter_mdc1 )->y() > 0.2 ||
590 ( *iter_mdc1 )->z() < -3.5 || ( *iter_mdc1 )->z() > 4.5 )
591 return StatusCode::SUCCESS;
592 if ( m_printOutInfo ) { m_printOut->addNumber( 10 ); }
593 if ( ( *iter_mdc2 )->x() < -0.15 || ( *iter_mdc2 )->x() > 0.35 ||
594 ( *iter_mdc2 )->y() < -0.3 || ( *iter_mdc2 )->y() > 0.2 ||
595 ( *iter_mdc2 )->z() < -3.5 || ( *iter_mdc2 )->z() > 4.5 )
596 return StatusCode::SUCCESS;
597 if ( m_printOutInfo ) { m_printOut->addNumber( 11 ); }
598 if ( delta_phi < 170.0 || delta_phi > 190.0 ) return StatusCode::SUCCESS;
599 if ( m_printOutInfo ) { m_printOut->addNumber( 12 ); }
600 if ( m_calibData == "Bhabha" )
601 {
602 if (
e1 /
p1 < 0.75 ||
e2 /
p2 < 0.75 )
return StatusCode::SUCCESS;
603 if ( m_printOutInfo ) { m_printOut->addNumber( 13 ); }
604 }
605 }
606 else if ( m_data == "jpsi18" )
607 {
608 if ( ( *iter_mdc1 )->x() < -0.1 || ( *iter_mdc1 )->x() > 0.4 ||
609 ( *iter_mdc1 )->y() < -0.3 || ( *iter_mdc1 )->y() > 0.2 ||
610 ( *iter_mdc1 )->z() < -3.5 || ( *iter_mdc1 )->z() > 4.0 )
611 return StatusCode::SUCCESS;
612 if ( m_printOutInfo ) { m_printOut->addNumber( 10 ); }
613 if ( ( *iter_mdc2 )->x() < -0.1 || ( *iter_mdc2 )->x() > 0.4 ||
614 ( *iter_mdc2 )->y() < -0.3 || ( *iter_mdc2 )->y() > 0.2 ||
615 ( *iter_mdc2 )->z() < -3.5 || ( *iter_mdc2 )->z() > 4.0 )
616 return StatusCode::SUCCESS;
617 if ( m_printOutInfo ) { m_printOut->addNumber( 11 ); }
618 if ( delta_phi < 170.0 || delta_phi > 190.0 ) return StatusCode::SUCCESS;
619 if ( m_printOutInfo ) { m_printOut->addNumber( 12 ); }
620 if ( m_calibData == "Bhabha" )
621 {
622 if (
e1 /
p1 < 0.75 ||
e2 /
p2 < 0.75 )
return StatusCode::SUCCESS;
623 if ( m_printOutInfo ) { m_printOut->addNumber( 13 ); }
624 }
625 }
626 else if ( m_data == "jpsi19" )
627 {
628 if ( ( *iter_mdc1 )->x() < -0.1 || ( *iter_mdc1 )->x() > 0.4 ||
629 ( *iter_mdc1 )->y() < -0.3 || ( *iter_mdc1 )->y() > 0.2 ||
630 ( *iter_mdc1 )->z() < -3.5 || ( *iter_mdc1 )->z() > 4.0 )
631 return StatusCode::SUCCESS;
632 if ( m_printOutInfo ) { m_printOut->addNumber( 10 ); }
633 if ( ( *iter_mdc2 )->x() < -0.1 || ( *iter_mdc2 )->x() > 0.4 ||
634 ( *iter_mdc2 )->y() < -0.3 || ( *iter_mdc2 )->y() > 0.2 ||
635 ( *iter_mdc2 )->z() < -3.5 || ( *iter_mdc2 )->z() > 4.0 )
636 return StatusCode::SUCCESS;
637 if ( m_printOutInfo ) { m_printOut->addNumber( 11 ); }
638 if ( delta_phi < 170.0 || delta_phi > 190.0 ) return StatusCode::SUCCESS;
639 if ( m_printOutInfo ) { m_printOut->addNumber( 12 ); }
640 if ( m_calibData == "Bhabha" )
641 {
642 if (
e1 /
p1 < 0.75 ||
e2 /
p2 < 0.75 )
return StatusCode::SUCCESS;
643 if ( m_printOutInfo ) { m_printOut->addNumber( 13 ); }
644 }
645 }
646 else if ( m_data == "data20" )
647 {
648 if ( ( *iter_mdc1 )->x() < -0.1 || ( *iter_mdc1 )->x() > 0.4 ||
649 ( *iter_mdc1 )->y() < -0.3 || ( *iter_mdc1 )->y() > 0.2 ||
650 ( *iter_mdc1 )->z() < -3.5 || ( *iter_mdc1 )->z() > 4.0 )
651 return StatusCode::SUCCESS;
652 if ( m_printOutInfo ) { m_printOut->addNumber( 10 ); }
653 if ( ( *iter_mdc2 )->x() < -0.1 || ( *iter_mdc2 )->x() > 0.4 ||
654 ( *iter_mdc2 )->y() < -0.3 || ( *iter_mdc2 )->y() > 0.2 ||
655 ( *iter_mdc2 )->z() < -3.5 || ( *iter_mdc2 )->z() > 4.0 )
656 return StatusCode::SUCCESS;
657 if ( m_printOutInfo ) { m_printOut->addNumber( 11 ); }
658 if ( delta_phi < 170.0 || delta_phi > 190.0 ) return StatusCode::SUCCESS;
659 if ( m_printOutInfo ) { m_printOut->addNumber( 12 ); }
660 if ( m_calibData == "Bhabha" )
661 {
662 if (
e1 /
p1 < 0.75 ||
e2 /
p2 < 0.75 )
return StatusCode::SUCCESS;
663 if ( m_printOutInfo ) { m_printOut->addNumber( 13 ); }
664 }
665 }
666 else if ( m_data == "data21" )
667 {
668 if ( ( *iter_mdc1 )->x() < -0.1 || ( *iter_mdc1 )->x() > 0.4 ||
669 ( *iter_mdc1 )->y() < -0.3 || ( *iter_mdc1 )->y() > 0.2 ||
670 ( *iter_mdc1 )->z() < -3.5 || ( *iter_mdc1 )->z() > 4.0 )
671 return StatusCode::SUCCESS;
672 if ( m_printOutInfo ) { m_printOut->addNumber( 10 ); }
673 if ( ( *iter_mdc2 )->x() < -0.1 || ( *iter_mdc2 )->x() > 0.4 ||
674 ( *iter_mdc2 )->y() < -0.3 || ( *iter_mdc2 )->y() > 0.2 ||
675 ( *iter_mdc2 )->z() < -3.5 || ( *iter_mdc2 )->z() > 4.0 )
676 return StatusCode::SUCCESS;
677 if ( m_printOutInfo ) { m_printOut->addNumber( 11 ); }
678 if ( delta_phi < 170.0 || delta_phi > 190.0 ) return StatusCode::SUCCESS;
679 if ( m_printOutInfo ) { m_printOut->addNumber( 12 ); }
680 if ( m_calibData == "Bhabha" )
681 {
682 if (
e1 /
p1 < 0.75 ||
e2 /
p2 < 0.75 )
return StatusCode::SUCCESS;
683 if ( m_printOutInfo ) { m_printOut->addNumber( 13 ); }
684 }
685 }
686 else if ( m_data == "data22" )
687 {
688 if ( ( *iter_mdc1 )->x() < -0.1 || ( *iter_mdc1 )->x() > 0.4 ||
689 ( *iter_mdc1 )->y() < -0.3 || ( *iter_mdc1 )->y() > 0.2 ||
690 ( *iter_mdc1 )->z() < -3.5 || ( *iter_mdc1 )->z() > 4.0 )
691 return StatusCode::SUCCESS;
692 if ( m_printOutInfo ) { m_printOut->addNumber( 10 ); }
693 if ( ( *iter_mdc2 )->x() < -0.1 || ( *iter_mdc2 )->x() > 0.4 ||
694 ( *iter_mdc2 )->y() < -0.3 || ( *iter_mdc2 )->y() > 0.2 ||
695 ( *iter_mdc2 )->z() < -3.5 || ( *iter_mdc2 )->z() > 4.0 )
696 return StatusCode::SUCCESS;
697 if ( m_printOutInfo ) { m_printOut->addNumber( 11 ); }
698 if ( delta_phi < 170.0 || delta_phi > 190.0 ) return StatusCode::SUCCESS;
699 if ( m_printOutInfo ) { m_printOut->addNumber( 12 ); }
700 if ( m_calibData == "Bhabha" )
701 {
702 if (
e1 /
p1 < 0.75 ||
e2 /
p2 < 0.75 )
return StatusCode::SUCCESS;
703 if ( m_printOutInfo ) { m_printOut->addNumber( 13 ); }
704 }
705 }
706
707 if ( m_calibData == "Bhabha" )
708 {
709 if ( (
etot -
e1 -
e2 ) > 0.3 )
return StatusCode::SUCCESS;
710 if ( m_printOutInfo ) { m_printOut->addNumber( 14 ); }
711 }
712 else if ( m_calibData == "Dimu" )
713 {
714 if (
e1 > 0.5 ||
e2 > 0.5 )
return StatusCode::SUCCESS;
715 if ( m_printOutInfo ) { m_printOut->addNumber( 13 ); }
716 }
717 }
718
719
721 RecExtTrackCol::iterator iter_track = extTrackCol->begin();
722 for ( ; iter_track < extTrackCol->end(); iter_track++ )
723 {
724 RecMdcTrackCol::iterator iter_mdc = mdcTrackCol->begin();
725 for ( ; iter_mdc != mdcTrackCol->end(); iter_mdc++ )
726 {
727 if ( ( *iter_mdc )->trackId() == ( *iter_track )->trackId() ) break;
728 }
729 double costheta =
cos( ( *iter_mdc )->theta() );
730 RecMdcKalTrackCol::iterator iter_kal = mdcKalTrackCol->begin();
731 for ( ; iter_kal != mdcKalTrackCol->end(); iter_kal++ )
732 {
733 if ( ( *iter_kal )->trackId() == ( *iter_track )->trackId() ) break;
734 }
735 double p[5] = { -1.0 };
736 int kal[5] = { -1 };
737 if ( iter_kal != mdcKalTrackCol->end() )
738 {
739 for ( unsigned int i = 0; i < 5; i++ )
740 {
746 p[i] = ( *iter_kal )->p3().mag();
747 kal[i] = ( *iter_kal )->getStat( 0, i );
748 }
749 }
750 TofTrack* tof = new TofTrack( run, event );
751 tof->
setExtTrack( ( *iter_track ), costheta, p, kal, t0, t0Stat );
752
753 if ( tofTrackVec->size() > 0 )
754 {
755 std::vector<TofTrack*>::iterator iterExt = tofTrackVec->begin();
756 for ( ; iterExt < tofTrackVec->end(); iterExt++ )
757 {
758 if ( ( *iterExt )->isNoHit() ) continue;
760 }
761 }
762
763 tofTrackVec->push_back( tof );
764 }
765
766 if ( m_printOutInfo ) { m_printOut->setTrack1Col( tofTrackVec ); }
767
768
770 if ( tofDataMap.empty() )
771 {
772 log << MSG::WARNING << "No Tof Data Map in RawDataProviderSvc! Run=" << run
773 << " Event=" << event << endmsg;
774 }
775
776 if ( m_checkDigi && m_checkDigiRaw )
777 {
778 SmartDataPtr<TofDigiCol> tofDigiCol( eventSvc(), "/Event/Digi/TofDigiCol" );
779 if ( !tofDigiCol )
780 { log << MSG::ERROR << "TofRec could not find Tof digi! Event = " << event << endmsg; }
781 else { m_checkdigi_tuple->FillCol( *eventHeader, tofDigiCol, t0, t0Stat ); }
782
783 m_checkdigi_tuple->FillCol( *eventHeader, tofDataMap, t0, t0Stat );
784 }
785
786 std::vector<int> deadId;
787 if ( m_forCalibration )
788 {
789 for ( unsigned int i = 0; i < 5; i++ )
790 {
792 if ( identmp != 0x2fffffff ) { deadId.push_back( identmp ); }
794 if ( identmp != 0x2fffffff ) { deadId.push_back( identmp ); }
795 }
796 for ( unsigned int i = 0; i < 500; i++ )
797 {
799 if ( identmp == 0x2fffffff ) break;
800 else { deadId.push_back( identmp ); }
801 }
802 }
803
804 std::vector<TofTrack*>::iterator
iter = tofTrackVec->begin();
805 for ( ;
iter < tofTrackVec->end();
iter++ )
806 {
807 if ( ( *iter )->isNoHit() ) continue;
808 ( *iter )->setTofData( tofDataMap );
809 if ( m_printOutInfo ) { m_printOut->setTrack2( ( *
iter ) ); }
810 if ( ( *iter )->isNoHit() ) continue;
811 ( *iter )->match( m_forCalibration, deadId, tofTrackVec );
812 if ( m_printOutInfo ) { m_printOut->setTrack3( ( *
iter ) ); }
813 }
814
815 iter = tofTrackVec->begin();
816 for ( ;
iter < tofTrackVec->end();
iter++ )
817 {
818
819 ( *iter )->setCalibration();
820
821 if ( m_checkDigi )
822 {
823 if ( m_checkTrigger )
824 {
825
826 SmartDataPtr<TrigData> trigData( eventSvc(), "/Event/Trig/TrigData" );
827 if ( !trigData )
828 {
829 log << MSG::FATAL << "Could not find Trigger Data for physics analysis" << endmsg;
830 m_checkdigi_tuple->Fill_TofTrack( *eventHeader, *
iter, t0, t0Stat );
831 }
832 else
833 { m_checkdigi_tuple->Fill_TofTrack( *eventHeader, *
iter, t0, t0Stat, trigData ); }
834 }
835 else
836 {
837 if ( ( run < 0 ) && m_checkMcTruth )
838 {
839 SmartDataPtr<TofMcHitCol> tofMcCol( eventSvc(), "/Event/MC/TofMcHitCol" );
840 SmartDataPtr<McParticleCol> mcParticleCol( eventSvc(), "/Event/MC/McParticleCol" );
841 if ( !tofMcCol || !mcParticleCol )
842 {
843 m_checkdigi_tuple->Fill_TofTrack( *eventHeader, *
iter, t0, t0Stat,
844 mdcKalTrackCol );
845 }
846 else
847 {
848 m_checkdigi_tuple->Fill_TofTrack( *eventHeader, *
iter, t0, t0Stat,
849 mdcKalTrackCol, tofMcCol, mcParticleCol,
850 m_calibData );
851 }
852 }
853 else
854 {
855 m_checkdigi_tuple->Fill_TofTrack( *eventHeader, *
iter, t0, t0Stat,
856 mdcKalTrackCol );
857 }
858 }
859 }
860 }
861
862 tds.
RegisterTDS( eventHeader->runNumber(), eventHeader->eventNumber(), tofTrackVec,
863 m_forCalibration, m_calibData );
864
866
867
868 SmartDataPtr<RecTofTrackCol> tofTrackCol( eventSvc(), "/Event/Recon/RecTofTrackCol" );
869 if ( !tofTrackCol )
870 {
871 log << MSG::FATAL << "TofRec could not find RecTofTrackCol!" << endmsg;
872 return StatusCode::FAILURE;
873 }
874 else
875 {
876 if ( m_saveRootFile )
877 { m_checkdata_tuple->FillCol( *eventHeader, tofTrackCol, mdcKalTrackCol ); }
878 }
879
880 if ( m_forCalibration )
881 {
882 SmartDataPtr<RecBTofCalHitCol> bhitCol( eventSvc(), "/Event/Recon/RecBTofCalHitCol" );
883 if ( !bhitCol )
884 { log << MSG::WARNING << "TofRec could not find RecBTofCalHitCol!" << endmsg; }
885 else
886 {
887 if ( m_saveRootFile ) { m_checkdata_tuple->FillCol( *eventHeader, bhitCol ); }
888 }
889
890 SmartDataPtr<RecETofCalHitCol> ehitCol( eventSvc(), "/Event/Recon/RecETofCalHitCol" );
891 if ( !ehitCol )
892 { log << MSG::WARNING << "TofRec could not find RecETofCalHitCol!" << endmsg; }
893 else
894 {
895 if ( m_saveRootFile ) { m_checkdata_tuple->FillCol( *eventHeader, ehitCol ); }
896 }
897 }
898 }
899 else
900 {
901 log << MSG::FATAL << "In TofRec: AcceleratorStatus is NOT correct! m_acceleratorStatus = "
902 << m_acceleratorStatus << endmsg;
903 return StatusCode::FAILURE;
904 }
905
906 return StatusCode::SUCCESS;
907}
std::multimap< unsigned int, TofData * > TofDataMap
double cos(const BesAngle a)
IRawDataProviderSvc * tofDigiSvc
std::vector< TofTrack * > TofTrackVec
virtual TofDataMap & tofDataMapTof(double estime=0)=0
virtual const int BrWest(unsigned int No)=0
virtual const int BrEast(unsigned int No)=0
virtual StatusCode chooseConstants(int run, int event)=0
virtual const int Endcap(unsigned int No)=0
StatusCode RegisterTDS(int runNumber, int eventNumber, std::vector< TofTrack * > *&tofTrackVec, bool m_forCalibration, std::string m_calibData)
StatusCode RegisterNullRecTofTrackCol()
void clearTofTrackVec(std::vector< TofTrack * > *&tofTrackVec)
void getMultiHit(TofTrack *&)
void setExtTrack(RecExtTrack *extTrack, double costheta, double p[5], int kal[5], double t0, int t0Stat)