I think this question was already answered here: Empty canvas, but I am curious as to what is happening under the hood.
When creating a ROOT macro which opens a TFile on the stack, ROOT is unable to draw a histogram:
void foo(void)
{
TFile f("some_file.root");
TH1D *h = new TH1D("h","blah",100,0,100);
h->Fill(1.0);
h->Draw();
}
produces an empty canvas whereas
void foo(void)
{
TFile *f = new TFile("some_file.root");
TH1D *h = new TH1D("h","blah",100,0,100);
h->Fill(1.0);
h->Draw();
}
works.
Is the TH1D somehow being associated with the TFile and then being deleted when it goes out of scope?
Thanks,
Tony