/[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.91 by mocchiut, Thu Dec 15 08:54:12 2011 UTC revision 1.94 by mocchiut, Wed Mar 12 16:37:29 2014 UTC
# Line 30  void GPamela::Clear() { Line 30  void GPamela::Clear() {
30  void GPamela::Delete() {  void GPamela::Delete() {
31    
32    Clear();    Clear();
33      /* EM all these are in the stack not in the heap, so no need to delete by hand...
34    delete[] Ipltof;    delete[] Ipltof;
35    delete[] Ipaddle;    delete[] Ipaddle;
36    delete[] Ipartof;    delete[] Ipartof;
# Line 131  void GPamela::Delete() { Line 131  void GPamela::Delete() {
131    delete[] Timecard;    delete[] Timecard;
132    delete[] Pathcard;    delete[] Pathcard;
133    delete[] P0card;    delete[] P0card;
134      */
135  }  }
136  ;  
137    
138  void GPamela::SetBranchAddress(TChain* fhBookTree) {  void GPamela::SetBranchAddress(TChain* fhBookTree) {
139    
# Line 474  void PamLevel2::Initialize() { Line 474  void PamLevel2::Initialize() {
474    runlastentry = 0LL;    runlastentry = 0LL;
475    gltsync = 0; // Emiliano    gltsync = 0; // Emiliano
476    fUpdateRunInfo = true; // Emiliano    fUpdateRunInfo = true; // Emiliano
477      fUseDBinRunInfo = true; // Emiliano
478    isSync = false; // by default assume that the level2 file(s) is(are) not sinchronized between L0/DB and L2, that is we miss some packets in L2 due to nested/DV-skipped events    isSync = false; // by default assume that the level2 file(s) is(are) not sinchronized between L0/DB and L2, that is we miss some packets in L2 due to nested/DV-skipped events
479    il0entry = 0LL;    il0entry = 0LL;
480    //  hasL0EE = true;    //  hasL0EE = true;
# Line 2820  Bool_t PamLevel2::UpdateRunInfo(Long64_t Line 2821  Bool_t PamLevel2::UpdateRunInfo(Long64_t
2821      run_tree->GetEntry(irun);      run_tree->GetEntry(irun);
2822      if (!GetOrbitalInfo())      if (!GetOrbitalInfo())
2823        cout << "** WARNING ** missing OrbitalInfo ---> run info might be not correctly updated " << endl;        cout << "** WARNING ** missing OrbitalInfo ---> run info might be not correctly updated " << endl;
2824      if (gltsync)      if ( fUseDBinRunInfo ){
2825        delete gltsync; //Emiliano        if (gltsync)
2826      if (!dbc || (dbc && !dbc->IsConnected()))          delete gltsync; //Emiliano
2827        SetDBConnection(); //Emiliano        if (!dbc || (dbc && !dbc->IsConnected()))
2828      gltsync = new GL_TIMESYNC(GetRunInfo()->ID_ROOT_L0, "ID", dbc, false); //Emiliano // the "false" means not to use level0 file (not necessary here)          SetDBConnection(); //Emiliano
2829      if (dbc){        gltsync = new GL_TIMESYNC(GetRunInfo()->ID_ROOT_L0, "ID", dbc, false); //Emiliano // the "false" means not to use level0 file (not necessary here)
2830        dbc->Close();// Emiliano        if (dbc){
2831        delete dbc;          dbc->Close();// Emiliano
2832        dbc=0;          delete dbc;
2833      };          dbc=0;
2834    };        }
2835        }
2836      }
2837    // ---------------------------------------------------------------    // ---------------------------------------------------------------
2838    // retrieve OBT and absolute time of the event    // retrieve OBT and absolute time of the event
2839    // ---------------------------------------------------------------    // ---------------------------------------------------------------
# Line 2839  Bool_t PamLevel2::UpdateRunInfo(Long64_t Line 2842  Bool_t PamLevel2::UpdateRunInfo(Long64_t
2842    prevpktnum = pktnum;    prevpktnum = pktnum;
2843    if (GetOrbitalInfo()) {    if (GetOrbitalInfo()) {
2844      abstime = GetOrbitalInfo()->absTime;      abstime = GetOrbitalInfo()->absTime;
2845      obt = gltsync->DBobt(GetOrbitalInfo()->OBT); // Emiliano      if ( fUseDBinRunInfo ) obt = gltsync->DBobt(GetOrbitalInfo()->OBT); // Emiliano
2846      pktnum = GetOrbitalInfo()->pkt_num; // Emiliano      pktnum = GetOrbitalInfo()->pkt_num; // Emiliano
2847    }    }
2848    else {    else {
2849      abstime = GetRunInfo()->RUNHEADER_TIME;      abstime = GetRunInfo()->RUNHEADER_TIME;
2850      obt = gltsync->DBobt(GetRunInfo()->RUNHEADER_OBT); // Emiliano      if ( fUseDBinRunInfo ) obt = gltsync->DBobt(GetRunInfo()->RUNHEADER_OBT); // Emiliano
2851      pktnum = GetRunInfo()->RUNHEADER_PKT; // Emiliano      pktnum = GetRunInfo()->RUNHEADER_PKT; // Emiliano
2852    }    }
2853    
# Line 2852  Bool_t PamLevel2::UpdateRunInfo(Long64_t Line 2855  Bool_t PamLevel2::UpdateRunInfo(Long64_t
2855      printf("0abstime %lld %lld pktnum %d %d obt %lld \n",abstime,prevabstime,pktnum,prevpktnum,obt);      printf("0abstime %lld %lld pktnum %d %d obt %lld \n",abstime,prevabstime,pktnum,prevpktnum,obt);
2856      printf("0        rth %d %d nevents %d  \n",GetRunInfo()->RUNHEADER_TIME,GetRunInfo()->RUNTRAILER_TIME,GetRunInfo()->NEVENTS);      printf("0        rth %d %d nevents %d  \n",GetRunInfo()->RUNHEADER_TIME,GetRunInfo()->RUNTRAILER_TIME,GetRunInfo()->NEVENTS);
2857      printf("0        rto %d %d \n",GetRunInfo()->RUNHEADER_OBT,GetRunInfo()->RUNTRAILER_OBT);      printf("0        rto %d %d \n",GetRunInfo()->RUNHEADER_OBT,GetRunInfo()->RUNTRAILER_OBT);
2858      printf("0        rto2 %lld %lld \n",gltsync->DBobt(GetRunInfo()->RUNHEADER_OBT),gltsync->DBobt(GetRunInfo()->RUNTRAILER_OBT));      if ( fUseDBinRunInfo ) printf("0        rto2 %lld %lld \n",gltsync->DBobt(GetRunInfo()->RUNHEADER_OBT),gltsync->DBobt(GetRunInfo()->RUNTRAILER_OBT));
2859      printf("0        bo irunentry %lld prevshift %lld irun %lld  \n",irunentry,prevshift,irun);      printf("0        bo irunentry %lld prevshift %lld irun %lld  \n",irunentry,prevshift,irun);
2860      printf("0        min %lld iev %lld max %lld tot %lld \n",totrunentrymin,iev,totrunentrymax,totrunentry);      printf("0        min %lld iev %lld max %lld tot %lld \n",totrunentrymin,iev,totrunentrymax,totrunentry);
2861    }    }
# Line 2875  Bool_t PamLevel2::UpdateRunInfo(Long64_t Line 2878  Bool_t PamLevel2::UpdateRunInfo(Long64_t
2878      }      }
2879    
2880      //      //
2881        bool a = true;
2882        bool b = true;
2883        if ( fUseDBinRunInfo ){
2884          a = false;    
2885          b = false;
2886          if ( obt < gltsync->DBobt(GetRunInfo()->RUNHEADER_OBT) ) a = true;
2887          if ( obt > gltsync->DBobt(GetRunInfo()->RUNTRAILER_OBT) ) b = true;
2888        }
2889      if ( iev < totrunentrymin || iev > totrunentrymax // entry is outside run limits      if ( iev < totrunentrymin || iev > totrunentrymax // entry is outside run limits
2890           || iev == 0 // or it is the first entry           || iev == 0 // or it is the first entry
2891           || (!isSync && (           || (!isSync && (
2892                           (abstime <= GetRunInfo()->RUNHEADER_TIME && obt < gltsync->DBobt(GetRunInfo()->RUNHEADER_OBT) ) // or it is outside obt limits (and abstime limits for security reasons)                           (abstime <= GetRunInfo()->RUNHEADER_TIME && a ) // or it is outside obt limits (and abstime limits for security reasons)
2893                           || (abstime >= GetRunInfo()->RUNTRAILER_TIME && obt > gltsync->DBobt(GetRunInfo()->RUNTRAILER_OBT) ) ))// or it is outside obt limits (and abstime limits for security reasons)                           || (abstime >= GetRunInfo()->RUNTRAILER_TIME && b ) ))// or it is outside obt limits (and abstime limits for security reasons)
2894           ){ // check on abstime and obt needed to handle nested+DV_skipped packets           ){ // check on abstime and obt needed to handle nested+DV_skipped packets
2895                
2896        // check for a new run (ma prima il primo!)        // check for a new run (ma prima il primo!)
# Line 2887  Bool_t PamLevel2::UpdateRunInfo(Long64_t Line 2898  Bool_t PamLevel2::UpdateRunInfo(Long64_t
2898          printf("1abstime %lld %lld pktnum %d %d obt %lld \n",abstime,prevabstime,pktnum,prevpktnum,obt);          printf("1abstime %lld %lld pktnum %d %d obt %lld \n",abstime,prevabstime,pktnum,prevpktnum,obt);
2899          printf("1        rth %d %d nevents %d  \n",GetRunInfo()->RUNHEADER_TIME,GetRunInfo()->RUNTRAILER_TIME,GetRunInfo()->NEVENTS);          printf("1        rth %d %d nevents %d  \n",GetRunInfo()->RUNHEADER_TIME,GetRunInfo()->RUNTRAILER_TIME,GetRunInfo()->NEVENTS);
2900          printf("1        rto %d %d \n",GetRunInfo()->RUNHEADER_OBT,GetRunInfo()->RUNTRAILER_OBT);          printf("1        rto %d %d \n",GetRunInfo()->RUNHEADER_OBT,GetRunInfo()->RUNTRAILER_OBT);
2901          printf("1        rto2 %lld %lld \n",gltsync->DBobt(GetRunInfo()->RUNHEADER_OBT),gltsync->DBobt(GetRunInfo()->RUNTRAILER_OBT));          if ( fUseDBinRunInfo ) printf("1        rto2 %lld %lld \n",gltsync->DBobt(GetRunInfo()->RUNHEADER_OBT),gltsync->DBobt(GetRunInfo()->RUNTRAILER_OBT));
2902          printf("1        bo irunentry %lld prevshift %lld irun %lld  \n",irunentry,prevshift,irun);          printf("1        bo irunentry %lld prevshift %lld irun %lld  \n",irunentry,prevshift,irun);
2903          printf("1        min %lld iev %lld max %lld tot %lld \n",totrunentrymin,iev,totrunentrymax,totrunentry);          printf("1        min %lld iev %lld max %lld tot %lld \n",totrunentrymin,iev,totrunentrymax,totrunentry);
2904        }        }
# Line 2914  Bool_t PamLevel2::UpdateRunInfo(Long64_t Line 2925  Bool_t PamLevel2::UpdateRunInfo(Long64_t
2925          totrunentry += GetRunInfo()->NEVENTS;          totrunentry += GetRunInfo()->NEVENTS;
2926          totrunentrymax = totrunentry - 1 - prevshift; // prevshift is needed to handle nested+DV_skipped packets          totrunentrymax = totrunentry - 1 - prevshift; // prevshift is needed to handle nested+DV_skipped packets
2927          irun = r;                  irun = r;        
2928            if ( fUseDBinRunInfo ){
2929              a = false;    
2930              b = false;
2931              if ( obt < gltsync->DBobt(GetRunInfo()->RUNHEADER_OBT) ) a = true;
2932              if ( obt > gltsync->DBobt(GetRunInfo()->RUNTRAILER_OBT) ) b = true;
2933            }
2934          if ( (iev >= totrunentrymin && iev <= totrunentrymax) || // entry is inside run limits          if ( (iev >= totrunentrymin && iev <= totrunentrymax) || // entry is inside run limits
2935               ( !isSync &&               ( !isSync &&
2936                 ( abstime >= GetRunInfo()->RUNHEADER_TIME  && obt >= gltsync->DBobt(GetRunInfo()->RUNHEADER_OBT) // or it is inside obt limits (and abstime limits for security reasons)                 ( abstime >= GetRunInfo()->RUNHEADER_TIME  && a // or it is inside obt limits (and abstime limits for security reasons)
2937                   && abstime <= GetRunInfo()->RUNTRAILER_TIME && obt <= gltsync->DBobt(GetRunInfo()->RUNTRAILER_OBT)))  // or it is inside obt limits (and abstime limits for security reasons)                   && abstime <= GetRunInfo()->RUNTRAILER_TIME && b))  // or it is inside obt limits (and abstime limits for security reasons)
2938               ){ // check on abstime and obt needed to handle nested+DV_skipped packets               ){ // check on abstime and obt needed to handle nested+DV_skipped packets
2939            if ( totrunentrymin > iev ){ // there is a shift (nested+DV_skipped packets)            if ( totrunentrymin > iev ){ // there is a shift (nested+DV_skipped packets)
2940              if ( !isSync ){              if ( !isSync ){
# Line 2943  Bool_t PamLevel2::UpdateRunInfo(Long64_t Line 2959  Bool_t PamLevel2::UpdateRunInfo(Long64_t
2959                        
2960    
2961            //            //
2962            if (gltsync)            if ( fUseDBinRunInfo ){
2963              delete gltsync; // Emiliano              if (gltsync)
2964            if (!dbc || (dbc && !dbc->IsConnected()))                delete gltsync; // Emiliano
2965              SetDBConnection(); //Emiliano              if (!dbc || (dbc && !dbc->IsConnected()))
2966            gltsync = new GL_TIMESYNC(GetRunInfo()->ID_ROOT_L0, "ID", dbc, false); // Emiliano                SetDBConnection(); //Emiliano
2967            if (dbc){              gltsync = new GL_TIMESYNC(GetRunInfo()->ID_ROOT_L0, "ID", dbc, false); // Emiliano
2968              dbc->Close(); // Emiliano              TrkParams::Set(GetRunInfo(), dbc);
2969              delete dbc;              if (dbc){
2970              dbc=0;                dbc->Close(); // Emiliano
2971            }                          delete dbc;
2972            if (gltsync->DBobt(GetRunInfo()->RUNHEADER_OBT) > gltsync->DBobt(GetRunInfo()->RUNTRAILER_OBT)) { // Emiliano                dbc=0;
2973              cout << "Bool_t PamLevel2::UpdateRunInfo(Long64_t iev) -- WARNING -- irun " << irun              }          
2974                   << "  has RUNHEADER_OBT>=RUNTRAILER_OBT " << endl;              if (gltsync->DBobt(GetRunInfo()->RUNHEADER_OBT) > gltsync->DBobt(GetRunInfo()->RUNTRAILER_OBT)) { // Emiliano
2975              cout                cout << "Bool_t PamLevel2::UpdateRunInfo(Long64_t iev) -- WARNING -- irun " << irun
2976                << "                                                            (NB!! in this case some events could be assigned to a wrong run)"                     << "  has RUNHEADER_OBT>=RUNTRAILER_OBT " << endl;
2977                << endl;                cout
2978                    << "                                                            (NB!! in this case some events could be assigned to a wrong run)"
2979                    << endl;
2980                }
2981            }            }
2982            //            //
2983            if (DBG) printf(" found \n");            if (DBG) printf(" found \n");
# Line 3015  Bool_t PamLevel2::UpdateRunInfo(Long64_t Line 3034  Bool_t PamLevel2::UpdateRunInfo(Long64_t
3034          printf("2abstime %lld %lld pktnum %d %d obt %lld \n",abstime,prevabstime,pktnum,prevpktnum,obt);          printf("2abstime %lld %lld pktnum %d %d obt %lld \n",abstime,prevabstime,pktnum,prevpktnum,obt);
3035          printf("2        rth %d %d nevents %d  \n",GetRunInfo()->RUNHEADER_TIME,GetRunInfo()->RUNTRAILER_TIME,GetRunInfo()->NEVENTS);          printf("2        rth %d %d nevents %d  \n",GetRunInfo()->RUNHEADER_TIME,GetRunInfo()->RUNTRAILER_TIME,GetRunInfo()->NEVENTS);
3036          printf("2        rto %d %d \n",GetRunInfo()->RUNHEADER_OBT,GetRunInfo()->RUNTRAILER_OBT);          printf("2        rto %d %d \n",GetRunInfo()->RUNHEADER_OBT,GetRunInfo()->RUNTRAILER_OBT);
3037          printf("2        rto2 %lld %lld \n",gltsync->DBobt(GetRunInfo()->RUNHEADER_OBT),gltsync->DBobt(GetRunInfo()->RUNTRAILER_OBT));          if ( fUseDBinRunInfo ) printf("2        rto2 %lld %lld \n",gltsync->DBobt(GetRunInfo()->RUNHEADER_OBT),gltsync->DBobt(GetRunInfo()->RUNTRAILER_OBT));
3038          printf("2        bo irunentry %lld prevshift %lld irun %lld  \n",irunentry,prevshift,irun);          printf("2        bo irunentry %lld prevshift %lld irun %lld  \n",irunentry,prevshift,irun);
3039          printf("2        min %lld iev %lld max %lld tot %lld \n",totrunentrymin,iev,totrunentrymax,totrunentry);          printf("2        min %lld iev %lld max %lld tot %lld \n",totrunentrymin,iev,totrunentrymax,totrunentry);
3040        }        }
# Line 3106  Bool_t PamLevel2::UpdateRunInfo(Long64_t Line 3125  Bool_t PamLevel2::UpdateRunInfo(Long64_t
3125        // update the tracker parameters        // update the tracker parameters
3126        // (non ho trovato nessun altro modo sicuro di farlo...)        // (non ho trovato nessun altro modo sicuro di farlo...)
3127        // ----------------------------------------------------        // ----------------------------------------------------
3128        if (!dbc || (dbc && !dbc->IsConnected()))        if ( fUseDBinRunInfo ){
3129          SetDBConnection();          if (!dbc || (dbc && !dbc->IsConnected()))
3130        TrkParams::Set(GetRunInfo(), dbc);            SetDBConnection();
3131        if (dbc){          TrkParams::Set(GetRunInfo(), dbc);
3132          dbc->Close();          if (dbc){
3133          delete dbc;            dbc->Close();
3134          dbc=0;            delete dbc;
3135        };            dbc=0;
3136            }
3137          }
3138        //            cout << endl;        //            cout << endl;
3139        prevshift = 0;        prevshift = 0;
3140        yprevshift = 0;        yprevshift = 0;
# Line 4385  Int_t PamLevel2::GetYodaEntry() { Line 4406  Int_t PamLevel2::GetYodaEntry() {
4406          cout << "  " << endl;          cout << "  " << endl;
4407        }        }
4408        if (shift > 0) {        if (shift > 0) {
4409          cout << " PKTNUM  L2 --- " << pktn << " --- L0 --- " << GetEventHeader()->GetPscuHeader()->GetCounter() << endl;          if (DBG) cout << " PKTNUM  L2 --- " << pktn << " --- L0 --- " << GetEventHeader()->GetPscuHeader()->GetCounter() << endl;
4410          if (DBG)          if (DBG)
4411            cout << "         RUN: ID " << GetRunInfo()->ID << " ID_ROOT_L0 " << run_obj->ID_ROOT_L0 << " ID_RUN_FRAG "            cout << "         RUN: ID " << GetRunInfo()->ID << " ID_ROOT_L0 " << run_obj->ID_ROOT_L0 << " ID_RUN_FRAG "
4412                 << GetRunInfo()->ID_RUN_FRAG << " EV_FROM " << GetRunInfo()->EV_FROM << endl;                 << GetRunInfo()->ID_RUN_FRAG << " EV_FROM " << GetRunInfo()->EV_FROM << endl;
# Line 4567  Int_t PamLevel2::GetYodaEntry() { Line 4588  Int_t PamLevel2::GetYodaEntry() {
4588                
4589          while ( (obt != (UInt_t)(GetEventHeader()->GetPscuHeader()->GetOrbitalTime()) || pktn != (UInt_t)(GetEventHeader()->GetPscuHeader()->GetCounter())) && (quellagiusta + (Long64_t) shift) < GetYodaTree()->GetEntries() && shift < maxshift ){          while ( (obt != (UInt_t)(GetEventHeader()->GetPscuHeader()->GetOrbitalTime()) || pktn != (UInt_t)(GetEventHeader()->GetPscuHeader()->GetCounter())) && (quellagiusta + (Long64_t) shift) < GetYodaTree()->GetEntries() && shift < maxshift ){
4590            if (shift > 0) {            if (shift > 0) {
4591              cout << " PKTNUM  L2 --- " << pktn << " --- L0 --- " << GetEventHeader()->GetPscuHeader()->GetCounter() << endl;              if (DBG) cout << " PKTNUM  L2 --- " << pktn << " --- L0 --- " << GetEventHeader()->GetPscuHeader()->GetCounter() << endl;
4592              if (DBG)              if (DBG)
4593                cout << "         RUN: ID " << GetRunInfo()->ID << " ID_ROOT_L0 " << run_obj->ID_ROOT_L0 << " ID_RUN_FRAG "                cout << "         RUN: ID " << GetRunInfo()->ID << " ID_ROOT_L0 " << run_obj->ID_ROOT_L0 << " ID_RUN_FRAG "
4594                     << GetRunInfo()->ID_RUN_FRAG << " EV_FROM " << GetRunInfo()->EV_FROM << endl;                     << GetRunInfo()->ID_RUN_FRAG << " EV_FROM " << GetRunInfo()->EV_FROM << endl;

Legend:
Removed from v.1.91  
changed lines
  Added in v.1.94

  ViewVC Help
Powered by ViewVC 1.1.23