/[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.39 by pam-fi, Mon May 14 11:57:36 2007 UTC revision 1.41 by pam-fi, Thu Aug 2 13:59:47 2007 UTC
# Line 304  void PamLevel2::Clear(){ Line 304  void PamLevel2::Clear(){
304    
305      if(h0_obj)   h0_obj->Clear();            if(h0_obj)   h0_obj->Clear();      
306  //    if(trk0_obj) trk0_obj->Clear();    //    if(trk0_obj) trk0_obj->Clear();  
     if(calo0_obj) calo0_obj->Clear();    
307      if(trk1_obj) trk1_obj->Clear();          if(trk1_obj) trk1_obj->Clear();    
308      if(trk2_obj) trk2_obj->Clear();      if(trk2_obj) trk2_obj->Clear();
309      if(trkh_obj) trkh_obj->Clear();      if(trkh_obj) trkh_obj->Clear();
310        if(calo0_obj) calo0_obj->Clear();  
311      if(calo1_obj)calo1_obj->Clear();      if(calo1_obj)calo1_obj->Clear();
312      if(calo2_obj)calo2_obj->Clear();      if(calo2_obj)calo2_obj->Clear();
313      if(tof_obj)  tof_obj->Clear();      if(tof_obj)  tof_obj->Clear();
# 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{
# Line 2964  Int_t PamLevel2::GetEntry(Long64_t iee){ Line 3005  Int_t PamLevel2::GetEntry(Long64_t iee){
3005  //     cout << "irunentry     "<<irunentry << endl;  //     cout << "irunentry     "<<irunentry << endl;
3006  //     cout << "runfirstentry "<<runfirstentry << endl;  //     cout << "runfirstentry "<<runfirstentry << endl;
3007  //     cout << "nevents       "<<GetRunInfo()->NEVENTS<< endl;  //     cout << "nevents       "<<GetRunInfo()->NEVENTS<< endl;
3008      if( TRK0 || CAL0 || TOF0 ){  
3009          if( !GetYodaEntry( ) ){  //     if( TRK0 || CAL0 || TOF0 ){
3010              cout << " Int_t PamLevel2::GetEntry(Int_t) -- ERROR -- error reading level0 tree"<<endl;  //      if( !GetYodaEntry( ) ){
3011              return 0;  //          cout << " Int_t PamLevel2::GetEntry(Int_t) -- ERROR -- error reading level0 tree"<<endl;
3012          }  //          return 0;
3013      }  //      }
3014    //     }
3015    
3016    
3017      return 1;      return 1;
3018    
3019  }  }
3020    
3021    TrkLevel0    *PamLevel2::GetTrkLevel0(){
3022        if( !TRK0 )return NULL;
3023        if( !GetYodaEntry( ) ){
3024            cout << " Int_t PamLevel2::GetTrkLevel0() -- ERROR -- error reading level0 tree"<<endl;
3025            return 0;
3026        }
3027        return trk0_obj;
3028    };
3029    CaloLevel0    *PamLevel2::GetCaloLevel0(){
3030        if( !CAL0 )return NULL;
3031        if( !GetYodaEntry( ) ){
3032            cout << " Int_t PamLevel2::GetCaloLevel0() -- ERROR -- error reading level0 tree"<<endl;
3033            return 0;
3034        }
3035        return calo0_obj;
3036    };
3037    
3038    
3039  /**  /**
3040   * Method to retrieve the level0 tree (YODA tree) that contains the current event.   * Method to retrieve the level0 tree (YODA tree) that contains the current event.
3041   * Given the run ID (...), if needed it query the DB and load the proper file.   * Given the run ID (...), if needed it query the DB and load the proper file.
# Line 3051  TTree* PamLevel2::GetYodaTree( ){ Line 3113  TTree* PamLevel2::GetYodaTree( ){
3113              };              };
3114              l0_tree->SetBranchAddress("Tracker" ,trk0_obj->GetPointerToTrackerEvent());              l0_tree->SetBranchAddress("Tracker" ,trk0_obj->GetPointerToTrackerEvent());
3115          }          }
3116          //---------------------------------------------------          //--------------------------------------------------
3117          // CALORIMETER:          // CALORIMETER:
3118          if(CAL0){          if(CAL0){
3119              if(!calo0_obj){              if(!calo0_obj){
# Line 3180  Int_t PamLevel2::GetYodaEntry(){ Line 3242  Int_t PamLevel2::GetYodaEntry(){
3242      return answer;      return answer;
3243            
3244  }  }
3245    /**
3246     * \Brief Set DB connection
3247     */
3248    Bool_t PamLevel2::SetDBConnection(){
3249    
3250        cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl;
3251        cout<<"Connecting to DB"<<endl;
3252        cout<<"HOST "<<host<<endl;
3253        cout<<"USER "<<user<<endl;
3254        cout<<"PSW  "<<psw<<endl;
3255        dbc = TSQLServer::Connect(host.Data(),user.Data(),psw.Data());
3256        if( !dbc )return false;
3257        if( !dbc->IsConnected() )return false;    
3258        cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl;
3259        return true;
3260    
3261    }

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

  ViewVC Help
Powered by ViewVC 1.1.23