--- PamelaLevel2/src/PamLevel2.cpp 2007/01/16 13:00:26 1.15 +++ PamelaLevel2/src/PamLevel2.cpp 2007/01/18 08:51:16 1.18 @@ -114,7 +114,9 @@ run_obj = 0;//new GL_RUN(); soft_obj = 0;// Emiliano - + irun = -1; + runfirstentry = 0ULL; + runlastentry = 0ULL; for(Int_t i=0; i<8; i++ )tree_clone[i]=NULL; @@ -177,9 +179,12 @@ // cout << "void PamLevel2::Clear()"<Clear(); // Emiliano: Do not deallocate run_obj here, it will give segmentation fault! call clear instead - if(soft_obj) soft_obj->Clear(); +// if(run_obj) run_obj->Clear(); // Emiliano: Do not deallocate run_obj here, it will give segmentation fault! call clear instead +// if(soft_obj) soft_obj->Clear(); if(trk1_obj) trk1_obj->Clear(); if(trk2_obj) trk2_obj->Clear(); @@ -915,18 +920,21 @@ TList *contents = new TList; // create output list contents->SetOwner(); - char *fullpath; +// char *fullpath; +// const char *fullpath; // if no input file list is given: if ( flisttxt != "" ){ - if( !gSystem->IsFileInIncludePath(flisttxt,&fullpath) ){ - cout <<"File "<ConcatFileName(gSystem->DirName(flisttxt),gSystem->BaseName(flisttxt)); - flisttxt = fullpath; - +// if( !gSystem->IsFileInIncludePath(flisttxt,&fullpath) ){ +// if( !(fullpath = gSystem->FindFile("./",flisttxt)) ){ +// cout <<"File "<ConcatFileName(gSystem->DirName(flisttxt),gSystem->BaseName(flisttxt)); + if( !gSystem->ChangeDirectory(ddir) ){ cout << "Cannot change directory : "<ChangeDirectory(wdir); // back to the working directory + return 0; + } int line=0; while (1) { TString file; @@ -948,13 +961,14 @@ } if(file.Contains("#"))file = file(0,file.First("#")); // cout <<"(2) " << file << endl; - if( gSystem->IsFileInIncludePath(file,&fullpath) ){ - - contents->Add(new TSystemFile(fullpath,gSystem->DirName(fullpath)));// add file to the list - - }else{ +// if( gSystem->IsFileInIncludePath(file,&fullpath) ){ +// if( (fullpath = gSystem->FindFile(ddir,file)) ){ + char *fullpath = gSystem->ConcatFileName(gSystem->DirName(ddir),gSystem->BaseName(file)); + contents->Add(new TSystemFile(fullpath,gSystem->DirName(fullpath)));// add file to the list + delete fullpath; +// }else{ // if(file.Data()!="")cout << "File: "< missing "<< endl; - }; +// }; }; in.close(); @@ -976,9 +990,12 @@ while ( (questo = (TSystemFile*) next()) ) { TString name = questo-> GetName(); if( name.EndsWith(".root") ){ - char *fullpath; - gSystem->IsFileInIncludePath(name,&fullpath); +// const char *fullpath = gSystem->FindFile(ddir,name); +// char *fullpath; +// gSystem->IsFileInIncludePath(name,&fullpath); + char *fullpath = gSystem->ConcatFileName(gSystem->DirName(ddir),gSystem->BaseName(name)); contents->Add(new TSystemFile(fullpath,gSystem->DirName(fullpath))); + delete fullpath; }; } delete temp; @@ -988,7 +1005,7 @@ gSystem->ChangeDirectory(wdir); // back to the working directory // cout << endl << "Selected files:" << endl; // contents->Print(); - cout << contents->GetEntries()<<" files selected\n"; + cout << contents->GetEntries()<<" files \n"; // cout << endl; // cout << "Working directory: "<< gSystem->WorkingDirectory()<< endl; return contents; @@ -1407,6 +1424,48 @@ return R; } +/** + * Update the runinfo informations (to be used to have Run infos event by event basis) + * @param run Pointer to the chain/tree which contains run infos + * @return true if a new run has been read, false if it is still the same run + */ +Bool_t PamLevel2::UpdateRunInfo(TChain *run, ULong64_t iev){ + // + // check if we have already called once GetEntry, if not call it + // + if ( run->GetEntries() <= 0 ) return(false); + // + Int_t oldrun = irun; + 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))); + irun++; + run->GetEntry(irun); + runfirstentry = runlastentry+1ULL; + runlastentry += (ULong64_t)(this->GetRunInfo()->NEVENTS); + }; + // + 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); + // + return(true); + // +}; +/** + * Update the runinfo informations (to be used to have Run infos event by event basis) + * @param run Pointer to the chain/tree which contains run infos + * @return true if a new run has been read, false if it is still the same run + */ +Bool_t PamLevel2::UpdateRunInfo(TTree *run, ULong64_t iev){ + return(UpdateRunInfo((TChain*)run,iev)); +}; + //-------------------------------------- // //