SetDirectory for multiple histograms


I need to open a ROOT file containing several histograms that I want to draw in a canvas. I get them with Get() and then I do a SetDirectory(0) (otherwise the histograms are not drawn).
First question: in order to have the histograms displayed is it mandatory to use SetDirectory(0) is there another way?
Second question: is there a way to avoid calling SetDirectory(0) individually for all histograms (the names do not follow a simple pattern such that I could use a regexp or similar)? I tried AddDirectory(kFALSE) but no success.

Many thanks in advance!


ROOT Version: 6.21/01
Platform: Ubuntu 18.04
Compiler: Not Provided


The problem that the histograms are not drawn is because they are deleted when you are closing the input ROOT file.
Using AddDirectory(kFALSE) before retrieving the histograms should work.
Otherwise a simple solution is is not to close/delete the input file or when you retrieve from the file you can copy the histogram (e.g. using Clone).

Best regards


Using AddDirectory(kFALSE) before retrieving the histograms worked.



This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.