loopdir.C

Go to the documentation of this file.
00001 void loopdir() {
00002    // example of script to loop on all the objects of a ROOT file directory
00003    // and print on Postscript all TH1 derived objects
00004    // This script uses the file generated by tutorial hsimple.C
00005    //Author: Rene Brun
00006    
00007    TString dir = gSystem->UnixPathName(gInterpreter->GetCurrentMacroName());
00008    dir.ReplaceAll("loopdir.C","../hsimple.C");
00009    dir.ReplaceAll("/./","/");
00010    if (!gInterpreter->IsLoaded(dir.Data())) gInterpreter->LoadMacro(dir.Data());
00011    TFile *f1 = (TFile*)gROOT->ProcessLineFast("hsimple(1)");
00012    TIter next(f1->GetListOfKeys());
00013    TKey *key;
00014    TCanvas c1;
00015    c1.Print("hsimple.ps[");
00016    while ((key = (TKey*)next())) {
00017       TClass *cl = gROOT->GetClass(key->GetClassName());
00018       if (!cl->InheritsFrom("TH1")) continue;
00019       TH1 *h = (TH1*)key->ReadObj();
00020       h->Draw();
00021       c1.Print("hsimple.ps");
00022    }
00023    c1.Print("hsimple.ps]");
00024 }
00025       

Generated on Tue Jul 5 15:44:49 2011 for ROOT_528-00b_version by  doxygen 1.5.1