Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
loopdir11.C File Reference

Detailed Description

View in nbviewer Open in SWAN 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

⦧U

void loopdir11() {
TFile *f1 = TFile::Open("hsimple.root");
c1.Print("hsimple.ps[");
for(auto k : *f1->GetListOfKeys()) {
TKey *key = static_cast<TKey*>(k);
if (!cl->InheritsFrom("TH1")) continue;
TH1 *h = key->ReadObject<TH1>();
h->Draw();
c1.Print("hsimple.ps");
}
c1.Print("hsimple.ps]");
}
#define h(i)
Definition RSha256.hxx:106
#define gROOT
Definition TROOT.h:406
The Canvas class.
Definition TCanvas.h:23
TClass instances represent classes, structs and namespaces in the ROOT type system.
Definition TClass.h:80
Bool_t InheritsFrom(const char *cl) const
Return kTRUE if this class inherits from a class with name "classname".
Definition TClass.cxx:4851
static TClass * GetClass(const char *name, Bool_t load=kTRUE, Bool_t silent=kFALSE)
Static method returning pointer to TClass of the specified class name.
Definition TClass.cxx:2957
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format.
Definition TFile.h:54
static TFile * Open(const char *name, Option_t *option="", const char *ftitle="", Int_t compress=ROOT::RCompressionSetting::EDefaults::kUseCompiledDefault, Int_t netopt=0)
Create / open a file.
Definition TFile.cxx:3997
TH1 is the base class of all histogram classes in ROOT.
Definition TH1.h:58
virtual void Draw(Option_t *option="")
Draw this histogram with options.
Definition TH1.cxx:3073
Book space in a file, create I/O buffers, to fill them, (un)compress them.
Definition TKey.h:28
T * ReadObject()
To read an object (non deriving from TObject) from the file.
Definition TKey.h:104
virtual const char * GetClassName() const
Definition TKey.h:76
void Print(const char *filename="") const override
Save Pad contents in a file in one of various formats.
Definition TPad.cxx:4692
return c1
Definition legend1.C:41
TF1 * f1
Definition legend1.C:11
Author
Rene Brun

Definition in file loopdir11.C.