--- PamelaLevel2/src/PamLevel2.cpp 2007/08/07 15:37:12 1.42 +++ PamelaLevel2/src/PamLevel2.cpp 2007/08/17 16:57:12 1.43 @@ -112,18 +112,6 @@ void PamLevel2::Initialize(){ -// 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(); - h0_obj = 0; trk0_obj = 0; calo0_obj = 0; @@ -198,6 +186,8 @@ SELLI = -1; + ISGP = false; + tsorted=0; timage=0; @@ -1918,11 +1908,15 @@ // // the absolute time is necessary to relate the event with the run // - if( !GetOrbitalInfo() ){ + if( !GetOrbitalInfo() && !ISGP){ cout << "Bool_t PamLevel2::UpdateRunInfo(TChain *run, ULong64_t iev) -- ERROR -- missing OrbitalInfo "<absTime; + + // // the first time the routine is called, set run search from the beginning // @@ -1932,11 +1926,19 @@ runfirstentry = 0LL; runlastentry += (Long64_t)(this->GetRunInfo()->NEVENTS); if ( (Long64_t)(this->GetRunInfo()->NEVENTS) > 0LL ) runlastentry -= 1LL; + + if( ISGP && run->GetEntries()!=1 ){ + cout << "** WARNING ** simulated files are assumed to have 1 single run, not "<< run->GetEntries() << endl; + cout << "** WARNING ** run will not be updated"<GetEntries()-1LL && - !(GetOrbitalInfo()->absTime >= GetRunInfo()->RUNHEADER_TIME && - GetOrbitalInfo()->absTime <= GetRunInfo()->RUNTRAILER_TIME) + if(ISGP)abstime = GetRunInfo()->RUNHEADER_TIME; // BARBATRUCCO + // + if ( irun == run->GetEntries()-1LL && + !(abstime >= GetRunInfo()->RUNHEADER_TIME && + abstime <= GetRunInfo()->RUNTRAILER_TIME) ){ irun = -1LL; runfirstentry = 0LL; @@ -1947,7 +1949,7 @@ // bool fromfirst = true; // - 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 ){ // while ( iev > (runfirstentry+(ULong64_t)(this->GetRunInfo()->NEVENTS-1)) && irun < run->GetEntries() ){ irun++; run->GetEntry(irun); @@ -1957,12 +1959,12 @@ // cout << " ))))) UPDATE RUN INFO ((((( @iev "<ID<<" irun "<GetRunInfo()->NEVENTS,(ULong64_t)(runfirstentry+(ULong64_t)(this->GetRunInfo()->NEVENTS))); - // printf(" abstime %u trailertime %u \n",GetOrbitalInfo()->absTime,GetRunInfo()->RUNTRAILER_TIME); + // printf(" abstime %u trailertime %u \n",abstime,GetRunInfo()->RUNTRAILER_TIME); // printf(" IDRUN %u \n",GetRunInfo()->ID); // // prevshift = 0; // - 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)){ printf(" resetting irun (it should NOT happen!!!)\n"); fromfirst = false; irun = 0; @@ -1975,10 +1977,10 @@ }; // if ( - !(GetOrbitalInfo()->absTime >= GetRunInfo()->RUNHEADER_TIME && - GetOrbitalInfo()->absTime <= GetRunInfo()->RUNTRAILER_TIME) + !(abstime >= GetRunInfo()->RUNHEADER_TIME && + abstime <= GetRunInfo()->RUNTRAILER_TIME) ) { - 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 %u \n",abstime); return false; } // @@ -2029,10 +2031,16 @@ // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- if(SELLI==0){ + ULong64_t abstime = 0; + ULong64_t obt = 0; + if( GetOrbitalInfo() ){ + abstime = GetOrbitalInfo()->absTime; + obt = GetOrbitalInfo()->OBT; + } // --------------------------------------------------------------- // the absolute time is necessary to relate the event with the run // --------------------------------------------------------------- - if( !GetOrbitalInfo() ){ + if( !GetOrbitalInfo() && !ISGP ){ cout << "Bool_t PamLevel2::UpdateRunInfo(Long64_t iev) -- ERROR -- missing OrbitalInfo "<GetEntry(irun); + + if( ISGP && run_tree->GetEntries()!=1 ){ + cout << "** WARNING ** simulated files are assumed to have 1 single run, not "<< run_tree->GetEntries() << endl; + cout << "** WARNING ** run will not be updated"<RUNHEADER_TIME; // BARBATRUCCO + obt = GetRunInfo()->RUNHEADER_OBT; // BARBATRUCCO + } // bool fromfirst = true; // first loop over runs @@ -2059,10 +2080,10 @@ while ( ( ( - !(GetOrbitalInfo()->absTime >= GetRunInfo()->RUNHEADER_TIME && // check on absolute time (s) - GetOrbitalInfo()->absTime <= GetRunInfo()->RUNTRAILER_TIME) && - !(GetOrbitalInfo()->OBT >= GetRunInfo()->RUNHEADER_OBT && // additional check on OBT (ms) - GetOrbitalInfo()->OBT <= GetRunInfo()->RUNTRAILER_OBT) + !(abstime >= GetRunInfo()->RUNHEADER_TIME && // check on absolute time (s) + abstime <= GetRunInfo()->RUNTRAILER_TIME) && + !(obt >= GetRunInfo()->RUNHEADER_OBT && // additional check on OBT (ms) + obt <= GetRunInfo()->RUNTRAILER_OBT) ) || GetRunInfo()->NEVENTS==0 || !(irunentry < GetRunInfo()->NEVENTS-1-prevshift) @@ -3178,14 +3199,21 @@ // cout << " irun "<< irun << " irunentry "<< irunentry<<" run_obj->EV_FROM "<EV_FROM <<" quella giusta "<ID_ROOT_L0 "<ID_ROOT_L0<absTime << endl; +// cout << " time "<< abstime << endl; // cout << " trk_calib_used "<TRK_CALIB_USED<< endl; - if( !GetOrbitalInfo() ){ + ULong64_t obt = 0; + ULong64_t pktn = 0; + if( GetOrbitalInfo() ){ + obt = GetOrbitalInfo()->OBT; + pktn = GetOrbitalInfo()->pkt_num; + } + + if( !GetOrbitalInfo() && !ISGP){ cout << "Int_t PamLevel2::GetYodaEntry() -- ERROR -- missing OrbitalInfo "<OBT==0 && GetOrbitalInfo()->pkt_num==0 ){ + if( obt==0 && pktn==0 && !ISGP ){ cout << "Int_t PamLevel2::GetYodaEntry() -- ERROR -- level2 event corrupted ?? "<0){ - cout << " PKTNUM L2 --- "<< GetOrbitalInfo()->pkt_num << " --- L0 --- "<< GetEventHeader()->GetPscuHeader()->GetCounter()<GetPscuHeader()->GetCounter()<ID << " ID_ROOT_L0 "<ID_ROOT_L0<<" ID_RUN_FRAG "<ID_RUN_FRAG << " EV_FROM "<EV_FROM < L0 mismatch ( irun "<pkt_num << " --- L0 --- "<< GetEventHeader()->GetPscuHeader()->GetCounter()<OBT << " --- L0 --- "<< GetEventHeader()->GetPscuHeader()->GetOrbitalTime()<GetPscuHeader()->GetOrbitalTime()); //BARBATRUCCO + pktn = (UInt_t)(GetEventHeader()->GetPscuHeader()->GetCounter()); //BARBATRUCCO + } + +// cout << "PKTNUM "<GetPscuHeader()->GetCounter()<GetPscuHeader()->GetOrbitalTime()<GetEntries()+1 )cout << ">>> end of level0 tree <<<"<OBT "<< GetOrbitalInfo()->OBT << endl; +// cout << " obt "<< obt << endl; // cout << " GetEventHeader()->GetPscuHeader()->GetOrbitalTime() "<< GetEventHeader()->GetPscuHeader()->GetOrbitalTime() << endl; -// cout << " GetOrbitalInfo()->pkt_num "<< GetOrbitalInfo()->pkt_num << endl; +// cout << " pktn "<< pktn << endl; // cout << " GetEventHeader()->GetPscuHeader()->GetCounter() "<< GetEventHeader()->GetPscuHeader()->GetCounter() << endl; // printf(" IDRUN %u \n",GetRunInfo()->ID); // @@ -3231,7 +3265,9 @@ shift = -1; }; - }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()) || + pktn != (UInt_t)(GetEventHeader()->GetPscuHeader()->GetCounter()) ) + && (quellagiusta+(Long64_t)shift) < GetYodaTree()->GetEntries() && shift < maxshift); if ( (quellagiusta+(Long64_t)shift+(Long64_t)prevshift) > GetYodaTree()->GetEntries() || shift == maxshift ) { cout << " Big trouble here, no such event in Level0 data! " <