Example of script showing how to navigate in a ROOT file with sub-directories and read the objects in each sub-directory.
This example uses the file produced by the tutorial importCode.C
ndirs++;
while ((key = (
TKey*)next())) {
readdir(subdir);
continue;
}
nfiles++;
if (strstr(key->
GetName(),
".h")) nh++;
if (strstr(key->
GetName(),
".c")) nc++;
if (strstr(key->
GetName(),
".C")) nC++;
if (strstr(key->
GetName(),
".py")) npy++;
delete macro;
}
}
void readCode() {
printf("File code.root does not exist. Run tutorial importCode.C first\n");
return;
}
printf("Reading file ==> code.root\n");
printf(
"File size in bytes = %lld\n",
f->GetEND());
printf(
"File compression factor = %g\n",
f->GetCompressionFactor());
printf("Number of sub-dirs = %d\n",ndirs);
printf("Number of macro files = %d\n",nfiles);
printf("Number of lines in mac = %d\n",nlines);
printf("Number of cxx,c,cc files = %d\n",nc);
printf("Number of C files = %d\n",nC);
printf("Number of Python files = %d\n",npy);
}
virtual Int_t GetEntries() const
Describe directory structure in memory.
virtual Bool_t cd(const char *path=0)
Change current directory to "this" directory.
virtual TList * GetListOfKeys() const
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format.
Book space in a file, create I/O buffers, to fill them, (un)compress them.
Bool_t IsFolder() const
Check if object referenced by the key is a folder.
virtual TObject * ReadObj()
To read a TObject* from the file.
Class supporting a collection of lines with C++ code.
TList * GetListOfLines() const
virtual const char * GetName() const
Returns name of object.
- Author
- Rene Brun
Definition in file readCode.C.