Print all histograms in file

Hello Rooters,

Does anyone know of a script that prints all histograms in the current .root file to PostScript? This seems like it would be a fairly common task.

Or better yet, a class which does this but also allows user-control such as “I want 2 columns and 3 rows of histograms per PostScript page”?

Thanks,
Ryan

I have added a new tutorial loopdir.C showing how to:
-loop on all objects in one file
-print on postscript all objects deriving from TH1

The script is now in CVS and also shown below

void loopdir() {
   // example of script to loop on all the objects of a directory
   // and print on Postscript all TH1 derived objects
   // This script uses the file generated by tutorial hsimple.C
   
   TFile f("hsimple.root");
   TIter next(f.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]");
}

Rene

Rene,

That works perfectly. Many thanks,

Ryan