Hi all,
I am currently trying to run code, which can be found in
and I ran into a problem where I don’t know how to proceed anymore. In the past, this code has been running without problems.
The CMSSW version is 11_3_2, which apparently has ROOT 6.22/09 running.
Let me first describe what the problem is and then go through the debugging steps I did. In L344-346, TTrees are read from a File and saved into pointers. These TTrees do exist and contain what is expected. However, when trying access branches in L408, these branches do not exist anymore.
Now I tried to find out what happened here and found out that the branches do not exist anymore because the Objects that the pointers point at are not the same anymore. These TTrees get overwritten in L371-374, when new TTrees are allocated to new points. Before this, TTrees are accessible and contain what is expected.
To be clear, this means that the pointer sectorNameTree, which is initialized in L374, points to the same address as the pointer baselineTreeX, which was initialized in L344. For some reason, ROOT or C++ thought that this place in memory was free and put a new TTree there, deleting the old content.
But why do these objects get overwritten? I was not sure, but I suspected it might have something to do with directories. So I checked what is in the current directory by doing gDirectory->GetList() at various places in the code. I found out that in fact, the TTrees vanish from the current directory once a new file is opened in L357. To me, this is unexpected, because usually, if one opens a new file and thus a new directory, all objects will be carried over.
So my next idea was to prevent the objects from getting overwritten. I tried this in two ways: One was using SetDirectory(nullptr) on the TTrees. This does not change anything. Another option was to add the TTrees to the directory again after opening the file (SetDirectory(gDirectory). Adding them succeeds in making them appear in gDirectory->GetList(), but does not prevent them from being overwritten anyway.
I am really confused by this behavior and don’t know how to prevent it. Is this intended behavior? Was anything about directories changed in recent versions of ROOT?
Cheers,
Marius