Cloning TH3F

Dear root supporters,

Is it possible to read a TH3F histogram from file and close the file?
I try it with different methods (new, Copy, Clone) but I get “segmentation violation” in all cases when trying to access the histogram after file closure (see attached scripts).

Thanks in advance,
Dmitry.
test2.C (478 Bytes)
test1.C (166 Bytes)

in test2.C (at beginning) add the line

TH1::AddDirectory(kFALSE):For explanation, read the chapter “Object Ownership” in the Users Guide.

Rene

Now I see. Thanks a lot!
Dmitry.