Skip to content

RDataFrame Reads Garbage Data instead of File #19104

Open
@davidkowalk

Description

@davidkowalk

Check duplicate issues.

  • 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

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

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions