275 {
276
277 MsgStream log(
msgSvc(), name());
278 log << MSG::INFO << "in execute()" << endreq;
279
280
281 SmartDataPtr<RecEsTimeCol> evTimeCol(eventSvc(),"/Event/Recon/RecEsTimeCol");
282 if (!evTimeCol) {
283 log << MSG::WARNING<< "Could not retrieve RecEsTimeCol , use t0=0" << endreq;
284 m_bunchT0=0.;
285 }else{
286 RecEsTimeCol::iterator iter_evt = evTimeCol->begin();
287 if (iter_evt != evTimeCol->end()){
288 m_bunchT0 = (*iter_evt)->getTest()*1.e-9;
289 }
290 }
291
292
293
294
295 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),"/Event/EventHeader");
296 if (!eventHeader) {
297 log << MSG::FATAL << "Could not find Event Header" << endreq;
298 return( StatusCode::FAILURE);
299 }
300
301
302 DataObject *aTrackCol;
303 DataObject *aRecHitCol;
304 SmartIF<IDataManagerSvc> dataManSvc(eventSvc());
305 if(!m_combineTracking){
306 eventSvc()->findObject("/Event/Recon/RecMdcTrackCol",aTrackCol);
307 if(aTrackCol != NULL) {
308 dataManSvc->clearSubTree("/Event/Recon/RecMdcTrackCol");
309 eventSvc()->unregisterObject("/Event/Recon/RecMdcTrackCol");
310 }
311 eventSvc()->findObject("/Event/Recon/RecMdcHitCol",aRecHitCol);
312 if(aRecHitCol != NULL) {
313 dataManSvc->clearSubTree("/Event/Recon/RecMdcHitCol");
314 eventSvc()->unregisterObject("/Event/Recon/RecMdcHitCol");
315 }
316 }
317
319 eventSvc()->findObject("/Event/Recon/RecMdcTrackCol",aTrackCol);
320 if (aTrackCol) {
322 }else{
325 if(!sc.isSuccess()) {
326 log << MSG::FATAL << " Could not register RecMdcTrack collection" <<endreq;
327 return StatusCode::FAILURE;
328 }
329 }
330 int nTdsTk = (int) trackList->size();
331 int nFitSucess = 0;
332
334 eventSvc()->findObject("/Event/Recon/RecMdcHitCol",aRecHitCol);
335 if (aRecHitCol) {
337 }else{
340 if(!sc.isSuccess()) {
341 log << MSG::FATAL << " Could not register RecMdcHit collection" <<endreq;
342 return StatusCode::FAILURE;
343 }
344 }
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361 t_eventNum=eventHeader->eventNumber();
362 t_runNum=eventHeader->runNumber();
363 m_eventNum=t_eventNum;
364 m_runNum=t_runNum;
365 log << MSG::INFO << "MdcHoughFinder: retrieved event: " << eventHeader->eventNumber() << " run: " << eventHeader->runNumber() << endreq;
366
367
368 int mc_particle=GetMcInfo();
369
370
371 if(
abs(m_costaTruth)<=0.83){m_cosCut=1;}
372 else{m_cosCut=0;}
373
374
375
376
377
378
379
380
381
382 vector<double> vec_u;
383 vector<double> vec_v;
384 vector<double> vec_p;
385 vector<double> vec_x_east;
386 vector<double> vec_y_east;
387 vector<double> vec_z_east;
388 vector<double> vec_x_west;
389 vector<double> vec_y_west;
390 vector<double> vec_z_west;
391 vector<double> vec_z_Mc;
392 vector<double> vec_x;
393 vector<double> vec_y;
394 vector<double> vec_z;
395 vector<int> vec_layer;
396 vector<int> vec_wire;
397 vector<int> vec_slant;
398 vector<double> vec_zStereo;
399 vector<double> l;
400
401 vector<int> vec_layer_Mc;
402 vector<int> vec_wire_Mc;
403 t_maxP=-999.;
404 t_minP=999.;
405
406
407 int t_nHit_Mc;
408 int digiId_Mc=0;
409 int nHitAxial_Mc=0;
410
411 SmartDataPtr<Event::MdcMcHitCol> mcMdcMcHitCol(eventSvc(),"/Event/MC/MdcMcHitCol");
412 if (!mcMdcMcHitCol) {
413 log << MSG::INFO << "Could not find MdcMcHit" << endreq;
414 }else{
415 Event::MdcMcHitCol::iterator iterMcHit = mcMdcMcHitCol->begin();
416
417 for(; iterMcHit != mcMdcMcHitCol->end(); ++iterMcHit,digiId_Mc++) {
421
422 vec_layer_Mc.push_back(layerId_Mc);
423 vec_wire_Mc.push_back(wireId_Mc);
424
425
426
427
428 m_layer_Mc[digiId_Mc]=layerId_Mc;
429 m_cell_Mc[digiId_Mc]=wireId_Mc;
430
431 if(m_data==0){
432 if ((layerId_Mc>=8&&layerId_Mc<=19)||(layerId_Mc>=36)) {
433 nHitAxial_Mc++;}
434 if(m_debug>0) {cout<<"("<<layerId_Mc<<","<<wireId_Mc<<")"<<"nHitAxial_Mc: "<<nHitAxial_Mc<<endl;}
435 m_layer[digiId_Mc]=layerId_Mc;
436 m_cell[digiId_Mc]=wireId_Mc;
437 const MdcGeoWire *geowir =m_mdcGeomSvc->
Wire(layerId_Mc,wireId_Mc);
440
441 m_x_east[digiId_Mc]=eastP.x();
442 m_y_east[digiId_Mc]=eastP.y();
443 m_z_east[digiId_Mc]=eastP.z();
444 m_x_west[digiId_Mc]=westP.x();
445 m_y_west[digiId_Mc]=westP.y();
446 m_z_west[digiId_Mc]=westP.z();
447
448 vec_x_east.push_back(eastP.x());
449 vec_y_east.push_back(eastP.y());
450 vec_z_east.push_back(eastP.z());
451 vec_x_west.push_back(westP.x());
452 vec_y_west.push_back(westP.y());
453 vec_z_west.push_back(westP.z());
454
455 double x = (*iterMcHit)->getPositionX()/10.;
456 double y = (*iterMcHit)->getPositionY()/10.;
457 double z = (*iterMcHit)->getPositionZ()/10.;
458
459 double u=CFtrans(x,y);
460 double v=CFtrans(y,x);
461 double p=sqrt(u*u+
v*
v);
462
463 vec_x.push_back(x);
464 vec_y.push_back(y);
465 vec_z.push_back(z);
466 vec_u.push_back(u);
468 vec_p.push_back(p);
469
471 m_y[digiId_Mc]=y;
472 m_z[digiId_Mc]=z;
473 m_u[digiId_Mc]=u;
475 m_p[digiId_Mc]=p;
476
477 int layer= layerId_Mc;
478 vec_slant.push_back(SlantId(layer));
479 m_slant[digiId_Mc]=SlantId(layer);
480 if (m_slant!=0)
481 {cout<<"layer: "<<layerId_Mc<<"wire: "<<wireId_Mc<<"x_east: "<<m_x_east[digiId_Mc]<<"y_east: "<<m_y_east[digiId_Mc]<<endl;}
482 }
483 }
484 }
485
486 t_nHit_Mc=digiId_Mc;
487 m_nHit_Mc=digiId_Mc;
488 if(m_data==0) {m_nHit=digiId_Mc;}
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505 vector<int> vec_hitSignal;
506 vector<int> vec_track_index;
507 int track_index_max=0;
508 uint32_t getDigiFlag = 0;
513
514 cout<<"MdcDigiVec: "<<mdcDigiVec.size()<<endl;
515 MdcDigiVec::iterator iter1 = mdcDigiVec.begin();
516 int t_nHit;
517 int digiId = 0;
518 int nHitAxial = 0;
519 int nHitLayer[43];
520 int nHitSignal=0;
521 int nHitAxialSignal=0;
522
523 for (;iter1 != mdcDigiVec.end(); iter1++, digiId++) {
524 int track_index=(*iter1)->getTrackIndex();
525
526 if(track_index>=1000) track_index-=1000;
527 vec_track_index.push_back(track_index);
528 if(track_index>=0){
529 nHitSignal++;
530 m_hitSignal[digiId]=1;
531 }
532
536
537
538
539
540 if ((layerId>=8&&layerId<=19)||(layerId>=36)) {
541 nHitAxial++;}
542 if (((layerId>=8&&layerId<=19)||(layerId>=36))&&track_index>=0) {
543 nHitAxialSignal++;}
544
545 vec_layer.push_back(layerId);
546 vec_wire.push_back(wireId);
547
548 nHitLayer[layerId]++;
549 m_layerNhit[layerId]=nHitLayer[layerId];
550
554
555 vec_x_east.push_back(eastP.x());
556 vec_y_east.push_back(eastP.y());
557 vec_z_east.push_back(eastP.z());
558 vec_x_west.push_back(westP.x());
559 vec_y_west.push_back(westP.y());
560 vec_z_west.push_back(westP.z());
561
562 m_x_east[digiId]=eastP.x();
563 m_y_east[digiId]=eastP.y();
564 m_z_east[digiId]=eastP.z();
565 m_x_west[digiId]=westP.x();
566 m_y_west[digiId]=westP.y();
567 m_z_west[digiId]=westP.z();
568 if(m_debug>0) {cout<<"event: "<<t_eventNum<<" "<<"layer: "<<layerId<<" "<<"wireId: "<<wireId<<" "<<"zeast: "<<vec_z_east.at(digiId)<<" "<<"zwest: "<<vec_z_west.at(digiId)<<" "<<endl;}
569
570 double x =(eastP.x()+westP.x())/2.;
571 double y =(eastP.y()+westP.y())/2.;
572 vec_x.push_back((vec_x_east[digiId]+vec_x_west[digiId])/2);
573 vec_y.push_back((vec_y_east[digiId]+vec_y_west[digiId])/2);
574 m_x[digiId]=(vec_x_east[digiId]+vec_x_west[digiId])/2;
575 m_y[digiId]=(vec_y_east[digiId]+vec_y_west[digiId])/2;
576 double u=CFtrans(x,y);
577 double v=CFtrans(y,x);
578
579
580 vec_p.push_back(sqrt(u*u+
v*
v));
581 vec_u.push_back(u);
583 m_u[digiId]=u;
585 m_p[digiId]=sqrt(u*u+
v*
v);
586
587 m_layer[digiId]=geowir->
Layer();
588 m_cell[digiId]=geowir->
Cell();
589 int layer= layerId;
590 vec_slant.push_back(SlantId(layer));
591 m_slant[digiId]=SlantId(layer);
592
593
594
595 }
596 for(int i=0;i<digiId;i++){
597 if(track_index_max<=vec_track_index[i]) track_index_max=vec_track_index[i];
598 }
599 track_index_max++;
600 m_trackNum_Mc=track_index_max;
601
602 vector< vector <int> > mc_track_hit(track_index_max,vector<int>() );
603 for(int i=0;i<track_index_max;i++){
604 for(int j=0;j<digiId;j++){
605 if(vec_track_index[j]==i) mc_track_hit[i].push_back(j);
606 }
607 }
608
609 track_index_max=m_trackNum_Mc_set;
610
611
612
613
614
615
616
617
618
619 m_nHit=digiId;
620 m_nHitAxial=nHitAxial;
621
622
623 m_nHitSignal=nHitSignal;
624 m_nHitAxialSignal=nHitAxialSignal;
625
626 cout<<"hit number: "<<digiId<<endl;
627
628
629
630 for(int i =0;i<m_nHit;i++){
631 if(t_maxP<vec_p[i]) {t_maxP=vec_p[i];}
632 }
633
634 for(
int i =0;i<
m_nHit;i++){
635 if(t_minP>vec_p[i]) {t_minP=vec_p[i];}
636 }
637 t_maxP=t_maxP+0.01;
638
639
640
641
642
643
644
645
646 int nhit;
647 if(m_data==0) {
648 nhit=m_nHit_Mc;}
649 else{
651
652 binX=m_binx;
653 binY=m_biny;
654 double binwidth=
M_PI/binX;
655 double binhigh=2*t_maxP/binY;
656 TH2D *h1=
new TH2D(
"h1",
"h1",binX,0,
M_PI,binY,-t_maxP,t_maxP);
657
658
659
660 vector<double> vec_rho;
661 vector<double> vec_theta;
662 vector< vector<int> > vec_hitNum(2,vector<int>());
663 int numCross=(int)(nhit*(nhit-1)/2);
664 if(m_method==0){
665 RhoTheta(numCross,nhit,vec_u,vec_v,vec_rho,vec_theta,vec_hitNum);
666 FillRhoTheta(h1,vec_theta,vec_rho,numCross);
667 }
668
669 vector< vector< vector<int> > > vec_selectNum(binX,vector< vector<int> >(binY,vector<int>() ) );
670 if(m_method==1){
671 FillHist(h1,vec_u,vec_v,nhit,vec_selectNum);
672 }
673
674
675 vector<bool> vec_truthHit(nhit,false);
676 vector< vector <int> > countij(binX,vector <int> (binY,0) );
677
678 vector< vector< vector<int> > > vec_selectHit(binX,vector< vector<int> >(binY,vector<int>() ) );
679 if(m_method==2){
680 FillCells(h1,nhit,binX,binY,vec_u,vec_v,vec_layer,vec_wire,countij,vec_selectNum,vec_selectHit);
681 }
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698 int max_count=0;
699 int max_binx=1;
700 int max_biny=1;
701 for(int i=0;i<binX;i++){
702 for(int j=0;j<binY;j++){
703 int count=h1->GetBinContent(i+1,j+1);
704 if(max_count<count) {
706 max_binx=i+1;
707 max_biny=j+1;
708 }
709 }
710 }
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777 // int columnx_split=(int)(column/10)*100+100;
778 // int columny_split=(int)(column%10)*100+100;
779 // //cout<<"column: "<<column<<" "<<"("<<columnx_split<<","<<columny_split<<")"<<peakArea[column]<<endl;
780 delete h1;
781 // }
782 // }
783 // double area_least=peakArea[0];
784 // for(int i=0;i<100;i++){
785 // if(area_least>peakArea[i]){
786 // area_least=peakArea[i];
787 // }
788 // }
789 // int num_area_least=0;
790 // for(int i=0;i<100;i++){
791 // if(area_least==peakArea[i]){
792 // num_area_least=i;
793 // }
794 // }
795 // int binx_split=(int)(num_area_least/10)*100+100;
796 // int biny_split=(int)(num_area_least%10)*100+100;
797 // m_areaLeast=area_least;
798 // m_areaLeastNum=num_area_least;
799 //cout<<"the max peakArea: "<<num_area_least<<"("<<binx_split<<","<<biny_split<<")"<<"peakarea is : "<<area_least<<endl;
800 */
801
802
803
804
805
806 int count_use=0;
807 double sum=0;
808 double sum2=0;
809 for(int i=0;i<binX;i++){
810 for(int j=0;j<binY;j++){
811 int count=h1->GetBinContent(i+1,j+1);
812
813 if(count!=0){
814 count_use++;
817 }
818 }
819 }
820 double f_n=m_ndev;
821 cout<<"count_use: "<<count_use<<endl;
822 double aver=sum/count_use;
823 double dev=sqrt(sum2/count_use-aver*aver);
824 int min_counts=(int)(aver+f_n*dev);
825 cout<<"aver: "<<aver<<" "<<"dev: "<<dev<<" min: "<<min_counts<<endl;
826
827
828 vector< vector <int> > hough_trans_CS(binX,vector <int> (binY,0) );
829 vector< vector <int> > hough_trans_CS_peak(binX,vector <int> (binY,0) );
830
831
832 for(int i=0;i<binX;i++){
833 for(int j=0;j<binY;j++){
834 hough_trans_CS[i][j]=h1->GetBinContent(i+1,j+1);
835 }
836 }
837
838 int peak_num=0;
839 for (int r=0; r<binY; r++) {
840 for (int a=0; a<binX; a++) {
841 long max_around=0;
842 for (int ar=a-1; ar<=a+1; ar++) {
843 for (int rx=r-1; rx<=r+1; rx++) {
844 int ax;
845 if (ar<0) { ax=ar+binX; }
846 else if (ar>=binX) { ax=ar-binX; }
847 else { ax=ar; }
848 if ( (ax!=a || rx!=r) && rx>=0 && rx<binY) {
849 if (hough_trans_CS[ax][rx]>max_around) { max_around=hough_trans_CS[ax][rx]; }
850 }
851 }
852 }
853 if (hough_trans_CS[a][r]<=min_counts) { hough_trans_CS_peak[a][r]=0; }
854 else if (hough_trans_CS[a][r]<max_around) { hough_trans_CS_peak[a][r]=0; }
855 else if (hough_trans_CS[a][r]==max_around) { hough_trans_CS_peak[a][r]=1; }
856 else if (hough_trans_CS[a][r]>max_around) { hough_trans_CS_peak[a][r]=2; }
857 if(hough_trans_CS_peak[a][r]!=0) {
858
859 peak_num++;
860 }
861 }
862 }
863
864
865
866 int peak_num_2=0;
867 for (int r=0; r<binY; r++) {
868 for (int a=0; a<binX; a++) {
869 if (hough_trans_CS_peak[a][r]==1) {
870 hough_trans_CS_peak[a][r]=2;
871 for (int ar=a-1; ar<=a+1; ar++) {
872 for (int rx=r-1; rx<=r+1; rx++) {
873 int ax;
874 if (ar<0) { ax=ar+binX; }
875 else if (ar>=binX) { ax=ar-binX; }
876 else { ax=ar; }
877 if ( (ax!=a || rx!=r) && rx>=0 && rx<binY) {
878 if (hough_trans_CS_peak[ax][rx]==1) { hough_trans_CS_peak[ax][rx]=0; }
879 }
880 }
881 }
882 }
883 if(hough_trans_CS_peak[a][r]!=0) {
884 peak_num_2++;
885
886
887
888
889
890 }
891 }
892 }
893
894
895
896 TH2D *h2 = new TH2D("h2","test2",binX,0,3.14,binY,-t_maxP,t_maxP);
897 for(int i=0;i<binX;i++){
898 for(int j=0;j<binY;j++){
899 if(hough_trans_CS_peak[i][j]==2){
900 h2->SetBinContent(i+1,j+1,hough_trans_CS[i][j]);
901 }
902 }
903 }
904
905 vector<int> peakList1[3];
906 for(
int n=0;
n<peak_num_2;
n++){
907 for (int r=0; r<binY; r++) {
908 for (int a=0; a<binX; a++) {
909 if (hough_trans_CS_peak[a][r]==2) {
910 peakList1[0].push_back(a+1);
911 peakList1[1].push_back(r+1);
912 peakList1[2].push_back(hough_trans_CS[a][r]);
913 }
914 }
915 }
916 }
917 cout<<"finish peak?"<<endl;
918 if(m_method==0) cout<<"numCross: "<<numCross<<endl;
919
920 int npeak1=peak_num_2;
921 int n_max;
922 for (int na=0; na<npeak1-1; na++) {
923 n_max=na;
924 for (int nb=na+1; nb<npeak1; nb++) {
925 if (peakList1[2][n_max]<peakList1[2][nb]) { n_max=nb; }
926 }
927 if (n_max!=na) {
928 float swap[3];
929 for (int i=0; i<3; i++) {
930 swap[i]=peakList1[i][na];
931 peakList1[i][na]=peakList1[i][n_max];
932 peakList1[i][n_max]=swap[i];
933 }
934 }
935 }
936 cout<<"npeak1: "<<npeak1<<endl;
937 for(
int n=0;
n<npeak1;
n++){
938 int bintheta=peakList1[0][
n];
939 int binrho=peakList1[1][
n];
940 int count=peakList1[2][
n];
941 for(
int i=0;i<
count;i++){
942
943
944 }
945
946 }
947
948 typedef std::map<int, int> M2;
949 typedef std::map<int, M2> M1;
950 M2 peak_combine_num;
951 M1 hit_combine;
952
953 int peak_track=0;
954
955 if(m_method==2){
956
957 int m=0;
959 int addnum=999;
960 vector<bool> peaktrack(npeak1,true);
961 while(addnum!=0)
962 {
963 addnum=0;
964 double peak_cellNum[43];
965 int peakX[43];
966 int peakY[43];
967 double bin_left[43];
968 double bin_right[43];
969 double bin_up[43];
970 double bin_down[43];
971 double area_left[43];
972 double area_right[43];
973
974 double area_down[43];
975 double area_up[43];
976
977 for(
int iLayer=0; iLayer<m_gm->
nLayer(); iLayer++){
978 peak_cellNum[iLayer]=m_peakCellNum[iLayer];
979 peakX[iLayer]=peakList1[0][
n];
980 peakY[iLayer]=peakList1[1][
n];
981 bin_left[iLayer]=peakX[iLayer]-peak_cellNum[iLayer];
982 bin_right[iLayer]=peakX[iLayer]+peak_cellNum[iLayer];
983 bin_up[iLayer]=peakY[iLayer]+peak_cellNum[iLayer];
984 bin_down[iLayer]=peakY[iLayer]-peak_cellNum[iLayer];
985 area_left[iLayer]=(bin_left[iLayer]-1)*binwidth;
986 area_right[iLayer]=(bin_right[iLayer])*binwidth;
987
988 area_down[iLayer]=(bin_down[iLayer]-1)*binhigh-t_maxP;
989 area_up[iLayer]=(bin_up[iLayer])*binhigh-t_maxP;
990 }
991 int count_peak=0;
992 for(int k=0;k<nhit;k++){
993 int layer=vec_layer[k];
994 double lineLeft=vec_u[k]*
cos(area_left[layer])+vec_v.at(k)*
sin(area_right[layer]);
995 double lineRight=vec_u[k]*
cos(area_left[layer])+vec_v.at(k)*
sin(area_right[layer]);
996
997 if((lineLeft<area_up[layer])&&(lineLeft>area_down[layer])||(lineRight<area_up[layer])&&(lineRight>area_down[layer])||((lineLeft-area_up[layer])*(area_down[layer]-lineRight)>0)){
998
999
1000
1001
1002
1003
1004 hit_combine[m][count_peak]=k;
1005
1006 count_peak++;
1007 }
1008
1009 peak_combine_num[m]=count_peak;
1010
1011
1012 }
1013 for(
int i=
n+1;i<npeak1;i++){
1014 if(peaktrack[i]==false) continue;
1015 int peaktheta=peakList1[0][i];
1016 int peakrho=peakList1[1][i];
1017 int peakhitNum=peakList1[2][i];
1018 int count_same_hit=0;
1019 for(int j=0;j<peakhitNum;j++){
1020
1021 for(int k=0;k<peak_combine_num[m];k++){
1022 if(vec_selectNum[peaktheta-1][peakrho-1][j]==hit_combine[m][k]){
1023 count_same_hit++;
1024 }
1025 }
1026 }
1027 double f_hit=m_hit_pro;
1028 if(count_same_hit>f_hit*peakhitNum){
1029 peaktrack[i]=false;
1030 }
1031 }
1032 for(
int i=
n+1;i<npeak1;i++){
1033 if(peaktrack[i]==true){
1034 addnum=i;
1035 break;
1036 }
1037 }
1038 if(addnum!=0) m++;
1039 cout<<"peak_m: "<<m+1<<endl;
1041 }
1042
1043
1044 for(int i=0;i<npeak1;i++){
1045 cout<<"track"<<i<<": "<<"("<<peakList1[0][i]<<","<<peakList1[1][i]<<","<<peakList1[2][i]<<")"<<" "<<"truth: "<<peaktrack[i]<<endl;
1046 if(peaktrack[i]==true){
1047 peak_track++;
1048 }
1049 }
1050 for( int i=0;i<peak_track;i++){
1051 for(int j =0;j<peak_combine_num[i];j++){
1052 int hit_number=hit_combine[i][j];
1053 cout<<" peak "<<i<<" has select hits: "<<vec_layer[hit_number]<<" "<<vec_wire[hit_number]<<endl;
1054 }
1055 cout<<"has collect :"<<peak_combine_num[i]<<" hits "<<endl;
1056 }
1057 cout<<"event"<<t_eventNum<<": "<<"has found: "<<peak_track<<" track."<<endl;
1058 m_trackNum=peak_track;
1059
1060
1061
1062
1063
1064 vector< vector<int> > rec_mc_num(peak_track,vector<int>(track_index_max,0) );
1065 vector< vector<int> > rec_mc_num_axial(peak_track,vector<int>(track_index_max,0) );
1066 if(track_index_max!=peak_track) cout<<"not match track number !"<<endl;
1067 for(int mc_track_num=0;mc_track_num<track_index_max;mc_track_num++){
1068 for(int i=0;i<peak_track;i++){
1069 for(int j=0;j<peak_combine_num[i];j++){
1070 for(int k=0;k<mc_track_hit[mc_track_num].size();k++){
1071 if(hit_combine[i][j]==mc_track_hit[mc_track_num][k]){
1072 rec_mc_num[i][mc_track_num]++;
1073 int hit_num=mc_track_hit[mc_track_num][k];
1074 if(vec_slant[hit_num]==0) rec_mc_num_axial[i][mc_track_num]++;
1075 }
1076 }
1077 }
1078 }
1079 }
1080 vector<int> rec_mc(peak_track,999);
1081 for(int i=0;i<peak_track;i++){
1082 for(int mc_track_num=0;mc_track_num<track_index_max;mc_track_num++){
1083 if(rec_mc_num[i][mc_track_num]>0.5*peak_combine_num[i]) rec_mc[i]=mc_track_num;
1084 cout<<"trackrec: "<<i<<" trackmc: "<<mc_track_num<<" "<<rec_mc_num[i][mc_track_num]<<" "<<peak_combine_num[i]<<endl;
1085 }
1086 }
1087 for(int i=0;i<peak_track;i++){
1088 cout<<"rec :"<<i<<"belong to mc track: "<<rec_mc[i]<<endl;
1089 }
1090 for(int i=0;i<peak_track;i++){
1091 int mc_track_num=rec_mc[i];
1092 if(mc_track_num!=999) {
1093 cout<<"debug mc_track_num: "<<mc_track_num<<endl;
1094 m_nHitSignal_select[i]=rec_mc_num[i][mc_track_num];
1095 m_nHitAxialSignal_select[i]=rec_mc_num_axial[i][mc_track_num];
1096 cout<<"m_nHitSignal_select: "<<m_nHitSignal_select[i]<<endl;
1097 }
1098 }
1099
1100
1101
1102
1103
1104
1105
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
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
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
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
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
1345double d0=-999.;
1346double phi0=-999.;
1347double omega=-999.;
1348double z0=0;
1349double tanl=0;
1350
1351for(track_fit=0;track_fit<peak_track;track_fit++){
1352 for(int i=0;i<nhit;i++){
1353 vec_truthHit[i]=false;
1354 }
1355 cout<<"track: "<<track_fit<<" has select: "<<peak_combine_num[track_fit]<<" hit ."<<endl;
1356 for(int i=0;i<peak_combine_num[track_fit];i++){
1357 int hitNum=hit_combine[track_fit][i];
1358 vec_truthHit[hitNum]=true;
1359 }
1360
1361 int nHitAxialSelect_temp=10;
1362 int leastSquare=LeastSquare(nhit,nHitAxialSelect_temp,vec_x,vec_y,vec_slant,vec_layer,vec_truthHit,d0,phi0,omega);
1363
1364 if(leastSquare==0){
1365
1368 float chisum =0.;
1370 bool permitFlips = true;
1371 bool lPickHits = m_pickHits;
1373
1374 int nDigi = digiToHots(newTrack,vec_truthHit);
1375 int nRecTk = 0;
1376
1377
1380
1382 bool fitSuccess = false;
1383
1384 if (!newFit || (newFit->
nActive()<3)) {
1385 if(m_debug>0){
1386 cout << "evt "<<t_eventNum<<" global fit failed ";
1387 if(newFit) cout <<
" nAct "<<newFit->
nActive();
1388 cout<<endl;
1389 }
1390
1391 }else{
1392 nRecTk = 1;
1393 fitSuccess = true;
1394 m_nEvtSuccess++;
1395
1396 if(m_debug>0) newTrack->
print(std::cout);
1397
1398 }
1399
1400 vector<int> nfit2d(peak_track,0);
1401 if(m_debug>0) cout<<" hot list:"<<endl;
1404 nfit2d[track_fit]++;
1405 cout <<
"(" <<((
MdcHit*)(hotIter->hit()))->layernumber()
1406 <<
","<<((
MdcHit*)(hotIter->hit()))->wirenumber()
1407 <<":"<<hotIter->isActive()<<") ";
1408 hotIter++;
1409 }
1410
1411 m_2d_nFit[track_fit]=nfit2d[track_fit];
1412
1413
1414 double x_cirtemp;
1415 double y_cirtemp;
1416 double r_temp;
1418
1423
1424
1425
1426
1427 r_temp=1./-par.
omega();
1430
1431 m_pt[track_fit]=r_temp/333.567;
1432 cout<<"pt_rec: "<<m_pt[track_fit]<<endl;
1433 }
1434 else{
1435 m_nFitFailure[track_fit]=2;
1436 }
1437
1438
1439 int z_stereoNum= Zposition(nhit,vec_slant,x_cirtemp,y_cirtemp,r_temp,vec_x_east,vec_x_west,vec_y_east, vec_y_west,vec_z_east,vec_z_west, vec_layer, vec_wire,vec_z,vec_zStereo,l,vec_truthHit);
1440
1441
1442
1443 m_zStereoNum=z_stereoNum;
1444 for(int i=0;i<z_stereoNum;i++){
1445
1446 m_zStereoNum=z_stereoNum;
1447 m_zStereo[i]=vec_zStereo[i];
1448
1449 m_l[i]=l[i];
1450 if(m_debug>0) cout<<" l: "<<m_l[i]<<" "<<"z: "<<vec_zStereo[i]<<endl;
1451 }
1452
1453
1454 Linefit(z_stereoNum,vec_zStereo,l,tanl,z0);
1455
1456 cout<<"tanl: "<<tanl<<endl;
1457 cout<<"z0: "<<z0<<endl;
1458 z0=dz_mc;
1459 tanl=tanl_mc;
1460 cout<<"tanltruth: "<<tanl<<endl;
1461 cout<<"z0truth: "<<z0<<endl;
1462
1463
1466 chisum =0.;
1468 permitFlips = true;
1469 lPickHits = m_pickHits;
1471
1472 int nDigi2 = digiToHots2(newTrack2,vec_truthHit);
1473
1474
1475
1478
1480
1481
1482
1483 if (!newFit2 || (newFit2->
nActive()<5)) {
1484
1485 if(m_debug>0){
1486 cout << "evt "<<t_eventNum<<" global fit failed ";
1487 if(newFit2) cout <<
" nAct "<<newFit2->
nActive();
1488 cout<<endl;
1489 }
1490
1491 }else{
1492
1493 nFitSucess++;
1495 int tkStat = 4;
1496 int tkId = nTdsTk + track_fit;
1497 mdcTrack->
storeTrack(tkId, trackList, hitList, tkStat);
1498 nRecTk = 1;
1499 fitSuccess = true;
1500 m_nEvtSuccess++;
1501
1502 if(m_debug>0) newTrack2->
print(std::cout);
1503
1504 }
1505
1506 vector<int> nfit3d(peak_track,0);
1507 if(m_debug>0) cout<<" hot list:"<<endl;
1510 nfit3d[track_fit]++;
1511 cout <<
"(" <<((
MdcHit*)(hotIter2->hit()))->layernumber()
1512 <<
","<<((
MdcHit*)(hotIter2->hit()))->wirenumber()
1513 <<":"<<hotIter2->isActive()<<") ";
1514 hotIter2++;
1515 }
1516
1517 m_3d_nFit[track_fit]=nfit3d[track_fit];
1518
1519
1521
1523
1524
1525
1526
1527
1528
1529
1530 r_temp=1./-par2.
omega();
1533
1534 m_d0[track_fit]=par2.
d0();
1535 m_phi0[track_fit]=par2.
phi0();
1536 m_omega[track_fit]=par2.
omega();
1537 m_z0[track_fit]=par2.
z0();
1538 m_tanl[track_fit]=par2.
tanDip();
1539
1540 double pxy=r_temp/333.567;
1541 double pz=pxy*par2.
tanDip();
1542 double pxyz=sqrt(pxy*pxy+pz*pz);
1543 m_pt2[track_fit]=pxy;
1544 m_pz[track_fit]=pxy*par2.
tanDip();
1545 m_pxyz[track_fit]=pxyz;
1546 cout<<"track"<<track_fit<<": "<<"pt_rec2: "<<m_pt2[track_fit]<<endl;
1547 cout<<"eventNum: "<<t_eventNum<<" "<<"track"<<track_fit<<": "<<"pz_rec: "<<m_pz[track_fit]<<endl;
1548 }
1549 else{
1550 m_nFitFailure[track_fit]=3;
1551 }
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569 }
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586}
1587m_nFitSucess=nFitSucess;
1588cout<<" Hough finder find "<<nFitSucess<<" tot "<<nTdsTk<< endl;
1589
1590delete h1;
1591delete h2;
1592cout<<"break: ????"<<endl;
1593ntuplehit->write();
1594cout<<"finish event "<<t_eventNum<<endl;
1595cout<<endl;
1596cout<<endl;
1597return StatusCode::SUCCESS;
1598}
std::vector< MdcDigi * > MdcDigiVec
double sin(const BesAngle a)
double cos(const BesAngle a)
ObjectVector< RecMdcHit > RecMdcHitCol
ObjectVector< RecMdcTrack > RecMdcTrackCol
NTuple::Item< long > m_nHit
**********Class see also m_nmax DOUBLE PRECISION m_amel DOUBLE PRECISION m_x2 DOUBLE PRECISION m_alfinv DOUBLE PRECISION m_Xenph INTEGER m_KeyWtm INTEGER m_idyfs DOUBLE PRECISION m_zini DOUBLE PRECISION m_q2 DOUBLE PRECISION m_Wt_KF DOUBLE PRECISION m_WtCut INTEGER m_KFfin *COMMON c_KarLud $ !Input CMS energy[GeV] $ !CMS energy after beam spread beam strahlung[GeV] $ !Beam energy spread[GeV] $ !z boost due to beam spread $ !electron beam mass *ff pair spectrum $ !minimum v
HepPoint3D Forward(void) const
HepPoint3D Backward(void) const
const MdcGeoWire *const Wire(unsigned id)
static int layer(const Identifier &id)
Values of different levels (failure returns 0)
static int wire(const Identifier &id)
void storeTrack(int trackId, RecMdcTrackCol *trackList, RecMdcHitCol *hitList, int tkStat)
MdcDigiVec & getMdcDigiVec(uint32_t control=0)
virtual int nActive() const =0
virtual TrkExchangePar helix(double fltL) const =0
const TrkHotList & hotList() const
hot_iterator begin() const
virtual void print(std::ostream &) const
const TrkFit * fitResult() const
bool setFlipAndDrop(TrkRecoTrk &, bool allowFlips, bool allowDrops) const
TrkRecoTrk * makeTrack(const TrkExchangePar &helix, const double chi2, const TrkContext &, double trackT0) const
_EXTERN_ std::string RecMdcTrackCol
_EXTERN_ std::string RecMdcHitCol