In the following, I purposefully put a TFile
on the heap.
TFile * myFile = new TFile("myCoolFile.root");
and read a TTree
from the file
TTree * myTree = (TTree*) myFile->Get<TTree>("myCoolTree");
My Questions are:
- How do I de-allocate the resources? Should I close the file and delete the pointers?
myFile->Close();
delete myFile;
delete myTree;
- Is there any way I can avoid using raw pointers? I understand that I can put
TFile
on the stack, but is there a way I can retrieve a reference-like view of theTTree
viaGet
instead of a pointer?