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())) {
if (key->IsFolder()) {
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());
readdir(f);
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);
}
- Author
- Rene Brun
Definition in file readCode.C.