/[PAMELA software]/PamelaLevel2/src/PamLevel2.cpp
ViewVC logotype

Diff of /PamelaLevel2/src/PamLevel2.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.40 by pam-fi, Fri May 25 13:38:51 2007 UTC revision 1.41 by pam-fi, Thu Aug 2 13:59:47 2007 UTC
# Line 658  void PamLevel2::SortTracks(){ Line 658  void PamLevel2::SortTracks(){
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);
# Line 672  void PamLevel2::SortTracks(){ Line 675  void PamLevel2::SortTracks(){
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;
# Line 680  void PamLevel2::SortTracks(){ Line 687  void PamLevel2::SortTracks(){
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;
# Line 701  void PamLevel2::SortTracks(){ Line 708  void PamLevel2::SortTracks(){
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 ){
# Line 712  void PamLevel2::SortTracks(){ Line 719  void PamLevel2::SortTracks(){
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              else ti_score++;
737    
738          //      cout << "CALO "<<tp_score<<ti_score<<endl;          //      cout << "CALO "<<tp_score<<ti_score<<endl;
739    
740        };        };
741        // ------------------------        // -----------------------------------------------------------------------------------------
742        // TOF check        // TOF check
743        // ------------------------                  // -----------------------------------------------------------------------------------------
744        // check the number of hit pmts along the track        // check the number of hit pmts along the track
745        // on S12 S21 and S32, where paddles are parallel to Y axis        // on S12 S21 and S32, where paddles are parallel to Y axis
746        if( use_TOF && !tof_obj ){        if( use_TOF && !tof_obj ){
# Line 875  void PamLevel2::SortTracks(){ Line 886  void PamLevel2::SortTracks(){
886              cout << "image: npmtadc "<< oi->npmtadc << endl;              cout << "image: npmtadc "<< oi->npmtadc << endl;
887              cout << "image: npmttdc "<< oi->npmttdc << endl;*/              cout << "image: npmttdc "<< oi->npmttdc << endl;*/
888                                    
889            for (Int_t ih=0; ih < op->npmtadc; ih++){  //        for (Int_t ih=0; ih < op->npmtadc; ih++){
890              Int_t pl = tof_obj->GetPlaneIndex( (op->pmtadc).At(ih) );  //          Int_t pl = tof_obj->GetPlaneIndex( (op->pmtadc).At(ih) );
891              if(pl == 1 || pl == 2 || pl == 5)nphit_p++;  //          if(pl == 1 || pl == 2 || pl == 5)nphit_p++;
892    //        };
893                    
894    //        for (Int_t ih=0; ih < oi->npmtadc; ih++){
895    //          Int_t pl = tof_obj->GetPlaneIndex( (oi->pmtadc).At(ih) );
896    //          if(pl == 1 || pl == 2 || pl == 5)nphit_i++;
897    //        };
898              // --- modified to count tdc signals (more efficient?)
899              // --- and to implement check on tdcflag
900              for (Int_t ih=0; ih < op->npmttdc; ih++){
901                Int_t pl = tof_obj->GetPlaneIndex( (op->pmttdc).At(ih) );
902    //          if( (op->tdcflag).At(ih)==0 && (pl == 1 || pl == 2 || pl == 5) )nphit_p++;
903                if( (op->tdcflag).At(ih)==0 )nphit_p++;
904            };            };
905                                    
906            for (Int_t ih=0; ih < oi->npmtadc; ih++){            for (Int_t ih=0; ih < oi->npmttdc; ih++){
907              Int_t pl = tof_obj->GetPlaneIndex( (oi->pmtadc).At(ih) );              Int_t pl = tof_obj->GetPlaneIndex( (oi->pmttdc).At(ih) );
908              if(pl == 1 || pl == 2 || pl == 5)nphit_i++;  //          if( (oi->tdcflag).At(ih)==0 && (pl == 1 || pl == 2 || pl == 5) )nphit_i++;  
909                if( (oi->tdcflag).At(ih)==0 )nphit_i++;    
910            };            };
911                                    
912            if(            if(
              use_TOF            &&  
913               (nphit_p+nphit_i) !=0 &&                 (nphit_p+nphit_i) !=0 &&  
914               true){               true){
915                                            
# Line 896  void PamLevel2::SortTracks(){ Line 919  void PamLevel2::SortTracks(){
919          };          };
920          //      cout << "TOF "<<tp_score<<ti_score<<endl;          //      cout << "TOF "<<tp_score<<ti_score<<endl;
921        };        };
922        if(tp_score == ti_score) use_TRK = true;  
923        // ------------------------  
924    //      if(tp_score == ti_score) use_TRK = true;
925    
926    
927          // -----------------------------------------------------------------------------------------
928        // tracker check        // tracker check
929        // ------------------------        // -----------------------------------------------------------------------------------------
930        // chi**2 difference is not always large enough to distinguish among        // chi**2 difference is not always large enough to distinguish among
931        // the real track and its image.        // the real track and its image.
932        // 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.
933          // *** MODIFIED ON AUGUST 2007 ***
934        if(use_TRK){        if(use_TRK){
935          if(      tp->chi2 > 0 && tp->chi2 < ti->chi2 ) tp_score++ ;  //      if(      tp->chi2 > 0 && tp->chi2 < ti->chi2 ) tp_score++ ;
936          else if( ti->chi2 > 0 && ti->chi2 < tp->chi2 ) ti_score++ ;  //      else if( ti->chi2 > 0 && ti->chi2 < tp->chi2 ) ti_score++ ;
937    
938              // CHECK 1 : number of points along X  
939              if ( tp->GetNX() >= ti->GetNX() )tp_score++ ;
940              if ( tp->GetNX() <= ti->GetNX() )ti_score++ ;
941              // CHECK 2 : number of points along Y  
942              if ( tp->GetNY() >= ti->GetNY() )tp_score++ ;
943              if ( tp->GetNY() <= ti->GetNY() )ti_score++ ;
944              // CHECK 3 : chi**2 along X  
945    //        if(      tp->GetChi2X() > 0 && (tp->GetChi2X() < ti->GetChi2X() || ti->GetChi2X() <=0) ) tp_score++ ;
946    //        if(      ti->GetChi2X() > 0 && (ti->GetChi2X() < tp->GetChi2X() || tp->GetChi2X() <=0) ) ti_score++ ;
947              // CHECK 4 : chi**2 along Y  
948    //        if(      tp->GetChi2Y() > 0 && (tp->GetChi2Y() < ti->GetChi2Y() || ti->GetChi2Y() <=0) ) tp_score++ ;
949    //        if(      ti->GetChi2Y() > 0 && (ti->GetChi2Y() < tp->GetChi2Y() || tp->GetChi2Y() <=0) ) ti_score++ ;
950              // CHECK 5 : total chi**2  
951    //        if(      tp->chi2 > 0 && (tp->chi2 < ti->chi2 || ti->chi2 <=0) ) tp_score++ ;
952    //        if(      ti->chi2 > 0 && (ti->chi2 < tp->chi2 || tp->chi2 <=0) ) ti_score++ ;
953    
954          //      cout << "TRK "<<tp_score<<ti_score<<endl;          //      cout << "TRK "<<tp_score<<ti_score<<endl;
955        };        };
956                            
957        // ------------------------  
958    
959          // *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
960        // the winner is....        // the winner is....
961        // ------------------------                  // *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
962        if      (tp_score > ti_score) {        if      (tp_score > ti_score) {
963          //              ts = tp;//the track sorted by the tracker!!          
         //              cs = cp;  
         //              os = op;  
         //      cout << "It's primary!" << endl;  
964    
965        }else if (tp_score < ti_score) {        }else if (tp_score < ti_score) {
966    
         //      cout << "It's image!" << endl;  
967    
968          ts = ti;//its image!!          ts = ti;//its image!!
969          cs = ci;          cs = ci;
# Line 936  void PamLevel2::SortTracks(){ Line 979  void PamLevel2::SortTracks(){
979    
980                                    
981        }else {        }else {
982          //              ts = tp;  
         //              cs = cp;  
         //              os = op;  
983  //      cout << "Warning - track image ambiguity not solved" << endl;  //      cout << "Warning - track image ambiguity not solved" << endl;
984          //                              cout << ts->GetNtot() << " "<< ts->chi2 << " " << npcfit[1] << " "<< nphit_p << endl;  
985        };        };
986                            
987      }else{      }else{

Legend:
Removed from v.1.40  
changed lines
  Added in v.1.41

  ViewVC Help
Powered by ViewVC 1.1.23