658 |
TClonesArray &ttimage = *timage; |
TClonesArray &ttimage = *timage; |
659 |
|
|
660 |
|
|
661 |
// loop over the tracks sorted by the tracker |
|
662 |
|
//-------------------------------------------------- |
663 |
|
// retrieve sorting method |
664 |
|
//-------------------------------------------------- |
665 |
Bool_t use_TRK = how.Contains("TRK", TString::kIgnoreCase); |
Bool_t use_TRK = how.Contains("TRK", TString::kIgnoreCase); |
666 |
Bool_t use_CAL = how.Contains("CAL", TString::kIgnoreCase); |
Bool_t use_CAL = how.Contains("CAL", TString::kIgnoreCase); |
667 |
Bool_t use_TOF = how.Contains("TOF", TString::kIgnoreCase); |
Bool_t use_TOF = how.Contains("TOF", TString::kIgnoreCase); |
675 |
}; |
}; |
676 |
|
|
677 |
// cout << "use_CAL "<<use_CAL<<" use_TOF "<<use_TOF<<" use_TRK "<<use_TRK <<endl; |
// cout << "use_CAL "<<use_CAL<<" use_TOF "<<use_TOF<<" use_TRK "<<use_TRK <<endl; |
678 |
|
|
679 |
|
|
680 |
|
//-------------------------------------------------- |
681 |
|
// loop over "physical" tracks sorted by the tracker |
682 |
|
//-------------------------------------------------- |
683 |
for(Int_t i=0; i < trk2_obj->TrkLevel2::GetNTracks(); i++){ |
for(Int_t i=0; i < trk2_obj->TrkLevel2::GetNTracks(); i++){ |
684 |
|
|
685 |
TrkTrack *ts = 0; |
TrkTrack *ts = 0; |
687 |
ToFTrkVar *os = 0; |
ToFTrkVar *os = 0; |
688 |
|
|
689 |
// get tracker tracks |
// get tracker tracks |
690 |
TrkTrack *tp = trk2_obj->TrkLevel2::GetTrack(i); //tracker |
TrkTrack *tp = trk2_obj->TrkLevel2::GetTrack(i); //tracker |
691 |
CaloTrkVar *cp = GetCaloStoredTrack(tp->GetSeqNo()); |
CaloTrkVar *cp = GetCaloStoredTrack(tp->GetSeqNo()); |
692 |
ToFTrkVar *op = GetToFStoredTrack(tp->GetSeqNo()); |
ToFTrkVar *op = GetToFStoredTrack(tp->GetSeqNo()); |
693 |
|
|
694 |
TrkTrack *ti = 0; //tracker (image) |
TrkTrack *ti = 0; //tracker (image) |
695 |
CaloTrkVar *ci = 0; |
CaloTrkVar *ci = 0; |
696 |
ToFTrkVar *oi = 0; |
ToFTrkVar *oi = 0; |
697 |
// cout << "trk track n. "<<i << " "<<hex<< tp <<dec<< endl; |
// cout << "trk track n. "<<i << " "<<hex<< tp <<dec<< endl; |
708 |
Int_t tp_score = 0; //main track sorted by the tracker |
Int_t tp_score = 0; //main track sorted by the tracker |
709 |
Int_t ti_score = 0; //image track |
Int_t ti_score = 0; //image track |
710 |
|
|
711 |
// ------------------------ |
// ----------------------------------------------------------------------------------------- |
712 |
// calorimeter check |
// calorimeter check |
713 |
// ------------------------ |
// ----------------------------------------------------------------------------------------- |
714 |
// check the Y spatial residual on the first calorimeter plane |
// check the Y spatial residual on the first calorimeter plane |
715 |
// (cut on calorimeter variables from Emiliano) |
// (cut on calorimeter variables from Emiliano) |
716 |
if( use_CAL && !calo2_obj ){ |
if( use_CAL && !calo2_obj ){ |
719 |
}; |
}; |
720 |
if( |
if( |
721 |
use_CAL && |
use_CAL && |
722 |
calo2_obj->npcfit[1] > 5 && //no. of fit planes on Y view |
// calo2_obj->npcfit[1] > 5 && //no. of fit planes on Y view |
723 |
calo2_obj->varcfit[1] < 1000. && //fit variance on Y view |
// calo2_obj->varcfit[1] < 1000. && //fit variance on Y view |
724 |
cp && ci && |
cp && ci && |
725 |
true){ |
true){ |
726 |
|
|
727 |
|
|
728 |
Float_t resy_p = cp->tbar[0][1] - calo2_obj->cbar[0][1]; if(resy_p < 0)resy_p= - resy_p; |
// Float_t resy_p = cp->tbar[0][1] - calo2_obj->cbar[0][1]; if(resy_p < 0)resy_p= - resy_p; |
729 |
Float_t resy_i = ci->tbar[0][1] - calo2_obj->cbar[0][1]; if(resy_i < 0)resy_i= - resy_i; |
// Float_t resy_i = ci->tbar[0][1] - calo2_obj->cbar[0][1]; if(resy_i < 0)resy_i= - resy_i; |
730 |
|
|
731 |
if(resy_p <= resy_i) tp_score++; |
// if(resy_p <= resy_i) tp_score++; |
732 |
else ti_score++; |
// else ti_score++; |
733 |
|
|
734 |
|
|
735 |
|
if( cp->npresh > ci->npresh) tp_score++; |
736 |
|
if( cp->npresh < ci->npresh) ti_score++; |
737 |
|
else ;//niente |
738 |
|
|
739 |
// cout << "CALO "<<tp_score<<ti_score<<endl; |
// cout << "CALO "<<tp_score<<ti_score<<endl; |
740 |
|
|
741 |
}; |
}; |
742 |
// ------------------------ |
// ----------------------------------------------------------------------------------------- |
743 |
// TOF check |
// TOF check |
744 |
// ------------------------ |
// ----------------------------------------------------------------------------------------- |
745 |
// check the number of hit pmts along the track |
// check the number of hit pmts along the track |
746 |
// on S12 S21 and S32, where paddles are parallel to Y axis |
// on S12 S21 and S32, where paddles are parallel to Y axis |
747 |
if( use_TOF && !tof_obj ){ |
if( use_TOF && !tof_obj ){ |
887 |
cout << "image: npmtadc "<< oi->npmtadc << endl; |
cout << "image: npmtadc "<< oi->npmtadc << endl; |
888 |
cout << "image: npmttdc "<< oi->npmttdc << endl;*/ |
cout << "image: npmttdc "<< oi->npmttdc << endl;*/ |
889 |
|
|
890 |
for (Int_t ih=0; ih < op->npmtadc; ih++){ |
// for (Int_t ih=0; ih < op->npmtadc; ih++){ |
891 |
Int_t pl = tof_obj->GetPlaneIndex( (op->pmtadc).At(ih) ); |
// Int_t pl = tof_obj->GetPlaneIndex( (op->pmtadc).At(ih) ); |
892 |
if(pl == 1 || pl == 2 || pl == 5)nphit_p++; |
// if(pl == 1 || pl == 2 || pl == 5)nphit_p++; |
893 |
|
// }; |
894 |
|
|
895 |
|
// for (Int_t ih=0; ih < oi->npmtadc; ih++){ |
896 |
|
// Int_t pl = tof_obj->GetPlaneIndex( (oi->pmtadc).At(ih) ); |
897 |
|
// if(pl == 1 || pl == 2 || pl == 5)nphit_i++; |
898 |
|
// }; |
899 |
|
// --- modified to count tdc signals (more efficient?) |
900 |
|
// --- and to implement check on tdcflag |
901 |
|
for (Int_t ih=0; ih < op->npmttdc; ih++){ |
902 |
|
Int_t pl = tof_obj->GetPlaneIndex( (op->pmttdc).At(ih) ); |
903 |
|
// if( (op->tdcflag).At(ih)==0 && (pl == 1 || pl == 2 || pl == 5) )nphit_p++; |
904 |
|
if( (op->tdcflag).At(ih)==0 )nphit_p++; |
905 |
}; |
}; |
906 |
|
|
907 |
for (Int_t ih=0; ih < oi->npmtadc; ih++){ |
for (Int_t ih=0; ih < oi->npmttdc; ih++){ |
908 |
Int_t pl = tof_obj->GetPlaneIndex( (oi->pmtadc).At(ih) ); |
Int_t pl = tof_obj->GetPlaneIndex( (oi->pmttdc).At(ih) ); |
909 |
if(pl == 1 || pl == 2 || pl == 5)nphit_i++; |
// if( (oi->tdcflag).At(ih)==0 && (pl == 1 || pl == 2 || pl == 5) )nphit_i++; |
910 |
|
if( (oi->tdcflag).At(ih)==0 )nphit_i++; |
911 |
}; |
}; |
912 |
|
|
913 |
if( |
if( |
|
use_TOF && |
|
914 |
(nphit_p+nphit_i) !=0 && |
(nphit_p+nphit_i) !=0 && |
915 |
true){ |
true){ |
916 |
|
|
917 |
if( nphit_p >= nphit_i) tp_score++; |
if ( nphit_p > nphit_i) tp_score++; |
918 |
else ti_score++; |
else if( nphit_p < nphit_i) ti_score++; |
919 |
|
else ;//niente |
920 |
}; |
}; |
921 |
}; |
}; |
922 |
// cout << "TOF "<<tp_score<<ti_score<<endl; |
// cout << "TOF "<<tp_score<<ti_score<<endl; |
923 |
}; |
}; |
924 |
if(tp_score == ti_score) use_TRK = true; |
|
925 |
// ------------------------ |
|
926 |
|
// if(tp_score == ti_score) use_TRK = true; |
927 |
|
|
928 |
|
|
929 |
|
// ----------------------------------------------------------------------------------------- |
930 |
// tracker check |
// tracker check |
931 |
// ------------------------ |
// ----------------------------------------------------------------------------------------- |
932 |
// chi**2 difference is not always large enough to distinguish among |
// chi**2 difference is not always large enough to distinguish among |
933 |
// the real track and its image. |
// the real track and its image. |
934 |
// Tracker check will be applied always when calorimeter and tof information is ambiguous. |
// Tracker check will be applied always when calorimeter and tof information is ambiguous. |
935 |
|
// *** MODIFIED ON AUGUST 2007 *** |
936 |
if(use_TRK){ |
if(use_TRK){ |
937 |
if( tp->chi2 > 0 && tp->chi2 < ti->chi2 ) tp_score++ ; |
// if( tp->chi2 > 0 && tp->chi2 < ti->chi2 ) tp_score++ ; |
938 |
else if( ti->chi2 > 0 && ti->chi2 < tp->chi2 ) ti_score++ ; |
// else if( ti->chi2 > 0 && ti->chi2 < tp->chi2 ) ti_score++ ; |
939 |
|
|
940 |
|
// CHECK 1 : number of points along X |
941 |
|
if ( tp->GetNX() >= ti->GetNX() )tp_score++ ; |
942 |
|
if ( tp->GetNX() <= ti->GetNX() )ti_score++ ; |
943 |
|
// CHECK 2 : number of points along Y |
944 |
|
if ( tp->GetNY() >= ti->GetNY() )tp_score++ ; |
945 |
|
if ( tp->GetNY() <= ti->GetNY() )ti_score++ ; |
946 |
|
// CHECK 3 : chi**2 along X |
947 |
|
// if( tp->GetChi2X() > 0 && (tp->GetChi2X() < ti->GetChi2X() || ti->GetChi2X() <=0) ) tp_score++ ; |
948 |
|
// if( ti->GetChi2X() > 0 && (ti->GetChi2X() < tp->GetChi2X() || tp->GetChi2X() <=0) ) ti_score++ ; |
949 |
|
// CHECK 4 : chi**2 along Y |
950 |
|
// if( tp->GetChi2Y() > 0 && (tp->GetChi2Y() < ti->GetChi2Y() || ti->GetChi2Y() <=0) ) tp_score++ ; |
951 |
|
// if( ti->GetChi2Y() > 0 && (ti->GetChi2Y() < tp->GetChi2Y() || tp->GetChi2Y() <=0) ) ti_score++ ; |
952 |
|
// CHECK 5 : total chi**2 |
953 |
|
// if( tp->chi2 > 0 && (tp->chi2 < ti->chi2 || ti->chi2 <=0) ) tp_score++ ; |
954 |
|
// if( ti->chi2 > 0 && (ti->chi2 < tp->chi2 || tp->chi2 <=0) ) ti_score++ ; |
955 |
|
|
956 |
// cout << "TRK "<<tp_score<<ti_score<<endl; |
// cout << "TRK "<<tp_score<<ti_score<<endl; |
957 |
}; |
}; |
958 |
|
|
959 |
// ------------------------ |
|
960 |
|
|
961 |
|
// *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* |
962 |
// the winner is.... |
// the winner is.... |
963 |
// ------------------------ |
// *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* |
964 |
if (tp_score > ti_score) { |
if (tp_score > ti_score) { |
965 |
// ts = tp;//the track sorted by the tracker!! |
|
|
// cs = cp; |
|
|
// os = op; |
|
|
// cout << "It's primary!" << endl; |
|
966 |
|
|
967 |
}else if (tp_score < ti_score) { |
}else if (tp_score < ti_score) { |
968 |
|
|
|
// cout << "It's image!" << endl; |
|
969 |
|
|
970 |
ts = ti;//its image!! |
ts = ti;//its image!! |
971 |
cs = ci; |
cs = ci; |
981 |
|
|
982 |
|
|
983 |
}else { |
}else { |
984 |
// ts = tp; |
|
|
// cs = cp; |
|
|
// os = op; |
|
985 |
// cout << "Warning - track image ambiguity not solved" << endl; |
// cout << "Warning - track image ambiguity not solved" << endl; |
986 |
// cout << ts->GetNtot() << " "<< ts->chi2 << " " << npcfit[1] << " "<< nphit_p << endl; |
|
987 |
}; |
}; |
988 |
|
|
989 |
}else{ |
}else{ |