I have an analysis code that produces root files that get opened and explored via TBrowser. Typically, we’d open several root files in a given session. We also may regenerate one root file (via dedicated C++ code calling root libraries), close that root file, and then reopen it within the same session. This all works fine with root 5.34. With root 6, I am having trouble even looking at a second root file within the session. To give you an example of this, I open file.root via the TBrowser, close it via the TBrowser, and then try to reopen it (again using the TBrowser). I get this:
(Here’s where I initially open the file via TBrowser:)
(I then close the file via TBrowser and try to re-open it:)
root [2] input_line_67:2:9: error: redefinition of 'ftmp’
TFile *ftmp = new TFile(“file.root”)
^
input_line_40:2:9: note: previous definition is here
TFile *ftmp = new TFile(“file.root”)
The same thing happens if I try to open a second root file with a different name. I would guess this is an issue with how the TBrowser is managing the files I’m opening and closing, but since I haven’t found any other complaints about this, I’m wondering if this is an installation issue on my end? I’m using the ubuntu16-x86_640gcc5.4 binary, which seems to behave well in every other respect.
Yes, I could get around this by scripting what I’m doing, but that’s not practical for our analysis. Thanks for the help.
What do you mean by “close the file via TBrowser”?
And where does the magic “File name : file.root” line come from (I do not get it when I “open” a file in TBrowser).
Apologies; I skipped a few steps in my ordering. The file contains a root tree. You get the magic “File name : file.root” when you right click on the tree and select “start viewer”. And you close the file by right clicking on the file name and selecting “close”. At least, this is how it used to work; the same options are still there in root 6 but seem to work a bit differently (or not work, as it were).
Thanks for giving this a try. Maybe using the TBrowser in root6 is simply problematic; perhaps the more rigorous C++ requirements imposed in root6 are the issue. I’m not sure why different installations behave differently. I have found a workaround, so I’ll post instructions here in case anyone else is in the same situation.
Instead of double clicking on a file in the TBrowser to open it, go to File > Open and select your file. Then, if you click on the ROOT Files folder in TBrowser, you’ll see the file there. You can open multiple files if you like, and access saved histograms in these files. If you want to use TreeViewer on any given file (or plot data via the command line), you can right click and select StartViewer. Once TreeViewer is open, use File > Open Tree File to switch between different trees in different files (the files containing the trees you want to view don’t need to be open already. I’m unsure of what happens if you have two trees in a given file).
You will get a slew of input_line errors (kind of like what Bertrand posted above) but you can still access and plot your data.