Problem opening a second root file within same root session via TBrowser

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:)

root [1] (TFile *) 0x3cf4450
(TTreeViewer *) 0x4161930
File name : file.root

(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.

I have tried to open and close several times the same root file from the TBrowser using ROOT 6.09/03 on Mac, and I do not have any problem.

Thanks, couet–that’s good to know.

Another clue, if anyone’s following this: my colleague had the same problem I did with root 6 (also on a linux machine, compiled from source).

Hi,

I just tried on Linux (CentOS 7) and have no problem opening a file several times (beside the error messages coming from the Tree Viewer):

[bellenot@bbcc7x64 rootdev]$ root -l
root [0] new TBrowser
(TBrowser *) 0x15284c0
root [1] (TFile *) 0x2cbfa80
(TTreeViewer *) 0x31334d0
File name : hsimple.root
input_line_81:2:15: error: redefinition of 'gTV'
 TTreeViewer *gTV = (TTreeViewer*)0x32740a0
              ^
input_line_71:2:15: note: previous definition is here
 TTreeViewer *gTV = (TTreeViewer*)0x31334d0
              ^
input_line_82:2:9: error: redefinition of 'tv__tree'
 TTree *tv__tree = 0;
        ^
input_line_73:2:9: note: previous definition is here
 TTree *tv__tree = 0;
        ^
input_line_83:2:9: error: redefinition of 'tv__tree_list'
 TList *tv__tree_list = new TList;
        ^
input_line_74:2:9: note: previous definition is here
 TList *tv__tree_list = new TList;
        ^
input_line_84:2:9: error: redefinition of 'tv__tree_file'
 TFile *tv__tree_file = 0;
        ^
input_line_75:2:9: note: previous definition is here
 TFile *tv__tree_file = 0;
        ^
File name : hsimple.root
[bellenot@bbcc7x64 rootdev]$

Cheers, Bertrand.

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).

Hi Pepe,

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).

Hi all,

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.

I have created https://sft.its.cern.ch/jira/browse/ROOT-8715 for the TTreeViewer issue.

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