Reading a histogram

Hi Root Experts,

I am trying to read a histogram using root v6. I am having trouble just doing something basic, such as, reading a histogram:
TFile f = new TFile(“filename.root”);
f->ls();
f->cd(“Dir/”);
TH1F * h1 = (TH1F
)f->Get(“hist1”);
h1->Draw("");

I get an output of the following:

*** Break *** segmentation violation

===========================================================
There was a crash.
This is the entire stack trace of all threads:

and a bunch of numbers after.

any help is appreciated.

Thank you

Try: TH1F *h1; gDirectory->GetObject("hist1", h1);

This works!

Thank you very much.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.