Ako_b
June 23, 2025, 3:13pm
1
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.
I’m reading Hadron Data into an RDataFrame. I left the office last week for the holidays and came back 2 days ago. Neither my Code nor the Data nor the Root version has changed but I’m seeing unphysical results which my code did not produce before.
Our experiment measures the LorentzVector of Photons scattered from a target. I’m combining pairs of photons to reconstruct the mother particles mass. As a minimal example:
using namespace ROOT;
void check_photon_data() {
RDataFrame df("t", "da…
opened 06:07PM - 19 Jun 25 UTC
bug
### Check duplicate issues.
- [x] Checked for duplicates
### Description
This… bug report is the result of this forum thread:
https://root-forum.cern.ch/t/rdataframe-reading-garbage-data/63763
When loading root files created by older versions RDataFrame reads arbitrary data instead of actual file.
### Reproducer
The following Root File
```cpp
using namespace ROOT;
void check_photon_data() {
RDataFrame df("t", "data/merged_20250610.root");
auto calculate_photon_pair_mass = [](const RVec<TVector3> Ps, const RVec<double> Es) -> RVec<double> {
//Calculates the invariant mass of each photon pair in hit
//Later the hits with only etas can be counted.
RVec<double> masses;
for (size_t i = 0; i < Es.size(); ++i) {
for (size_t j = i + 1; j < Es.size(); ++j) {
TLorentzVector p4_1, p4_2;
p4_1.SetVect(Ps[i]);
p4_1.SetE(Es[i]);
p4_2.SetVect(Ps[j]);
p4_2.SetE(Es[j]);
masses.push_back((p4_1 + p4_2).M());
}
}
return masses;
};
auto df_out = df.Define("mass", calculate_photon_pair_mass, {"lP4BGONeutral.fP", "lP4BGONeutral.fE"})
.Define("p2",
[](const RVec<TVector3>& Ps){
RVec<double> p2;
for (TVector3 p:Ps) {
p2.push_back(p*p);
}
return p2;
},
{"lP4BGONeutral.fP"})
.Define("E2",
[](const RVec<double>& Es) {
RVec<double> E2;
for (double E:Es) {
E2.push_back(E*E);
}
return E2;
},
{"lP4BGONeutral.fE"})
.Define("nPhotonsP", [](const RVec<TVector3>& Ps){return Ps.size();}, {"lP4BGONeutral.fP"})
.Define("nPhotonsE", [](const RVec<double>& Es){return Es.size();}, {"lP4BGONeutral.fE"})
;
df_out.Display({"mass", "E2", "p2", "lP4Tagger.fE"}, 50) -> Print();
df.Histo1D("lP4BGONeutral.fE") -> DrawClone();
df_out.Histo1D("lP4BGONeutral.fE") -> DrawClone();
df_out.Histo1D({"E2", "E2", 100, 0., 200000.} , "E2") -> DrawClone();
}
```
### ROOT version
ROOT 6.34.08
Built for linuxx8664gcc on May 17 2025, 14:17:01
From tags/6-34-08@6-34-08
With c++ (GCC) 15.1.1 20250425
### Installation method
pacman
### Operating system
arch linux
### Additional context
_No response_
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.
ferhue
June 23, 2025, 6:23pm
2
Looks like the same issue and a PR has been already proposed.
(The bug also affects in principle in-memory trees).
1 Like
Ako_b
June 24, 2025, 2:54pm
3
Thanks for the reply. It seems indeed that I’ve submitted a duplicate bug report, my apologies.
Looking forward for the fix!
ferhue
June 24, 2025, 3:46pm
4
Thanks, No problem. The fix is now in master. And will appear in next 6.36 patch release