TChain does not have
Close() method (so how do we handle this guy at the end of a macro ?).
What makes it different from
TFile ? any technical explaination for that ?
As you can see in this example tutorial, no manual deletion/closing is necessary when using
The resources are managed and closed automatically in the destructor of the
TChain, where the files are closed as well. By the way, the
TFile does the same, so if you’re correctly managing the TFile object lifetime, then you don’t even need to call
Close(). In other words, if you are not memory-leaking the TFile object, then
Close() is called in the constructor. Wrapping the pointer returned by
TFile::Open() in a smart pointer is a good way to achieve this, like in this RNTuple tutorial:
So no, there is no technical reason for that, more a historical one I guess. The
TChain class is newer than
TFile, and probably it was written in a time where people already understood that proper lifetime management plus deleting resources in the constructor was the way to go.