--- PamelaLevel2/src/PamLevel2.cpp 2007/03/08 13:46:34 1.22 +++ PamelaLevel2/src/PamLevel2.cpp 2007/03/22 10:12:35 1.36 @@ -85,9 +85,32 @@ // //-------------------------------------- /** - * Constructor + * Default Constructor */ PamLevel2::PamLevel2(){ + Initialize(); +}; + +/** + * Constructor with given dir, list and detectors + */ +PamLevel2::PamLevel2(TString ddir,TString list,TString detlist){ + Initialize(); + GetPamTree(GetListOfLevel2Files(ddir,list),detlist); + GetRunTree(GetListOfLevel2Files(ddir,list)); +}; + +/** + * Constructor with given dir and list + */ +PamLevel2::PamLevel2(TString ddir,TString list){ + Initialize(); + GetPamTree(GetListOfLevel2Files(ddir,list),""); + GetRunTree(GetListOfLevel2Files(ddir,list)); +}; + + +void PamLevel2::Initialize(){ // trk2_obj = TrkLevel2::GetTrkLevel2(); // trk1_obj = TrkLevel1::GetTrkLevel1(); @@ -103,6 +126,7 @@ h0_obj = 0; trk0_obj = 0; + calo0_obj = 0; trk2_obj = 0; trk1_obj = 0; @@ -118,22 +142,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; iClose(); - if(pam_tree)pam_tree->Delete();; + // if(pam_tree)pam_tree->Delete();; + + if ( pam_tree ){ + // + // we have first to find which chains we have to delete, then delete the main chain and only after delete the friend chains. Any other order causes a segfault... + // + TList *temp = pam_tree->GetListOfFriends(); + TList *contents = new TList; // create chain friend list + contents->SetOwner(); + TIter next(temp); + TChain *questo = 0; + while ( (questo = (TChain*) next()) ){ + TString name = questo->GetName(); + contents->Add((TChain*)gROOT->FindObject(name.Data()));// add object to the list + }; + // + // deleting the main chain + // + pam_tree->Delete(); + // + // deleting the friends... + // + TIter next2(contents); + TChain *questa = 0; + while ( questa = (TChain*)next2() ){ + TString name = questa->GetName(); + questa->Delete(); + questa=NULL; + }; + // + }; + pam_tree = NULL; + if(run_tree)run_tree->Delete();; if(sel_tree)sel_tree->Delete();; for(Int_t i=0; iDelete();; @@ -241,9 +299,10 @@ // if(soft_obj) soft_obj->Clear(); 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(trk2_obj) trk2_obj->Clear(); if(trkh_obj) trkh_obj->Clear(); if(calo1_obj)calo1_obj->Clear(); if(calo2_obj)calo2_obj->Clear(); @@ -263,7 +322,81 @@ if(timage){ timage->Delete(); } - +}; + +void PamLevel2::Reset(){ + // + // First of all clear everything + // + Clear(); + // + // close and reset chains and pointers + // + if ( pam_tree ){ + // + // we have first to find which chains we have to delete, then delete the main chain and only after delete the friend chains. Any other order causes a segfault... + // + TList *temp = pam_tree->GetListOfFriends(); + TList *contents = new TList; // create chain friend list + contents->SetOwner(); + TIter next(temp); + TChain *questo = 0; + while ( (questo = (TChain*) next()) ){ + TString name = questo->GetName(); + contents->Add((TChain*)gROOT->FindObject(name.Data()));// add object to the list + }; + // + // deleting the main chain + // + pam_tree->Delete(); + // + // deleting the friends... + // + TIter next2(contents); + TChain *questa = 0; + while ( questa = (TChain*)next2() ){ + TString name = questa->GetName(); + questa->Delete(); + questa=NULL; + }; + // + }; + pam_tree = NULL; + // + if(run_tree)run_tree->Delete();; + run_tree = NULL; + if(sel_tree)sel_tree->Delete();; + sel_tree = NULL; + // + // Close file + // + if(l0_file)l0_file->Close("R"); + l0_file = NULL; + // + h0_obj = 0; + trk0_obj = 0; + calo0_obj = 0; + // + trk2_obj = 0; + trk1_obj = 0; + trkh_obj = 0; + calo1_obj = 0; + calo2_obj = 0; + tof_obj = 0; + trig_obj = 0; + s4_obj = 0; + nd_obj = 0; + ac_obj = 0; + orb_obj = 0; + // + // Reset run pointers + // + run_obj = 0;//new GL_RUN(); + soft_obj = 0;// Emiliano + irun = -1; + runfirstentry = 0ULL; + runlastentry = 0ULL; + // }; @@ -554,6 +687,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 +709,7 @@ cout << "void PamLevel2::SortTracks(TString how): how= "<SetBranchAddress("TrigLevel2", GetPointerTo("TrigLevel2")); cout << "Trigger : set branch address TrigLevel2"<AddFriend(R); }else{ cout << "Trigger : missing tree"<SetBranchAddress("S4Level2", GetPointerTo("S4Level2")); cout << "S4 : set branch address S4Level2"<AddFriend(S); }else{ cout << "S4 : missing tree"<SetBranchAddress("NDLevel2", GetPointerTo("NDLevel2")); cout << "NeutronD : set branch address NDLevel2"<AddFriend(N); }else{ cout << "NeutronD : missing tree"<SetBranchAddress("AcLevel2", GetPointerTo("AcLevel2")); cout << "Anticounter : set branch address AcLevel2"<AddFriend(A); }else{ cout << "Anticounter : missing tree"<SetBranchAddress("OrbitalInfo", GetPointerTo("OrbitalInfo")); cout << "OrbitalInfo : set branch address OrbitalInfo"<AddFriend(B); }else{ cout << "OrbitalInfo : missing tree"<GetEntries()<WorkingDirectory(); - if(ddir=="")ddir = wdir; + // if(ddir=="")ddir = wdir; // TSystemDirectory *datadir = new TSystemDirectory(gSystem->BaseName(ddir),ddir); - cout << "Level2 data directory : "<< ddir << endl; - + if ( ddir != ""){ + cout << "Level2 data directory : "<< ddir << endl; + } else { + cout << "Level2 data directory not given as input: trying to evaluate from list or taking working directory " << endl; + }; TList *contents = new TList; // create output list contents->SetOwner(); @@ -1008,6 +1150,7 @@ // return 0; // } // flisttxt = fullpath; + if ( !flisttxt.EndsWith(".root") ){ flisttxt = gSystem->ConcatFileName(gSystem->DirName(flisttxt),gSystem->BaseName(flisttxt)); @@ -1040,7 +1183,14 @@ // if( gSystem->IsFileInIncludePath(file,&fullpath) ){ // if( (fullpath = gSystem->FindFile(ddir,file)) ){ if( file.EndsWith(".root") ){ - char *fullpath = gSystem->ConcatFileName(gSystem->DirName(ddir),gSystem->BaseName(file)); + TString filedir; + if (ddir != ""){ + filedir = ddir; // take the input dir + } else { + gSystem->ChangeDirectory(wdir); // back to the working directory + filedir = gSystem->DirName(file); // this will take the path if exist in the list otherwise it will return automatically the working dir + }; + char *fullpath = gSystem->ConcatFileName(gSystem->DirName(filedir),gSystem->BaseName(file)); contents->Add(new TSystemFile(fullpath,gSystem->DirName(fullpath)));// add file to the list delete fullpath; } @@ -1049,13 +1199,22 @@ // }; }; in.close(); - + } else { + if(flisttxt.Contains("#"))flisttxt = flisttxt(0,flisttxt.First("#")); + 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."<WorkingDirectory()<< endl; - + if ( ddir == "" ){ + ddir = wdir; + cout << "Level2 data directory : "<< ddir << endl; + }; + TSystemDirectory *datadir = new TSystemDirectory(gSystem->BaseName(ddir),ddir); TList *temp = datadir->GetListOfFiles(); // temp->Print(); @@ -1099,6 +1258,14 @@ * @return Pointer to a TChain */ TChain *PamLevel2::GetPamTree(TList *fl, TString detlist ){ + // + // + // + if ( pam_tree ){ + printf("WARNING: TChain *PamLevel2::GetPamTree(TList *fl, TString detlist) -- pam_tree already exists!\n "); + return pam_tree; + }; + // TChain *Trout =0; @@ -1119,16 +1286,16 @@ if(ORB)cout<<"ORB "; cout << endl; - TChain *T = 0; - TChain *C = 0; - TChain *O = 0; - TChain *R = 0; - TChain *S = 0; - TChain *N = 0; - TChain *A = 0; - TChain *B = 0; + TChain *T = 0; + TChain *C = 0; + TChain *O = 0; + TChain *R = 0; + TChain *S = 0; + TChain *N = 0; + TChain *A = 0; + TChain *B = 0; - TChain *L = 0; + TChain *L = 0; if(TRK2||TRK1||TRKh) T = new TChain("Tracker"); if(CAL2||CAL1) C = new TChain("Calorimeter"); @@ -1138,7 +1305,6 @@ if(ND) N = new TChain("NeutronD"); if(AC) A = new TChain("Anticounter"); if(ORB) B = new TChain("OrbitalInfo"); - L = new TChain("SelectionList"); // loop over files and create chains @@ -1158,9 +1324,10 @@ if(ORB) B->Add(name); if(SELLI==1) L->Add(name); }; - } + }; cout << "done chain \n"; + cout << "+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" <SetBranchStatus("TrkHough",0,found); if(TRKh)cout << "Tracker : set branch address TrkHough"<AddFriend("Tracker"); + else Trout->AddFriend("Tracker"); }else{ cout << "Tracker : missing tree"<AddFriend("SelectionList"); + cout << "----------------------------------------------------" <Delete(); @@ -1448,8 +1617,15 @@ * @return Pointer to a TChain */ TChain *PamLevel2::GetRunTree(TList *fl){ - - TChain *R = new TChain("Run"); + // + // + // + if ( run_tree ){ + printf("WARNING: TChain *PamLevel2::GetRunTree(TList *fl) -- run_tree already exists!\n "); + return run_tree; + }; + // + TChain *R = new TChain("Run"); // loop over files and create chains TIter next(fl); @@ -1488,21 +1664,26 @@ * @return Pointer to a TTree */ TTree *PamLevel2::GetRunTree(TFile *f){ + if ( run_tree ){ + printf("WARNING: TTree *PamLevel2::GetRunTree(TFile *f) -- run_tree already exists!\n "); + return run_tree; + }; + cout << "TTree *PamLevel2::GetRunTree(TFile *f) -- obsolte "<Get("Run"); + TTree *T = (TTree*)f->Get("Run"); - if(R){ - R->SetBranchAddress("RunInfo", GetPointerTo("RunInfo")); + if(T){ + T->SetBranchAddress("RunInfo", GetPointerTo("RunInfo")); cout << "Run : set branch address RunInfo"<SetBranchAddress("SoftInfo", GetPointerTo("SoftInfo")); // Emiliano + T->SetBranchAddress("SoftInfo", GetPointerTo("SoftInfo")); // Emiliano cout << "Software : set branch address SoftInfo"<GetEntries() <= 0 ) return(false); + cout << "Bool_t PamLevel2::UpdateRunInfo(TChain *run, Long64_t iev) --- NON FUNZIONA BENISSIMO.... "<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 ( irun < 0 ){ - irun = 0; - run->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))); + + // + // the absolute time is necessary to relate the event with the run + // + if( !GetOrbitalInfo() ){ + cout << "Bool_t PamLevel2::UpdateRunInfo(TChain *run, ULong64_t iev) -- ERROR -- missing OrbitalInfo "<GetEntry(irun); + runfirstentry = 0LL; + runlastentry += (Long64_t)(this->GetRunInfo()->NEVENTS); + if ( (Long64_t)(this->GetRunInfo()->NEVENTS) > 0LL ) runlastentry -= 1LL; + }; + // + if ( irun == run->GetEntries()-1LL && + !(GetOrbitalInfo()->absTime >= GetRunInfo()->RUNHEADER_TIME && + GetOrbitalInfo()->absTime <= GetRunInfo()->RUNTRAILER_TIME) + ){ + irun = -1LL; + runfirstentry = 0LL; + runlastentry = -1LL; + }; + // modificato il controllo sull'aggiornamento del run, per evitare problemi + // dovuti agli eventi annidati (NB! NEVENTS conta anche questi!!) + // + bool fromfirst = true; + // + while ( !(GetOrbitalInfo()->absTime >= GetRunInfo()->RUNHEADER_TIME && GetOrbitalInfo()->absTime <= GetRunInfo()->RUNTRAILER_TIME) && irun < run->GetEntries()-1LL ){ +// 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 == (Long64_t)(run->GetEntries()-1LL) && 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 ( + !(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); +// cout << irun << " "<< irunentry << endl; 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); + }; + // + bool fromfirst = true; // first loop over runs + // ------------------------------------------------------ + // loop over runs to find the one that contains the event + // ------------------------------------------------------ + 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) && + irun < run_tree->GetEntries() ){ + irun++; + // ------------------------------------ + // if the end of run tree is reached... + // ------------------------------------ + if( irun == run_tree->GetEntries() ){ + if(!fromfirst){ + // ----------------------------------------------------- + // if it happened already once and the run was not found + // ---> exit with error + // ----------------------------------------------------- + cout << "Bool_t PamLevel2::UpdateRunInfo(Long64_t iev) -- ERROR -- event entry #"<0)runfirstentry += (GetRunInfo()->NEVENTS); + run_tree->GetEntry(irun); + if(GetRunInfo()->RUNHEADER_OBT>=GetRunInfo()->RUNTRAILER_OBT ){ + cout << "Bool_t PamLevel2::UpdateRunInfo(Long64_t iev) -- WARNING -- irun "<=RUNTRAILER_OBT " < exit with FALSE + // -------------------------------------- + if ( irun == oldrun ) return(false); + + // -------------------------------------- + // ... otherwise + // ---> exit with TRUE + // -------------------------------------- + cout << endl << " ))))) UPDATE RUN INFO ((((( @iev "<ID<<" irun "<GetEntry(iev); + if(irun != oldrun){ + run_tree->GetEntry(irun); + cout << endl << " ))))) UPDATE RUN INFO ((((( @iev "<ID<<" irun "<Branch("SoftInfo","SoftInfo",GetPointerTo("SoftInfo")); cout << "Run : branch SoftInfo"<GetEntries(); i++){ + run_tree->GetEntry(i); + cout << i<< "\t | "<ID<<"\t "<NEVENTS<< "\t "<RUNHEADER_TIME<<" <---> "<RUNTRAILER_TIME<Fill(); + } + cout << "----------------------------------------------------"<Branch("RunEntry",&irun,"runentry/I"); - sel_tree_clone->Branch("EventEntry",&irunentry,"eventry/I"); + sel_tree_clone->Branch("RunEntry",&irun,"runentry/L"); + sel_tree_clone->Branch("EventEntry",&irunentry,"eventry/L"); Int_t i=0; @@ -2213,6 +2578,7 @@ pam_tree_clone[i]->Branch("TrkLevel1","TrkLevel1", GetPointerTo("TrkLevel1")); pam_tree_clone[i]->BranchRef(); cout << "Tracker : branch TrkLevel1"<Branch("TrkLevel2", "TrkLevel2",GetPointerTo("TrkLevel2")); @@ -2294,16 +2660,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( !pam_tree->GetEntry(ii) ){ + cout << " Int_t PamLevel2::GetEntry(Int_t) -- ERROR -- error reading pam tree"<Fill(); - +// if(UPDATED && run_tree_clone)run_tree_clone->Fill(); + // cout << "PamLevel2::GetEntry("<ID_ROOT_L0; -// cout << "iroot "<Close(); @@ -2444,6 +2835,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){ @@ -2452,12 +2844,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 << " irunentry "<EV_FROM<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 "<OBT==0 && GetOrbitalInfo()->pkt_num==0 ){ + cout << "Int_t PamLevel2::GetYodaEntry() -- ERROR -- level2 event corrupted ?? "<0){ + cout << " PKTNUM L2 --- "<< GetOrbitalInfo()->pkt_num << " --- L0 --- "<< GetEventHeader()->GetPscuHeader()->GetCounter()<ID << " ID_ROOT_L0 "<ID_ROOT_L0<<" ID_RUN_FRAG "<ID_RUN_FRAG << " EV_FROM "<EV_FROM < L0 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() && shift < maxshift); + + if ( (quellagiusta+(Long64_t)shift) == GetYodaTree()->GetEntries() || shift == maxshift ) { + 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; } + +