I have a situation where I would like to have objects placed on Canvas to be persistent even after closing the file. Is there a way of doing this using just pointer objects ?
I am trying to get the difference between copy and clone of TH1 class assuming copy is a persistent copy of the object while clone not. Can somebody explain what is the difference ?
Also I had issues with using the hold->Copy(hnew);
The error I get is this :
[color=#BF0000]/home/test.C:16:10: error: non-const lvalue reference to type ‘TObject’ cannot bind to a temporary of type ‘TH1D *’[/color]
Before closing the file:
your_histo_pointer->SetDirectory(0); // (0) … or … (gROOT)
Have one more question related to this.
Is the histogram that’s present inside the canvas, required to have the histogram object declared in the code i.e. is there a way to free up the histogram point declared in the code ?
[code]TFile *file = new TFile(“someFile.root”, “r”);
TCanvas *c = new TCanvas(“c”, “”, 900, 460);
TH1D h = (TH1D)file->Get(“histName”);
h->SetDirectory(0);
file->Close()
delete h; // Is this possible ?[/code]
i.e. TCanvas holds the object while the reference to the histogram is removed ?