--- PamelaLevel2/src/PamLevel2.cpp 2007/03/08 15:25:27 1.23 +++ PamelaLevel2/src/PamLevel2.cpp 2007/03/21 09:07:32 1.33 @@ -103,6 +103,7 @@ h0_obj = 0; trk0_obj = 0; + calo0_obj = 0; trk2_obj = 0; trk1_obj = 0; @@ -118,22 +119,23 @@ run_obj = 0;//new GL_RUN(); soft_obj = 0;// Emiliano - irun = -1; - runfirstentry = 0ULL; - runlastentry = 0ULL; + irun = -1LL; + runfirstentry = 0LL; + runlastentry = 0LL; l0_file = NULL; l0_tree = NULL; iroot = -1; dbc = 0; + + prevshift = 0; - irun = -1; run_tree = NULL; run_tree_clone = NULL; sel_tree = NULL; sel_tree_clone = NULL; - irunentry = -1; + irunentry = -1LL; pam_tree = NULL; for(Int_t i=0; iClear(); if(h0_obj) h0_obj->Clear(); - if(trk0_obj) trk0_obj->Clear(); +// if(trk0_obj) trk0_obj->Clear(); + if(calo0_obj) calo0_obj->Clear(); if(trk1_obj) trk1_obj->Clear(); if(trk2_obj) trk2_obj->Clear(); if(trkh_obj) trkh_obj->Clear(); @@ -554,6 +558,7 @@ use_CAL && calo2_obj->npcfit[1] > 15 && //no. of fit planes on Y view calo2_obj->varcfit[1] < 1000. && //fit variance on Y view + cp && ci && true){ @@ -575,7 +580,7 @@ cout << "void PamLevel2::SortTracks(TString how): how= "<GetEntries()<ConcatFileName(gSystem->DirName(flisttxt),gSystem->BaseName(flisttxt)); @@ -1049,7 +1055,11 @@ // }; }; in.close(); - + } else { + char *fullpath = gSystem->ConcatFileName(gSystem->DirName(flisttxt),gSystem->BaseName(flisttxt)); + contents->Add(new TSystemFile(fullpath,gSystem->DirName(fullpath)));// add file to the list + delete fullpath; + }; }else{ cout << "No input file list given."<GetEntries() <= 0 ) return(false); // - Int_t oldrun = irun; +// Int_t oldrun = irun; + Long64_t oldrun = irun; // -------------------------------------- // if it is a full file (not preselected) // -------------------------------------- if(SELLI==0){ + + if( !GetOrbitalInfo() ){ + cout << "Bool_t PamLevel2::UpdateRunInfo(TChain *run, ULong64_t iev) -- ERROR -- missing OrbitalInfo "<GetEntry(0); - runfirstentry = 0ULL; - runlastentry += (ULong64_t)(this->GetRunInfo()->NEVENTS) - 1ULL; - }; - while ( iev > (runfirstentry+(ULong64_t)(this->GetRunInfo()->NEVENTS-1)) && irun < run->GetEntries() ){ - // printf(" iev %llu %u %llu \n",iev,this->GetRunInfo()->NEVENTS,(ULong64_t)(runfirstentry+(ULong64_t)(this->GetRunInfo()->NEVENTS))); + run->GetEntry(irun); + runfirstentry = 0LL; + runlastentry += (Long64_t)(this->GetRunInfo()->NEVENTS); + if ( (Long64_t)(this->GetRunInfo()->NEVENTS) > 0LL ) runlastentry -= 1LL; +// cout << " ))))) UPDATE RUN INFO ((((( @iev "<ID<<" irun "<absTime >= GetRunInfo()->RUNHEADER_TIME && GetOrbitalInfo()->absTime <= GetRunInfo()->RUNTRAILER_TIME) && irun < run->GetEntries()-1 ){ +// while ( iev > (runfirstentry+(ULong64_t)(this->GetRunInfo()->NEVENTS-1)) && irun < run->GetEntries() ){ irun++; run->GetEntry(irun); - runfirstentry = runlastentry+1ULL; - runlastentry += (ULong64_t)(this->GetRunInfo()->NEVENTS); + runfirstentry = runlastentry; + if ( (Long64_t)(this->GetRunInfo()->NEVENTS) > 0LL ) runfirstentry += 1LL; + runlastentry += (Long64_t)(this->GetRunInfo()->NEVENTS); +// 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(" IDRUN %u \n",GetRunInfo()->ID); + // +// prevshift = 0; + // + if ( irun == run->GetEntries()-1 && fromfirst && !(GetOrbitalInfo()->absTime >= GetRunInfo()->RUNHEADER_TIME && GetOrbitalInfo()->absTime <= GetRunInfo()->RUNTRAILER_TIME)){ + printf(" resetting irun (it should NOT happen!!!)\n"); + fromfirst = false; + irun = 0; + run->GetEntry(irun); + runfirstentry = 0ULL; + runlastentry += (Long64_t)(this->GetRunInfo()->NEVENTS); + if ( (Long64_t)(this->GetRunInfo()->NEVENTS) > 0LL ) runlastentry -= 1LL; + }; + // }; // + if ( !fromfirst && + !(GetOrbitalInfo()->absTime >= GetRunInfo()->RUNHEADER_TIME && + GetOrbitalInfo()->absTime <= GetRunInfo()->RUNTRAILER_TIME) + ) { + printf(" Something very wrong here: cannot find RUN containing absolute time %u \n",GetOrbitalInfo()->absTime); + return false; + } + // if ( irun == oldrun || irun >= run->GetEntries() ) return(false); // // printf(" iev %llu irun %i nevents %u 1st %llu last %llu \n",iev,irun,this->GetRunInfo()->NEVENTS,(ULong64_t)runfirstentry,(ULong64_t)runlastentry); // + prevshift = 0; + cout << " ))))) UPDATE RUN INFO ((((( @iev "<ID<<" irun "<GetEntry(iev); if(irun != oldrun){ run->GetEntry(irun); + cout << " ))))) UPDATE RUN INFO ((((( @iev "<ID<<" irun "<GetEntries() <= 0 ) { +// cout << " Bool_t PamLevel2::UpdateRunInfo(ULong64_t iev) -- ERROR -- run tree is empty"<GetEntry(irun); +// runfirstentry = iev; +// if( iev != 0){ +// cout << "Bool_t PamLevel2::UpdateRunInfo(TChain *run, ULong64_t iev) -- WARNING -- "<absTime >= GetRunInfo()->RUNHEADER_TIME && GetOrbitalInfo()->absTime <= GetRunInfo()->RUNTRAILER_TIME) && irun < run->GetEntries() ){ +// irun++; +// if( irun == run->GetEntries() ){ +// if(!fromfirst){ +// cout << "Bool_t PamLevel2::UpdateRunInfo(TChain *run, ULong64_t iev) -- ERROR -- event entry #"<GetEntry(irun); +// runfirstentry = iev; +// }; +// // +// if ( irun == oldrun ) return(false); +// // +// cout << " ))))) UPDATE RUN INFO ((((( @iev "<ID<<" irun "<GetEntry(iev); +// if(irun != oldrun){ +// run->GetEntry(irun); +// cout << " ))))) UPDATE RUN INFO ((((( @iev "<ID<<" irun "<Branch("TrkLevel1","TrkLevel1", GetPointerTo("TrkLevel1")); pam_tree_clone[i]->BranchRef(); cout << "Tracker : branch TrkLevel1"<Branch("TrkLevel2", "TrkLevel2",GetPointerTo("TrkLevel2")); @@ -2294,16 +2431,11 @@ void PamLevel2::FillCloneTrees(){ // cout << "PamLevel2::FillCloneTrees()" << irunentry << endl; + for(Int_t i=0; iFill(); } if(sel_tree_clone)sel_tree_clone->Fill(); -// if( irunentry == 0 || run_tree_clone->GetEntries()==0 )run_tree_clone->Fill(); -// Int_t nstoredruns = run_tree_clone->GetEntries(); -// if( irun == nstoredruns )run_tree_clone->Fill(); -// else if( irun > nstoredruns || irun < nstoredruns-1){ -// cout << " PamLevel2::FillCloneTrees() -- ERROR -- current run "<< irun <<" stored runs "<< nstoredruns <GetEntry(ii) ) return 0; - //------------------------------- - - if(!run_tree ){ - cout << " Int_t PamLevel2::GetEntry(Int_t) -- ERROR -- run tree not loaded"<GetEntry(ii) ){ + cout << " Int_t PamLevel2::GetEntry(Int_t) -- ERROR -- error reading pam tree"<Fill(); @@ -2401,8 +2553,8 @@ return NULL; } Int_t irootnew = run_obj->ID_ROOT_L0; -// cout << "iroot "<Close(); @@ -2446,6 +2601,7 @@ l0_tree = (TTree*)l0_file->Get("Physics"); if(!h0_obj)h0_obj = new EventHeader(); l0_tree->SetBranchAddress("Header" ,&h0_obj); + prevshift = 0; //--------------------------------------------------- // TRACKER: if(TRK0){ @@ -2454,12 +2610,16 @@ trk0_obj->Set(); }; l0_tree->SetBranchAddress("Tracker" ,trk0_obj->GetPointerToTrackerEvent()); - TrkParams::SetCalib(run_obj,dbc); } //--------------------------------------------------- // CALORIMETER: if(CAL0){ - cout << "PamLevel2::GetYodaTree() --- level0 calorimeter not implemented "<Set(); + }; + l0_tree->SetBranchAddress("Calorimeter" ,calo0_obj->GetPointerToCalorimeterEvent()); + // cout << "PamLevel2::GetYodaTree() --- level0 calorimeter not implemented "<IsConnected())){ + cout << " TTree* PamLevel2::GetYodaTree( ) -- no DB connected... hai fatto qualche cazzata "<EV_FROM; - // ------------------------------------------ - // otherwise read the "preselected-list" tree - // ------------------------------------------ + Long64_t quellagiusta = irunentry + (Long64_t)(run_obj->EV_FROM); + + +// cout << " irun "<< irun << " irunentry "<< irunentry<<" run_obj->EV_FROM "<EV_FROM <<" quella giusta "<ID_ROOT_L0 "<ID_ROOT_L0<absTime << endl; +// cout << " trk_calib_used "<TRK_CALIB_USED<< endl; + + if( !GetOrbitalInfo() ){ + cout << "Int_t PamLevel2::GetYodaEntry() -- ERROR -- missing OrbitalInfo "<0){ + cout << " level0 <--> level2 mismatch ( irun "<GetEntry(quellagiusta+(Long64_t)shift+(Long64_t)prevshift); + shift++; + if( !GetEventHeader() ){ + cout << "Int_t PamLevel2::GetYodaEntry() -- ERROR -- missing EventHeader "<pkt_num << " --- L0 --- "<< GetEventHeader()->GetPscuHeader()->GetCounter()<OBT << " --- L0 --- "<< GetEventHeader()->GetPscuHeader()->GetOrbitalTime()<GetEntries()+1 )cout << ">>> end of level0 tree <<<"<OBT "<< GetOrbitalInfo()->OBT << endl; +// cout << " GetEventHeader()->GetPscuHeader()->GetOrbitalTime() "<< GetEventHeader()->GetPscuHeader()->GetOrbitalTime() << endl; +// cout << " GetOrbitalInfo()->pkt_num "<< GetOrbitalInfo()->pkt_num << endl; +// cout << " GetEventHeader()->GetPscuHeader()->GetCounter() "<< GetEventHeader()->GetPscuHeader()->GetCounter() << endl; +// printf(" IDRUN %u \n",GetRunInfo()->ID); +// + if ( prevshift != 0 && (quellagiusta+(Long64_t)shift) == GetYodaTree()->GetEntries() ){ + prevshift = 0; + shift = -1; + }; + + }while( ( GetOrbitalInfo()->OBT != (UInt_t)(GetEventHeader()->GetPscuHeader()->GetOrbitalTime()) || GetOrbitalInfo()->pkt_num != (UInt_t)(GetEventHeader()->GetPscuHeader()->GetCounter())) && (quellagiusta+(Long64_t)shift) < GetYodaTree()->GetEntries() ); + + if ( (quellagiusta+(Long64_t)shift) == GetYodaTree()->GetEntries() ) cout << " Big trouble here, no such event in Level0 data! " <GetEntry(quellagiusta); +// return GetYodaTree()->GetEntry(quellagiusta); + if ( shift > 1 ) prevshift += (shift-1); - return 1; + return answer; } + +