I am looping over a TTree that is read from a TFile. During the look there is a histogram I would like to use after the loop so I use TH1::Clone() to get a copy, however, after the loop ends the tree and file are closed and the clone appears to get delete-ed. How can I stop this from happening?
I’ve tried using gDirectory->AddDirectory(false) at the start of my program and also calling it with respect to the TFile from which the TTree is read. However it doesn’t keep the clone from being delete-ed.