175 {
176
177 MsgStream log(
msgSvc(), name() );
178 log << MSG::INFO << "in execute()" << endmsg;
179
180
181 int event, run;
182
183 SmartDataPtr<Event::EventHeader> eventHeader( eventSvc(), "/Event/EventHeader" );
184 if ( !eventHeader )
185 {
186 log << MSG::FATAL << "Could not find Event Header" << endmsg;
187 return ( StatusCode::FAILURE );
188 }
189 log << MSG::INFO << "Run: " << eventHeader->runNumber()
190 << " Event: " << eventHeader->eventNumber() << endmsg;
191
192 event = eventHeader->eventNumber();
193 run = eventHeader->runNumber();
194
195
196 string release = getenv(
"BES_RELEASE" );
197
198
199
200 for ( std::vector<FilterEvent>::iterator it = m_filter_event.begin();
201 it != m_filter_event.end(); ++it )
202 {
203 const FilterEvent& fe = ( *it );
204 if (
release == fe.bossver && run == fe.runid && event == fe.eventid )
205 {
206 cout << "SKIP: " << fe.bossver << " " << fe.runid << " " << fe.eventid << std::endl;
207 return StatusCode::SUCCESS;
208 }
209 }
210
211 int digiId;
212
213
214
215 Hep3Vector cosmicMom;
216 if ( m_mccosmic == 1 )
217 {
218 SmartDataPtr<McParticleCol> mcParticleCol( eventSvc(), "/Event/MC/McParticleCol" );
219 if ( !mcParticleCol )
220 {
221 log << MSG::FATAL << "Could not find McParticle" << endmsg;
222 return ( StatusCode::FAILURE );
223 }
224
225 McParticleCol::iterator iter_mc = mcParticleCol->begin();
226 for ( ; iter_mc != mcParticleCol->end(); iter_mc++, digiId++ )
227 {
228 log << MSG::DEBUG << " particleId = " << ( *iter_mc )->particleProperty() << endmsg;
229 int pid = ( *iter_mc )->particleProperty();
230
231 if ( fabs( pid ) != 13 ) continue;
232
233 HepLorentzVector initialMomentum = ( *iter_mc )->initialFourMomentum();
234 Hep3Vector startP( initialMomentum.px(), initialMomentum.py(), initialMomentum.pz() );
235 Hep3Vector rotate( -initialMomentum.px(), initialMomentum.pz(), initialMomentum.py() );
236
237 if ( m_NtOutput >= 1 )
238 {
239 m_px_mc = initialMomentum.px();
240 m_py_mc = initialMomentum.py();
241 m_pz_mc = initialMomentum.pz();
242
243 m_theta_mc = rotate.theta();
244 m_phi_mc = rotate.phi();
245
246 m_theta_mc_pipe = startP.theta();
247 m_phi_mc_pipe = startP.phi();
248
249
250 }
251
252
253 cosmicMom = startP;
254 }
255 }
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312 SmartDataPtr<MucDigiCol> mucDigiCol( eventSvc(), "/Event/Digi/MucDigiCol" );
313 if ( !mucDigiCol )
314 {
315 log << MSG::FATAL << "Could not find MUC digi" << endmsg;
316 return ( StatusCode::FAILURE );
317 }
318
319 MucDigiCol::iterator iter4 = mucDigiCol->begin();
320 digiId = 0;
321 for ( ; iter4 != mucDigiCol->end(); iter4++, digiId++ ) {}
322 log << MSG::INFO << "MUC digis:: " << digiId << endmsg;
323 if ( digiId == 0 ) return ( StatusCode::SUCCESS );
324
325
327 int trackId = -1;
328 int muctrackId = -1;
329
330 if ( m_united != 1 )
331
332 {
333 Identifier mucID;
334 if ( !aMucRecHitContainer ) { aMucRecHitContainer = new MucRecHitContainer(); }
335 aMucRecHitContainer->Clear();
336
338 aMucRecHitContainer->SetMucRecHitCol( aMucRecHitCol );
339
340 SmartIF<IDataManagerSvc> dataManSvc( eventSvc() );
341 DataObject* mucRecHitCol;
342 eventSvc()->findObject( "/Event/Recon/MucRecHitCol", mucRecHitCol );
343 if ( mucRecHitCol != NULL )
344 {
345 dataManSvc->clearSubTree( "/Event/Recon/MucRecHitCol" );
346 eventSvc()->unregisterObject( "/Event/Recon/MucRecHitCol" );
347 }
348
349 StatusCode sc = eventSvc()->registerObject( "/Event/Recon/MucRecHitCol",
350 aMucRecHitContainer->GetMucRecHitCol() );
351
352 MucDigiCol::iterator iterMuc = mucDigiCol->begin();
353 int mucDigiId = 0;
354 for ( ; iterMuc != mucDigiCol->end(); iterMuc++, mucDigiId++ )
355 {
356 mucID = ( *iterMuc )->identify();
361
362
363
364 aMucRecHitContainer->AddHit( part, seg, gap, strip );
365 log << MSG::INFO << " digit" << mucDigiId << " : "
366 << " part " << part << " seg " << seg << " gap " << gap << " strip " << strip
367 << endmsg;
368 }
369
370 DataObject* aReconEvent;
371 eventSvc()->findObject( "/Event/Recon", aReconEvent );
372 if ( aReconEvent == NULL )
373 {
374
375 aReconEvent = new ReconEvent();
376 StatusCode sc = eventSvc()->registerObject( "/Event/Recon", aReconEvent );
377 if ( sc != StatusCode::SUCCESS )
378 {
379 log << MSG::FATAL << "Could not register ReconEvent" << endmsg;
380 return ( StatusCode::FAILURE );
381 }
382 }
383 StatusCode fr = eventSvc()->findObject( "/Event/Recon", aReconEvent );
384 if ( fr != StatusCode::SUCCESS )
385 {
386 log << MSG::WARNING << "Could not find register ReconEvent, will create it" << endmsg;
387 StatusCode sc = eventSvc()->registerObject( "/Event/Recon", aReconEvent );
388 if ( sc != StatusCode::SUCCESS )
389 {
390 log << MSG::FATAL << "Could not register ReconEvent" << endmsg;
391 return ( StatusCode::FAILURE );
392 }
393 }
394
395
396
397 DataObject* mucTrackCol;
398 eventSvc()->findObject( "/Event/Recon/RecMucTrackCol", mucTrackCol );
399 if ( mucTrackCol != NULL )
400 {
401 dataManSvc->clearSubTree( "/Event/Recon/RecMucTrackCol" );
402 eventSvc()->unregisterObject( "/Event/Recon/RecMucTrackCol" );
403 }
404
406 sc = eventSvc()->registerObject( "/Event/Recon/RecMucTrackCol", aMucTrackCol );
407 aMucTrackCol->clear();
408
409
410 SmartDataPtr<RecMucTrackCol> findMucTrackCol( eventSvc(), "/Event/Recon/RecMucTrackCol" );
411 if ( !findMucTrackCol )
412 {
413 log << MSG::FATAL << "Could not find RecMucTrackCol" << endmsg;
414 return ( StatusCode::FAILURE );
415 }
416 aMucTrackCol->clear();
417
418 log << MSG::INFO << "MaxHitsRec : " << m_maxHitsRec << endmsg;
419 if ( digiId > m_maxHitsRec )
420 return StatusCode::SUCCESS;
421
422
423
424 trackId = 0;
425 muctrackId = 0;
426 }
427 else if ( m_united == 1 )
428 {
429
430 Identifier mucID;
431 if ( !aMucRecHitContainer ) { aMucRecHitContainer = new MucRecHitContainer(); }
432 aMucRecHitContainer->Clear();
433
434 SmartDataPtr<MucRecHitCol> aMucRecHitCol( eventSvc(), "/Event/Recon/MucRecHitCol" );
435 if ( aMucRecHitCol == NULL ) { log << MSG::WARNING << "MucRecHitCol is NULL" << endmsg; }
436
437 aMucRecHitContainer->SetMucRecHitCol( aMucRecHitCol );
438
439 SmartDataPtr<RecMucTrackCol> mucTrackCol( eventSvc(), "/Event/Recon/RecMucTrackCol" );
440 if ( mucTrackCol == NULL ) { log << MSG::WARNING << "aMucTrackCol is NULL" << endmsg; }
441
442 log << MSG::INFO << "mucTrackCol size: " << mucTrackCol->size()
443 << " hitCol size: " << aMucRecHitCol->size() << endmsg;
444 aMucTrackCol = mucTrackCol;
445
446
447 SmartDataPtr<RecExtTrackCol> aExtTrackCol( eventSvc(), "/Event/Recon/RecExtTrackCol" );
448 if ( !aExtTrackCol ) { log << MSG::WARNING << "Can't find ExtTrackCol in TDS!" << endmsg; }
449
450 SmartDataPtr<RecMdcTrackCol> aMdcTrackCol( eventSvc(), "/Event/Recon/RecMdcTrackCol" );
451 if ( !aMdcTrackCol ) { log << MSG::WARNING << "Can't find MdcTrackCol in TDS!" << endmsg; }
452
453 if ( aExtTrackCol && aMdcTrackCol ) trackId = aMdcTrackCol->size();
454 muctrackId = aMucTrackCol->size();
455 }
456
457 int hasEmcUp = 0;
458 int hasEmcDown = 0;
459 SmartDataPtr<RecEmcShowerCol> aShowerCol( eventSvc(), "/Event/Recon/RecEmcShowerCol" );
460 if ( !aShowerCol )
461 {
462 log << MSG::WARNING << "Could not find RecEmcShowerCol" << endmsg;
463
464 }
465 else
466 {
467 RecEmcShowerCol::iterator iShowerCol;
468 for ( iShowerCol = aShowerCol->begin(); iShowerCol != aShowerCol->end(); iShowerCol++ )
469 {
470
471
472
473
474
475
476 if ( ( ( *iShowerCol )->position() ).phi() > 0 &&
477 ( ( *iShowerCol )->position() ).phi() < 3.1415926 )
478 hasEmcUp++;
479 else hasEmcDown++;
480 }
481 }
482 if ( m_NtOutput >= 1 )
483 {
484 m_emcUp = hasEmcUp;
485 m_emcDown = hasEmcDown;
486 }
487
488
489 m_NEvent++;
491
493 p3DRoadC->clear();
494
496
498 p2DRoad0C->clear();
499
501
503 p2DRoad1C->clear();
504 log << MSG::INFO << "Muc 2D 3D Road Container created" << endmsg;
505
506
507
508
509
510
511
512
513 MucRecHit *pHit0 = 0, *pHit1 = 0;
514 int count0, count1,
count, iGap0, iGap1;
515 int orient;
516
518 {
520 {
521 for ( int iOrient = 0; iOrient < 2; iOrient++ )
522 {
523 int nLoops = 1;
525 for ( int iLoop = 0; iLoop < nLoops; iLoop++ )
526 {
527
529 if ( m_seedtype == 1 )
530 {
533 }
534 else
535 {
536 int setgap0 = 0;
537 MucDigiCol::iterator iterMuc = mucDigiCol->begin();
538 int mucDigiId = 0;
539 Identifier mucID;
540 iGap0 = 0;
541 iGap1 = 0;
542 for ( ; iterMuc != mucDigiCol->end(); iterMuc++, mucDigiId++ )
543 {
544 mucID = ( *iterMuc )->identify();
549 int orient = 0;
550 if ( ( part == 1 && gap % 2 == 0 ) || ( part != 1 && gap % 2 == 1 ) ) orient = 1;
551
552 if ( part == iPart && seg == iSeg && orient == iOrient && setgap0 == 0 )
553 {
554 iGap0 = gap;
555 setgap0 = 1;
556 }
557 if ( part == iPart && seg == iSeg && orient == iOrient && setgap0 == 1 &&
558 gap != iGap0 )
559 { iGap1 = gap; }
560 }
561 }
562
563 if ( m_MsOutput )
564 cout << "Find seed gap in ( " << iPart << " " << iSeg << " ) gap0: " << iGap0
565 << " gap1: " << iGap1 << endl;
566
567
568 if ( iGap0 > iGap1 )
569 {
570 int tempGap = iGap0;
571 iGap0 = iGap1;
572 iGap1 = tempGap;
573 }
574 if ( iGap1 == iGap0 ) continue;
575
576 count0 = aMucRecHitContainer->GetGapHitCount( iPart, iSeg, iGap0 );
577 for ( int iHit0 = 0; iHit0 < count0; iHit0++ )
578 {
579
580 pHit0 = aMucRecHitContainer->GetHit( iPart, iSeg, iGap0, iHit0 );
581 if ( !pHit0 )
582 {
583 log << MSG::FATAL << "MucRecRoadFinder-E10 "
584 << " part " << iPart << " seg " << iSeg << " gap " << iGap0
585 << " null pointer" << endl;
586 }
587 else
588 {
589
590
591 if ( m_united == 1 && pHit0->
GetHitMode() != -1 )
continue;
592
593 count1 = aMucRecHitContainer->GetGapHitCount( iPart, iSeg, iGap1 );
594 if ( m_MsOutput )
595 cout << "part " << iPart << " seg " << iSeg << " orient " << iOrient
596 << " gap0 " << iGap0 << " count0 " << count0 << " gap1 " << iGap1
597 << " count1 " << count1 << endl;
598 for ( int iHit1 = 0; iHit1 < count1; iHit1++ )
599 {
600
601 pHit1 = aMucRecHitContainer->GetHit( iPart, iSeg, iGap1, iHit1 );
602 if ( !pHit1 )
603 {
604 log << MSG::ERROR << "MucRecRoadFinder-E10 "
605 << " part " << iPart << " seg " << iSeg << " gap " << iGap1
606 << " null pointer" << endl;
607 }
608 else
609 {
610
611
612 if ( m_united == 1 && pHit1->GetHitMode() != -1 ) continue;
613
614
615
616 MucRec2DRoad* road2D =
617 new MucRec2DRoad( iPart, iSeg, iOrient, 0.0, 0.0, 3000.0 );
618 if ( !road2D )
619 {
620 log << MSG::FATAL << "MucRecRoadFinder-E20 "
621 << "failed to create 2D road!" << endmsg;
622 continue;
623 }
625
627 log << MSG::ERROR << "pHit0->GetGap(), null pointer" << endmsg;
629 {
630
631
632
633
634
635
636 bool isseed = true;
638 pHit1->SetHitSeed( true );
639
641 if ( m_MsOutput )
643 <<
", hitId= " << pHit0->
Part() <<
" " << pHit0->
Seg() <<
" "
644 << pHit0->
Gap() <<
" " << pHit0->
Strip() << endl;
645 }
646
647 if ( pHit1->GetGap()->Orient() == iOrient )
648 {
649
650
651
652
653
655 if ( m_MsOutput )
657 << ", hitId= " << pHit1->Part() << " " << pHit1->Seg() << " "
658 << pHit1->Gap() << " " << pHit1->Strip() << endl;
659 }
660 if ( m_MsOutput )
661 cout <<
"Hit cout " << road2D->
GetTotalHits() <<
", slope "
663
664
665
666
667
668
669 for ( int i = 0; i < length; i++ )
670 {
672
673 float dXmin = kInfinity;
674 MucRecHit* pHit = 0;
675
677
678
679
680
681
682
683
684 count = aMucRecHitContainer->GetGapHitCount( iPart, iSeg, iGap );
685 for (
int iHit = 0; iHit <
count; iHit++ )
686 {
687 pHit = aMucRecHitContainer->GetHit( iPart, iSeg, iGap, iHit );
688 if ( !pHit )
689 {
690 log << MSG::FATAL << "MucRecRoadFinder-E20 null cluster pointer pHit"
691 << endmsg;
692 continue;
693 }
694 else
695 {
696
697
698 if ( m_united == 1 && pHit->
GetHitMode() != -1 )
continue;
699
700
702 if ( m_MsOutput )
703 cout << "dX = " << dX << " Win = " << Win
704 <<
", hit: " << pHit->
Part() <<
" " << pHit->
Seg() <<
" "
705 << pHit->
Gap() <<
" " << pHit->
Strip() << endl;
706
707 if ( dX < Win )
708 {
709
710
711 if ( iGap == iGap0 || iGap == iGap1 )
712 {
713
715 {
717 }
719 {
721 }
722 }
723
724
725 if ( m_onlyseedfit == 0 ) road2D->
AttachHit( pHit );
726 else
727 {
728 if ( iGap == iGap0 || iGap == iGap1 ) road2D->
AttachHit( pHit );
730 }
731 }
732 }
733 }
734
735 }
736
737
738
739
740
741
742
743 bool lastGapOK = false;
745 else
746 {
747 log << MSG::INFO <<
" 2D lastGap " << road2D->
GetLastGap() <<
" < "
749 }
750
751
752
753
754 bool firedGapsOK = false;
756 else
757 {
760 }
761
762
763 bool duplicateRoad = false;
764 int maxSharedHits = 0, sharedHits = 0;
765 if ( iOrient == 0 )
766 {
767 for ( int index = 0; index < (int)p2DRoad0C->size(); index++ )
768 { sharedHits = ( *p2DRoad0C )[index]->GetNSharedHits( road2D ); }
769 if ( maxSharedHits < sharedHits ) maxSharedHits = sharedHits;
770 }
771 else
772 {
773 for ( int index = 0; index < (int)p2DRoad1C->size(); index++ )
774 { sharedHits = ( *p2DRoad1C )[index]->GetNSharedHits( road2D ); }
775 if ( maxSharedHits < sharedHits ) maxSharedHits = sharedHits;
776 }
777
780 {
781 duplicateRoad = true;
782 log << MSG::INFO << " maxSharedHits " << maxSharedHits << " > "
784 }
785
786
787
788
789
790
791
792 if ( lastGapOK && firedGapsOK && !duplicateRoad )
793 {
794 if ( iOrient == 0 )
795 {
796 log << MSG::INFO << "Add a road0" << endmsg;
797 p2DRoad0C->add( road2D );
798 }
799 else
800 {
801 log << MSG::INFO << "Add a road1" << endmsg;
802 p2DRoad1C->add( road2D );
803 }
804 }
805 else
806 {
807
808
809 vector<MucRecHit*> road2DHits = road2D->
GetHits();
810 for ( int i = 0; i < road2DHits.size(); i++ )
811 {
812 MucRecHit* ihit = road2DHits[i];
813 if ( ihit->
Gap() == iGap0 || ihit->
Gap() == iGap1 )
814 {
817 }
818 }
819 delete road2D;
820 }
821 }
822 }
823 }
824 }
825 }
826 }
827 }
828 }
829
830 int print2DRoadInfo = 0;
831 if ( print2DRoadInfo == 1 )
832 {
833
834 cout << "In 2DRoad container : " << endl
835 << " Num of 2DRoad0 = " << p2DRoad0C->size() << endl
836 << endl;
837
838 for ( int iRoad = 0; iRoad < (int)p2DRoad0C->size(); iRoad++ )
839 {
840
841 MucRec2DRoad* road = ( *p2DRoad0C )[iRoad];
842 cout << " " << iRoad << "th 2DRoad0 :" << endl
843 <<
" Part = " << road->
GetPart() << endl
844 <<
" Seg = " << road->
GetSeg() << endl
845 <<
" Orient = " << road->
GetOrient() << endl
846 <<
" LastGap = " << road->
GetLastGap() << endl
849 <<
" Slope = " << road->
GetSlope() << endl
851 << endl;
852
853 }
854
855 cout << " Num of 2DRoad1 = " << p2DRoad1C->size() << endl << endl;
856
857 for ( int iRoad = 0; iRoad < (int)p2DRoad1C->size(); iRoad++ )
858 {
859
860 MucRec2DRoad* road = ( *p2DRoad1C )[iRoad];
861 cout << " " << iRoad << "th 2DRoad1 :" << endl
862 <<
" Part = " << road->
GetPart() << endl
863 <<
" Seg = " << road->
GetSeg() << endl
864 <<
" Orient = " << road->
GetOrient() << endl
865 <<
" LastGap = " << road->
GetLastGap() << endl
868 <<
" Slope = " << road->
GetSlope() << endl
870 << endl;
871
872 }
873 }
874
875
876
877 for ( int iRoad0 = 0; iRoad0 < (int)p2DRoad0C->size(); iRoad0++ )
878 {
879 MucRec2DRoad* road0 = ( *p2DRoad0C )[iRoad0];
880 for ( int iRoad1 = 0; iRoad1 < (int)p2DRoad1C->size(); iRoad1++ )
881 {
882 MucRec2DRoad* road1 = ( *p2DRoad1C )[iRoad1];
883
884
885 if ( !( road0 && road1 ) )
886 {
887 cout << "Null pointer to road0 or road1: "
888 << "road0 = " << road0 << "road1 = " << road1 << endl;
889 continue;
890 }
891
892
894 { continue; }
895
896 MucRec3DRoad* road3D = new MucRec3DRoad( road0, road1 );
897
898
899
900
901
902
903
904
905
906
907
908
909 bool lastGapDeltaOK = false;
911 else { cout <<
"LastGapDelta = " << road3D->
GetLastGapDelta() << endl; }
912
913 bool totalHitsDeltaOK = false;
915 else
916 {
917
918 }
919
920 bool chiSquareCutOK = false;
924 else { cout << "xChiSquare = " << xChiSquare << "yChiSquare = " << yChiSquare << endl; }
925
926 bool minLastGapOK = false;
928 else { log << MSG::INFO <<
" minLastGap = " << road3D->
GetLastGap() << endmsg; }
929
930 bool duplicateRoad = false;
931 int maxSharedHits = 0, sharedHits = 0;
932 for ( int i = 0; i < (int)p3DRoadC->size(); i++ )
933 {
934 sharedHits = ( *p3DRoadC )[i]->GetNSharedHits( road3D );
935 if ( maxSharedHits < sharedHits ) maxSharedHits = sharedHits;
936
937
938 }
940 {
941 duplicateRoad = true;
942 log << MSG::INFO << " MaxShareHits = " << maxSharedHits << endmsg;
943 }
944
945 if ( lastGapDeltaOK && totalHitsDeltaOK && chiSquareCutOK && minLastGapOK &&
946 !duplicateRoad )
947 {
948 float vx, vy, x0, y0;
949 float slope1 = 100, slope0 = 100;
952
954 {
957 }
958 else
959 {
960 vx = slope1;
962 vy = slope0;
964 }
966
967 log << MSG::INFO << "Add a 3D Road ... " << endmsg;
968
969 float startx = 0.0, starty = 0.0, startz = 0.0;
970 float sigmax = 0.0, sigmay = 0.0, sigmaz = 0.0;
971 road3D->
ProjectWithSigma( 0, startx, starty, startz, sigmax, sigmay, sigmaz );
972
973
974
975
976 float vz = 1;
977 float sign = vy / fabs( vy );
978 float signx = vx / fabs( vx );
979
981 {
982 if ( road3D->
GetSeg() > 4 )
983 {
984
985 vx *= -sign;
986 vy *= -sign;
987 vz *= -sign;
988 }
989 else if ( road3D->
GetSeg() < 2 )
990 {
991 vx *= signx;
992 vy *= signx;
993 vz *= signx;
994 }
995 else if ( road3D->
GetSeg() >= 3 && road3D->
GetSeg() <= 4 )
996 {
997 vx *= -signx;
998 vy *= -signx;
999 vz *= -signx;
1000 }
1001 else
1002 {
1003 vx *= sign;
1004 vy *= sign;
1005 vz *= sign;
1006 }
1007 }
1008 else if ( road3D->
GetPart() == 0 )
1009 {
1010
1011
1012
1013
1014
1015 }
1016 else if ( road3D->
GetPart() == 2 )
1017 {
1018
1019
1020 vx *= -1;
1021 vy *= -1;
1022 vz *= -1;
1023
1024
1025
1026 }
1027
1028 Hep3Vector mom( vx, vy, vz );
1029
1030
1031
1032
1033
1034
1035 startx /= 10;
1036 starty /= 10;
1037 startz /= 10;
1038 startx -= vx / mom.mag();
1039 starty -= vy / mom.mag();
1040 startz -= vz / mom.mag();
1041
1042
1043 RecMucTrack* aTrack = new RecMucTrack();
1046 aTrack->
SetMucPos( startx, starty, startz );
1051
1052
1053
1055 aTrack->
setId( muctrackId );
1056 trackId++;
1057 muctrackId++;
1058
1059
1060 aMucTrackCol->add( aTrack );
1062 p3DRoadC->add( road3D );
1063
1064
1065
1066 vector<MucRecHit*> attachedHits = aTrack->
GetHits();
1068 vector<float> distanceHits = aTrack->
getDistHits();
1069
1070 for ( int i = 0; i < expectedHits.size(); i++ )
1071 {
1072 MucRecHit* ihit = expectedHits[i];
1073
1074
1075 }
1076
1077 vector<int> multiHit;
1078 for ( int i = 0; i < attachedHits.size(); i++ )
1079 {
1080 MucRecHit* ihit = attachedHits[i];
1081
1082
1083 int hitnum = 0;
1084 for ( int k = 0; k < attachedHits.size(); k++ )
1085 {
1086 MucRecHit* khit = attachedHits[k];
1087 if ( ( ihit->
Part() == khit->
Part() ) && ( ihit->
Seg() == khit->
Seg() ) &&
1088 ( ihit->
Gap() == khit->
Gap() ) )
1089 hitnum++;
1090 }
1091 multiHit.push_back( hitnum );
1092
1093 }
1094
1095 for ( int i = 0; i < expectedHits.size(); i++ )
1096 {
1097
1098 MucRecHit* ihit = expectedHits[i];
1099
1100
1101
1102 int diff = -999;
1103
1104 for ( int j = 0; j < attachedHits.size(); j++ )
1105 {
1106 MucRecHit* jhit = attachedHits[j];
1107
1108
1109
1110
1111 if ( ( jhit->
Part() == ihit->
Part() ) && ( jhit->
Seg() == ihit->
Seg() ) &&
1112 ( jhit->
Gap() == ihit->
Gap() ) && attachedHits.size() == distanceHits.size() )
1113 {
1115
1116
1117 if ( m_NtOutput >= 2 )
1118 {
1119
1120 m_part = ihit->
Part();
1121 m_seg = ihit->
Seg();
1122 m_gap = ihit->
Gap();
1123 m_strip = jhit->
Strip();
1124 m_diff = diff;
1125 m_dist = distanceHits[j];
1126
1127
1128 m_angle_cosmic = -999;
1129 m_angle_updown = -999;
1130
1131
1132
1133
1137 m_multihit = multiHit[j];
1138 m_run = eventHeader->runNumber();
1139 m_event = eventHeader->eventNumber();
1140
1141 m_tuple->write();
1142 }
1143 }
1144 }
1145
1146 if ( diff == -999 )
1147 {
1148 if ( m_NtOutput >= 2 )
1149 {
1150 m_part = ihit->
Part();
1151 m_seg = ihit->
Seg();
1152 m_gap = ihit->
Gap();
1153 m_strip = ihit->
Strip();
1154 m_diff = diff;
1155 m_dist = -999;
1156 m_angle_updown = -999;
1157 m_angle_cosmic = -999;
1158
1159
1160
1161
1163 m_run = eventHeader->runNumber();
1164 m_event = eventHeader->eventNumber();
1165
1166 }
1167 }
1168
1169 }
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202 */
1203 }
1204 else
1205 {
1206
1207 delete road3D;
1208
1209 }
1210 }
1211 }
1212
1213
1214 RecMucTrack* aaTrack = 0;
1215 RecMucTrack* bbTrack = 0;
1216
1217 int hasMucUp = 0;
1218 int hasMucDown = 0;
1219 for ( int iTrack = 0; iTrack < (int)aMucTrackCol->size(); iTrack++ )
1220 {
1221 aaTrack = ( *aMucTrackCol )[iTrack];
1224 hasMucUp++;
1225 else hasMucDown++;
1226
1227 double px, py, pz, p, theta, phi;
1231
1232 if ( py < 0 ) continue;
1233
1234 if ( m_NtOutput >= 1 )
1235 {
1236
1237 m_angle_updown = -999;
1239 if ( m_angle_cosmic > 1.57 ) m_angle_cosmic = 3.14159265 - m_angle_cosmic;
1240 m_run = eventHeader->runNumber();
1241 m_event = eventHeader->eventNumber();
1242
1243 Hep3Vector rotate( -px, pz, py );
1244 theta = rotate.theta();
1245 phi = rotate.phi();
1246
1247 m_px = px;
1248 m_py = py;
1249 m_pz = pz;
1250 m_theta = theta;
1251 m_phi = phi;
1254
1255
1256
1257
1258 Hep3Vector mucPos = aaTrack->
getMucPos();
1259 double posx, posy, posz;
1260 posx = mucPos.x();
1261 posy = mucPos.y();
1262 posz = mucPos.z();
1263
1264 m_projx = -999;
1265 m_projz = -999;
1266 if ( py != 0 )
1267 {
1268 m_projx = posx - px / py * posy;
1269 m_projz = posz - pz / py * posy;
1270 }
1271
1272 }
1273 }
1274 if ( m_NtOutput >= 1 )
1275 {
1276 m_mucUp = hasMucUp;
1277 m_mucDown = hasMucDown;
1278 m_tuple->write();
1279 }
1280
1281 int forCosmic = 0;
1282 if ( aMucTrackCol->size() >= 2 && forCosmic == 1 )
1283 {
1284 for ( int iTrack = 0; iTrack < (int)aMucTrackCol->size(); iTrack++ )
1285 {
1286 log << MSG::DEBUG << "iTrack " << iTrack << " / " << (int)aMucTrackCol->size() << endmsg;
1287 aaTrack = ( *aMucTrackCol )[iTrack];
1288 if ( aaTrack->
trackId() >= 0 )
continue;
1290
1291 for ( int jTrack = iTrack + 1; jTrack < (int)aMucTrackCol->size(); jTrack++ )
1292 {
1293 bbTrack = ( *aMucTrackCol )[jTrack];
1294
1297
1298
1299 if ( fabs( mom_a.angle( mom_b ) - 3.1415926 ) < 0.2 )
1300 {
1302
1303
1304
1305
1306 }
1307
1308 if ( m_NtOutput >= 1 )
1309 {
1310 m_angle_cosmic = cosmicMom.angle( mom_a );
1311 if ( cosmicMom.angle( mom_a ) > 1.57 )
1312 m_angle_cosmic = 3.14159265 - cosmicMom.angle( mom_a );
1313
1314 m_angle_updown = fabs( mom_a.angle( mom_b ) - 3.1415926 );
1315 m_px = -999;
1316 m_py = -999;
1317 m_pz = -999;
1318 m_theta = -999;
1319 m_phi = -999;
1320 m_theta_pipe = -999;
1321 m_phi_pipe = -999;
1322 m_px_mc = -999;
1323 m_py_mc = -999;
1324 m_pz_mc = -999;
1325 m_theta_mc = -999;
1326 m_phi_mc = -999;
1327 m_theta_mc_pipe = -999;
1328 m_phi_mc_pipe = -999;
1329
1330
1331 }
1332 }
1333 }
1334 }
1335
1336 if ( p3DRoadC->size() != 0 )
1337 {
1338 log << MSG::INFO << "In 3DRoad container : "
1339 << " Num of 3DRoad = " << p3DRoadC->size() << endmsg;
1340
1341 int print2DRoadInfo = 0;
1342 if ( print2DRoadInfo == 1 )
1343 {
1344 for ( int iRoad = 0; iRoad < (int)p3DRoadC->size(); iRoad++ )
1345 {
1346 MucRec3DRoad* road = ( *p3DRoadC )[iRoad];
1347 cout << endl
1348 << " " << iRoad << "th 3DRoad :" << endl
1349 <<
" Part = " << road->
GetPart() << endl
1350 <<
" Seg = " << road->
GetSeg() << endl
1358 <<
" SlopeZX = " << road->
GetSlopeZX() << endl
1360 <<
" SlopeZY = " << road->
GetSlopeZY() << endl
1362 << " Hits Info : " << endl;
1363
1364 }
1365 }
1366
1367 m_NEventReco++;
1368 }
1369
1370
1371 for ( int i = 0; i < p3DRoadC->size(); i++ ) delete ( *p3DRoadC )[i];
1372 for ( int i = 0; i < p2DRoad0C->size(); i++ ) delete ( *p2DRoad0C )[i];
1373 for ( int i = 0; i < p2DRoad1C->size(); i++ ) delete ( *p2DRoad1C )[i];
1374
1375 p3DRoadC->clear();
1376 p2DRoad0C->clear();
1377 p2DRoad1C->clear();
1378 delete p3DRoadC;
1379 delete p2DRoad0C;
1380 delete p2DRoad1C;
1381
1382 return StatusCode::SUCCESS;
1383}
DOUBLE_PRECISION count[3]
ObjectVector< MucRec2DRoad > MucRec2DRoadContainer
ObjectVector< MucRec3DRoad > MucRec3DRoadContainer
ObjectVector< MucRecHit > MucRecHitCol
ObjectVector< RecMucTrack > RecMucTrackCol
const int kMaxDeltaLastGap
const int kMinSharedHits2D
const int kMaxDeltaTotalHits
const float kWindowSize[3][9]
const int kSearchOrder[kNSeedLoops][3][2][5]
const int kMaxSkippedGaps
const int kSearchLength[kNSeedLoops][3][2]
int maxHitsInLayer() const
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)
int GetNGapsWithHits() const
How many gaps provide hits attached to this road?
int GetTotalHits() const
How many hits in all does this road contain?
float GetReducedChiSquare() const
Chi-square parameter (per degree of freedom) of the trajectory fit.
float GetIntercept() const
Intercept of trajectory.
void AttachHit(MucRecHit *hit)
Attach the given hit to this road.
int GetLastGap() const
Which gap is the last one with hits attached to this road?
void AttachHitNoFit(MucRecHit *hit)
Attach the given hit to this road, but not fit this road.
float GetSlope() const
Slope of trajectory.
void SetMaxNSkippedGaps(const int &nGaps)
int GetPart() const
In which part was this road found?
float GetHitDistance(const MucRecHit *hit)
Distance to a hit.
int GetDegreesOfFreedom() const
How many degrees of freedom in the trajectory fit?
vector< MucRecHit * > GetHits() const
int GetSeg() const
In which segment was this road found?
int GetOrient() const
In which orientation was this road found?
float GetSlopeZX() const
Get Z-X dimension slope.
float GetSlopeZY() const
Get Z-Y dimension slope.
void TransformPhiRToXY(const float &vk, const float &vr, const float &k0, const float &r0, float &vx, float &vy, float &x0, float &y0) const
Where does the trajectory of this road intersect the reference plane?
int GetLastGapDelta() const
Difference between the last gap in the two 1-D roads.
int GetPart() const
In which part was this road found?
int GetLastGap() const
Which gap is the last one with hits attached to this road?
int GetTotalHitsDelta() const
Difference between the number of hits in the two 1-D roads.
int GetTotalHits() const
How many hits in all does this road contain?
float GetInterceptZY() const
Get Z-Y dimension intercept.
void SetSimpleFitParams(const float &m_SlopeZX, const float &m_InterceptZX, const float &m_SlopeZY, const float &m_InterceptZY)
set the fit parameters : slope and intercept for XZ and YZ.
int GetSeg() const
In which segment was this road found?
int GetDegreesOfFreedom() const
How many degrees of freedom in the trajectory fit?
void ProjectWithSigma(const int &gap, float &x, float &y, float &z, float &sigmaX, float &sigmaY, float &sigmaZ)
Where does the trajectory of this road intersect a specific gap?
float GetInterceptZX() const
Get Z-X dimension intercept.
int GetNGapsWithHits() const
How many gaps provide hits attached to this road?
float GetReducedChiSquare() const
Chi-square parameter (per degree of freedom) of the trajectory fit.
int GetMaxHitsPerGap() const
How many hits were attached in the gap with the most attached hits?
void SetHitSeed(int seed)
MucGeoGap * GetGap() const
Get geometry data for the gap containing this hit.
int Part() const
Get Part.
int Strip() const
Get Strip.
void SetHitMode(int recmode)
void TrackFinding(RecMucTrack *aTrack)
Hep3Vector getMucPos() const
start position of this track in Muc.
void SetExtMucPos(const float x, const float y, const float z)
void SetCurrentDir(const float x, const float y, const float z)
set current direction of the trajectory.
void setTrackId(const int trackId)
set the index for this track.
void SetMucMomentum(const float px, const float py, const float pz)
set start moment of the track in Muc.
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.
Hep3Vector getMucMomentum() const
Start momentum of this track in Muc.
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)
vector< float > getDistHits() const