196 {
197
198 MsgStream log(
msgSvc(), name() );
199 log << MSG::INFO << "in execute()" << endmsg;
200
201 StatusCode sc = StatusCode::SUCCESS;
202
203
204 int event, run;
205
206 SmartDataPtr<Event::EventHeader> eventHeader( eventSvc(), "/Event/EventHeader" );
207 if ( !eventHeader )
208 {
209 log << MSG::FATAL << "Could not find Event Header" << endmsg;
210
211 }
212 m_totalEvent++;
213 log << MSG::INFO << "Event: " << m_totalEvent
214 << "\tcurrent run: " << eventHeader->runNumber()
215 << "\tcurrent event: " << eventHeader->eventNumber() << endmsg;
216
217 event = eventHeader->eventNumber();
218 run = eventHeader->runNumber();
219
220 string release = getenv(
"BES_RELEASE" );
221
222
223
224 for ( std::vector<FilterEvent>::iterator it = m_filter_event.begin();
225 it != m_filter_event.end(); ++it )
226 {
227 const FilterEvent& fe = ( *it );
228 if (
release == fe.bossver && run == fe.runid && event == fe.eventid )
229 {
230 cout << "SKIP: " << fe.bossver << " " << fe.runid << " " << fe.eventid << std::endl;
231 return StatusCode::SUCCESS;
232 }
233 }
234
235
236 if ( m_CompareWithMcHit == 1 )
237 {
238 SmartDataPtr<McParticleCol> mcParticleCol( eventSvc(), "/Event/MC/McParticleCol" );
239 if ( !mcParticleCol )
240 {
241 log << MSG::FATAL << "Could not find McParticle" << endmsg;
242
243 }
244
245 McParticleCol::iterator iter_mc = mcParticleCol->begin();
246
247
248
249 int pid = ( *iter_mc )->particleProperty();
250 int charge = 0;
252
253 if ( pid > 0 )
254 {
255 if ( m_particleTable->particle( pid ) )
256 {
257 charge = (int)m_particleTable->particle( pid )->charge();
258 mass = m_particleTable->particle( pid )->mass();
259 }
260 else
261 log << MSG::ERROR << "no this particle id in particle table, please check data"
262 << endmsg;
263 }
264 else if ( pid < 0 )
265 {
266 if ( m_particleTable->particle( -pid ) )
267 {
268 charge = (int)m_particleTable->particle( -pid )->charge();
269 charge *= -1;
270 mass = m_particleTable->particle( -pid )->mass();
271 }
272 else
273 log << MSG::ERROR << "no this particle id in particle table, please check data"
274 << endmsg;
275 }
276 else { log << MSG::WARNING << "wrong particle id, please check data" << endmsg; }
277
278
279
280
281
282
283
284 HepLorentzVector initialMomentum = ( *iter_mc )->initialFourMomentum();
285 HepLorentzVector initialPos = ( *iter_mc )->initialPosition();
286 if ( m_NtOutput >= 1 )
287 {
288 m_px_mc = initialMomentum.px();
289 m_py_mc = initialMomentum.py();
290 m_pz_mc = initialMomentum.pz();
291 }
292
293
294 log << MSG::INFO << " particleId = " << ( *iter_mc )->particleProperty() << endmsg;
295 }
296
297
298 int digiId = 0;
299 SmartDataPtr<MucDigiCol> mucDigiCol( eventSvc(), "/Event/Digi/MucDigiCol" );
300 if ( !mucDigiCol )
301 {
302 log << MSG::FATAL << "Could not find MUC digi" << endmsg;
303 return ( StatusCode::FAILURE );
304 }
305 MucDigiCol::iterator iter4 = mucDigiCol->begin();
306 for ( ; iter4 != mucDigiCol->end(); iter4++, digiId++ ) {}
307 log << MSG::INFO << "Total MUC digis:\t" << digiId << endmsg;
308 if ( digiId == 0 ) return ( StatusCode::SUCCESS );
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336 Identifier mucID;
337
338
339
340
341 if ( m_CompareWithMcHit )
342 {
345
346 SmartDataPtr<McParticleCol> mcParticleCol( eventSvc(), "/Event/MC/McParticleCol" );
347 if ( !mcParticleCol )
348 {
349 log << MSG::FATAL << "Could not find McParticle" << endmsg;
350
351 }
352 McParticleCol::iterator iter_mc = mcParticleCol->begin();
353
354
355 SmartDataPtr<Event::MucMcHitCol> aMucMcHitCol( eventSvc(), "/Event/MC/MucMcHitCol" );
356 if ( !aMucMcHitCol )
357 {
358 log << MSG::WARNING << "Could not find MucMcHitCol" << endmsg;
359
360 }
361
362 log << MSG::DEBUG << "MucMcHitCol contains " << aMucMcHitCol->size() << " Hits " << endmsg;
363 MucMcHitCol::iterator iter_MucMcHit = aMucMcHitCol->begin();
364 for ( ; iter_MucMcHit != aMucMcHitCol->end(); iter_MucMcHit++ )
365 {
366 mucID = ( *iter_MucMcHit )->identify();
367
368 log << MSG::DEBUG << " MucMcHit "
369 << " : "
372 << " Track Id " << ( *iter_MucMcHit )->getTrackIndex() << " pos x "
373 << ( *iter_MucMcHit )->getPositionX() << " pos y "
374 << ( *iter_MucMcHit )->getPositionY() << " pos z "
375 << ( *iter_MucMcHit )->getPositionZ() << endmsg;
376
377 McParticle* assocMcPart = 0;
378 for ( iter_mc = mcParticleCol->begin(); iter_mc != mcParticleCol->end(); iter_mc++ )
379 {
380 if ( ( *iter_mc )->trackIndex() == ( *iter_MucMcHit )->getTrackIndex() )
381 {
382 assocMcPart = *iter_mc;
383 break;
384 }
385 }
386 if ( assocMcPart == 0 )
387 {
388 log << MSG::WARNING << "No Corresponding Mc Particle found for this MucMcHit"
389 << endmsg;
390 }
391
392 MucMcHit* assocMucMcHit = *iter_MucMcHit;
395 if ( relMcMuc == 0 ) log << MSG::DEBUG << "relMcMuc not created " << endmsg;
396 else
397 {
399 if ( !addstat ) delete relMcMuc;
400 }
401 }
402
403 log << MSG::DEBUG <<
" Fill McPartToMucHitTab, size " << assocMcMuc.
size() << endmsg;
404 iter_mc = mcParticleCol->begin();
405 for ( ; iter_mc != mcParticleCol->end(); iter_mc++ )
406 {
407 log << MSG::DEBUG << " Track index " << ( *iter_mc )->trackIndex()
408 << " particleId = " << ( *iter_mc )->particleProperty() << endmsg;
409
410 vector<McPartToMucHitRel*> vecMucMcHit = assocMcMuc.
getRelByFirst( *iter_mc );
411 vector<McPartToMucHitRel*>::iterator iter_MucMcHit = vecMucMcHit.begin();
412 for ( ; iter_MucMcHit != vecMucMcHit.end(); iter_MucMcHit++ )
413 {
414 mucID = ( *iter_MucMcHit )->getSecond()->identify();
415
416 log << MSG::DEBUG
417
418 << " MC Particle index " << ( *iter_MucMcHit )->getFirst()->trackIndex()
419 << " contains "
420 << " MucMcHit "
424
425
426
427 << endmsg;
428 }
429 }
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445 }
446
447
448
449 if ( !m_MucRecHitContainer ) { m_MucRecHitContainer = new MucRecHitContainer(); }
450 m_MucRecHitContainer->Clear();
452 m_MucRecHitContainer->SetMucRecHitCol( aMucRecHitCol );
453
454 SmartIF<IDataManagerSvc> dataManSvc( eventSvc() );
455 DataObject* mucRecHitCol;
456 eventSvc()->findObject( "/Event/Recon/MucRecHitCol", mucRecHitCol );
457 if ( mucRecHitCol != NULL )
458 {
459 dataManSvc->clearSubTree( "/Event/Recon/MucRecHitCol" );
460 eventSvc()->unregisterObject( "/Event/Recon/MucRecHitCol" );
461 }
462
463 sc = eventSvc()->registerObject( "/Event/Recon/MucRecHitCol", aMucRecHitCol );
464 if ( !sc )
465 {
466 log << MSG::ERROR << "/Event/Recon/MucRecHitCol not registerd!" << endmsg;
467 return ( StatusCode::FAILURE );
468 }
469
470 log << MSG::INFO << "Add digis" << endmsg;
471 MucDigiCol::iterator iter_Muc = mucDigiCol->begin();
472 int mucDigiId = 0;
473 for ( ; iter_Muc != mucDigiCol->end(); iter_Muc++, mucDigiId++ )
474 {
475 mucID = ( *iter_Muc )->identify();
480
481 m_MucRecHitContainer->AddHit( part, seg, gap, strip );
482
483 log << MSG::DEBUG << " digit" << mucDigiId << " : "
484 << " part " << part << " seg " << seg << " gap " << gap << " strip " << strip
485 << endmsg;
486 }
487
488
489
491
492
493 DataObject* aReconEvent;
494 eventSvc()->findObject( "/Event/Recon", aReconEvent );
495 if ( aReconEvent == NULL )
496 {
497
498 aReconEvent = new ReconEvent();
499 StatusCode sc = eventSvc()->registerObject( "/Event/Recon", aReconEvent );
500 if ( sc != StatusCode::SUCCESS )
501 {
502 log << MSG::FATAL << "Could not register ReconEvent" << endmsg;
503 return ( StatusCode::FAILURE );
504 }
505 }
506 StatusCode fr = eventSvc()->findObject( "/Event/Recon", aReconEvent );
507 if ( fr != StatusCode::SUCCESS )
508 {
509 log << MSG::WARNING << "Could not find register ReconEvent, will create it" << endmsg;
510 StatusCode sc = eventSvc()->registerObject( "/Event/Recon", aReconEvent );
511 if ( sc != StatusCode::SUCCESS )
512 {
513 log << MSG::FATAL << "Could not register ReconEvent" << endmsg;
514 return ( StatusCode::FAILURE );
515 }
516 }
517
518 DataObject* mucTrackCol;
519 eventSvc()->findObject( "/Event/Recon/RecMucTrackCol", mucTrackCol );
520 if ( mucTrackCol != NULL )
521 {
522 dataManSvc->clearSubTree( "/Event/Recon/RecMucTrackCol" );
523 eventSvc()->unregisterObject( "/Event/Recon/RecMucTrackCol" );
524 }
525
526 sc = eventSvc()->registerObject( "/Event/Recon/RecMucTrackCol", aRecMucTrackCol );
527 if ( sc != StatusCode::SUCCESS )
528 {
529 log << MSG::FATAL << "Could not register MUC track collection" << endmsg;
530 return ( StatusCode::FAILURE );
531 }
532
533
534 SmartDataPtr<RecMucTrackCol> findRecMucTrackCol( eventSvc(), "/Event/Recon/RecMucTrackCol" );
535 if ( !findRecMucTrackCol )
536 {
537 log << MSG::FATAL << "Could not find RecMucTrackCol" << endmsg;
538 return ( StatusCode::FAILURE );
539 }
540 aRecMucTrackCol->clear();
541
542
543
544
545
546 SmartDataPtr<RecExtTrackCol> aExtTrackCol( eventSvc(), "/Event/Recon/RecExtTrackCol" );
547 if ( !aExtTrackCol )
548 {
549 log << MSG::WARNING << "Can't find ExtTrackCol in TDS!" << endmsg;
550
551 }
552
553 SmartDataPtr<RecMdcTrackCol> aMdcTrackCol( eventSvc(), "/Event/Recon/RecMdcTrackCol" );
554 if ( !aMdcTrackCol )
555 {
556 log << MSG::WARNING << "Can't find MdcTrackCol in TDS!" << endmsg;
557
558 }
559
560
561
562 SmartDataPtr<RecEmcShowerCol> aShowerCol( eventSvc(), "/Event/Recon/RecEmcShowerCol" );
563 if ( !aShowerCol )
564 {
565 log << MSG::WARNING << "Could not find RecEmcShowerCol" << endmsg;
566
567 }
568
569
570
571
572
573
574
575
576
577 int muctrackId = 0;
578
579 log << MSG::INFO << "Add tracks info, ExtTrackSeedMode = " << m_ExtTrackSeedMode
580 << ", EmcShowerSeedMode = " << m_EmcShowerSeedMode << endmsg;
581
582 if ( m_ExtTrackSeedMode == 1 )
583 {
584 SmartDataPtr<McParticleCol> mcParticleCol( eventSvc(), "/Event/MC/McParticleCol" );
585 if ( !mcParticleCol )
586 {
587 log << MSG::FATAL << "Could not find McParticle" << endmsg;
588
589 return ( StatusCode::SUCCESS );
590 }
591 McParticleCol::iterator iter_mc = mcParticleCol->begin();
592
593 int trackIndex = -99;
594 for ( int iTrack = 0; iter_mc != mcParticleCol->end(); iter_mc++, iTrack++ )
595 {
596 if ( !( *iter_mc )->primaryParticle() ) continue;
597 int pid = ( *iter_mc )->particleProperty();
598 int charge = 0;
600 if ( pid > 0 )
601 {
602 if ( m_particleTable->particle( pid ) )
603 {
604 charge = (int)m_particleTable->particle( pid )->charge();
605 mass = m_particleTable->particle( pid )->mass();
606 }
607 else
608 log << MSG::ERROR << "no this particle id in particle table, please check data"
609 << endmsg;
610 }
611 else if ( pid < 0 )
612 {
613 if ( m_particleTable->particle( -pid ) )
614 {
615 charge = (int)m_particleTable->particle( -pid )->charge();
616 charge *= -1;
617 mass = m_particleTable->particle( -pid )->mass();
618 }
619 else
620 log << MSG::ERROR << "no this particle id in particle table, please check data"
621 << endmsg;
622 }
623 else { log << MSG::WARNING << "wrong particle id, please check data" << endmsg; }
624
625 if ( !charge )
626 {
627 log << MSG::WARNING << " neutral particle charge = 0!!! ...just skip it !" << endmsg;
628 continue;
629 }
630
631 trackIndex = ( *iter_mc )->trackIndex();
632 log << MSG::DEBUG << "iTrack " << iTrack << " index " << trackIndex
633 << " particleId = " << ( *iter_mc )->particleProperty() << endmsg;
634
635 RecMucTrack* aTrack = new RecMucTrack();
637 aTrack->
setId( muctrackId );
638
639 HepLorentzVector initialMomentum = ( *iter_mc )->initialFourMomentum();
640 HepLorentzVector initialPos = ( *iter_mc )->initialPosition();
641 float theta0 = initialMomentum.theta();
642 float phi0 = initialMomentum.phi();
643
644
645
646 float x0 = initialPos.x();
647 float y0 = initialPos.y();
648 float z0 = initialPos.z();
649
650 Hep3Vector startPos( x0, y0, z0 );
651 Hep3Vector startP( initialMomentum.px(), initialMomentum.py(), initialMomentum.pz() );
652 log << MSG::DEBUG << "startP " << startP << " startPos " << startPos << endmsg;
653 Hep3Vector endPos( 0, 0, 0 ), endP;
654
659 aTrack->
SetExtMucPos( endPos.x(), endPos.y(), endPos.z() );
661 aTrack->
SetMucPos( endPos.x(), endPos.y(), endPos.z() );
665
666
667
668
669
670
671
672
673
674
675 log << MSG::INFO << "Add track, trkIndex: " << trackIndex << "\tmucTrkId: " << muctrackId
676 << endmsg;
677 aRecMucTrackCol->add( aTrack );
678 muctrackId++;
679 }
680 }
681 else if ( m_ExtTrackSeedMode == 2 )
682 {
683 if ( !aExtTrackCol || !aMdcTrackCol )
684 {
685 log << MSG::WARNING << "Can't find ExtTrackCol or MdcTrackCol in TDS!" << endmsg;
686 return StatusCode::SUCCESS;
687 }
688
689 int trackIndex = -99;
690 double kdep = -99;
691 double krechi = 0.;
692 int kdof = 0;
693 int kbrLay = -1;
694 int kecLay = -1;
695
696
697 RecExtTrackCol::iterator iter_ExtTrack = aExtTrackCol->begin();
698 RecMdcTrackCol::iterator iter_MdcTrack = aMdcTrackCol->begin();
699 int iExtTrack = 0;
700 for ( ; iter_ExtTrack != aExtTrackCol->end() && iter_MdcTrack != aMdcTrackCol->end();
701 iter_ExtTrack++, iter_MdcTrack++, iExtTrack++ )
702 {
703 trackIndex = ( *iter_ExtTrack )->GetTrackId();
704 log << MSG::DEBUG << "iExtTrack " << iExtTrack << " index " << trackIndex << " MucPos "
705 << iExtTrack << ( *iter_ExtTrack )->mucPosition().x() << " "
706 << ( *iter_ExtTrack )->mucPosition().y() << " "
707 << ( *iter_ExtTrack )->mucPosition().z() << " r "
708 << ( *iter_ExtTrack )->mucPosition().r() << endmsg;
709
710 if ( ( *iter_ExtTrack )->mucPosition().x() == -99 &&
711 ( *iter_ExtTrack )->mucPosition().y() == -99 &&
712 ( *iter_ExtTrack )->mucPosition().z() == -99 )
713 {
714 log << MSG::INFO << "Bad ExtTrack, trackIndex: " << trackIndex << ", skip" << endmsg;
715 continue;
716 }
717
718
719 krechi = ( *iter_ExtTrack )->MucKalchi2();
720 kdof = ( *iter_ExtTrack )->MucKaldof();
721 kdep = ( *iter_ExtTrack )->MucKaldepth();
722 kbrLay = ( *iter_ExtTrack )->MucKalbrLastLayer();
723 kecLay = ( *iter_ExtTrack )->MucKalecLastLayer();
724 if ( kdof <= 0 ) krechi = 0.;
725 else krechi = krechi / kdof;
726 kdep = kdep / 10.;
727
728 RecMucTrack* aTrack = new RecMucTrack();
730 aTrack->
setId( muctrackId );
731
733
735
736
742
743
744 Hep3Vector mdcMomentum = ( *iter_MdcTrack )->p3();
745 Hep3Vector mucPos = ( *iter_ExtTrack )->mucPosition();
746 Hep3Vector mucMomentum = ( *iter_ExtTrack )->mucMomentum();
747
748
749 aTrack->
SetMdcMomentum( mdcMomentum.x(), mdcMomentum.y(), mdcMomentum.z() );
750 aTrack->
SetExtMucPos( mucPos.x(), mucPos.y(), mucPos.z() );
751
753 aTrack->
SetMucPos( mucPos.x(), mucPos.y(), mucPos.z() );
754 aTrack->
SetMucMomentum( mucMomentum.x(), mucMomentum.y(), mucMomentum.z() );
756 aTrack->
SetCurrentDir( mucMomentum.x(), mucMomentum.y(), mucMomentum.z() );
758
759 log << MSG::INFO << "Add track, trkIndex: " << trackIndex << "\tmucTrkId: " << muctrackId
760 << endmsg;
761 aRecMucTrackCol->add( aTrack );
762 muctrackId++;
763 }
764 }
765 else if ( m_ExtTrackSeedMode == 3 )
766 {
767
768 if ( !aMdcTrackCol )
769 {
770 log << MSG::WARNING << "Can't find MdcTrackCol in TDS!" << endmsg;
771 return StatusCode::SUCCESS;
772
773 }
774 log << MSG::INFO << "Mdc track size: " << aMdcTrackCol->size() << endmsg;
775
776 int trackIndex = -99;
777 for ( RecMdcTrackCol::iterator iter_mdc1 = aMdcTrackCol->begin();
778 iter_mdc1 != aMdcTrackCol->end(); iter_mdc1++ )
779 {
780
781
782
783
784 trackIndex = ( *iter_mdc1 )->trackId();
785 HepVector helix = ( *iter_mdc1 )->helix();
786
787
788 float x0 = helix[0] *
cos( helix[1] );
789 float y0 = helix[0] *
sin( helix[1] );
790 float z0 = helix[3];
791
792
793
794
795
796 float dx = -1 *
sin( helix[1] );
797 float dy =
cos( helix[1] );
798 float dz = helix[4];
799
800
801
802 RecMucTrack* aTrack = new RecMucTrack();
804 aTrack->
setId( muctrackId );
805 muctrackId++;
806
808
809 Hep3Vector mucPos( x0, y0, z0 );
810 Hep3Vector mucMomentum( dx, dy, dz );
811
814
820
821 log << MSG::INFO << "Add track, trkIndex: " << trackIndex << "\tmucTrkId: " << muctrackId
822 << endmsg;
823 aRecMucTrackCol->add( aTrack );
824 muctrackId++;
825 }
826 }
827 else { log << MSG::INFO << "ExtTrackSeedMode error!" << endmsg; }
828
829
830 if ( m_EmcShowerSeedMode == 1 )
831 {
832 int trackIndex = 999;
833 RecEmcShowerCol::iterator iShowerCol;
834 for ( iShowerCol = aShowerCol->begin(); iShowerCol != aShowerCol->end(); iShowerCol++ )
835 {
836
837
838
839
840 RecMucTrack* aTrack = new RecMucTrack();
842 aTrack->
setId( muctrackId );
844
845 Hep3Vector mucPos = ( *iShowerCol )->position();
846 Hep3Vector mucMomentum = ( *iShowerCol )->position();
847
848 aTrack->
SetExtMucPos( mucPos.x(), mucPos.y(), mucPos.z() );
849
851 aTrack->
SetMucPos( mucPos.x(), mucPos.y(), mucPos.z() );
852 aTrack->
SetMucMomentum( mucMomentum.x(), mucMomentum.y(), mucMomentum.z() );
854 aTrack->
SetCurrentDir( mucMomentum.x(), mucMomentum.y(), mucMomentum.z() );
856
857
858 log << MSG::INFO << "Add track, trkIndex: " << trackIndex << "\tmucTrkId: " << muctrackId
859 << endmsg;
860 aRecMucTrackCol->add( aTrack );
861 muctrackId++;
862
863 m_emcrec = 1;
864 }
865 }
866 log << MSG::DEBUG << " track container filled " << endmsg;
867
868
869 log << MSG::INFO << "Start tracking..." << endmsg;
870 int runVerbose = 1;
871 RecMucTrack* aTrack = 0;
872 for ( int iTrack = 0; iTrack < (int)aRecMucTrackCol->size(); iTrack++ )
873 {
874 log << MSG::DEBUG << "iTrack " << iTrack << endmsg;
875 aTrack = ( *aRecMucTrackCol )[iTrack];
876
877
880 if ( currentPos.mag() <
kMinor )
881 {
882 log << MSG::WARNING << "No MUC intersection in track " << iTrack << endmsg;
883 continue;
884 }
885
886
887 int firstHitFound[2] = { 0, 0 };
888
889 int firstHitGap[2] = { -1, -1 };
890
892 {
895 {
896
897 int seg = -1;
899 ;
900
901 float xInsct, yInsct, zInsct;
902 aTrack->
Project( iPart, iGap, xInsct, yInsct, zInsct, seg );
903 if ( m_MsOutput )
904 cout << "part " << iPart << " gap " << iGap << " x " << xInsct << " y " << yInsct
905 << " z " << zInsct << " seg " << seg << endl;
906
907 if ( seg == -1 ) continue;
908
910
911 for (
int iDeltaSeg = 0; iDeltaSeg <
kNSegSearch; iDeltaSeg++ )
912 {
916
917
918
919
920
921
924
925 if ( firstHitFound[orient] != 1 )
927
928 for ( int iHit = 0; iHit < m_MucRecHitContainer->GetGapHitCount( iPart, iSeg, iGap );
929 iHit++ )
930 {
931 log << MSG::DEBUG << "iSeg " << iSeg << " iHit " << iHit << endmsg;
932 MucRecHit* pHit = m_MucRecHitContainer->GetHit( iPart, iSeg, iGap, iHit );
933
934
935 if ( !pHit )
936 {
937 log << MSG::WARNING << "MucRecTrkExt: null pointer to pHit" << endmsg;
938 continue;
939 }
940 else
941 {
942
943
944
945
947 log << MSG::DEBUG << "distance = " << setw( 8 ) << dX << " size " << setw( 4 )
948 << window << endmsg;
949
950 if ( m_NtOutput >= 2 )
951 {
952 m_distance = dX;
953 m_part = iPart;
954 m_seg = iSeg;
955 m_gap = iGap;
956 m_strip = pHit->
Strip();
957 m_diff = -99;
958 m_tuple->write();
959 }
960
961 if ( fabs( dX ) < window )
962 {
963
964
965
966
967
969 {
972
973
974 }
976 {
977
978
979
981 {
984 }
985 }
986
987
989
990 if ( firstHitGap[orient] == -1 ) firstHitGap[orient] = iGap;
991 firstHitFound[orient] = 1;
992
993
994 log << MSG::DEBUG << " part " << iPart << " seg " << iSeg << " gap " << iGap
995 <<
" strip " << setw( 2 ) << pHit->
Strip() <<
" attatched" << endmsg;
996 log << MSG::DEBUG <<
"current total hits " << aTrack->
GetTotalHits() << endmsg;
997 }
998 else
999 {
1000 m_NHitsLostInGap[iGap]++;
1001
1002
1003
1004
1005 }
1006 }
1007 }
1009 }
1010
1011
1012
1013 if ( m_ExtTrackSeedMode != 3 && !m_Blind )
1014 {
1015 if ( firstHitFound[orient] && firstHitGap[orient] != iGap ) aTrack->
CorrectDir();
1017 }
1018
1019
1021 }
1022 }
1023 aTrack->
LineFit( m_fittingMethod );
1025 log << MSG::INFO <<
"Fit track done! trackIndex: " << aTrack->
trackId()
1026 <<
", mucId: " << aTrack->
id() <<
", RecMode: " << aTrack->
GetRecMode() << endmsg;
1027
1028 if ( m_NtOutput >= 1 )
1029 {
1030 m_depth = aTrack->
depth();
1033 m_Chi2 = aTrack->
chi2();
1040
1041 m_emctrack = m_emcrec;
1042 }
1043
1044
1045 if ( m_NtOutput >= 2 )
1046 {
1047 vector<MucRecHit*> attachedHits = aTrack->
GetHits();
1049 vector<float> distanceHits = aTrack->
getDistHits();
1052
1053 for ( int i = 0; i < expectedHits.size(); i++ )
1054 {
1055 MucRecHit* ihit = expectedHits[i];
1056
1057
1058 }
1059
1060 for ( int j = 0; j < attachedHits.size(); j++ )
1061 {
1062 MucRecHit* jhit = attachedHits[j];
1063
1064
1065 if ( attachedHits.size() == distanceHits.size() )
1066 {
1067 m_part = jhit->
Part();
1068 m_seg = jhit->
Seg();
1069 m_gap = jhit->
Gap();
1070 m_strip = jhit->
Strip();
1071 m_distance = distanceHits[j];
1072 m_Distance = distanceHits_quad[j];
1073 m_diff = -9999;
1074
1075
1076
1077 m_tuple->write();
1078 }
1079 }
1080 }
1081
1083
1084
1085 log << MSG::DEBUG <<
"track Index " << aTrack->
trackId() << setw( 2 )
1086 << mucDigiCol->size() - nHitsAttached << " of " << setw( 2 ) << mucDigiCol->size()
1087 << " lost " << endmsg;
1088
1089 }
1090
1091
1092
1093
1094
1095
1096 if ( m_MucHitSeedMode == 1 )
1097 {
1098 MucRecHit *pHit = 0, *pHit0 = 0, *pHit1 = 0;
1100
1102 {
1104 {
1105 bool hit0 = false, hit1 = false;
1106 int firstgap0 = -1, firstgap1 = -1;
1107 int nStrip0 = 0, nStrip1 = 0;
1108 Hep3Vector posHit0, posHit1;
1110 {
1111 count = m_MucRecHitContainer->GetGapHitCount( iPart, iSeg, iGap );
1112 for (
int iHit0 = 0; iHit0 <
count; iHit0++ )
1113 {
1114
1115 pHit = m_MucRecHitContainer->GetHit( iPart, iSeg, iGap, iHit0 );
1116 if ( !pHit )
1117 {
1118 log << MSG::FATAL << "MucRecRoadFinder-E10 "
1119 << " part " << iPart << " seg " << iSeg << " gap " << iGap << " null pointer"
1120 << endl;
1121 }
1122 else
1123 {
1124
1126 {
1128 if ( orient == 1 && hit0 == false )
1129 {
1130 hit0 = true;
1131 firstgap0 = iGap;
1132 }
1133 if ( iGap == firstgap0 )
1134 {
1136 nStrip0++;
1137 }
1138
1139 if ( orient == 0 && hit1 == false )
1140 {
1141 hit1 = true;
1142 firstgap1 = iGap;
1143 }
1144 if ( iGap == firstgap1 )
1145 {
1147 nStrip1++;
1148 }
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159 }
1160 }
1161 }
1162 }
1163
1164
1165 if ( hit0 && hit1 )
1166 {
1167 posHit0 /= nStrip0;
1168 posHit1 /= nStrip1;
1169
1170
1171
1172 int trackIndex = 999;
1173 RecMucTrack* aTrack = new RecMucTrack();
1175 aTrack->
setId( muctrackId );
1176 muctrackId++;
1177
1179
1180 Hep3Vector mucPos, mucMomentum;
1181 if ( iPart == 1 )
1182 {
1183 mucMomentum.set( posHit0.x(), posHit0.y(), posHit1.z() );
1184 mucPos = mucMomentum * 0.9;
1185
1186 }
1187 else
1188 {
1189 mucMomentum.set( posHit0.x(), posHit1.y(), posHit0.z() * 0.5 + posHit1.z() * 0.5 );
1190 mucPos = mucMomentum * 0.9;
1191
1192 }
1193
1194 aTrack->
SetExtMucPos( mucPos.x(), mucPos.y(), mucPos.z() );
1195
1197 aTrack->
SetMucPos( mucPos.x(), mucPos.y(), mucPos.z() );
1198 aTrack->
SetMucMomentum( mucMomentum.x(), mucMomentum.y(), mucMomentum.z() );
1199 aTrack->
SetCurrentPos( mucPos.x(), mucPos.y(), mucPos.z() );
1200 aTrack->
SetCurrentDir( mucMomentum.x(), mucMomentum.y(), mucMomentum.z() );
1201
1203 aRecMucTrackCol->add( aTrack );
1204
1206 }
1207
1208 if ( m_NtOutput >= 1 )
1209 {
1210 m_depth = aTrack->
depth();
1213 m_Chi2 = aTrack->
chi2();
1220
1221 m_emctrack = 2;
1222 }
1223
1224 }
1225 }
1226 }
1227
1228
1229 int nTracksTotal = 0;
1230 int nTracksFound = 0;
1231 int nTracksLost = 0;
1232 int nTracksLostByExt = 0;
1233 int nTracksMisFound = 0;
1234
1235 int nDigisTotal = 0;
1236 int nHitsTotal = 0;
1237 int nHitsFound = 0;
1238 int nHitsLost = 0;
1239 int nHitsMisFound = 0;
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448 m_NDigisTotal += nDigisTotal;
1449 m_NHitsTotal += nHitsTotal;
1450 m_NHitsFoundTotal += nHitsFound;
1451 m_NHitsLostTotal += nHitsLost;
1452 m_NHitsMisFoundTotal += nHitsMisFound;
1453
1454
1455 m_NTracksTotal += nTracksTotal;
1456 m_NTracksRecoTotal += nTracksFound;
1457 m_NTracksLostByMdcTotal += nTracksLost;
1458 m_NTracksLostByExtTotal += nTracksLostByExt;
1459 m_NTracksMdcGhostTotal += nTracksMisFound;
1460 if ( aRecMucTrackCol->size() > 0 )
1461 {
1462 RecMucTrack* aRecMucTrack = ( *aRecMucTrackCol )[0];
1463
1464 if ( m_NtOutput >= 1 )
1465 {
1469
1473 }
1474
1475
1476 }
1477
1478 if ( m_NtOutput >= 1 ) m_tuple->write();
1479 return StatusCode::SUCCESS;
1480}
DOUBLE_PRECISION count[3]
double sin(const BesAngle a)
double cos(const BesAngle a)
ObjectVector< MucRecHit > MucRecHitCol
ObjectVector< RecMucTrack > RecMucTrackCol
const int kDeltaSeg[kNSegSearch]
const float kFirstHitWindowRatio
void setkalbrLastLayer(int br)
int maxHitsInLayer() const
void setkalecLastLayer(int ec)
void setkalRechi2(double ch)
void setkalDepth(double de)
void init()
Initialize the internal pointer to an ObjectList of relations.
unsigned long size() const
This method returns the number of relations in the table.
bool addRelation(Relation< T1, T2 > *rel)
std::vector< Relation< T1, T2 > * > getRelByFirst(const T1 *pobj) const
MucGeoGap * GetGap(const int part, const int seg, const int gap) const
Get a pointer to the gap identified by (part,seg,gap).
static MucGeoGeneral * Instance()
Get a pointer to the single instance of MucGeoGeneral.
static int barrel_ec(const Identifier &id)
Values of different levels.
static int layer(const Identifier &id)
static int channel(const Identifier &id)
static int segment(const Identifier &id)
static value_type getPartNum()
static value_type getSegNum(int part)
static value_type getGapNum(int part)
Hep3Vector GetCenterPos() const
Get Center position of the strip (global coords).
int Part() const
Get Part.
int Strip() const
Get Strip.
void SetHitMode(int recmode)
void TrackFinding(RecMucTrack *aTrack)
float getWindowSize(Hep3Vector mom, int part, int seg, int gap)
int GetTotalHits() const
How many hits in all does this track contain?
void LineFit(int fittingMethod)
Line fit with hits on a seg with max hits.
void CorrectPos()
Correct current position of this trajectory.
void CorrectDir()
Correct direction of this trajectory.
void ComputeTrackInfo(int fittingmethod)
Get corresponding monte carlo track pointer.
void pushExtDistHits(float dist)
vector< float > getExtDistHits() const
void SetMdcMomentum(const float px, const float py, const float pz)
set start moment of the track in Mdc.
Hep3Vector getMucPos() const
start position of this track in Muc.
Hep3Vector getMucPosSigma() const
void AttachInsct(Hep3Vector insct)
Attach the intersection to this trajectory.
void SetExtMucPos(const float x, const float y, const float z)
void SetExtTrackID(int id)
set Ext track id. for compute from mdc myself
void SetMdcPos(const float x, const float y, const float z)
set start position of the track in Mdc.
void SetCurrentDir(const float x, const float y, const float z)
set current direction of the trajectory.
void SetExtTrack(RecExtTrack *extTrack)
set Ext track point.
void setTrackId(const int trackId)
set the index for this track.
Hep3Vector GetExtMucDistance() const
Distance match of the ext track with muc track in first layer.
void GetMdcExtTrack(Hep3Vector mdcStartPos, Hep3Vector mdcStartMomentum, int charge, Hep3Vector &mucStartPos, Hep3Vector &mucStartMomentum)
compute ext track myself from mdc.
Hep3Vector GetMucStripPos() const
Hep3Vector GetCurrentDir() const
Current direction.
Hep3Vector getMdcMomentum() const
momentum of this track in Mdc
Hep3Vector CalculateInsct(const int part, const int seg, const int gap)
Calculate intersection from all hits attached on this gap.
void Project(const int &part, const int &gap, float &x, float &y, float &z, int &seg)
Where does the trajectory of this track intersect a specific gap?
vector< float > getQuadDistHits() const
void SetMucMomentum(const float px, const float py, const float pz)
set start moment of the track in Muc.
Hep3Vector GetCurrentInsct() const
Current intersection.
void SetExtMucMomentum(const float px, const float py, const float pz)
set start moment of ext track in Muc.
vector< MucRecHit * > GetHits() const
Get all hits on this track.
void AttachHit(MucRecHit *hit)
set corresponding monte carlo track pointer.
Hep3Vector GetCurrentPos() const
Current position.
void SetCurrentInsct(const float x, const float y, const float z)
set current intersection of the trajectory with strip plane.
void SetCurrentPos(const float x, const float y, const float z)
set current position of the trajectory.
vector< MucRecHit * > GetExpectedHits() const
void SetRecMode(int recmode)
void SetMucPos(const float x, const float y, const float z)
set start position of the track in Muc. (after line fit and correction)
float GetHitDistance2(const MucRecHit *hit)
no abs value
vector< float > getDistHits() const
Event::Relation< Event::McParticle, Event::MucMcHit > McPartToMucHitRel
Event::RelTable< Event::McParticle, Event::MucMcHit > McPartToMucHitTab