--- PamelaLevel2/src/PamLevel2.cpp 2007/01/15 11:51:40 1.13 +++ PamelaLevel2/src/PamLevel2.cpp 2007/01/18 08:51:16 1.18 @@ -113,7 +113,10 @@ orb_obj = 0; 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; @@ -143,6 +146,7 @@ void PamLevel2::Delete(){ if(run_obj)delete run_obj; + if(soft_obj)delete soft_obj; //Emiliano // 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(trk1_obj) trk1_obj->Clear(); if(trk2_obj) trk2_obj->Clear(); @@ -209,11 +220,17 @@ TString objname = c; if(!objname.CompareTo("TrkLevel1")) { - if(!trk1_obj) trk1_obj = new TrkLevel1(); + if(!trk1_obj){ + trk1_obj = new TrkLevel1(); + trk1_obj->Set(); + } return &trk1_obj; }; if(!objname.CompareTo("TrkLevel2")) { - if(!trk2_obj) trk2_obj = new TrkLevel2(); + if(!trk2_obj){ + trk2_obj = new TrkLevel2(); + trk2_obj->Set(); + } return &trk2_obj; }; if(!objname.CompareTo("TrkHough")) { @@ -225,11 +242,17 @@ return &calo1_obj; }; if(!objname.CompareTo("CaloLevel2")) { - if(!calo2_obj) calo2_obj = new CaloLevel2(); + if(!calo2_obj){ + calo2_obj = new CaloLevel2(); + calo2_obj->Set(); + }; return &calo2_obj; }; if(!objname.CompareTo("ToFLevel2")) { - if(!tof_obj) tof_obj = new ToFLevel2(); + if(!tof_obj){ + tof_obj = new ToFLevel2(); + tof_obj->Set(); + } return &tof_obj; }; if(!objname.CompareTo("TrigLevel2")) { @@ -254,6 +277,9 @@ }; if(!objname.CompareTo("RunInfo"))return &run_obj; + + if(!objname.CompareTo("SoftInfo"))return &soft_obj; // Emiliano + return NULL; }; //-------------------------------------- @@ -894,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; @@ -927,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(); @@ -955,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; @@ -967,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; @@ -1358,6 +1396,8 @@ R->SetBranchAddress("RunInfo", GetPointerTo("RunInfo")); cout << "Run : set branch address RunInfo"<SetBranchAddress("SoftInfo", GetPointerTo("SoftInfo")); // Emiliano + cout << "Software : set branch address SoftInfo"<SetBranchAddress("RunInfo", GetPointerTo("RunInfo")); cout << "Run : set branch address RunInfo"<SetBranchAddress("SoftInfo", GetPointerTo("SoftInfo")); // Emiliano + cout << "Software : set branch address SoftInfo"<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)); +}; + //-------------------------------------- // //