Retrieve piped histogram from tree

Hi !

I am trying to retrieve a piped histogram from a tree in a macro. I do:


And then, I tried the various possiblities below:

TH2D* h1 = (TH2D*)gPad->GetPrimitive(“h1”);
TH2D* h1 = (TH2D*)gDirectory->Get(“h1”);
(and the same with TH2D -> TH2F because i am not sure of what
is created in this case).

But i didnt succeed to get a valid pointer h1.
Any hint ?

gDirectory->Get(“h1”) should work.
Did you close the file between the call to tree->Draw
and the call to gDirectory->Get

More details please