173 {
174
175 MsgStream log(
msgSvc(), name());
176 log << MSG::INFO << "in execute()" << endreq;
177
178
179 int event, run;
180
181 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),"/Event/EventHeader");
182 if (!eventHeader) {
183 log << MSG::FATAL << "Could not find Event Header" << endreq;
184 return( StatusCode::FAILURE);
185 }
186 log << MSG::INFO << "Run: " << eventHeader->runNumber() << " Event: " << eventHeader->eventNumber() << endreq;
187
188event = eventHeader->eventNumber();
189run = eventHeader->runNumber();
190
191
192 string release = getenv(
"BES_RELEASE");
193
194
195
196 for (std::vector<FilterEvent>::iterator it = m_filter_event.begin();
197 it != m_filter_event.end(); ++it) {
198 const FilterEvent& fe = (*it);
199 if (
release == fe.bossver && run == fe.runid && event == fe.eventid) {
200 cout << "SKIP: " << fe.bossver << " "
201 << fe.runid << " "
202 << fe.eventid << std::endl;
203 return StatusCode::SUCCESS;
204 }
205 }
206
207 int digiId;
208
209
210
211 Hep3Vector cosmicMom;
212 if(m_mccosmic==1){
213 SmartDataPtr<McParticleCol> mcParticleCol(eventSvc(),"/Event/MC/McParticleCol");
214 if (!mcParticleCol) {
215 log << MSG::FATAL << "Could not find McParticle" << endreq;
216 return( StatusCode::FAILURE);
217 }
218
219 McParticleCol::iterator iter_mc = mcParticleCol->begin();
220 for (;iter_mc != mcParticleCol->end(); iter_mc++, digiId++) {
221 log << MSG::DEBUG
222 << " particleId = " << (*iter_mc)->particleProperty()
223 << endreq;
224 int pid = (*iter_mc)->particleProperty();
225
226 if(fabs(pid)!=13) continue;
227
228 HepLorentzVector initialMomentum = (*iter_mc)->initialFourMomentum();
229 Hep3Vector startP(initialMomentum.px(), initialMomentum.py(), initialMomentum.pz());
230 Hep3Vector rotate(-initialMomentum.px(),initialMomentum.pz(),initialMomentum.py());
231
232 if(m_NtOutput>=1){
233 m_px_mc = initialMomentum.px();
234 m_py_mc = initialMomentum.py();
235 m_pz_mc = initialMomentum.pz();
236
237 m_theta_mc = rotate.theta();
238 m_phi_mc = rotate.phi();
239
240 m_theta_mc_pipe = startP.theta();
241 m_phi_mc_pipe = startP.phi();
242
243
244 }
245
246
247 cosmicMom = startP;
248
249 }
250 }
251
252
253
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 SmartDataPtr<MucDigiCol> mucDigiCol(eventSvc(),"/Event/Digi/MucDigiCol");
308 if (!mucDigiCol) {
309 log << MSG::FATAL << "Could not find MUC digi" << endreq;
310 return( StatusCode::FAILURE);
311 }
312
313 MucDigiCol::iterator iter4 = mucDigiCol->begin();
314 digiId = 0;
315 for (;iter4 != mucDigiCol->end(); iter4++, digiId++) {
316 }
317 log << MSG::INFO << "MUC digis:: " << digiId << endreq;
318 if( digiId == 0) return( StatusCode::SUCCESS );
319
320
322 int trackId = -1;
323 int muctrackId = -1;
324
325 if(m_united != 1)
326 {
328 if (!aMucRecHitContainer) {
330 }
331 aMucRecHitContainer->
Clear();
332
335
336
337 SmartIF<IDataManagerSvc> dataManSvc(eventSvc());
338 DataObject *mucRecHitCol;
339 eventSvc()->findObject("/Event/Recon/MucRecHitCol",mucRecHitCol);
340 if(mucRecHitCol !=
NULL) {
341 dataManSvc->clearSubTree("/Event/Recon/MucRecHitCol");
342 eventSvc()->unregisterObject("/Event/Recon/MucRecHitCol");
343 }
344
345 StatusCode sc = eventSvc()->registerObject(
"/Event/Recon/MucRecHitCol", aMucRecHitContainer->
GetMucRecHitCol());
346
347 MucDigiCol::iterator iterMuc = mucDigiCol->begin();
348 int mucDigiId = 0;
349 for (;iterMuc != mucDigiCol->end(); iterMuc++, mucDigiId++) {
350 mucID = (*iterMuc)->identify();
355
356
357
358 aMucRecHitContainer->
AddHit(part, seg, gap, strip);
359 log << MSG::INFO << " digit" << mucDigiId << " : "
360 << " part " << part
361 << " seg " << seg
362 << " gap " << gap
363 << " strip " << strip
364 << endreq;
365 }
366
367 DataObject *aReconEvent ;
368 eventSvc()->findObject("/Event/Recon",aReconEvent);
369 if(aReconEvent==
NULL) {
370
372 StatusCode sc = eventSvc()->registerObject("/Event/Recon",aReconEvent);
373 if(sc!=StatusCode::SUCCESS) {
374 log << MSG::FATAL << "Could not register ReconEvent" <<endreq;
375 return( StatusCode::FAILURE);
376 }
377 }
378 StatusCode fr = eventSvc()->findObject("/Event/Recon",aReconEvent);
379 if(fr!=StatusCode::SUCCESS) {
380 log << MSG::WARNING << "Could not find register ReconEvent, will create it" <<endreq;
381 StatusCode sc = eventSvc()->registerObject("/Event/Recon",aReconEvent);
382 if(sc!=StatusCode::SUCCESS) {
383 log << MSG::FATAL << "Could not register ReconEvent" <<endreq;
384 return( StatusCode::FAILURE);
385 }
386 }
387
388
389
390 DataObject *mucTrackCol;
391 eventSvc()->findObject("/Event/Recon/RecMucTrackCol",mucTrackCol);
392 if(mucTrackCol !=
NULL) {
393 dataManSvc->clearSubTree("/Event/Recon/RecMucTrackCol");
394 eventSvc()->unregisterObject("/Event/Recon/RecMucTrackCol");
395 }
396
398 sc = eventSvc()->registerObject("/Event/Recon/RecMucTrackCol", aMucTrackCol);
399 aMucTrackCol->clear();
400
401
402 SmartDataPtr<RecMucTrackCol> findMucTrackCol(eventSvc(),"/Event/Recon/RecMucTrackCol");
403 if (!findMucTrackCol) {
404 log << MSG::FATAL << "Could not find RecMucTrackCol" << endreq;
405 return( StatusCode::FAILURE);
406 }
407 aMucTrackCol->clear();
408
409
410 log << MSG::INFO <<"MaxHitsRec : "<<m_maxHitsRec<< endreq;
411 if(digiId> m_maxHitsRec) return StatusCode::SUCCESS;
412
413
414
415 trackId = 0;
416 muctrackId = 0;
417 }
418 else if(m_united == 1){
419
421 if (!aMucRecHitContainer) {
423 }
424 aMucRecHitContainer->
Clear();
425
426 SmartDataPtr<MucRecHitCol> aMucRecHitCol (eventSvc(),"/Event/Recon/MucRecHitCol");
427 if(aMucRecHitCol ==
NULL) {
428 log << MSG::WARNING << "MucRecHitCol is NULL" << endreq;
429 }
430
432
433 SmartDataPtr<RecMucTrackCol> mucTrackCol (eventSvc(),"/Event/Recon/RecMucTrackCol");
434 if(mucTrackCol ==
NULL) {
435 log << MSG::WARNING << "aMucTrackCol is NULL" << endreq;
436 }
437
438 log << MSG::INFO <<"mucTrackCol size: "<<mucTrackCol->size()<<" hitCol size: "<<aMucRecHitCol->size()<<endreq;
439 aMucTrackCol = mucTrackCol;
440
441
442 SmartDataPtr<RecExtTrackCol> aExtTrackCol(eventSvc(),"/Event/Recon/RecExtTrackCol");
443 if (!aExtTrackCol) {
444 log << MSG::WARNING << "Can't find ExtTrackCol in TDS!" << endreq;
445 }
446
447 SmartDataPtr<RecMdcTrackCol> aMdcTrackCol(eventSvc(),"/Event/Recon/RecMdcTrackCol");
448 if (!aMdcTrackCol) {
449 log << MSG::WARNING << "Can't find MdcTrackCol in TDS!" << endreq;
450 }
451
452 if( aExtTrackCol && aMdcTrackCol ) trackId = aMdcTrackCol->size();
453 muctrackId = aMucTrackCol->size();
454 }
455
456 int hasEmcUp = 0;
457 int hasEmcDown = 0;
458 SmartDataPtr<RecEmcShowerCol> aShowerCol(eventSvc(),"/Event/Recon/RecEmcShowerCol");
459 if (!aShowerCol) {
460 log << MSG::WARNING << "Could not find RecEmcShowerCol" << endreq;
461
462 }
463 else{
464 RecEmcShowerCol::iterator iShowerCol;
465 for(iShowerCol=aShowerCol->begin();
466 iShowerCol!=aShowerCol->end();
467 iShowerCol++){
468
469
470
471
472
473
474 if(((*iShowerCol)->position()).phi()>0&&((*iShowerCol)->position()).phi()<3.1415926) hasEmcUp++;
475 else hasEmcDown++;
476 }
477 }
478 if(m_NtOutput >= 1){
479 m_emcUp = hasEmcUp; m_emcDown = hasEmcDown;
480 }
481
482
483 m_NEvent++;
485
486 if (!p3DRoadC) {
488 }
489 p3DRoadC->clear();
490
492
493 if (!p2DRoad0C) {
495 }
496 p2DRoad0C->clear();
497
499
500 if (!p2DRoad1C) {
502 }
503 p2DRoad1C->clear();
504 log << MSG::INFO << "Muc 2D 3D Road Container created" << endreq;
505
506
507
508
509
510
511
512
514 int count0, count1,
count, iGap0, iGap1;
515 int orient;
516
519 for (int iOrient = 0; iOrient < 2; iOrient++) {
520 int nLoops = 1;
522 for (int iLoop = 0; iLoop < nLoops; iLoop++) {
523
525 if(m_seedtype == 1){
528 }
529 else {
530 int setgap0 = 0;
531 MucDigiCol::iterator iterMuc = mucDigiCol->begin();
532 int mucDigiId = 0;
534 iGap0 = 0; iGap1 = 0;
535 for (;iterMuc != mucDigiCol->end(); iterMuc++, mucDigiId++) {
536 mucID = (*iterMuc)->identify();
541 int orient = 0;
542 if ( (part == 1 && gap % 2 == 0) || (part != 1 && gap % 2 == 1) ) orient = 1;
543
544 if(part == iPart && seg == iSeg && orient == iOrient && setgap0 == 0){
545 iGap0 = gap;
546 setgap0 = 1;
547 }
548 if(part == iPart && seg == iSeg && orient == iOrient && setgap0 == 1 && gap != iGap0 ){
549 iGap1 = gap;
550 }
551 }
552 }
553
554 if(m_MsOutput) cout <<"Find seed gap in ( "<<iPart<<" "<<iSeg<<" ) gap0: "<<iGap0<<" gap1: "<<iGap1<<endl;
555
556
557 if(iGap0 > iGap1){
558 int tempGap = iGap0;
559 iGap0 = iGap1;
560 iGap1 = tempGap;
561 }
562 if(iGap1 == iGap0) continue;
563
565 for (int iHit0 = 0; iHit0 < count0; iHit0++) {
566
567 pHit0 = aMucRecHitContainer->
GetHit(iPart, iSeg, iGap0, iHit0);
568 if (!pHit0) {
569 log << MSG::FATAL << "MucRecRoadFinder-E10 " << " part " << iPart
570 << " seg " << iSeg << " gap " << iGap0 << " null pointer"
571 << endl;
572 }
573 else {
574
575
576 if(m_united == 1 && pHit0->
GetHitMode() != -1)
continue;
577
579 if(m_MsOutput) cout << "part " << iPart << " seg " << iSeg << " orient " << iOrient
580 << " gap0 " << iGap0 << " count0 " << count0
581 << " gap1 " << iGap1 << " count1 " << count1 << endl;
582 for (int iHit1 = 0; iHit1 < count1; iHit1++) {
583
584 pHit1 = aMucRecHitContainer->
GetHit(iPart, iSeg, iGap1, iHit1);
585 if (!pHit1) {
586 log << MSG::ERROR << "MucRecRoadFinder-E10 " << " part " << iPart
587 << " seg " << iSeg << " gap " << iGap1 << " null pointer"
588 << endl;
589 } else {
590
591
592 if(m_united == 1 && pHit1->GetHitMode() != -1) continue;
593
594
595
597 if (!road2D) {
598 log << MSG::FATAL << "MucRecRoadFinder-E20 " << "failed to create 2D road!" << endreq;
599 continue;
600 }
602
603 if (!pHit0->
GetGap()) log << MSG::ERROR <<
"pHit0->GetGap(), null pointer" << endreq;
605
606
607
608
609
610 bool isseed = true;
612 pHit1->SetHitSeed(true);
613
615 if(m_MsOutput) cout <<
"pHit0 attached, " << road2D->
GetTotalHits()
616 <<
", hitId= "<<pHit0->
Part()<<
" "<<pHit0->
Seg()<<
" "<<pHit0->
Gap()<<
" "<<pHit0->
Strip()<<endl;
617 }
618
619 if (pHit1->GetGap()->Orient() == iOrient) {
620
621
622
623
625 if(m_MsOutput) cout <<
"pHit1 attached, " << road2D->
GetTotalHits()
626 << ", hitId= "<<pHit1->Part()<<" "<<pHit1->Seg()<<" "<<pHit1->Gap()<<" "<<pHit1->Strip()<<endl;
627 }
628 if(m_MsOutput) cout <<
"Hit cout " << road2D->
GetTotalHits() <<
", slope " << road2D->
GetSlope() << endl;
629
630
631
632
633
634
635 for (int i = 0; i < length; i++) {
637
638 float dXmin = kInfinity;
640
642
643
644
645
646
647
648
650 for (
int iHit = 0; iHit <
count; iHit++) {
651 pHit = aMucRecHitContainer->
GetHit(iPart, iSeg, iGap, iHit);
652 if (!pHit) {
653 log << MSG::FATAL << "MucRecRoadFinder-E20 null cluster pointer pHit" << endreq;
654 continue;
655 }
656 else {
657
658
659 if(m_united == 1 && pHit->
GetHitMode() != -1)
continue;
660
661
663 if(m_MsOutput) cout<<
"dX = "<<dX<<
" Win = "<<Win<<
", hit: "<<pHit->
Part()<<
" "<<pHit->
Seg()<<
" "<<pHit->
Gap()<<
" "<<pHit->
Strip()<<endl;
664
665 if (dX < Win) {
666
667
668 if(iGap == iGap0 || iGap == iGap1) {
671 }
674 }
675 }
676
677 if(m_onlyseedfit == 0)road2D->
AttachHit(pHit);
678 else {
679 if(iGap == iGap0 || iGap == iGap1) road2D->
AttachHit(pHit);
681 }
682 }
683 }
684 }
685
686
687 }
688
689
690
691
692
693
694
695
696 bool lastGapOK = false;
698 lastGapOK = true;
699 }
700 else {
702 }
703
704
705
706
707 bool firedGapsOK = false;
709 firedGapsOK = true;
710 }
711 else {
713 }
714
715
716 bool duplicateRoad = false;
717 int maxSharedHits = 0, sharedHits = 0;
718 if (iOrient == 0) {
719 for (int index = 0; index < (int)p2DRoad0C->size(); index++) {
720 sharedHits =(*p2DRoad0C)[index]->GetNSharedHits(road2D);
721 }
722 if (maxSharedHits < sharedHits) maxSharedHits = sharedHits;
723 }
724 else {
725 for (int index = 0; index < (int)p2DRoad1C->size(); index++) {
726 sharedHits = (*p2DRoad1C)[index]->GetNSharedHits(road2D);
727 }
728 if (maxSharedHits < sharedHits) maxSharedHits = sharedHits;
729 }
730
733 duplicateRoad = true;
734 log<<MSG::INFO <<
" maxSharedHits " << maxSharedHits <<
" > " <<
kMinSharedHits2D << endreq;
735 }
736
737
738
739
740
741
742
743 if (lastGapOK && firedGapsOK && !duplicateRoad) {
744 if (iOrient == 0) {
745 log<<MSG::INFO << "Add a road0" << endreq;
746 p2DRoad0C->add(road2D);
747 }
748 else {
749 log<<MSG::INFO << "Add a road1" << endreq;
750 p2DRoad1C->add(road2D);
751 }
752 }
753 else {
754
755
756 vector<MucRecHit*> road2DHits = road2D->
GetHits();
757 for(int i=0; i< road2DHits.size(); i++)
758 {
760 if(ihit->
Gap() == iGap0 || ihit->
Gap() == iGap1){
763 }
764 }
765 delete road2D;
766 }
767 }
768 }
769 }
770 }
771 }
772 }
773 }
774 }
775
776 int print2DRoadInfo = 0;
777 if (print2DRoadInfo == 1) {
778
779 cout << "In 2DRoad container : " << endl
780 << " Num of 2DRoad0 = " << p2DRoad0C->size() << endl
781 << endl;
782
783 for (int iRoad = 0; iRoad < (int)p2DRoad0C->size(); iRoad++) {
784
786 cout << " " << iRoad << "th 2DRoad0 :" << endl
787 <<
" Part = " << road->
GetPart() << endl
788 <<
" Seg = " << road->
GetSeg() << endl
789 <<
" Orient = " << road->
GetOrient() << endl
790 <<
" LastGap = " << road->
GetLastGap() << endl
793 <<
" Slope = " << road->
GetSlope() << endl
795 << endl;
796
797 }
798
799 cout << " Num of 2DRoad1 = " << p2DRoad1C->size() << endl
800 << endl;
801
802 for ( int iRoad = 0; iRoad < (int)p2DRoad1C->size(); iRoad++) {
803
805 cout << " " << iRoad << "th 2DRoad1 :" << endl
806 <<
" Part = " << road->
GetPart() << endl
807 <<
" Seg = " << road->
GetSeg() << endl
808 <<
" Orient = " << road->
GetOrient() << endl
809 <<
" LastGap = " << road->
GetLastGap() << endl
812 <<
" Slope = " << road->
GetSlope() << endl
814 << endl;
815
816 }
817 }
818
819
820
821 for ( int iRoad0 = 0; iRoad0 < (int)p2DRoad0C->size(); iRoad0++) {
823 for ( int iRoad1 = 0; iRoad1 < (int)p2DRoad1C->size(); iRoad1++){
825
826
827 if ( !(road0 &&road1) ) {
828 cout << "Null pointer to road0 or road1: "
829 << "road0 = " << road0
830 << "road1 = " << road1
831 << endl;
832 continue;
833 }
834
835
838 continue;
839 }
840
842
843
844
845
846
847
848
849
850
851
852
853
854 bool lastGapDeltaOK = false;
856 lastGapDeltaOK = true;
857 }
858 else {
860 }
861
862 bool totalHitsDeltaOK = false;
864 totalHitsDeltaOK = true;
865 }
866 else {
867
868 }
869
870 bool chiSquareCutOK = false;
875 chiSquareCutOK = true;
876 }
877 else {
878 cout << "xChiSquare = " << xChiSquare
879 << "yChiSquare = " << yChiSquare
880 << endl;
881 }
882
883 bool minLastGapOK = false;
885 minLastGapOK = true;
886 }
887 else {
888 log<<MSG::INFO <<
" minLastGap = " << road3D->
GetLastGap() << endreq;
889 }
890
891 bool duplicateRoad = false;
892 int maxSharedHits = 0, sharedHits = 0;
893 for ( int i = 0; i < (int)p3DRoadC->size(); i++){
894 sharedHits =(*p3DRoadC)[i]->GetNSharedHits(road3D);
895 if ( maxSharedHits < sharedHits) maxSharedHits = sharedHits;
896
897
898 }
901 duplicateRoad = true;
902 log<<MSG::INFO << " MaxShareHits = " << maxSharedHits << endreq;
903 }
904
905 if ( lastGapDeltaOK &&
906 totalHitsDeltaOK &&
907 chiSquareCutOK &&
908 minLastGapOK &&
909 !duplicateRoad ) {
910 float vx, vy, x0, y0;
911 float slope1 = 100, slope0 = 100;
914
918 vx, vy, x0, y0);
919 }
920 else {
921 vx = slope1;
923 vy = slope0;
925 }
927
928 log<<MSG::INFO << "Add a 3D Road ... " << endreq;
929
930 float startx = 0.0, starty = 0.0, startz = 0.0;
931 float sigmax = 0.0, sigmay = 0.0, sigmaz = 0.0;
932 road3D->
ProjectWithSigma(0, startx, starty, startz, sigmax, sigmay, sigmaz);
933
934
935
936
937 float vz = 1;
938 float sign = vy/fabs(vy);
939 float signx = vx/fabs(vx);
940
943
944 vx *= -sign;
945 vy *= -sign;
946 vz *= -sign;
947 }
948 else if(road3D->
GetSeg()<2){
949 vx *= signx;
950 vy *= signx;
951 vz *= signx;
952 }
954 vx *= -signx;
955 vy *= -signx;
956 vz *= -signx;
957 }
958 else{
959 vx *= sign;
960 vy *= sign;
961 vz *= sign;
962 }
963 }
964 else if(road3D->
GetPart() == 0){
965
966
967
968
969
970 }
971 else if(road3D->
GetPart() == 2){
972
973
974 vx *= -1;
975 vy *= -1;
976 vz *= -1;
977
978
979
980
981 }
982
983
984 Hep3Vector mom(vx, vy, vz);
985
986
987
988
989
990
991 startx /= 10; starty /= 10; startz /= 10;
992 startx -= vx/mom.mag(); starty -= vy/mom.mag(); startz -= vz/mom.mag();
993
994
998 aTrack->
SetMucPos(startx, starty, startz);
1003
1004
1005
1007 aTrack->
setId(muctrackId);
1008 trackId++;
1009 muctrackId++;
1010
1011
1012 aMucTrackCol->add(aTrack);
1014 p3DRoadC->add(road3D);
1015
1016
1017
1018 vector<MucRecHit*> attachedHits = aTrack->
GetHits();
1020 vector<float> distanceHits = aTrack->
getDistHits();
1021
1022 for(int i=0; i< expectedHits.size(); i++)
1023 {
1025
1026 }
1027
1028 vector<int> multiHit;
1029 for(int i=0; i< attachedHits.size(); i++)
1030 {
1032
1033
1034 int hitnum = 0;
1035 for(int k=0; k < attachedHits.size(); k++){
1038 hitnum++;
1039 }
1040 multiHit.push_back(hitnum);
1041
1042
1043 }
1044
1045 for(int i=0; i< expectedHits.size(); i++)
1046 {
1047
1049
1050
1051 int diff = -999;
1052
1053 for(int j=0; j< attachedHits.size(); j++){
1055
1056
1057
1058 if((jhit->
Part()==ihit->
Part())&&(jhit->
Seg()==ihit->
Seg())&&(jhit->
Gap()==ihit->
Gap())&&attachedHits.size()==distanceHits.size())
1059 {
1061
1062
1063 if(m_NtOutput>=2){
1064
1065 m_part = ihit->
Part(); m_seg = ihit->
Seg(); m_gap = ihit->
Gap();
1066 m_strip = jhit->
Strip();
1067 m_diff = diff;
1068 m_dist = distanceHits[j];
1069
1070
1071 m_angle_cosmic = -999;
1072 m_angle_updown = -999;
1073
1074
1075
1079 m_multihit = multiHit[j];
1080 m_run = eventHeader->runNumber();
1081 m_event = eventHeader->eventNumber();
1082
1083 m_tuple->write();
1084 }
1085 }
1086
1087
1088 }
1089
1090
1091
1092 if(diff == -999) {
1093 if(m_NtOutput>=2){
1094 m_part = ihit->
Part(); m_seg = ihit->
Seg(); m_gap = ihit->
Gap();
1095 m_strip = ihit->
Strip();
1096 m_diff = diff;
1097 m_dist = -999;
1098 m_angle_updown = -999;
1099 m_angle_cosmic = -999;
1100
1101
1102
1104 m_run = eventHeader->runNumber();
1105 m_event = eventHeader->eventNumber();
1106
1107 }
1108 }
1109
1110
1111 }
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144 */
1145
1146 }
1147 else {
1148
1149 delete road3D;
1150
1151 }
1152 }
1153 }
1154
1155
1156
1159
1160 int hasMucUp = 0;
1161 int hasMucDown = 0;
1162 for(int iTrack = 0; iTrack < (int)aMucTrackCol->size(); iTrack++) {
1163 aaTrack = (*aMucTrackCol)[iTrack];
1165 else hasMucDown++;
1166
1167
1168 double px,py,pz,p,theta,phi;
1172
1173 if(py<0)continue;
1174
1175 if(m_NtOutput>=1){
1176
1177 m_angle_updown = -999;
1179 if(m_angle_cosmic>1.57) m_angle_cosmic = 3.14159265 - m_angle_cosmic;
1180 m_run = eventHeader->runNumber();
1181 m_event = eventHeader->eventNumber();
1182
1183 Hep3Vector rotate(-px,pz,py);
1184 theta = rotate.theta();
1185 phi = rotate.phi();
1186
1187 m_px = px; m_py = py; m_pz = pz;
1188 m_theta = theta; m_phi = phi;
1191
1192
1193
1194
1195 Hep3Vector mucPos = aaTrack->
getMucPos();
1196 double posx, posy, posz;
1197 posx = mucPos.x(); posy = mucPos.y(); posz = mucPos.z();
1198
1199 m_projx = -999; m_projz = -999;
1200 if(py!=0){
1201 m_projx = posx - px/py*posy;
1202 m_projz = posz - pz/py*posy;
1203 }
1204
1205 }
1206
1207 }
1208 if(m_NtOutput>=1){
1209 m_mucUp = hasMucUp; m_mucDown = hasMucDown;
1210 m_tuple->write();
1211 }
1212
1213 int forCosmic = 0;
1214 if(aMucTrackCol->size()>=2 && forCosmic == 1){
1215 for(int iTrack = 0; iTrack < (int)aMucTrackCol->size(); iTrack++) {
1216 log << MSG::DEBUG << "iTrack " << iTrack << " / " <<(int)aMucTrackCol->size()<<endreq;
1217 aaTrack = (*aMucTrackCol)[iTrack];
1218 if(aaTrack->
trackId()>=0)
continue;
1220
1221 for(int jTrack = iTrack+1; jTrack < (int)aMucTrackCol->size(); jTrack++){
1222 bbTrack = (*aMucTrackCol)[jTrack];
1223
1226
1227
1228 if(fabs(mom_a.angle(mom_b) - 3.1415926)<0.2)
1229 {
1231
1232
1233
1234
1235
1236 }
1237
1238 if(m_NtOutput>=1){
1239 m_angle_cosmic = cosmicMom.angle(mom_a);
1240 if(cosmicMom.angle(mom_a)>1.57) m_angle_cosmic = 3.14159265 - cosmicMom.angle(mom_a);
1241
1242 m_angle_updown = fabs(mom_a.angle(mom_b) - 3.1415926);
1243 m_px = -999; m_py = -999; m_pz = -999; m_theta = -999; m_phi = -999; m_theta_pipe = -999; m_phi_pipe = -999;
1244 m_px_mc = -999; m_py_mc = -999; m_pz_mc = -999; m_theta_mc = -999; m_phi_mc = -999;
1245 m_theta_mc_pipe = -999; m_phi_mc_pipe = -999;
1246
1247
1248 }
1249 }
1250
1251 }
1252
1253
1254 }
1255
1256 if( p3DRoadC->size() !=0 ) {
1257 log<<MSG::INFO << "In 3DRoad container : "
1258 << " Num of 3DRoad = " << p3DRoadC->size() <<endreq;
1259
1260 int print2DRoadInfo = 0;
1261 if (print2DRoadInfo == 1) {
1262 for ( int iRoad = 0; iRoad < (int)p3DRoadC->size(); iRoad++) {
1264 cout << endl << " " << iRoad << "th 3DRoad :" << endl
1265 <<
" Part = " << road->
GetPart() << endl
1266 <<
" Seg = " << road->
GetSeg() << endl
1274 <<
" SlopeZX = " << road->
GetSlopeZX() << endl
1276 <<
" SlopeZY = " << road->
GetSlopeZY() << endl
1278 << " Hits Info : " << endl;
1279
1280 }
1281 }
1282
1283 m_NEventReco ++;
1284 }
1285
1286
1287 for(int i = 0 ; i < p3DRoadC->size(); i++)
1288 delete (*p3DRoadC)[i];
1289 for(int i = 0 ; i < p2DRoad0C->size(); i++)
1290 delete (*p2DRoad0C)[i];
1291 for(int i = 0 ; i < p2DRoad1C->size(); i++)
1292 delete (*p2DRoad1C)[i];
1293
1294 p3DRoadC->clear();
1295 p2DRoad0C->clear();
1296 p2DRoad1C->clear();
1297 delete p3DRoadC;
1298 delete p2DRoad0C;
1299 delete p2DRoad1C;
1300 return StatusCode::SUCCESS;
1301}
DOUBLE_PRECISION count[3]
ObjectVector< MucRec2DRoad > MucRec2DRoadContainer
ObjectVector< MucRec3DRoad > MucRec3DRoadContainer
ObjectVector< MucRecHit > MucRecHitCol
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]
ObjectVector< RecMucTrack > RecMucTrackCol
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 Clear()
Remove all hit objects from the container, and destroy them.
MucRecHit * GetHit(const MucRecHitID hitID)
Get a MucRecHit object by hit identifier.
void AddHit(const Identifier id)
MucRecHitCol * GetMucRecHitCol()
Get MucRecHitCol pointer.
void SetMucRecHitCol(MucRecHitCol *p)
int GetGapHitCount(const MucRecHitID gapID)
How many hits are there in this gap?
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)
set start position of ext track in Muc. (compute from MdcPos MdcMomentum or get from ExtTrack)
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