Drawing of projections


I guess I am missing something, but I cannot draw a projection from a TH2F
using Draw, instead I need to use DrawCopy and then it works, is this expected
or am I doing something wrong?

I attach a root file and the macro projection.C to reproduce the problem.

Thanks in advance,
test1.root (5.39 KB)
projection.C (514 Bytes)

simply replace

TFile file("test1.root"); by

TFile *file= new TFile("test1.root");
otherwise your objects are destroyed when the TFile object goes out of scope at the end of the function.
For more details read chapter about Object Ownership in the Users Guide


Thanks for your answer, this solves the problem.

Best regards,