Histogram gets deleted in named macro

Hi,

In a named macro I create a histogram and draw it (see sample code). However, when I open a file, the histogram is drawn but deleted immediately. I understand that in a named macro pointers to objects get deleted when the file is closed. I also remember from a previous discussion that there is an option to make the histogram persistent.

Unfortunately, I couldn’t dig out that information. How do I make the histogram persistent after the file is closed?

Thanks,
Jochen

void test(){ //TFile f("../output/test_JCCA.root"); TH1F *h = new TH1F("h","",100,0,100); h->Draw(); }

[quote]Unfortunately, I couldn’t dig out that information. How do I make the histogram persistent after the file is closed?[/quote]Use h->SetDirectory(0) (see the User’s Guide for more details).

Cheers,
Philippe.