Revision 8c49506593ec98a48775b3771f3b537a1b974c45 authored by Timur Pocheptsov on 26 March 2014, 16:41:21 UTC, committed by Timur Pocheptsov on 26 March 2014, 16:41:21 UTC
1 parent 6fbc5a9
loopdir.C
void loopdir() {
// example of script to loop on all the objects of a ROOT file directory
// and print on Postscript all TH1 derived objects
// This script uses the file generated by tutorial hsimple.C
//Author: Rene Brun
TString dir = gSystem->UnixPathName(gInterpreter->GetCurrentMacroName());
dir.ReplaceAll("loopdir.C","../hsimple.C");
dir.ReplaceAll("/./","/");
if (!gInterpreter->IsLoaded(dir.Data())) gInterpreter->LoadMacro(dir.Data());
TFile *f1 = (TFile*)gROOT->ProcessLineFast("hsimple(1)");
TIter next(f1->GetListOfKeys());
TKey *key;
TCanvas c1;
c1.Print("hsimple.ps[");
while ((key = (TKey*)next())) {
TClass *cl = gROOT->GetClass(key->GetClassName());
if (!cl->InheritsFrom("TH1")) continue;
TH1 *h = (TH1*)key->ReadObj();
h->Draw();
c1.Print("hsimple.ps");
}
c1.Print("hsimple.ps]");
}
![swh spinner](/static/img/swh-spinner.gif)
Computing file changes ...