/[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.51 by mocchiut, Mon Oct 29 09:13:06 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 112  PamLevel2::PamLevel2(TString ddir,TStrin Line 117  PamLevel2::PamLevel2(TString ddir,TStrin
117    
118  void PamLevel2::Initialize(){  void PamLevel2::Initialize(){
119                    
 //     trk2_obj  = TrkLevel2::GetTrkLevel2();  
 //     trk1_obj  = TrkLevel1::GetTrkLevel1();  
 //     trkh_obj  = TrkHough::GetTrkHough();  
 //     calo1_obj = CaloLevel1::GetCaloLevel1();  
 //     calo2_obj = CaloLevel2::GetCaloLevel2();  
 //     tof_obj   = ToFLevel2::GetToFLevel2();  
 //     trig_obj  = TrigLevel2::GetTrigLevel2();  
 //     s4_obj    = S4Level2::GetS4Level2();  
 //     nd_obj    = NDLevel2::GetNDLevel2();  
 //     ac_obj    = AcLevel2::GetAcLevel2();  
 //     orb_obj   = OrbitalInfo::GetOrbitalInfo();  
       
120      h0_obj    = 0;      h0_obj    = 0;
121      trk0_obj  = 0;      trk0_obj  = 0;
122      calo0_obj  = 0;      calo0_obj  = 0;
# Line 152  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 162  void PamLevel2::Initialize(){ Line 156  void PamLevel2::Initialize(){
156      pam_tree = NULL;      pam_tree = NULL;
157      for(Int_t i=0; i<NCLONES; i++ )pam_tree_clone[i]=NULL;      for(Int_t i=0; i<NCLONES; i++ )pam_tree_clone[i]=NULL;
158    
159        totdltime[0] = 0LL;
160        totdltime[1] = 0LL;
161    
162      host = "mysql://localhost/pamelaprod";      host = "mysql://localhost/pamelaprod";
163      user = "anonymous";      user = "anonymous";
164      psw = "";      psw = "";
# Line 198  void PamLevel2::Initialize(){ Line 195  void PamLevel2::Initialize(){
195    
196      SELLI = -1;      SELLI = -1;
197    
198        ISGP = false;
199    
200      tsorted=0;      tsorted=0;
201      timage=0;      timage=0;
202            
# Line 401  void PamLevel2::Reset(){ Line 400  void PamLevel2::Reset(){
400    runfirstentry = 0ULL;    runfirstentry = 0ULL;
401    runlastentry = 0ULL;        runlastentry = 0ULL;    
402    //    //
403      totdltime[0] = 0LL;
404      totdltime[1] = 0LL;
405      //
406  };  };
407    
408  Bool_t PamLevel2::IsGood(){  Bool_t PamLevel2::IsGood(){
# Line 635  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 658  void PamLevel2::SortTracks(){ Line 660  void PamLevel2::SortTracks(){
660    TClonesArray &ttimage = *timage;    TClonesArray &ttimage = *timage;
661    
662    
663    // loop over the tracks sorted by the tracker  
664      //--------------------------------------------------
665      // retrieve sorting method
666      //--------------------------------------------------
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;
690    };    };
691    
692    //   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;
693          
694    
695      //--------------------------------------------------
696      // loop over "physical" tracks sorted by the tracker
697      //--------------------------------------------------
698    for(Int_t i=0; i < trk2_obj->TrkLevel2::GetNTracks(); i++){    for(Int_t i=0; i < trk2_obj->TrkLevel2::GetNTracks(); i++){
699                    
700      TrkTrack   *ts = 0;      TrkTrack   *ts = 0;
# Line 680  void PamLevel2::SortTracks(){ Line 702  void PamLevel2::SortTracks(){
702      ToFTrkVar  *os = 0;      ToFTrkVar  *os = 0;
703                    
704      // get tracker tracks      // get tracker tracks
705      TrkTrack   *tp = trk2_obj->TrkLevel2::GetTrack(i);                    //tracker      TrkTrack   *tp = trk2_obj->TrkLevel2::GetTrack(i); //tracker
706      CaloTrkVar *cp = GetCaloStoredTrack(tp->GetSeqNo());      CaloTrkVar *cp = GetCaloStoredTrack(tp->GetSeqNo());
707      ToFTrkVar  *op = GetToFStoredTrack(tp->GetSeqNo());      ToFTrkVar  *op = GetToFStoredTrack(tp->GetSeqNo());
708    
709      TrkTrack   *ti = 0;              //tracker (image)      TrkTrack   *ti = 0; //tracker (image)
710      CaloTrkVar *ci = 0;      CaloTrkVar *ci = 0;
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 698  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
734        // ------------------------        // -----------------------------------------------------------------------------------------
735        // check the Y spatial residual on the first calorimeter plane        // check the Y spatial residual on the first calorimeter plane
736        // (cut on calorimeter variables from Emiliano)        // (cut on calorimeter variables from Emiliano)
737        if( use_CAL && !calo2_obj ){        if( use_CAL && !calo2_obj ){
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 ){
742            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
752           calo2_obj->varcfit[1] < 1000. &&  //fit variance on Y view  //       calo2_obj->varcfit[1] < 1000. &&  //fit variance on Y view
753           cp && ci &&           cp && ci &&
754           true){           true){
755    
756                                    
757          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;
758          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;
759                                    
760          if(resy_p <= resy_i) tp_score++;  //      if(resy_p <= resy_i) tp_score++;
761          else                 ti_score++;  //      else                 ti_score++;
762                    
763    
764            if( cp->npresh > ci->npresh){
765              tp_score++;
766              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    
775        };        };
776        // ------------------------        // -----------------------------------------------------------------------------------------
777        // TOF check        // TOF check
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 ){        //
786                          if( (use_TOF || use_S1 || use_S2 || use_S3 ) && !op && oi ){
787            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 749  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 842  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 875  void PamLevel2::SortTracks(){ Line 929  void PamLevel2::SortTracks(){
929              cout << "image: npmtadc "<< oi->npmtadc << endl;              cout << "image: npmtadc "<< oi->npmtadc << endl;
930              cout << "image: npmttdc "<< oi->npmttdc << endl;*/              cout << "image: npmttdc "<< oi->npmttdc << endl;*/
931                                    
932            for (Int_t ih=0; ih < op->npmtadc; ih++){  //        for (Int_t ih=0; ih < op->npmtadc; ih++){
933              Int_t pl = tof_obj->GetPlaneIndex( (op->pmtadc).At(ih) );  //          Int_t pl = tof_obj->GetPlaneIndex( (op->pmtadc).At(ih) );
934              if(pl == 1 || pl == 2 || pl == 5)nphit_p++;  //          if(pl == 1 || pl == 2 || pl == 5)nphit_p++;
935    //        };
936                    
937    //        for (Int_t ih=0; ih < oi->npmtadc; ih++){
938    //          Int_t pl = tof_obj->GetPlaneIndex( (oi->pmtadc).At(ih) );
939    //          if(pl == 1 || pl == 2 || pl == 5)nphit_i++;
940    //        };
941              // --- modified to count tdc signals (more efficient?)
942              // --- and to implement check on tdcflag
943              for (Int_t ih=0; ih < op->npmttdc; ih++){
944                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++;
946                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->npmtadc; ih++){            for (Int_t ih=0; ih < oi->npmttdc; ih++){
952              Int_t pl = tof_obj->GetPlaneIndex( (oi->pmtadc).At(ih) );              Int_t pl = tof_obj->GetPlaneIndex( (oi->pmttdc).At(ih) );
953              if(pl == 1 || pl == 2 || pl == 5)nphit_i++;  //          if( (oi->tdcflag).At(ih)==0 && (pl == 1 || pl == 2 || pl == 5) )nphit_i++;  
954                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(
              use_TOF            &&  
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 ti_score++;                totp_score += nphit_p;
965                  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;
975        };        };
976        if(tp_score == ti_score) use_TRK = true;  
977        // ------------------------  
978    //      if(tp_score == ti_score) use_TRK = true;
979    
980    
981          // -----------------------------------------------------------------------------------------
982        // tracker check        // tracker check
983        // ------------------------        // -----------------------------------------------------------------------------------------
984        // chi**2 difference is not always large enough to distinguish among        // chi**2 difference is not always large enough to distinguish among
985        // the real track and its image.        // the real track and its image.
986        // 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.
987          // *** MODIFIED ON AUGUST 2007 ***
988        if(use_TRK){        if(use_TRK){
989          if(      tp->chi2 > 0 && tp->chi2 < ti->chi2 ) tp_score++ ;  //      if(      tp->chi2 > 0 && tp->chi2 < ti->chi2 ) tp_score++ ;
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  
993            if ( tp->GetNX() >= ti->GetNX() ){
994              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  
1002            if ( tp->GetNY() >= ti->GetNY() ){
1003              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  
1011    //        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++ ;
1013              // CHECK 4 : chi**2 along Y  
1014    //        if(      tp->GetChi2Y() > 0 && (tp->GetChi2Y() < ti->GetChi2Y() || ti->GetChi2Y() <=0) ) tp_score++ ;
1015    //        if(      ti->GetChi2Y() > 0 && (ti->GetChi2Y() < tp->GetChi2Y() || tp->GetChi2Y() <=0) ) ti_score++ ;
1016              // CHECK 5 : total chi**2  
1017    //        if(      tp->chi2 > 0 && (tp->chi2 < ti->chi2 || ti->chi2 <=0) ) tp_score++ ;
1018    //        if(      ti->chi2 > 0 && (ti->chi2 < tp->chi2 || tp->chi2 <=0) ) ti_score++ ;
1019    
1020          //      cout << "TRK "<<tp_score<<ti_score<<endl;          //      cout << "TRK "<<tp_score<<ti_score<<endl;
1021        };        };
1022                            
1023        // ------------------------  
1024    
1025          // *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
1026        // the winner is....        // the winner is....
1027        // ------------------------                  // *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
1028        if      (tp_score > ti_score) {        if      (tp_score > ti_score) {
1029          //              ts = tp;//the track sorted by the tracker!!          
         //              cs = cp;  
         //              os = op;  
         //      cout << "It's primary!" << endl;  
1030    
1031        }else if (tp_score < ti_score) {        }else if (tp_score < ti_score) {
1032    
         //      cout << "It's image!" << endl;  
1033    
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 934  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          //              ts = tp;  
         //              cs = cp;  
         //              os = op;  
1053  //      cout << "Warning - track image ambiguity not solved" << endl;  //      cout << "Warning - track image ambiguity not solved" << endl;
1054          //                              cout << ts->GetNtot() << " "<< ts->chi2 << " " << npcfit[1] << " "<< nphit_p << endl;  
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 957  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 1856  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 1875  Bool_t PamLevel2::UpdateRunInfo(TChain * Line 1995  Bool_t PamLevel2::UpdateRunInfo(TChain *
1995        //        //
1996        // the absolute time is necessary to relate the event with the run        // the absolute time is necessary to relate the event with the run
1997        //        //
1998        if( !GetOrbitalInfo() ){        if( !GetOrbitalInfo() && !ISGP){
1999            cout << "Bool_t PamLevel2::UpdateRunInfo(TChain *run, ULong64_t iev) -- ERROR -- missing OrbitalInfo "<<endl;            cout << "Bool_t PamLevel2::UpdateRunInfo(TChain *run, ULong64_t iev) -- ERROR -- missing OrbitalInfo "<<endl;
2000            return(false);            return(false);
2001        }        }
2002    
2003          ULong64_t abstime = 0;
2004          if( GetOrbitalInfo() )abstime=GetOrbitalInfo()->absTime;
2005    
2006    
2007        //        //
2008        // the first time the routine is called, set run search from the beginning        // the first time the routine is called, set run search from the beginning
2009        //        //
# Line 1889  Bool_t PamLevel2::UpdateRunInfo(TChain * Line 2013  Bool_t PamLevel2::UpdateRunInfo(TChain *
2013            runfirstentry = 0LL;            runfirstentry = 0LL;
2014            runlastentry += (Long64_t)(this->GetRunInfo()->NEVENTS);            runlastentry += (Long64_t)(this->GetRunInfo()->NEVENTS);
2015            if ( (Long64_t)(this->GetRunInfo()->NEVENTS) > 0LL ) runlastentry -= 1LL;            if ( (Long64_t)(this->GetRunInfo()->NEVENTS) > 0LL ) runlastentry -= 1LL;
2016              
2017              if( ISGP && run->GetEntries()!=1 ){
2018                  cout << "** WARNING ** simulated files are assumed to have 1 single run, not "<< run->GetEntries() << endl;
2019                  cout << "** WARNING ** run will not be updated"<<endl;
2020              }
2021    
2022        };              };      
2023        //        //
2024         if ( irun == run->GetEntries()-1LL &&        if(ISGP)abstime = GetRunInfo()->RUNHEADER_TIME; // BARBATRUCCO
2025             !(GetOrbitalInfo()->absTime >= GetRunInfo()->RUNHEADER_TIME &&        //
2026               GetOrbitalInfo()->absTime <= GetRunInfo()->RUNTRAILER_TIME)        if ( irun == run->GetEntries()-1LL &&
2027               !(abstime >= GetRunInfo()->RUNHEADER_TIME &&
2028                 abstime <= GetRunInfo()->RUNTRAILER_TIME)
2029              ){              ){
2030           irun = -1LL;           irun = -1LL;
2031           runfirstentry = 0LL;           runfirstentry = 0LL;
# Line 1904  Bool_t PamLevel2::UpdateRunInfo(TChain * Line 2036  Bool_t PamLevel2::UpdateRunInfo(TChain *
2036        //        //
2037        bool fromfirst = true;        bool fromfirst = true;
2038        //        //
2039        while ( !(GetOrbitalInfo()->absTime >= GetRunInfo()->RUNHEADER_TIME && GetOrbitalInfo()->absTime <= GetRunInfo()->RUNTRAILER_TIME) && irun < run->GetEntries()-1LL ){        while ( !(abstime >= GetRunInfo()->RUNHEADER_TIME && abstime <= GetRunInfo()->RUNTRAILER_TIME) && irun < run->GetEntries()-1LL ){
2040  //      while ( iev > (runfirstentry+(ULong64_t)(this->GetRunInfo()->NEVENTS-1)) && irun < run->GetEntries() ){  //      while ( iev > (runfirstentry+(ULong64_t)(this->GetRunInfo()->NEVENTS-1)) && irun < run->GetEntries() ){
2041            irun++;            irun++;
2042            run->GetEntry(irun);            run->GetEntry(irun);
# Line 1914  Bool_t PamLevel2::UpdateRunInfo(TChain * Line 2046  Bool_t PamLevel2::UpdateRunInfo(TChain *
2046  //        cout << " ))))) UPDATE RUN INFO (((((  @iev "<<iev<<" run "<<GetRunInfo()->ID<<" irun "<<irun<<endl;  //        cout << " ))))) UPDATE RUN INFO (((((  @iev "<<iev<<" run "<<GetRunInfo()->ID<<" irun "<<irun<<endl;
2047  //        cout << "runfirstentry "<<runfirstentry<<endl;  //        cout << "runfirstentry "<<runfirstentry<<endl;
2048            //      printf(" iev %llu %u %llu \n",iev,this->GetRunInfo()->NEVENTS,(ULong64_t)(runfirstentry+(ULong64_t)(this->GetRunInfo()->NEVENTS)));            //      printf(" iev %llu %u %llu \n",iev,this->GetRunInfo()->NEVENTS,(ULong64_t)(runfirstentry+(ULong64_t)(this->GetRunInfo()->NEVENTS)));
2049            //      printf(" abstime %u trailertime %u \n",GetOrbitalInfo()->absTime,GetRunInfo()->RUNTRAILER_TIME);            //      printf(" abstime %u trailertime %u \n",abstime,GetRunInfo()->RUNTRAILER_TIME);
2050            //      printf(" IDRUN %u \n",GetRunInfo()->ID);            //      printf(" IDRUN %u \n",GetRunInfo()->ID);
2051            //            //
2052  //        prevshift = 0;  //        prevshift = 0;
2053            //            //
2054            if ( irun == (Long64_t)(run->GetEntries()-1LL) && fromfirst && !(GetOrbitalInfo()->absTime >= GetRunInfo()->RUNHEADER_TIME && GetOrbitalInfo()->absTime <= GetRunInfo()->RUNTRAILER_TIME)){            if ( irun == (Long64_t)(run->GetEntries()-1LL) && fromfirst && !(abstime >= GetRunInfo()->RUNHEADER_TIME && abstime <= GetRunInfo()->RUNTRAILER_TIME)){
2055                printf(" resetting irun  (it should NOT happen!!!)\n");                printf(" resetting irun  (it should NOT happen!!!)\n");
2056                fromfirst = false;                fromfirst = false;
2057                irun = 0;                irun = 0;
# Line 1932  Bool_t PamLevel2::UpdateRunInfo(TChain * Line 2064  Bool_t PamLevel2::UpdateRunInfo(TChain *
2064        };        };
2065        //        //
2066        if (        if (
2067             !(GetOrbitalInfo()->absTime >= GetRunInfo()->RUNHEADER_TIME &&             !(abstime >= GetRunInfo()->RUNHEADER_TIME &&
2068               GetOrbitalInfo()->absTime <= GetRunInfo()->RUNTRAILER_TIME)               abstime <= GetRunInfo()->RUNTRAILER_TIME)
2069            ) {            ) {
2070            printf(" Something very wrong here: cannot find RUN containing absolute time %u \n",GetOrbitalInfo()->absTime);          printf(" Something very wrong here: cannot find RUN containing absolute time %llu \n",abstime);
2071            return false;            return false;
2072        }        }
2073        //        //
# Line 1987  Bool_t PamLevel2::UpdateRunInfo(Long64_t Line 2119  Bool_t PamLevel2::UpdateRunInfo(Long64_t
2119      if(SELLI==0){      if(SELLI==0){
2120    
2121          // ---------------------------------------------------------------          // ---------------------------------------------------------------
2122            // increment dead and live-time counters
2123            // ---------------------------------------------------------------
2124            if( GetTrigLevel2() ){
2125                totdltime[0]+=GetTrigLevel2()->dltime[0];
2126                totdltime[1]+=GetTrigLevel2()->dltime[1];
2127            }
2128            totdltime[2]++;
2129    
2130    //      cout << setw(10)<<totdltime[0]<<setw(10)<<totdltime[1]<<setw(10)<<totdltime[2]<<endl;
2131    
2132            // ---------------------------------------------------------------
2133            // retrieve OBT and absolute time of the event
2134            // ---------------------------------------------------------------
2135            ULong64_t abstime = 0;
2136            ULong64_t obt     = 0;
2137            if( GetOrbitalInfo() ){
2138                abstime = GetOrbitalInfo()->absTime;
2139                obt     = GetOrbitalInfo()->OBT;
2140            }
2141            // ---------------------------------------------------------------
2142          // the absolute time is necessary to relate the event with the run          // the absolute time is necessary to relate the event with the run
2143          // ---------------------------------------------------------------          // ---------------------------------------------------------------
2144          if( !GetOrbitalInfo() ){          if( !GetOrbitalInfo() && !ISGP ){
2145              cout << "Bool_t PamLevel2::UpdateRunInfo(Long64_t iev) -- ERROR -- missing OrbitalInfo "<<endl;              cout << "Bool_t PamLevel2::UpdateRunInfo(Long64_t iev) -- ERROR -- missing OrbitalInfo "<<endl;
2146              return(false);              return(false);
2147          }          }
# Line 2002  Bool_t PamLevel2::UpdateRunInfo(Long64_t Line 2154  Bool_t PamLevel2::UpdateRunInfo(Long64_t
2154              irunentry = 0;              irunentry = 0;
2155              prevshift = 0;              prevshift = 0;
2156              run_tree->GetEntry(irun);              run_tree->GetEntry(irun);
2157    
2158                if( ISGP && run_tree->GetEntries()!=1 ){
2159                    cout << "** WARNING ** simulated files are assumed to have 1 single run, not "<< run_tree->GetEntries() << endl;
2160                    cout << "** WARNING ** run will not be updated"<<endl;
2161                }
2162          };                };      
2163    
2164            // -----------------------------------------------------------------------
2165            // if it is simulation, assign abstime by hand (temporaneo!!!)
2166            // -----------------------------------------------------------------------
2167            if(ISGP){
2168                abstime = GetRunInfo()->RUNHEADER_TIME; // BARBATRUCCO
2169                obt     = GetRunInfo()->RUNHEADER_OBT; // BARBATRUCCO
2170            }
2171          //          //
2172          bool fromfirst = true; // first loop over runs          bool fromfirst = true; // first loop over runs
2173    
# Line 2016  Bool_t PamLevel2::UpdateRunInfo(Long64_t Line 2181  Bool_t PamLevel2::UpdateRunInfo(Long64_t
2181          while (          while (
2182              (              (
2183                  (                  (
2184                      !(GetOrbitalInfo()->absTime >= GetRunInfo()->RUNHEADER_TIME &&    // check on absolute time (s)                      !(abstime >= GetRunInfo()->RUNHEADER_TIME &&    // check on absolute time (s)
2185                        GetOrbitalInfo()->absTime <= GetRunInfo()->RUNTRAILER_TIME) &&                        abstime <= GetRunInfo()->RUNTRAILER_TIME) &&
2186                      !(GetOrbitalInfo()->OBT >= GetRunInfo()->RUNHEADER_OBT &&         // additional check on OBT (ms)                      !(obt >= GetRunInfo()->RUNHEADER_OBT &&         // additional check on OBT (ms)
2187                        GetOrbitalInfo()->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
2202                // -----------------------------------------
2203                if(fromfirst){
2204                    if(oldrun==irun){
2205                        /// decrement counters
2206                        if( GetTrigLevel2()){
2207                            totdltime[0]-=GetTrigLevel2()->dltime[0];//live-time
2208                            totdltime[1]-=GetTrigLevel2()->dltime[1];//dead-time
2209                        }
2210                        totdltime[2]--;                              //event counter
2211                        cout << endl;
2212                        cout << "n.events     : "<<totdltime[2]<<endl;
2213                        cout << "RUN LIVE-TIME: "<<totdltime[0]*0.16<<" ms"<<endl;
2214                        cout << "RUN DEAD-TIME: "<<totdltime[1]*0.01<<" ms"<<endl;      
2215                    }else{
2216                        totdltime[0]=0;//live-time
2217                        totdltime[1]=0;//dead-time
2218                        totdltime[2]=0;                             //event counter
2219                        cout << " *** JUMP RUN *** irun "<<irun<<endl;
2220                    }
2221                    /// add an entry
2222                    if(run_tree_clone)
2223                        if(run_tree_clone->GetBranch("DeadLiveTime")->GetEntries() < run_tree->GetEntries())
2224                            run_tree_clone->GetBranch("DeadLiveTime")->Fill();
2225                    /// reset counters
2226                    if( GetTrigLevel2() ){
2227                        totdltime[0]=GetTrigLevel2()->dltime[0];//live-time
2228                        totdltime[1]=0;                         //dead-time
2229                    }
2230                    totdltime[2]=1;                             //event counter
2231                }
2232    
2233    
2234              irun++;              irun++;
2235              // ------------------------------------              // ------------------------------------
2236              // if the end of run tree is reached...              // if the end of run tree is reached...
# Line 2053  Bool_t PamLevel2::UpdateRunInfo(Long64_t Line 2258  Bool_t PamLevel2::UpdateRunInfo(Long64_t
2258              // -------------------------------------------------------------------              // -------------------------------------------------------------------
2259              if(irun>0)runfirstentry += (GetRunInfo()->NEVENTS)-prevshift;              if(irun>0)runfirstentry += (GetRunInfo()->NEVENTS)-prevshift;
2260              irunentry = 0;              irunentry = 0;
2261              prevshift = 0;              prevshift = 0;          
2262              run_tree->GetEntry(irun);                    run_tree->GetEntry(irun);      
2263              if(GetRunInfo()->RUNHEADER_OBT>GetRunInfo()->RUNTRAILER_OBT ){              if(GetRunInfo()->RUNHEADER_OBT>GetRunInfo()->RUNTRAILER_OBT ){
2264                  cout << "Bool_t PamLevel2::UpdateRunInfo(Long64_t iev) -- WARNING -- irun "<<irun<<"  has RUNHEADER_OBT>=RUNTRAILER_OBT " <<endl;                  cout << "Bool_t PamLevel2::UpdateRunInfo(Long64_t iev) -- WARNING -- irun "<<irun<<"  has RUNHEADER_OBT>=RUNTRAILER_OBT " <<endl;
# Line 2073  Bool_t PamLevel2::UpdateRunInfo(Long64_t Line 2278  Bool_t PamLevel2::UpdateRunInfo(Long64_t
2278    
2279          // --------------------------------------          // --------------------------------------
2280          // ... otherwise          // ... otherwise
2281            // --------------------------------------
2282    
2283    
2284    
2285    //      // -----------------------------------------
2286    //      // store dead and live-time of previous run
2287    //      // -----------------------------------------
2288    //      // --------------------------------------------------------------
2289    //      // if the run is empty, fill the dead-live time branch with zeros
2290    //      // --------------------------------------------------------------
2291    //      /// if some runs have been jumped, fill with zeros
2292    //      if(irun-oldrun>1){
2293    //          ULong64_t  temp[3];
2294    //          temp[0]=totdltime[0];
2295    //          temp[1]=totdltime[1];
2296    //          temp[2]=totdltime[2];
2297    //          for(int i=oldrun+1; i<irun; irun++){
2298    //              totdltime[0]=0;
2299    //              totdltime[1]=0;
2300    //              totdltime[2]=0;
2301    //              cout << " ** JUMPED RUN **"<<endl;
2302    //              if(run_tree_clone)
2303    //                  if(run_tree_clone->GetBranch("DeadLiveTime")->GetEntries() < run_tree->GetEntries())
2304    //                      run_tree_clone->GetBranch("DeadLiveTime")->Fill();
2305    //          }
2306    //          totdltime[0]=temp[0];
2307    //          totdltime[1]=temp[1];
2308    //          totdltime[2]=temp[2];
2309    //      }
2310    //      /// decrement counters
2311    //      if( GetTrigLevel2() ){
2312    //          totdltime[0]-=GetTrigLevel2()->dltime[0];//live-time
2313    //          totdltime[1]-=GetTrigLevel2()->dltime[1];//dead-time
2314    //      }
2315    //      totdltime[2]--;                              //event counter
2316    //      /// add an entry
2317    //      if(irun>0 ){
2318    //          cout << endl;
2319    //          cout << "n.events     : "<<totdltime[2]<<endl;
2320    //          cout << "RUN LIVE-TIME: "<<totdltime[0]*0.16<<" ms"<<endl;
2321    //          cout << "RUN DEAD-TIME: "<<totdltime[1]*0.01<<" ms"<<endl;      
2322    //          if(run_tree_clone)
2323    //              if(run_tree_clone->GetBranch("DeadLiveTime")->GetEntries() < run_tree->GetEntries())
2324    //                  run_tree_clone->GetBranch("DeadLiveTime")->Fill();
2325    //      }
2326    //      /// reset counters
2327    //      if( GetTrigLevel2() ){
2328    //          totdltime[0]=GetTrigLevel2()->dltime[0];//live-time
2329    //          totdltime[1]=0;                         //dead-time
2330    //      }
2331    //      totdltime[2]=1;                             //event counter
2332            
2333    
2334            // --------------------------------------
2335          // ---> exit with TRUE          // ---> exit with TRUE
2336          // --------------------------------------          // --------------------------------------
2337          cout << endl << " ))))) UPDATE RUN INFO (((((  @iev "<<iev<<" run "<<GetRunInfo()->ID<<" irun "<<irun<<endl;          cout << endl << " ))))) UPDATE RUN INFO (((((  @iev "<<iev<<" run "<<GetRunInfo()->ID<<" irun "<<irun<<endl;
# Line 2087  Bool_t PamLevel2::UpdateRunInfo(Long64_t Line 2346  Bool_t PamLevel2::UpdateRunInfo(Long64_t
2346              true ){              true ){
2347              cout << "* fragment *"<<endl;                            cout << "* fragment *"<<endl;              
2348          }          }
2349            
2350          return(true);              return(true);    
2351      };      };
2352      // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-      // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
# Line 2767  void PamLevel2::CreateCloneTrees(TFile * Line 3026  void PamLevel2::CreateCloneTrees(TFile *
3026      }      }
3027      cout << "----------------------------------------------------"<<endl;      cout << "----------------------------------------------------"<<endl;
3028    
3029        // ------------------------------------
3030        // add branch with dead and live times
3031        // ------------------------------------
3032        run_tree_clone->Branch("DeadLiveTime",totdltime,"dltime[3]/l");
3033        cout << "Run          : branch DeadLiveTime"<<endl;
3034    
3035    
3036      sel_tree_clone = new TTree("SelectionList","List of selected events ");      sel_tree_clone = new TTree("SelectionList","List of selected events ");
3037      sel_tree_clone->Branch("RunEntry",&irun,"runentry/L");      sel_tree_clone->Branch("RunEntry",&irun,"runentry/L");
# Line 2893  TTree* PamLevel2::GetCloneTree(TString n Line 3158  TTree* PamLevel2::GetCloneTree(TString n
3158  void PamLevel2::WriteCloneTrees(){  void PamLevel2::WriteCloneTrees(){
3159      cout << "+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" <<endl;      cout << "+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" <<endl;
3160      cout << "Write clones of PAMELA trees "<<endl;      cout << "Write clones of PAMELA trees "<<endl;
3161      cout << run_tree_clone->GetName()<<endl;          cout << run_tree_clone->GetName()<<endl;  
3162        if(run_tree_clone->GetBranch("DeadLiveTime")->GetEntries() < run_tree->GetEntries())
3163            run_tree_clone->GetBranch("DeadLiveTime")->Fill();
3164      run_tree_clone->Write();      run_tree_clone->Write();
3165      cout << sel_tree_clone->GetName()<<endl;          cout << sel_tree_clone->GetName()<<endl;    
3166      sel_tree_clone->Write();      sel_tree_clone->Write();
# Line 3029  TTree* PamLevel2::GetYodaTree( ){ Line 3296  TTree* PamLevel2::GetYodaTree( ){
3296          //===================================          //===================================
3297          if(!dbc || (dbc && !dbc->IsConnected())){          if(!dbc || (dbc && !dbc->IsConnected())){
3298              cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl;              cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl;
3299              cout<<"Connecting to DB"<<endl;              cout<<"Re-connecting to DB"<<endl;
3300              cout<<"HOST "<<host<<endl;              cout<<"HOST "<<host<<endl;
3301              cout<<"USER "<<user<<endl;              cout<<"USER "<<user<<endl;
3302              cout<<"PSW  "<<psw<<endl;              cout<<"PSW  "<<psw<<endl;
# Line 3088  TTree* PamLevel2::GetYodaTree( ){ Line 3355  TTree* PamLevel2::GetYodaTree( ){
3355              cout << "PamLevel2::GetYodaTree() --- level0 TOF not implemented "<<endl;              cout << "PamLevel2::GetYodaTree() --- level0 TOF not implemented "<<endl;
3356          }          }
3357    
3358            dbc->Close();
3359    
3360    
3361      };      };
3362    
3363      if(!dbc || (dbc && !dbc->IsConnected())){  //     if(!dbc || (dbc && !dbc->IsConnected())){
3364          cout << " TTree* PamLevel2::GetYodaTree( ) -- no DB connected... hai fatto qualche cazzata "<<endl;  //      cout << " TTree* PamLevel2::GetYodaTree( ) -- no DB connected... hai fatto qualche cazzata "<<endl;
3365      }  //     }
3366    
3367      if ( TRK0 ){      if ( TRK0 ){
3368          TrkParams::Load(6);          TrkParams::Load(6);
# Line 3106  TTree* PamLevel2::GetYodaTree( ){ Line 3376  TTree* PamLevel2::GetYodaTree( ){
3376          };          };
3377      }      }
3378    
3379    
3380  //    cout << l0_tree << endl;  //    cout << l0_tree << endl;
       
3381      return l0_tree;      return l0_tree;
3382    
3383  }  }
# Line 3135  Int_t PamLevel2::GetYodaEntry(){ Line 3405  Int_t PamLevel2::GetYodaEntry(){
3405    
3406  //     cout << " irun "<< irun << " irunentry "<< irunentry<<" run_obj->EV_FROM "<<run_obj->EV_FROM <<" quella giusta "<<quellagiusta << endl;  //     cout << " irun "<< irun << " irunentry "<< irunentry<<" run_obj->EV_FROM "<<run_obj->EV_FROM <<" quella giusta "<<quellagiusta << endl;
3407  //     cout << " iroot "<<iroot<<" run_obj->ID_ROOT_L0 "<<run_obj->ID_ROOT_L0<<endl;  //     cout << " iroot "<<iroot<<" run_obj->ID_ROOT_L0 "<<run_obj->ID_ROOT_L0<<endl;
3408  //     cout << " time "<< GetOrbitalInfo()->absTime << endl;  //     cout << " time "<< abstime << endl;
3409  //     cout << " trk_calib_used "<<run_obj->TRK_CALIB_USED<< endl;  //     cout << " trk_calib_used "<<run_obj->TRK_CALIB_USED<< endl;
3410            
3411      if( !GetOrbitalInfo() ){      ULong64_t obt     = 0;
3412        ULong64_t pktn    = 0;
3413        if( GetOrbitalInfo() ){
3414            obt     = GetOrbitalInfo()->OBT;
3415            pktn    = GetOrbitalInfo()->pkt_num;
3416        }
3417    
3418        if( !GetOrbitalInfo() && !ISGP){
3419          cout << "Int_t PamLevel2::GetYodaEntry() -- ERROR -- missing OrbitalInfo "<<endl;          cout << "Int_t PamLevel2::GetYodaEntry() -- ERROR -- missing OrbitalInfo "<<endl;
3420          return 0;          return 0;
3421      }      }
3422      if( GetOrbitalInfo()->OBT==0 && GetOrbitalInfo()->pkt_num==0 ){      if( obt==0 && pktn==0 && !ISGP ){
3423          cout << "Int_t PamLevel2::GetYodaEntry() -- ERROR -- level2 event corrupted ?? "<<endl;          cout << "Int_t PamLevel2::GetYodaEntry() -- ERROR -- level2 event corrupted ?? "<<endl;
3424          return 0;          return 0;
3425      }      }
# Line 3161  Int_t PamLevel2::GetYodaEntry(){ Line 3438  Int_t PamLevel2::GetYodaEntry(){
3438      Int_t answer = 0;      Int_t answer = 0;
3439      Int_t shift =0;      Int_t shift =0;
3440      //    printf(" siamo qui %i %i \n",shift,prevshift);      //    printf(" siamo qui %i %i \n",shift,prevshift);
3441      Int_t maxshift = 10;      //    Int_t maxshift = 50; // EMILIANO
3442      do{      do{
3443          if(shift>0){              if(shift>0){    
3444              cout << " PKTNUM  L2 --- "<< GetOrbitalInfo()->pkt_num << " --- L0 --- "<< GetEventHeader()->GetPscuHeader()->GetCounter()<<endl;              cout << " PKTNUM  L2 --- "<< pktn << " --- L0 --- "<< GetEventHeader()->GetPscuHeader()->GetCounter()<<endl;
3445              cout << "         RUN: ID "<< GetRunInfo()->ID << " ID_ROOT_L0 "<<run_obj->ID_ROOT_L0<<" ID_RUN_FRAG "<<GetRunInfo()->ID_RUN_FRAG << " EV_FROM "<<GetRunInfo()->EV_FROM  <<endl;              cout << "         RUN: ID "<< GetRunInfo()->ID << " ID_ROOT_L0 "<<run_obj->ID_ROOT_L0<<" ID_RUN_FRAG "<<GetRunInfo()->ID_RUN_FRAG << " EV_FROM "<<GetRunInfo()->EV_FROM  <<endl;
3446              cout << "         L2 <--> L0 mismatch ( irun "<<irun<<" irunentry "<<irunentry<<" shift "<<shift<<" prevshift "<<prevshift<<" )"<<endl;              cout << "         L2 <--> L0 mismatch ( irun "<<irun<<" irunentry "<<irunentry<<" shift "<<shift<<" prevshift "<<prevshift<<" )"<<endl;
3447          }          }
# Line 3174  Int_t PamLevel2::GetYodaEntry(){ Line 3451  Int_t PamLevel2::GetYodaEntry(){
3451              cout << "Int_t PamLevel2::GetYodaEntry() -- ERROR -- missing EventHeader "<<endl;              cout << "Int_t PamLevel2::GetYodaEntry() -- ERROR -- missing EventHeader "<<endl;
3452              return 0;              return 0;
3453          }          }
3454  //      cout << "PKTNUM "<<shift<<" ==  L2 --- "<< GetOrbitalInfo()->pkt_num << " --- L0 --- "<< GetEventHeader()->GetPscuHeader()->GetCounter()<<endl;  
3455  //      cout << " L2 --- "<< GetOrbitalInfo()->OBT << " --- L0 --- "<< GetEventHeader()->GetPscuHeader()->GetOrbitalTime()<<endl;          if(ISGP){
3456                obt = (UInt_t)(GetEventHeader()->GetPscuHeader()->GetOrbitalTime()); //BARBATRUCCO
3457                pktn = (UInt_t)(GetEventHeader()->GetPscuHeader()->GetCounter()); //BARBATRUCCO
3458            }
3459    
3460    //      cout << "PKTNUM "<<shift<<" ==  L2 --- "<< pktn << " --- L0 --- "<< GetEventHeader()->GetPscuHeader()->GetCounter()<<endl;
3461    //      cout << " L2 --- "<< obt << " --- L0 --- "<< GetEventHeader()->GetPscuHeader()->GetOrbitalTime()<<endl;
3462  //      if( (quellagiusta+shift) == l0_tree->GetEntries()+1 )cout << ">>> end of level0 tree <<<"<<endl;  //      if( (quellagiusta+shift) == l0_tree->GetEntries()+1 )cout << ">>> end of level0 tree <<<"<<endl;
3463  //      cout << " GetOrbitalInfo()->OBT "<< GetOrbitalInfo()->OBT << endl;  //      cout << " obt "<< obt << endl;
3464  //      cout << " GetEventHeader()->GetPscuHeader()->GetOrbitalTime() "<< GetEventHeader()->GetPscuHeader()->GetOrbitalTime() << endl;  //      cout << " GetEventHeader()->GetPscuHeader()->GetOrbitalTime() "<< GetEventHeader()->GetPscuHeader()->GetOrbitalTime() << endl;
3465  //      cout << " GetOrbitalInfo()->pkt_num "<< GetOrbitalInfo()->pkt_num << endl;  //      cout << " pktn "<< pktn << endl;
3466  //      cout << " GetEventHeader()->GetPscuHeader()->GetCounter() "<< GetEventHeader()->GetPscuHeader()->GetCounter() << endl;  //      cout << " GetEventHeader()->GetPscuHeader()->GetCounter() "<< GetEventHeader()->GetPscuHeader()->GetCounter() << endl;
3467  //      printf(" IDRUN %u \n",GetRunInfo()->ID);  //      printf(" IDRUN %u \n",GetRunInfo()->ID);
3468  //  //
# Line 3188  Int_t PamLevel2::GetYodaEntry(){ Line 3471  Int_t PamLevel2::GetYodaEntry(){
3471            shift = -1;            shift = -1;
3472          };          };
3473    
3474      }while( ( GetOrbitalInfo()->OBT != (UInt_t)(GetEventHeader()->GetPscuHeader()->GetOrbitalTime()) || GetOrbitalInfo()->pkt_num != (UInt_t)(GetEventHeader()->GetPscuHeader()->GetCounter())) && (quellagiusta+(Long64_t)shift) < GetYodaTree()->GetEntries() && shift < maxshift);      }while( ( obt != (UInt_t)(GetEventHeader()->GetPscuHeader()->GetOrbitalTime()) ||
3475                  pktn != (UInt_t)(GetEventHeader()->GetPscuHeader()->GetCounter())       )
3476                && (quellagiusta+(Long64_t)shift) < GetYodaTree()->GetEntries() && shift < maxshift);
3477    
3478      if ( (quellagiusta+(Long64_t)shift+(Long64_t)prevshift) > GetYodaTree()->GetEntries() || shift == maxshift ) {      if ( (quellagiusta+(Long64_t)shift+(Long64_t)prevshift) > GetYodaTree()->GetEntries() || shift == maxshift ) {
3479          cout << " Big trouble here, no such event in Level0 data! " <<endl;          cout << " Big trouble here, no such event in Level0 data! " <<endl;
# Line 3218  Bool_t PamLevel2::SetDBConnection(){ Line 3503  Bool_t PamLevel2::SetDBConnection(){
3503      return true;      return true;
3504    
3505  }  }
3506    
3507    /**
3508     * \Brief Add a friend to the pamela chain.
3509     * @param cname name of the chain to be added
3510     */
3511    
3512    TChain* PamLevel2::AddFriend(TString cname){
3513    
3514        if(!GetPamTree()){
3515            cout << " TChain* PamLevel2::AddFriend(TString cname) --- a pamela tree must be created first"<<endl;
3516            return NULL;
3517        }
3518    
3519    
3520        TChain *c = new TChain( cname.Data() );
3521    
3522        TIter next( GetPamTree()->GetListOfFiles() );
3523        Int_t nf = 0;
3524        TChainElement* element = 0;    
3525        while ((element = (TChainElement*) next())) {      
3526            c->Add(element->GetTitle());
3527            nf++;
3528        }
3529    
3530        GetPamTree()->AddFriend(cname.Data());
3531    
3532        cout << "external chain created and added to pamela friends :"<<cname<<endl;
3533        cout << "n.files "<<nf<<endl;
3534        
3535    
3536        return c;    
3537    
3538    }

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

  ViewVC Help
Powered by ViewVC 1.1.23