/[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.45 by pam-fi, Wed Sep 12 08:14:00 2007 UTC revision 1.50 by mocchiut, Fri Oct 26 09:08:51 2007 UTC
# Line 11  PamTrack::PamTrack(){ Line 11  PamTrack::PamTrack(){
11      calo_track = 0;      calo_track = 0;
12      tof_track  = 0;      tof_track  = 0;
13      candeleteobj = 0;      candeleteobj = 0;
14        pscore = 0;
15        iscore = 0;
16  };  };
17  //--------------------------------------  //--------------------------------------
18  //  //
# Line 60  void PamTrack::Clear(){ Line 62  void PamTrack::Clear(){
62          calo_track = 0;          calo_track = 0;
63          tof_track  = 0;          tof_track  = 0;
64      }      }
65        pscore = 0;
66        iscore = 0;
67    
68  }  }
69  void PamTrack::Delete(){  void PamTrack::Delete(){
70  //    cout << "PamTrack::Delete() "<<candeleteobj<<endl;  //    cout << "PamTrack::Delete() "<<candeleteobj<<endl;
# Line 140  void PamLevel2::Initialize(){ Line 145  void PamLevel2::Initialize(){
145      dbc     = 0;      dbc     = 0;
146    
147      prevshift = 0;      prevshift = 0;
148        maxshift = 10; //EMILIANO
149            
150      run_tree = NULL;      run_tree = NULL;
151      run_tree_clone = NULL;      run_tree_clone = NULL;
# Line 631  void PamLevel2::SortTracks(TString how){ Line 637  void PamLevel2::SortTracks(TString how){
637  void PamLevel2::SortTracks(){  void PamLevel2::SortTracks(){
638    TString how = howtosort;    TString how = howtosort;
639    
640    //    cout <<" PamLevel2::SortTracks(TString how) "<<endl;    //  cout <<" PamLevel2::SortTracks(TString how) "<<endl;
641    if( !trk2_obj ){    if( !trk2_obj ){
642      cout << "void PamLevel2::SortTracks():  TrkLevel2 not loaded !!!";      cout << "void PamLevel2::SortTracks():  TrkLevel2 not loaded !!!";
643      return;      return;
# Line 661  void PamLevel2::SortTracks(){ Line 667  void PamLevel2::SortTracks(){
667    Bool_t use_TRK = how.Contains("TRK", TString::kIgnoreCase);    Bool_t use_TRK = how.Contains("TRK", TString::kIgnoreCase);
668    Bool_t use_CAL = how.Contains("CAL", TString::kIgnoreCase);    Bool_t use_CAL = how.Contains("CAL", TString::kIgnoreCase);
669    Bool_t use_TOF = how.Contains("TOF", TString::kIgnoreCase);    Bool_t use_TOF = how.Contains("TOF", TString::kIgnoreCase);
670          Bool_t use_S1 = how.Contains("S1", TString::kIgnoreCase);
671      Bool_t use_S2 = how.Contains("S2", TString::kIgnoreCase);
672      Bool_t use_S3 = how.Contains("S3", TString::kIgnoreCase);
673      
674      if ( use_TOF ){
675        use_S1 = true;
676        use_S2 = true;
677        use_S3 = true;
678      };
679    if( !CAL2 &&  use_CAL) use_CAL = false;    if( !CAL2 &&  use_CAL) use_CAL = false;
680    if( !TOF &&  use_TOF) use_TOF = false;    if( !TOF ){
681            use_TOF = false;
682        use_S1  = false;
683        use_S2  = false;
684        use_S3  = false;
685      }
686    
687    if( !TRK2 ){    if( !TRK2 ){
688      //  cout << "SortTracks() : without tracker does not work!!! (not yet)" << endl;      //  cout << "SortTracks() : without tracker does not work!!! (not yet)" << endl;
689      return;      return;
# Line 692  void PamLevel2::SortTracks(){ Line 711  void PamLevel2::SortTracks(){
711      ToFTrkVar  *oi = 0;      ToFTrkVar  *oi = 0;
712      //  cout << "trk track n. "<<i << " "<<hex<< tp <<dec<< endl;      //  cout << "trk track n. "<<i << " "<<hex<< tp <<dec<< endl;
713      // if track has an image, check image selection      // if track has an image, check image selection
714    
715        Int_t tp_score = 0;  //main track sorted by the tracker
716        Int_t ti_score = 0;  //image track
717        Int_t totp_score = 0;  //main track sorted by the tracker
718        Int_t toti_score = 0;  //image track
719    
720      if(tp->HasImage()){      if(tp->HasImage()){
721                            
722        ti = trk2_obj->TrkLevel2::GetTrackImage(i);              //tracker (image)        ti = trk2_obj->TrkLevel2::GetTrackImage(i);              //tracker (image)
# Line 701  void PamLevel2::SortTracks(){ Line 726  void PamLevel2::SortTracks(){
726        //            cout << "its image "<<i << " "<<hex<< ti <<dec<< endl;        //            cout << "its image "<<i << " "<<hex<< ti <<dec<< endl;
727    
728        //assign starting scores        //assign starting scores
729        Int_t tp_score = 0;  //main track sorted by the tracker        tp_score = 0;  //main track sorted by the tracker
730        Int_t ti_score = 0;  //image track        ti_score = 0;  //image track
731                            
732        // -----------------------------------------------------------------------------------------        // -----------------------------------------------------------------------------------------
733        // calorimeter check        // calorimeter check
# Line 713  void PamLevel2::SortTracks(){ Line 738  void PamLevel2::SortTracks(){
738          cout << "void PamLevel2::SortTracks(): howtosort= "<<how<<" but CaloLevel2 not loaded !!!";          cout << "void PamLevel2::SortTracks(): howtosort= "<<how<<" but CaloLevel2 not loaded !!!";
739          return;          return;
740        };        };
741        if( use_CAL && !cp &&  ci )ti_score++;        if( use_CAL && !cp &&  ci ){
742        if( use_CAL &&  cp && !ci )tp_score++;          ti_score++;
743            toti_score++;
744          };
745          if( use_CAL &&  cp && !ci ){
746            tp_score++;
747            totp_score++;
748          };
749        if(        if(
750           use_CAL            &&           use_CAL            &&
751  //       calo2_obj->npcfit[1] > 5     &&   //no. of fit planes on Y view  //       calo2_obj->npcfit[1] > 5     &&   //no. of fit planes on Y view
# Line 730  void PamLevel2::SortTracks(){ Line 761  void PamLevel2::SortTracks(){
761  //      else                 ti_score++;  //      else                 ti_score++;
762                    
763    
764            if( cp->npresh > ci->npresh) tp_score++;          if( cp->npresh > ci->npresh){
765            if( cp->npresh < ci->npresh) ti_score++;            tp_score++;
766            else ;//niente            totp_score++;
767            };
768            if( cp->npresh < ci->npresh){
769              ti_score++;
770              toti_score++;
771            };
772    
773          //      cout << "CALO "<<tp_score<<ti_score<<endl;          //      cout << "CALO "<<tp_score<<ti_score<<endl;
774    
# Line 742  void PamLevel2::SortTracks(){ Line 778  void PamLevel2::SortTracks(){
778        // -----------------------------------------------------------------------------------------        // -----------------------------------------------------------------------------------------
779        // check the number of hit pmts along the track        // check the number of hit pmts along the track
780        // on S12 S21 and S32, where paddles are parallel to Y axis        // on S12 S21 and S32, where paddles are parallel to Y axis
781        if( use_TOF && !tof_obj ){        if( (use_TOF || use_S1 || use_S2 || use_S3 ) && !tof_obj ){
782          cout << "void PamLevel2::SortTracks(): howtosort= "<<how<<" but ToFLevel2 not loaded !!!";          cout << "void PamLevel2::SortTracks(): howtosort= "<<how<<" but ToFLevel2 not loaded !!!";
783          return;          return;
784        };        };
785        if( use_TOF && !op &&  oi )ti_score++;        //
786        if( use_TOF &&  op && !oi )tp_score++;        if( (use_TOF || use_S1 || use_S2 || use_S3 ) && !op && oi ){
787        if( use_TOF && op && oi ){          ti_score++;
788                            toti_score++;
789          };
790          if( (use_TOF || use_S1 || use_S2 || use_S3 ) && op && !oi ){
791            tp_score++;
792            totp_score++;
793          };
794          if( (use_TOF || use_S1 || use_S2 || use_S3 ) && op && oi ){
795          //          //
796          Float_t sen = 0.;          Float_t sen = 0.;
797          for (Int_t ih=0; ih < op->npmtadc; ih++){          for (Int_t ih=0; ih < op->npmtadc; ih++){
# Line 761  void PamLevel2::SortTracks(){ Line 803  void PamLevel2::SortTracks(){
803            if ( pl == 2 || pl == 3 || pl == 4 || pl == 5 ) sen += (oi->dedx).At(ih);            if ( pl == 2 || pl == 3 || pl == 4 || pl == 5 ) sen += (oi->dedx).At(ih);
804          };          };
805          //          //
806          if (  sen >= sortthr ){          if (  sen >= sortthr && false){ // temporary disabled NUCLEI special algorithm since the new one should work for every particle (to be checked!)
807            //printf(" IS A NUCLEUS! en = %f \n",sen);            //printf(" IS A NUCLEUS! en = %f \n",sen);
808            //            //
809            // is a nucleus use a different algorithm            // is a nucleus use a different algorithm
# Line 854  void PamLevel2::SortTracks(){ Line 896  void PamLevel2::SortTracks(){
896    
897                                    
898            if(            if(
899               use_TOF            &&               (use_TOF || use_S1 || use_S2 || use_S3)            &&
900               (nphit_p+nphit_i) !=0 &&                 (nphit_p+nphit_i) !=0 &&  
901               true){               true){
902                                            
# Line 899  void PamLevel2::SortTracks(){ Line 941  void PamLevel2::SortTracks(){
941            // --- modified to count tdc signals (more efficient?)            // --- modified to count tdc signals (more efficient?)
942            // --- and to implement check on tdcflag            // --- and to implement check on tdcflag
943            for (Int_t ih=0; ih < op->npmttdc; ih++){            for (Int_t ih=0; ih < op->npmttdc; ih++){
944              //      Int_t pl = tof_obj->GetPlaneIndex( (op->pmttdc).At(ih) );              Int_t pl = tof_obj->GetPlaneIndex( (op->pmttdc).At(ih) );
945  //          if( (op->tdcflag).At(ih)==0 && (pl == 1 || pl == 2 || pl == 5) )nphit_p++;  //          if( (op->tdcflag).At(ih)==0 && (pl == 1 || pl == 2 || pl == 5) )nphit_p++;
946              if( (op->tdcflag).At(ih)==0 )nphit_p++;              if ( (use_S1 && ( pl == 0 || pl == 1 )) || (use_S2 && ( pl == 2 || pl == 3 )) || (use_S3 && ( pl == 4 || pl == 5 )) ){
947                  if( (op->tdcflag).At(ih)==0 )nphit_p++;
948                };
949            };            };
950                                    
951            for (Int_t ih=0; ih < oi->npmttdc; ih++){            for (Int_t ih=0; ih < oi->npmttdc; ih++){
952              //      Int_t pl = tof_obj->GetPlaneIndex( (oi->pmttdc).At(ih) );              Int_t pl = tof_obj->GetPlaneIndex( (oi->pmttdc).At(ih) );
953  //          if( (oi->tdcflag).At(ih)==0 && (pl == 1 || pl == 2 || pl == 5) )nphit_i++;    //          if( (oi->tdcflag).At(ih)==0 && (pl == 1 || pl == 2 || pl == 5) )nphit_i++;  
954              if( (oi->tdcflag).At(ih)==0 )nphit_i++;                  if ( (use_S1 && ( pl == 0 || pl == 1 )) || (use_S2 && ( pl == 2 || pl == 3 )) || (use_S3 && ( pl == 4 || pl == 5 )) ){
955                  if( (oi->tdcflag).At(ih)==0 )nphit_i++;  
956                };
957            };            };
958                                    
959            if(            if(
960               (nphit_p+nphit_i) !=0 &&                 (nphit_p+nphit_i) !=0 &&  
961               true){               true){
962                                            
963              if     ( nphit_p > nphit_i) tp_score++;              if ( nphit_p != nphit_i ){
964              else if( nphit_p < nphit_i) ti_score++;                totp_score += nphit_p;
965              else ;//niente                toti_score += nphit_i;
966                  tp_score+=nphit_p;
967                  ti_score+=nphit_i;
968                };
969                //      if     ( nphit_p > nphit_i) tp_score+=nphit_p;
970                //      else if( nphit_p < nphit_i) ti_score+=nphit_i;
971                //      else ;//niente
972            };            };
973          };          };
974          //      cout << "TOF "<<tp_score<<ti_score<<endl;          //      cout << "TOF "<<tp_score<<ti_score<<endl;
# Line 938  void PamLevel2::SortTracks(){ Line 990  void PamLevel2::SortTracks(){
990  //      else if( ti->chi2 > 0 && ti->chi2 < tp->chi2 ) ti_score++ ;  //      else if( ti->chi2 > 0 && ti->chi2 < tp->chi2 ) ti_score++ ;
991    
992            // CHECK 1 : number of points along X              // CHECK 1 : number of points along X  
993            if ( tp->GetNX() >= ti->GetNX() )tp_score++ ;          if ( tp->GetNX() >= ti->GetNX() ){
994            if ( tp->GetNX() <= ti->GetNX() )ti_score++ ;            tp_score++ ;
995              totp_score++ ;
996            };
997            if ( tp->GetNX() <= ti->GetNX() ){
998              ti_score++ ;
999              toti_score++ ;
1000            };
1001            // CHECK 2 : number of points along Y              // CHECK 2 : number of points along Y  
1002            if ( tp->GetNY() >= ti->GetNY() )tp_score++ ;          if ( tp->GetNY() >= ti->GetNY() ){
1003            if ( tp->GetNY() <= ti->GetNY() )ti_score++ ;            tp_score++ ;
1004              totp_score++ ;
1005            };
1006            if ( tp->GetNY() <= ti->GetNY() ){
1007              ti_score++ ;
1008              toti_score++ ;
1009            };
1010            // CHECK 3 : chi**2 along X              // CHECK 3 : chi**2 along X  
1011  //        if(      tp->GetChi2X() > 0 && (tp->GetChi2X() < ti->GetChi2X() || ti->GetChi2X() <=0) ) tp_score++ ;  //        if(      tp->GetChi2X() > 0 && (tp->GetChi2X() < ti->GetChi2X() || ti->GetChi2X() <=0) ) tp_score++ ;
1012  //        if(      ti->GetChi2X() > 0 && (ti->GetChi2X() < tp->GetChi2X() || tp->GetChi2X() <=0) ) ti_score++ ;  //        if(      ti->GetChi2X() > 0 && (ti->GetChi2X() < tp->GetChi2X() || tp->GetChi2X() <=0) ) ti_score++ ;
# Line 970  void PamLevel2::SortTracks(){ Line 1034  void PamLevel2::SortTracks(){
1034          ts = ti;//its image!!          ts = ti;//its image!!
1035          cs = ci;          cs = ci;
1036          os = oi;          os = oi;
1037            Int_t totis = toti_score;
1038    
1039          ti = tp;//its image!!          ti = tp;//its image!!
1040          ci = cp;          ci = cp;
# Line 979  void PamLevel2::SortTracks(){ Line 1044  void PamLevel2::SortTracks(){
1044          cp = cs;          cp = cs;
1045          op = os;          op = os;
1046    
1047            toti_score = totp_score;
1048            totp_score = totis;
1049    
1050                                    
1051        }else {        }else {
1052    
# Line 987  void PamLevel2::SortTracks(){ Line 1055  void PamLevel2::SortTracks(){
1055        };        };
1056                            
1057      }else{      }else{
1058          totp_score = 1;
1059          toti_score = 0;
1060          
1061        //            ts = tp;        //            ts = tp;
1062        //            cs = cp;        //            cs = cp;
1063        //            os = op;        //            os = op;
# Line 1000  void PamLevel2::SortTracks(){ Line 1071  void PamLevel2::SortTracks(){
1071      //  cout<<"o "<<tp<<endl;      //  cout<<"o "<<tp<<endl;
1072      //  cout<<"o "<<cp<<endl;      //  cout<<"o "<<cp<<endl;
1073      //  cout<<"o "<<op<<endl;      //  cout<<"o "<<op<<endl;
1074    
1075      new(ttsorted[i]) PamTrack(tp,cp,op);      new(ttsorted[i]) PamTrack(tp,cp,op);
1076      new(ttimage[i])  PamTrack(ti,ci,oi);      new(ttimage[i])  PamTrack(ti,ci,oi);
1077    
1078        ((PamTrack*)(ttsorted[i]))->SetPScore(totp_score);
1079        ((PamTrack*)(ttsorted[i]))->SetIScore(toti_score);
1080        ((PamTrack*)(ttimage[i]))->SetPScore(totp_score);
1081        ((PamTrack*)(ttimage[i]))->SetIScore(toti_score);
1082    };    };
1083    
1084    if( tsorted->GetEntries() != trk2_obj->GetNTracks() ){    if( tsorted->GetEntries() != trk2_obj->GetNTracks() ){
# Line 1899  Bool_t PamLevel2::UpdateRunInfo(TChain * Line 1976  Bool_t PamLevel2::UpdateRunInfo(TChain *
1976    //    //
1977    // check if we have already called once GetEntry, if not call it    // check if we have already called once GetEntry, if not call it
1978    //    //
1979      cout << "Bool_t PamLevel2::UpdateRunInfo(TChain *run, Long64_t iev) --- NON FUNZIONA BENISSIMO.... "<<endl;      cout << "Bool_t PamLevel2::UpdateRunInfo(TChain *run, Long64_t iev) --- ATTENZIONE --- NON E` MANTENUTA!!!!!!!.... "<<endl;
1980      if(!run){      if(!run){
1981            cout << "Bool_t PamLevel2::UpdateRunInfo(TChain *run, ULong64_t iev) -- ERROR -- missing RunInfo tree "<<endl;            cout << "Bool_t PamLevel2::UpdateRunInfo(TChain *run, ULong64_t iev) -- ERROR -- missing RunInfo tree "<<endl;
1982            return(false);                    return(false);        
# Line 2085  Bool_t PamLevel2::UpdateRunInfo(Long64_t Line 2162  Bool_t PamLevel2::UpdateRunInfo(Long64_t
2162          };                };      
2163    
2164          // -----------------------------------------------------------------------          // -----------------------------------------------------------------------
2165          // if it is simulation, assigh abstime by hand (temporaneo!!!)          // if it is simulation, assign abstime by hand (temporaneo!!!)
2166          // -----------------------------------------------------------------------          // -----------------------------------------------------------------------
2167          if(ISGP){          if(ISGP){
2168              abstime = GetRunInfo()->RUNHEADER_TIME; // BARBATRUCCO              abstime = GetRunInfo()->RUNHEADER_TIME; // BARBATRUCCO
# Line 2110  Bool_t PamLevel2::UpdateRunInfo(Long64_t Line 2187  Bool_t PamLevel2::UpdateRunInfo(Long64_t
2187                        obt <= GetRunInfo()->RUNTRAILER_OBT)                        obt <= GetRunInfo()->RUNTRAILER_OBT)
2188                      )                      )
2189                  || GetRunInfo()->NEVENTS==0                  || GetRunInfo()->NEVENTS==0
2190                  || !(irunentry < GetRunInfo()->NEVENTS-1-prevshift)  //              || !(irunentry < GetRunInfo()->NEVENTS-1-prevshift) // ERRORE!!! fa saltare i run con 1 evento
2191                    || !(irunentry <= GetRunInfo()->NEVENTS-1-prevshift)
2192                  )                  )
2193                  && irun < run_tree->GetEntries() ){                  && irun < run_tree->GetEntries() ){
2194    
2195                // - - - - - - - - - - - - -
2196                // irunentry = position of current entry, relative to the run
2197                // prevshift = shift needed to synchronize l0 and l2 data (nested events)
2198                // - - - - - - - - - - - - -
2199    
2200              // -----------------------------------------              // -----------------------------------------
2201              // store dead and live-time of previous run              // store dead and live-time of previous run
# Line 3355  Int_t PamLevel2::GetYodaEntry(){ Line 3435  Int_t PamLevel2::GetYodaEntry(){
3435      Int_t answer = 0;      Int_t answer = 0;
3436      Int_t shift =0;      Int_t shift =0;
3437      //    printf(" siamo qui %i %i \n",shift,prevshift);      //    printf(" siamo qui %i %i \n",shift,prevshift);
3438      Int_t maxshift = 10;      //    Int_t maxshift = 50; // EMILIANO
3439      do{      do{
3440          if(shift>0){              if(shift>0){    
3441              cout << " PKTNUM  L2 --- "<< pktn << " --- L0 --- "<< GetEventHeader()->GetPscuHeader()->GetCounter()<<endl;              cout << " PKTNUM  L2 --- "<< pktn << " --- L0 --- "<< GetEventHeader()->GetPscuHeader()->GetCounter()<<endl;

Legend:
Removed from v.1.45  
changed lines
  Added in v.1.50

  ViewVC Help
Powered by ViewVC 1.1.23