Reading TClonesArray branches via RDataFrame broken in 6.36.00

Describe the bug

Garbage data are read from TClonesArray branches when opening TTree via RDataFrame.

The issue seemingly appeared in 6.36.00 and was not present in 6.34.04

Expected behavior

Correct data are expected to be read.

To Reproduce

I’ve managed to reproduce the issue in ROOT interpreter

class Track : public TObject {
public:
    double Energy;
};


TTree tree("Events", "events");

TClonesArray arr("Track");

tree.Branch("Tracks.", &arr);

for (size_t i = 0; i < 5; ++i) {
    arr.ConstructedAt(i);

    dynamic_cast<Track*>(arr.At(i))->Energy = i;
}

tree.Fill();
tree.Scan("Tracks.Energy");
/*
***********************************
*    Row   * Instance * Tracks.En *
***********************************
*        0 *        0 *         0 *
*        0 *        1 *         1 *
*        0 *        2 *         2 *
*        0 *        3 *         3 *
*        0 *        4 *         4 *
***********************************
*/


ROOT::RDataFrame d(tree);
d.Display({"Tracks.Energy"})->Print();

// 6.36.00 garbage output (see setup 1)
/*
+-----+---------------+
| Row | Tracks.Energy | 
+-----+---------------+
| 0   | 0.000000      | 
|     | 0.000000      | 
|     | 0.000000      | 
|     | 1.000000      | 
|     | 0.000000      | 
+-----+---------------+
*/

// 6.34.04 correct output (see setup 2)
/*
+-----+---------------+
| Row | Tracks.Energy | 
+-----+---------------+
| 0   | 0.000000      | 
|     | 1.000000      | 
|     | 2.000000      | 
|     | 3.000000      | 
|     | 4.000000      | 
+-----+---------------+

*/

Setup 1 (via dnf)

ROOT v6.36.00
Built for linuxx8664gcc on Jun 07 2025, 00:00:00
From tags/6-36-00@6-36-00
With g++ (GCC) 11.5.0 20240719 (Red Hat 11.5.0-5)
Binary directory: /usr/bin

Setup 2 (built from source)

ROOT v6.34.04
Built for linuxx8664gcc on Feb 11 2025, 17:50:03
From tags/6-34-04@6-34-04
With c++ (GCC) 11.5.0 20240719 (Red Hat 11.5.0-2)
Binary directory: /opt/root-6.34.04-debug/bin

Additional context

Upon further research I’ve found possibly related issue.

However, the description says

When loading root files created by older versions RDataFrame reads arbitrary data instead of actual file.

while in my case even new files and in-memory trees are affected.

Looks like the same issue and a PR has been already proposed.
(The bug also affects in principle in-memory trees).

1 Like

Thanks for the reply. It seems indeed that I’ve submitted a duplicate bug report, my apologies.
Looking forward for the fix!

Thanks, No problem. The fix is now in master. And will appear in next 6.36 patch release