Hi Michael, It is difficult to give a diagnostic without having a simple piece of code to test. Remember that when calling TKey::ReadObj, you read the object in the current directory. Rene Brun On Mon, 19 May 2003, Michael Gold wrote: > Dear rooters: > > this is the continuation of a problem I previously > reported in attempting to collect a bunch of > directories from a number of files into > a single directory in an output file. > > The subroutine attached below manages to read the directories in > TDirectory *inDir ("db") and append them to outDir TDirectory ("db") > which exists in the output file (TFile *fout). > When I do fout->ls("-m"); > > I get the directories listed as follows: > > TFile* results/edil08.root > TDirectory* db data base stuff > OBJ: TTree STNTUPLE stn analysis ntuple : 0 at: 0xadb5878 > OBJ: TH1F Ncon conversion pair multiplicity : 0 at: 0xc136060 > ..... > TDirectory* db data base stuff > TDirectory* run_140157 run_140157 > TDirectory* run_140187 run_140187 > TDirectory* run_140217 run_140217 > > which is peculiar because the directory "db" is listed twice. > this may or may not be related to the problem, which is that > when I do fout->ls("-d") only the first listing of db appears, > (not the second that actually contains all the sub directories) > and the output file has an empty db directory. > > any advice as always is greatly appreciated. > > sincerely, > Michael Gold > > ----------------------- > ps: here is the subroutine: > > void readDb(string inFile, TFile *fout) > { > TDirectory* save_dir = gDirectory; > TDirectory *outDir = (TDirectory *) fout->GetKey("db")->ReadObj(); > TFile *input = new TFile(inFile.c_str()); > TDirectory *inDir = (TDirectory *) input->GetKey("db")->ReadObj(); > assert(inDir); > assert(outDir); > TIter next( inDir->GetListOfKeys()); > TKey *kdir; > while (( kdir = (TKey *)next())) { > if(kdir->ReadObj()->InheritsFrom("TDirectory")) { > TDirectory *subDir = (TDirectory *) kdir->ReadObj() ; > outDir->Append(subDir); > input->GetList()->Remove(subDir); //<======== > } > } > //outDir->ls(); > delete input; > save_dir->cd(); > } > >
This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:11 MET