swh:1:snp:af87cd67498ef4fe47c76ed3e7caffe5b61facaf
Raw File
Tip revision: 6b8f54808eb13103e87cae19c642aec474270422 authored by Axel Naumann on 11 September 2019, 13:36:49 UTC
Update ROOT version files to v6.18/04.
Tip revision: 6b8f548
loopdir11.C
/// \file
/// \ingroup tutorial_io
/// \notebook -nodraw
/// 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
///
/// \macro_image
/// \macro_code
///
/// \author Rene Brun

void loopdir11() {
   TFile *f1 = TFile::Open("hsimple.root");
   TCanvas c1;
   c1.Print("hsimple.ps[");
   for(auto k : *f1->GetListOfKeys()) {
      TKey *key = static_cast<TKey*>(k);
      TClass *cl = gROOT->GetClass(key->GetClassName());
      if (!cl->InheritsFrom("TH1")) continue;
      TH1 *h = key->ReadObject<TH1>();
      h->Draw();
      c1.Print("hsimple.ps");
   }
   c1.Print("hsimple.ps]");
}
back to top