/[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.42 by pam-fi, Tue Aug 7 15:37:12 2007 UTC revision 1.46 by mocchiut, Wed Sep 12 09:25:22 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 162  void PamLevel2::Initialize(){ Line 155  void PamLevel2::Initialize(){
155      pam_tree = NULL;      pam_tree = NULL;
156      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;
157    
158        totdltime[0] = 0LL;
159        totdltime[1] = 0LL;
160    
161      host = "mysql://localhost/pamelaprod";      host = "mysql://localhost/pamelaprod";
162      user = "anonymous";      user = "anonymous";
163      psw = "";      psw = "";
# Line 198  void PamLevel2::Initialize(){ Line 194  void PamLevel2::Initialize(){
194    
195      SELLI = -1;      SELLI = -1;
196    
197        ISGP = false;
198    
199      tsorted=0;      tsorted=0;
200      timage=0;      timage=0;
201            
# Line 401  void PamLevel2::Reset(){ Line 399  void PamLevel2::Reset(){
399    runfirstentry = 0ULL;    runfirstentry = 0ULL;
400    runlastentry = 0ULL;        runlastentry = 0ULL;    
401    //    //
402      totdltime[0] = 0LL;
403      totdltime[1] = 0LL;
404      //
405  };  };
406    
407  Bool_t PamLevel2::IsGood(){  Bool_t PamLevel2::IsGood(){
# Line 635  void PamLevel2::SortTracks(TString how){ Line 636  void PamLevel2::SortTracks(TString how){
636  void PamLevel2::SortTracks(){  void PamLevel2::SortTracks(){
637    TString how = howtosort;    TString how = howtosort;
638    
639    //    cout <<" PamLevel2::SortTracks(TString how) "<<endl;    //  cout <<" PamLevel2::SortTracks(TString how) "<<endl;
640    if( !trk2_obj ){    if( !trk2_obj ){
641      cout << "void PamLevel2::SortTracks():  TrkLevel2 not loaded !!!";      cout << "void PamLevel2::SortTracks():  TrkLevel2 not loaded !!!";
642      return;      return;
# Line 665  void PamLevel2::SortTracks(){ Line 666  void PamLevel2::SortTracks(){
666    Bool_t use_TRK = how.Contains("TRK", TString::kIgnoreCase);    Bool_t use_TRK = how.Contains("TRK", TString::kIgnoreCase);
667    Bool_t use_CAL = how.Contains("CAL", TString::kIgnoreCase);    Bool_t use_CAL = how.Contains("CAL", TString::kIgnoreCase);
668    Bool_t use_TOF = how.Contains("TOF", TString::kIgnoreCase);    Bool_t use_TOF = how.Contains("TOF", TString::kIgnoreCase);
669          Bool_t use_S1 = how.Contains("S1", TString::kIgnoreCase);
670      Bool_t use_S2 = how.Contains("S2", TString::kIgnoreCase);
671      Bool_t use_S3 = how.Contains("S3", TString::kIgnoreCase);
672      
673      if ( use_TOF ){
674        use_S1 = true;
675        use_S2 = true;
676        use_S3 = true;
677      };
678    if( !CAL2 &&  use_CAL) use_CAL = false;    if( !CAL2 &&  use_CAL) use_CAL = false;
679    if( !TOF &&  use_TOF) use_TOF = false;    if( !TOF ){
680            use_TOF = false;
681        use_S1  = false;
682        use_S2  = false;
683        use_S3  = false;
684      }
685    
686    if( !TRK2 ){    if( !TRK2 ){
687      //  cout << "SortTracks() : without tracker does not work!!! (not yet)" << endl;      //  cout << "SortTracks() : without tracker does not work!!! (not yet)" << endl;
688      return;      return;
# Line 696  void PamLevel2::SortTracks(){ Line 710  void PamLevel2::SortTracks(){
710      ToFTrkVar  *oi = 0;      ToFTrkVar  *oi = 0;
711      //  cout << "trk track n. "<<i << " "<<hex<< tp <<dec<< endl;      //  cout << "trk track n. "<<i << " "<<hex<< tp <<dec<< endl;
712      // if track has an image, check image selection      // if track has an image, check image selection
713    
714        Int_t tp_score = 0;  //main track sorted by the tracker
715        Int_t ti_score = 0;  //image track
716        Int_t totp_score = 0;  //main track sorted by the tracker
717        Int_t toti_score = 0;  //image track
718    
719      if(tp->HasImage()){      if(tp->HasImage()){
720                            
721        ti = trk2_obj->TrkLevel2::GetTrackImage(i);              //tracker (image)        ti = trk2_obj->TrkLevel2::GetTrackImage(i);              //tracker (image)
# Line 705  void PamLevel2::SortTracks(){ Line 725  void PamLevel2::SortTracks(){
725        //            cout << "its image "<<i << " "<<hex<< ti <<dec<< endl;        //            cout << "its image "<<i << " "<<hex<< ti <<dec<< endl;
726    
727        //assign starting scores        //assign starting scores
728        Int_t tp_score = 0;  //main track sorted by the tracker        tp_score = 0;  //main track sorted by the tracker
729        Int_t ti_score = 0;  //image track        ti_score = 0;  //image track
730                            
731        // -----------------------------------------------------------------------------------------        // -----------------------------------------------------------------------------------------
732        // calorimeter check        // calorimeter check
# Line 717  void PamLevel2::SortTracks(){ Line 737  void PamLevel2::SortTracks(){
737          cout << "void PamLevel2::SortTracks(): howtosort= "<<how<<" but CaloLevel2 not loaded !!!";          cout << "void PamLevel2::SortTracks(): howtosort= "<<how<<" but CaloLevel2 not loaded !!!";
738          return;          return;
739        };        };
740          if( use_CAL && !cp &&  ci ){
741            ti_score++;
742            toti_score++;
743          };
744          if( use_CAL &&  cp && !ci ){
745            tp_score++;
746            totp_score++;
747          };
748        if(        if(
749           use_CAL            &&           use_CAL            &&
750  //       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 732  void PamLevel2::SortTracks(){ Line 760  void PamLevel2::SortTracks(){
760  //      else                 ti_score++;  //      else                 ti_score++;
761                    
762    
763            if( cp->npresh > ci->npresh) tp_score++;          if( cp->npresh > ci->npresh){
764            if( cp->npresh < ci->npresh) ti_score++;            tp_score++;
765            else ;//niente            totp_score++;
766            };
767            if( cp->npresh < ci->npresh){
768              ti_score++;
769              toti_score++;
770            };
771    
772          //      cout << "CALO "<<tp_score<<ti_score<<endl;          //      cout << "CALO "<<tp_score<<ti_score<<endl;
773    
# Line 744  void PamLevel2::SortTracks(){ Line 777  void PamLevel2::SortTracks(){
777        // -----------------------------------------------------------------------------------------        // -----------------------------------------------------------------------------------------
778        // check the number of hit pmts along the track        // check the number of hit pmts along the track
779        // on S12 S21 and S32, where paddles are parallel to Y axis        // on S12 S21 and S32, where paddles are parallel to Y axis
780        if( use_TOF && !tof_obj ){        if( (use_TOF || use_S1 || use_S2 || use_S3 ) && !tof_obj ){
781          cout << "void PamLevel2::SortTracks(): howtosort= "<<how<<" but ToFLevel2 not loaded !!!";          cout << "void PamLevel2::SortTracks(): howtosort= "<<how<<" but ToFLevel2 not loaded !!!";
782          return;          return;
783        };        };
784        if( use_TOF && op && oi ){        //
785                          if( (use_TOF || use_S1 || use_S2 || use_S3 ) && !op && oi ){
786            ti_score++;
787            toti_score++;
788          };
789          if( (use_TOF || use_S1 || use_S2 || use_S3 ) && op && !oi ){
790            tp_score++;
791            totp_score++;
792          };
793          if( (use_TOF || use_S1 || use_S2 || use_S3 ) && op && oi ){
794          //          //
795          Float_t sen = 0.;          Float_t sen = 0.;
796          for (Int_t ih=0; ih < op->npmtadc; ih++){          for (Int_t ih=0; ih < op->npmtadc; ih++){
# Line 761  void PamLevel2::SortTracks(){ Line 802  void PamLevel2::SortTracks(){
802            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);
803          };          };
804          //          //
805          if (  sen >= sortthr ){          if (  sen >= sortthr && false){ // temporary disabled NUCLEI special algorithm since the new one should work for every particle (to be checked!)
806            //printf(" IS A NUCLEUS! en = %f \n",sen);            //printf(" IS A NUCLEUS! en = %f \n",sen);
807            //            //
808            // is a nucleus use a different algorithm            // is a nucleus use a different algorithm
# Line 854  void PamLevel2::SortTracks(){ Line 895  void PamLevel2::SortTracks(){
895    
896                                    
897            if(            if(
898               use_TOF            &&               (use_TOF || use_S1 || use_S2 || use_S3)            &&
899               (nphit_p+nphit_i) !=0 &&                 (nphit_p+nphit_i) !=0 &&  
900               true){               true){
901                                            
# Line 901  void PamLevel2::SortTracks(){ Line 942  void PamLevel2::SortTracks(){
942            for (Int_t ih=0; ih < op->npmttdc; ih++){            for (Int_t ih=0; ih < op->npmttdc; ih++){
943              Int_t pl = tof_obj->GetPlaneIndex( (op->pmttdc).At(ih) );              Int_t pl = tof_obj->GetPlaneIndex( (op->pmttdc).At(ih) );
944  //          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++;
945              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 )) ){
946                  if( (op->tdcflag).At(ih)==0 )nphit_p++;
947                };
948            };            };
949                                    
950            for (Int_t ih=0; ih < oi->npmttdc; ih++){            for (Int_t ih=0; ih < oi->npmttdc; ih++){
951              Int_t pl = tof_obj->GetPlaneIndex( (oi->pmttdc).At(ih) );              Int_t pl = tof_obj->GetPlaneIndex( (oi->pmttdc).At(ih) );
952  //          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++;  
953              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 )) ){
954                  if( (oi->tdcflag).At(ih)==0 )nphit_i++;  
955                };
956            };            };
957                                    
958            if(            if(
959               (nphit_p+nphit_i) !=0 &&                 (nphit_p+nphit_i) !=0 &&  
960               true){               true){
961                                            
962                if ( nphit_p != nphit_i ){
963                  totp_score += nphit_p;
964                  toti_score += nphit_i;
965                };
966              if     ( nphit_p > nphit_i) tp_score++;              if     ( nphit_p > nphit_i) tp_score++;
967              else if( nphit_p < nphit_i) ti_score++;              else if( nphit_p < nphit_i) ti_score++;
968              else ;//niente              else ;//niente
# Line 938  void PamLevel2::SortTracks(){ Line 987  void PamLevel2::SortTracks(){
987  //      else if( ti->chi2 > 0 && ti->chi2 < tp->chi2 ) ti_score++ ;  //      else if( ti->chi2 > 0 && ti->chi2 < tp->chi2 ) ti_score++ ;
988    
989            // CHECK 1 : number of points along X              // CHECK 1 : number of points along X  
990            if ( tp->GetNX() >= ti->GetNX() )tp_score++ ;          if ( tp->GetNX() >= ti->GetNX() ){
991            if ( tp->GetNX() <= ti->GetNX() )ti_score++ ;            tp_score++ ;
992              totp_score++ ;
993            };
994            if ( tp->GetNX() <= ti->GetNX() ){
995              ti_score++ ;
996              toti_score++ ;
997            };
998            // CHECK 2 : number of points along Y              // CHECK 2 : number of points along Y  
999            if ( tp->GetNY() >= ti->GetNY() )tp_score++ ;          if ( tp->GetNY() >= ti->GetNY() ){
1000            if ( tp->GetNY() <= ti->GetNY() )ti_score++ ;            tp_score++ ;
1001              totp_score++ ;
1002            };
1003            if ( tp->GetNY() <= ti->GetNY() ){
1004              ti_score++ ;
1005              toti_score++ ;
1006            };
1007            // CHECK 3 : chi**2 along X              // CHECK 3 : chi**2 along X  
1008  //        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++ ;
1009  //        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 987  void PamLevel2::SortTracks(){ Line 1048  void PamLevel2::SortTracks(){
1048        };        };
1049                            
1050      }else{      }else{
1051          totp_score = 1;
1052          toti_score = 0;
1053          
1054        //            ts = tp;        //            ts = tp;
1055        //            cs = cp;        //            cs = cp;
1056        //            os = op;        //            os = op;
# Line 1000  void PamLevel2::SortTracks(){ Line 1064  void PamLevel2::SortTracks(){
1064      //  cout<<"o "<<tp<<endl;      //  cout<<"o "<<tp<<endl;
1065      //  cout<<"o "<<cp<<endl;      //  cout<<"o "<<cp<<endl;
1066      //  cout<<"o "<<op<<endl;      //  cout<<"o "<<op<<endl;
1067    
1068      new(ttsorted[i]) PamTrack(tp,cp,op);      new(ttsorted[i]) PamTrack(tp,cp,op);
1069      new(ttimage[i])  PamTrack(ti,ci,oi);      new(ttimage[i])  PamTrack(ti,ci,oi);
1070    
1071        ((PamTrack*)(ttsorted[i]))->SetPScore(totp_score);
1072        ((PamTrack*)(ttimage[i]))->SetIScore(toti_score);
1073    };    };
1074    
1075    if( tsorted->GetEntries() != trk2_obj->GetNTracks() ){    if( tsorted->GetEntries() != trk2_obj->GetNTracks() ){
# Line 1918  Bool_t PamLevel2::UpdateRunInfo(TChain * Line 1986  Bool_t PamLevel2::UpdateRunInfo(TChain *
1986        //        //
1987        // the absolute time is necessary to relate the event with the run        // the absolute time is necessary to relate the event with the run
1988        //        //
1989        if( !GetOrbitalInfo() ){        if( !GetOrbitalInfo() && !ISGP){
1990            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;
1991            return(false);            return(false);
1992        }        }
1993    
1994          ULong64_t abstime = 0;
1995          if( GetOrbitalInfo() )abstime=GetOrbitalInfo()->absTime;
1996    
1997    
1998        //        //
1999        // 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
2000        //        //
# Line 1932  Bool_t PamLevel2::UpdateRunInfo(TChain * Line 2004  Bool_t PamLevel2::UpdateRunInfo(TChain *
2004            runfirstentry = 0LL;            runfirstentry = 0LL;
2005            runlastentry += (Long64_t)(this->GetRunInfo()->NEVENTS);            runlastentry += (Long64_t)(this->GetRunInfo()->NEVENTS);
2006            if ( (Long64_t)(this->GetRunInfo()->NEVENTS) > 0LL ) runlastentry -= 1LL;            if ( (Long64_t)(this->GetRunInfo()->NEVENTS) > 0LL ) runlastentry -= 1LL;
2007              
2008              if( ISGP && run->GetEntries()!=1 ){
2009                  cout << "** WARNING ** simulated files are assumed to have 1 single run, not "<< run->GetEntries() << endl;
2010                  cout << "** WARNING ** run will not be updated"<<endl;
2011              }
2012    
2013        };              };      
2014        //        //
2015         if ( irun == run->GetEntries()-1LL &&        if(ISGP)abstime = GetRunInfo()->RUNHEADER_TIME; // BARBATRUCCO
2016             !(GetOrbitalInfo()->absTime >= GetRunInfo()->RUNHEADER_TIME &&        //
2017               GetOrbitalInfo()->absTime <= GetRunInfo()->RUNTRAILER_TIME)        if ( irun == run->GetEntries()-1LL &&
2018               !(abstime >= GetRunInfo()->RUNHEADER_TIME &&
2019                 abstime <= GetRunInfo()->RUNTRAILER_TIME)
2020              ){              ){
2021           irun = -1LL;           irun = -1LL;
2022           runfirstentry = 0LL;           runfirstentry = 0LL;
# Line 1947  Bool_t PamLevel2::UpdateRunInfo(TChain * Line 2027  Bool_t PamLevel2::UpdateRunInfo(TChain *
2027        //        //
2028        bool fromfirst = true;        bool fromfirst = true;
2029        //        //
2030        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 ){
2031  //      while ( iev > (runfirstentry+(ULong64_t)(this->GetRunInfo()->NEVENTS-1)) && irun < run->GetEntries() ){  //      while ( iev > (runfirstentry+(ULong64_t)(this->GetRunInfo()->NEVENTS-1)) && irun < run->GetEntries() ){
2032            irun++;            irun++;
2033            run->GetEntry(irun);            run->GetEntry(irun);
# Line 1957  Bool_t PamLevel2::UpdateRunInfo(TChain * Line 2037  Bool_t PamLevel2::UpdateRunInfo(TChain *
2037  //        cout << " ))))) UPDATE RUN INFO (((((  @iev "<<iev<<" run "<<GetRunInfo()->ID<<" irun "<<irun<<endl;  //        cout << " ))))) UPDATE RUN INFO (((((  @iev "<<iev<<" run "<<GetRunInfo()->ID<<" irun "<<irun<<endl;
2038  //        cout << "runfirstentry "<<runfirstentry<<endl;  //        cout << "runfirstentry "<<runfirstentry<<endl;
2039            //      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)));
2040            //      printf(" abstime %u trailertime %u \n",GetOrbitalInfo()->absTime,GetRunInfo()->RUNTRAILER_TIME);            //      printf(" abstime %u trailertime %u \n",abstime,GetRunInfo()->RUNTRAILER_TIME);
2041            //      printf(" IDRUN %u \n",GetRunInfo()->ID);            //      printf(" IDRUN %u \n",GetRunInfo()->ID);
2042            //            //
2043  //        prevshift = 0;  //        prevshift = 0;
2044            //            //
2045            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)){
2046                printf(" resetting irun  (it should NOT happen!!!)\n");                printf(" resetting irun  (it should NOT happen!!!)\n");
2047                fromfirst = false;                fromfirst = false;
2048                irun = 0;                irun = 0;
# Line 1975  Bool_t PamLevel2::UpdateRunInfo(TChain * Line 2055  Bool_t PamLevel2::UpdateRunInfo(TChain *
2055        };        };
2056        //        //
2057        if (        if (
2058             !(GetOrbitalInfo()->absTime >= GetRunInfo()->RUNHEADER_TIME &&             !(abstime >= GetRunInfo()->RUNHEADER_TIME &&
2059               GetOrbitalInfo()->absTime <= GetRunInfo()->RUNTRAILER_TIME)               abstime <= GetRunInfo()->RUNTRAILER_TIME)
2060            ) {            ) {
2061            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);
2062            return false;            return false;
2063        }        }
2064        //        //
# Line 2030  Bool_t PamLevel2::UpdateRunInfo(Long64_t Line 2110  Bool_t PamLevel2::UpdateRunInfo(Long64_t
2110      if(SELLI==0){      if(SELLI==0){
2111    
2112          // ---------------------------------------------------------------          // ---------------------------------------------------------------
2113            // increment dead and live-time counters
2114            // ---------------------------------------------------------------
2115            if( GetTrigLevel2() ){
2116                totdltime[0]+=GetTrigLevel2()->dltime[0];
2117                totdltime[1]+=GetTrigLevel2()->dltime[1];
2118            }
2119            totdltime[2]++;
2120    
2121    //      cout << setw(10)<<totdltime[0]<<setw(10)<<totdltime[1]<<setw(10)<<totdltime[2]<<endl;
2122    
2123            // ---------------------------------------------------------------
2124            // retrieve OBT and absolute time of the event
2125            // ---------------------------------------------------------------
2126            ULong64_t abstime = 0;
2127            ULong64_t obt     = 0;
2128            if( GetOrbitalInfo() ){
2129                abstime = GetOrbitalInfo()->absTime;
2130                obt     = GetOrbitalInfo()->OBT;
2131            }
2132            // ---------------------------------------------------------------
2133          // the absolute time is necessary to relate the event with the run          // the absolute time is necessary to relate the event with the run
2134          // ---------------------------------------------------------------          // ---------------------------------------------------------------
2135          if( !GetOrbitalInfo() ){          if( !GetOrbitalInfo() && !ISGP ){
2136              cout << "Bool_t PamLevel2::UpdateRunInfo(Long64_t iev) -- ERROR -- missing OrbitalInfo "<<endl;              cout << "Bool_t PamLevel2::UpdateRunInfo(Long64_t iev) -- ERROR -- missing OrbitalInfo "<<endl;
2137              return(false);              return(false);
2138          }          }
# Line 2045  Bool_t PamLevel2::UpdateRunInfo(Long64_t Line 2145  Bool_t PamLevel2::UpdateRunInfo(Long64_t
2145              irunentry = 0;              irunentry = 0;
2146              prevshift = 0;              prevshift = 0;
2147              run_tree->GetEntry(irun);              run_tree->GetEntry(irun);
2148    
2149                if( ISGP && run_tree->GetEntries()!=1 ){
2150                    cout << "** WARNING ** simulated files are assumed to have 1 single run, not "<< run_tree->GetEntries() << endl;
2151                    cout << "** WARNING ** run will not be updated"<<endl;
2152                }
2153          };                };      
2154    
2155            // -----------------------------------------------------------------------
2156            // if it is simulation, assigh abstime by hand (temporaneo!!!)
2157            // -----------------------------------------------------------------------
2158            if(ISGP){
2159                abstime = GetRunInfo()->RUNHEADER_TIME; // BARBATRUCCO
2160                obt     = GetRunInfo()->RUNHEADER_OBT; // BARBATRUCCO
2161            }
2162          //          //
2163          bool fromfirst = true; // first loop over runs          bool fromfirst = true; // first loop over runs
2164    
# Line 2059  Bool_t PamLevel2::UpdateRunInfo(Long64_t Line 2172  Bool_t PamLevel2::UpdateRunInfo(Long64_t
2172          while (          while (
2173              (              (
2174                  (                  (
2175                      !(GetOrbitalInfo()->absTime >= GetRunInfo()->RUNHEADER_TIME &&    // check on absolute time (s)                      !(abstime >= GetRunInfo()->RUNHEADER_TIME &&    // check on absolute time (s)
2176                        GetOrbitalInfo()->absTime <= GetRunInfo()->RUNTRAILER_TIME) &&                        abstime <= GetRunInfo()->RUNTRAILER_TIME) &&
2177                      !(GetOrbitalInfo()->OBT >= GetRunInfo()->RUNHEADER_OBT &&         // additional check on OBT (ms)                      !(obt >= GetRunInfo()->RUNHEADER_OBT &&         // additional check on OBT (ms)
2178                        GetOrbitalInfo()->OBT <= GetRunInfo()->RUNTRAILER_OBT)                        obt <= GetRunInfo()->RUNTRAILER_OBT)
2179                      )                      )
2180                  || GetRunInfo()->NEVENTS==0                  || GetRunInfo()->NEVENTS==0
2181                  || !(irunentry < GetRunInfo()->NEVENTS-1-prevshift)                  || !(irunentry < GetRunInfo()->NEVENTS-1-prevshift)
2182                  )                  )
2183                  && irun < run_tree->GetEntries() ){                  && irun < run_tree->GetEntries() ){
2184    
2185    
2186    
2187    
2188                // -----------------------------------------
2189                // store dead and live-time of previous run
2190                // -----------------------------------------
2191                if(fromfirst){
2192                    if(oldrun==irun){
2193                        /// decrement counters
2194                        if( GetTrigLevel2()){
2195                            totdltime[0]-=GetTrigLevel2()->dltime[0];//live-time
2196                            totdltime[1]-=GetTrigLevel2()->dltime[1];//dead-time
2197                        }
2198                        totdltime[2]--;                              //event counter
2199                        cout << endl;
2200                        cout << "n.events     : "<<totdltime[2]<<endl;
2201                        cout << "RUN LIVE-TIME: "<<totdltime[0]*0.16<<" ms"<<endl;
2202                        cout << "RUN DEAD-TIME: "<<totdltime[1]*0.01<<" ms"<<endl;      
2203                    }else{
2204                        totdltime[0]=0;//live-time
2205                        totdltime[1]=0;//dead-time
2206                        totdltime[2]=0;                             //event counter
2207                        cout << " *** JUMP RUN *** irun "<<irun<<endl;
2208                    }
2209                    /// add an entry
2210                    if(run_tree_clone)
2211                        if(run_tree_clone->GetBranch("DeadLiveTime")->GetEntries() < run_tree->GetEntries())
2212                            run_tree_clone->GetBranch("DeadLiveTime")->Fill();
2213                    /// reset counters
2214                    if( GetTrigLevel2() ){
2215                        totdltime[0]=GetTrigLevel2()->dltime[0];//live-time
2216                        totdltime[1]=0;                         //dead-time
2217                    }
2218                    totdltime[2]=1;                             //event counter
2219                }
2220    
2221    
2222              irun++;              irun++;
2223              // ------------------------------------              // ------------------------------------
2224              // if the end of run tree is reached...              // if the end of run tree is reached...
# Line 2096  Bool_t PamLevel2::UpdateRunInfo(Long64_t Line 2246  Bool_t PamLevel2::UpdateRunInfo(Long64_t
2246              // -------------------------------------------------------------------              // -------------------------------------------------------------------
2247              if(irun>0)runfirstentry += (GetRunInfo()->NEVENTS)-prevshift;              if(irun>0)runfirstentry += (GetRunInfo()->NEVENTS)-prevshift;
2248              irunentry = 0;              irunentry = 0;
2249              prevshift = 0;              prevshift = 0;          
2250              run_tree->GetEntry(irun);                    run_tree->GetEntry(irun);      
2251              if(GetRunInfo()->RUNHEADER_OBT>GetRunInfo()->RUNTRAILER_OBT ){              if(GetRunInfo()->RUNHEADER_OBT>GetRunInfo()->RUNTRAILER_OBT ){
2252                  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 2116  Bool_t PamLevel2::UpdateRunInfo(Long64_t Line 2266  Bool_t PamLevel2::UpdateRunInfo(Long64_t
2266    
2267          // --------------------------------------          // --------------------------------------
2268          // ... otherwise          // ... otherwise
2269            // --------------------------------------
2270    
2271    
2272    
2273    //      // -----------------------------------------
2274    //      // store dead and live-time of previous run
2275    //      // -----------------------------------------
2276    //      // --------------------------------------------------------------
2277    //      // if the run is empty, fill the dead-live time branch with zeros
2278    //      // --------------------------------------------------------------
2279    //      /// if some runs have been jumped, fill with zeros
2280    //      if(irun-oldrun>1){
2281    //          ULong64_t  temp[3];
2282    //          temp[0]=totdltime[0];
2283    //          temp[1]=totdltime[1];
2284    //          temp[2]=totdltime[2];
2285    //          for(int i=oldrun+1; i<irun; irun++){
2286    //              totdltime[0]=0;
2287    //              totdltime[1]=0;
2288    //              totdltime[2]=0;
2289    //              cout << " ** JUMPED RUN **"<<endl;
2290    //              if(run_tree_clone)
2291    //                  if(run_tree_clone->GetBranch("DeadLiveTime")->GetEntries() < run_tree->GetEntries())
2292    //                      run_tree_clone->GetBranch("DeadLiveTime")->Fill();
2293    //          }
2294    //          totdltime[0]=temp[0];
2295    //          totdltime[1]=temp[1];
2296    //          totdltime[2]=temp[2];
2297    //      }
2298    //      /// decrement counters
2299    //      if( GetTrigLevel2() ){
2300    //          totdltime[0]-=GetTrigLevel2()->dltime[0];//live-time
2301    //          totdltime[1]-=GetTrigLevel2()->dltime[1];//dead-time
2302    //      }
2303    //      totdltime[2]--;                              //event counter
2304    //      /// add an entry
2305    //      if(irun>0 ){
2306    //          cout << endl;
2307    //          cout << "n.events     : "<<totdltime[2]<<endl;
2308    //          cout << "RUN LIVE-TIME: "<<totdltime[0]*0.16<<" ms"<<endl;
2309    //          cout << "RUN DEAD-TIME: "<<totdltime[1]*0.01<<" ms"<<endl;      
2310    //          if(run_tree_clone)
2311    //              if(run_tree_clone->GetBranch("DeadLiveTime")->GetEntries() < run_tree->GetEntries())
2312    //                  run_tree_clone->GetBranch("DeadLiveTime")->Fill();
2313    //      }
2314    //      /// reset counters
2315    //      if( GetTrigLevel2() ){
2316    //          totdltime[0]=GetTrigLevel2()->dltime[0];//live-time
2317    //          totdltime[1]=0;                         //dead-time
2318    //      }
2319    //      totdltime[2]=1;                             //event counter
2320            
2321    
2322            // --------------------------------------
2323          // ---> exit with TRUE          // ---> exit with TRUE
2324          // --------------------------------------          // --------------------------------------
2325          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 2130  Bool_t PamLevel2::UpdateRunInfo(Long64_t Line 2334  Bool_t PamLevel2::UpdateRunInfo(Long64_t
2334              true ){              true ){
2335              cout << "* fragment *"<<endl;                            cout << "* fragment *"<<endl;              
2336          }          }
2337            
2338          return(true);              return(true);    
2339      };      };
2340      // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-      // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
# Line 2810  void PamLevel2::CreateCloneTrees(TFile * Line 3014  void PamLevel2::CreateCloneTrees(TFile *
3014      }      }
3015      cout << "----------------------------------------------------"<<endl;      cout << "----------------------------------------------------"<<endl;
3016    
3017        // ------------------------------------
3018        // add branch with dead and live times
3019        // ------------------------------------
3020        run_tree_clone->Branch("DeadLiveTime",totdltime,"dltime[3]/l");
3021        cout << "Run          : branch DeadLiveTime"<<endl;
3022    
3023    
3024      sel_tree_clone = new TTree("SelectionList","List of selected events ");      sel_tree_clone = new TTree("SelectionList","List of selected events ");
3025      sel_tree_clone->Branch("RunEntry",&irun,"runentry/L");      sel_tree_clone->Branch("RunEntry",&irun,"runentry/L");
# Line 2936  TTree* PamLevel2::GetCloneTree(TString n Line 3146  TTree* PamLevel2::GetCloneTree(TString n
3146  void PamLevel2::WriteCloneTrees(){  void PamLevel2::WriteCloneTrees(){
3147      cout << "+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" <<endl;      cout << "+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" <<endl;
3148      cout << "Write clones of PAMELA trees "<<endl;      cout << "Write clones of PAMELA trees "<<endl;
3149      cout << run_tree_clone->GetName()<<endl;          cout << run_tree_clone->GetName()<<endl;  
3150        if(run_tree_clone->GetBranch("DeadLiveTime")->GetEntries() < run_tree->GetEntries())
3151            run_tree_clone->GetBranch("DeadLiveTime")->Fill();
3152      run_tree_clone->Write();      run_tree_clone->Write();
3153      cout << sel_tree_clone->GetName()<<endl;          cout << sel_tree_clone->GetName()<<endl;    
3154      sel_tree_clone->Write();      sel_tree_clone->Write();
# Line 3178  Int_t PamLevel2::GetYodaEntry(){ Line 3390  Int_t PamLevel2::GetYodaEntry(){
3390    
3391  //     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;
3392  //     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;
3393  //     cout << " time "<< GetOrbitalInfo()->absTime << endl;  //     cout << " time "<< abstime << endl;
3394  //     cout << " trk_calib_used "<<run_obj->TRK_CALIB_USED<< endl;  //     cout << " trk_calib_used "<<run_obj->TRK_CALIB_USED<< endl;
3395            
3396      if( !GetOrbitalInfo() ){      ULong64_t obt     = 0;
3397        ULong64_t pktn    = 0;
3398        if( GetOrbitalInfo() ){
3399            obt     = GetOrbitalInfo()->OBT;
3400            pktn    = GetOrbitalInfo()->pkt_num;
3401        }
3402    
3403        if( !GetOrbitalInfo() && !ISGP){
3404          cout << "Int_t PamLevel2::GetYodaEntry() -- ERROR -- missing OrbitalInfo "<<endl;          cout << "Int_t PamLevel2::GetYodaEntry() -- ERROR -- missing OrbitalInfo "<<endl;
3405          return 0;          return 0;
3406      }      }
3407      if( GetOrbitalInfo()->OBT==0 && GetOrbitalInfo()->pkt_num==0 ){      if( obt==0 && pktn==0 && !ISGP ){
3408          cout << "Int_t PamLevel2::GetYodaEntry() -- ERROR -- level2 event corrupted ?? "<<endl;          cout << "Int_t PamLevel2::GetYodaEntry() -- ERROR -- level2 event corrupted ?? "<<endl;
3409          return 0;          return 0;
3410      }      }
# Line 3207  Int_t PamLevel2::GetYodaEntry(){ Line 3426  Int_t PamLevel2::GetYodaEntry(){
3426      Int_t maxshift = 10;      Int_t maxshift = 10;
3427      do{      do{
3428          if(shift>0){              if(shift>0){    
3429              cout << " PKTNUM  L2 --- "<< GetOrbitalInfo()->pkt_num << " --- L0 --- "<< GetEventHeader()->GetPscuHeader()->GetCounter()<<endl;              cout << " PKTNUM  L2 --- "<< pktn << " --- L0 --- "<< GetEventHeader()->GetPscuHeader()->GetCounter()<<endl;
3430              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;
3431              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;
3432          }          }
# Line 3217  Int_t PamLevel2::GetYodaEntry(){ Line 3436  Int_t PamLevel2::GetYodaEntry(){
3436              cout << "Int_t PamLevel2::GetYodaEntry() -- ERROR -- missing EventHeader "<<endl;              cout << "Int_t PamLevel2::GetYodaEntry() -- ERROR -- missing EventHeader "<<endl;
3437              return 0;              return 0;
3438          }          }
3439  //      cout << "PKTNUM "<<shift<<" ==  L2 --- "<< GetOrbitalInfo()->pkt_num << " --- L0 --- "<< GetEventHeader()->GetPscuHeader()->GetCounter()<<endl;  
3440  //      cout << " L2 --- "<< GetOrbitalInfo()->OBT << " --- L0 --- "<< GetEventHeader()->GetPscuHeader()->GetOrbitalTime()<<endl;          if(ISGP){
3441                obt = (UInt_t)(GetEventHeader()->GetPscuHeader()->GetOrbitalTime()); //BARBATRUCCO
3442                pktn = (UInt_t)(GetEventHeader()->GetPscuHeader()->GetCounter()); //BARBATRUCCO
3443            }
3444    
3445    //      cout << "PKTNUM "<<shift<<" ==  L2 --- "<< pktn << " --- L0 --- "<< GetEventHeader()->GetPscuHeader()->GetCounter()<<endl;
3446    //      cout << " L2 --- "<< obt << " --- L0 --- "<< GetEventHeader()->GetPscuHeader()->GetOrbitalTime()<<endl;
3447  //      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;
3448  //      cout << " GetOrbitalInfo()->OBT "<< GetOrbitalInfo()->OBT << endl;  //      cout << " obt "<< obt << endl;
3449  //      cout << " GetEventHeader()->GetPscuHeader()->GetOrbitalTime() "<< GetEventHeader()->GetPscuHeader()->GetOrbitalTime() << endl;  //      cout << " GetEventHeader()->GetPscuHeader()->GetOrbitalTime() "<< GetEventHeader()->GetPscuHeader()->GetOrbitalTime() << endl;
3450  //      cout << " GetOrbitalInfo()->pkt_num "<< GetOrbitalInfo()->pkt_num << endl;  //      cout << " pktn "<< pktn << endl;
3451  //      cout << " GetEventHeader()->GetPscuHeader()->GetCounter() "<< GetEventHeader()->GetPscuHeader()->GetCounter() << endl;  //      cout << " GetEventHeader()->GetPscuHeader()->GetCounter() "<< GetEventHeader()->GetPscuHeader()->GetCounter() << endl;
3452  //      printf(" IDRUN %u \n",GetRunInfo()->ID);  //      printf(" IDRUN %u \n",GetRunInfo()->ID);
3453  //  //
# Line 3231  Int_t PamLevel2::GetYodaEntry(){ Line 3456  Int_t PamLevel2::GetYodaEntry(){
3456            shift = -1;            shift = -1;
3457          };          };
3458    
3459      }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()) ||
3460                  pktn != (UInt_t)(GetEventHeader()->GetPscuHeader()->GetCounter())       )
3461                && (quellagiusta+(Long64_t)shift) < GetYodaTree()->GetEntries() && shift < maxshift);
3462    
3463      if ( (quellagiusta+(Long64_t)shift+(Long64_t)prevshift) > GetYodaTree()->GetEntries() || shift == maxshift ) {      if ( (quellagiusta+(Long64_t)shift+(Long64_t)prevshift) > GetYodaTree()->GetEntries() || shift == maxshift ) {
3464          cout << " Big trouble here, no such event in Level0 data! " <<endl;          cout << " Big trouble here, no such event in Level0 data! " <<endl;
# Line 3261  Bool_t PamLevel2::SetDBConnection(){ Line 3488  Bool_t PamLevel2::SetDBConnection(){
3488      return true;      return true;
3489    
3490  }  }
3491    
3492    /**
3493     * \Brief Add a friend to the pamela chain.
3494     * @param cname name of the chain to be added
3495     */
3496    
3497    TChain* PamLevel2::AddFriend(TString cname){
3498    
3499        if(!GetPamTree()){
3500            cout << " TChain* PamLevel2::AddFriend(TString cname) --- a pamela tree must be created first"<<endl;
3501            return NULL;
3502        }
3503    
3504    
3505        TChain *c = new TChain( cname.Data() );
3506    
3507        TIter next( GetPamTree()->GetListOfFiles() );
3508        Int_t nf = 0;
3509        TChainElement* element = 0;    
3510        while ((element = (TChainElement*) next())) {      
3511            c->Add(element->GetTitle());
3512            nf++;
3513        }
3514    
3515        GetPamTree()->AddFriend(cname.Data());
3516    
3517        cout << "external chain created and added to pamela friends :"<<cname<<endl;
3518        cout << "n.files "<<nf<<endl;
3519        
3520    
3521        return c;    
3522    
3523    }

Legend:
Removed from v.1.42  
changed lines
  Added in v.1.46

  ViewVC Help
Powered by ViewVC 1.1.23