Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sanity check for Vary is too restrictive #17486

Closed
1 task
vepadulano opened this issue Jan 22, 2025 · 0 comments · Fixed by #17478
Closed
1 task

Sanity check for Vary is too restrictive #17486

vepadulano opened this issue Jan 22, 2025 · 0 comments · Fixed by #17478
Assignees

Comments

@vepadulano
Copy link
Member

Check duplicate issues.

  • Checked for duplicates

Description

One of the sanity checks done when calling the Vary operation is to make sure all columns to be varied are of the same type. This is done by string comparison, which is limiting because sometimes the same type might be hidden by a typedef. For a full description of the issue, see https://root-forum.cern.ch/t/inconsistent-behaviour-of-rdataframe-columntypes/62605

Reproducer

Reproducer from the forum issue

#include <ROOT/RDataFrame.hxx>
#include <ROOT/RVec.hxx>
#include <TFile.h>
#include <TTree.h>

int create_root_file()
{
        TFile* f = TFile::Open("tree.root", "RECREATE");
        TTree *t = new TTree("tree", "tree");
        Float_t v[3] = {0., 1., 2.};
        t->Branch("v", &v, "v[3]/F");
        t->Branch("w", &v, "w[3]/F");
        t->Fill();
        t->Write();
        f->Close();
        return 0;
}


int main()
{
        create_root_file();

        ROOT::RDataFrame df_start("tree", "tree.root");
        auto df = df_start.Filter("true");
        auto t1 = df.GetColumnType("v");
        df = df.Redefine("v", "v");
        auto t2 = df.GetColumnType("v");
        std::cout 
                << t1 << " from TFile\n"
                << t2 << "   from Redefine(...)\n"
                << typeid(float).name() << "\n"
                << typeid(Float_t).name() << "\n"
                << typeid(ROOT::VecOps::RVec<float>).name() << "\n"
                << typeid(ROOT::VecOps::RVec<Float_t>).name() << "\n"
                << ROOT::RDF::RDFInternal::TypeID2TypeName(typeid(ROOT::VecOps::RVec<float>)) << "\n"
                << ROOT::RDF::RDFInternal::TypeID2TypeName(typeid(ROOT::VecOps::RVec<Float_t>)) << "\n"
        ;
        // uncomment the line below to get the error
        // df = df.Vary({"v", "w"}, [] (const ROOT::RVecF& v, const ROOT::RVecF& w) { return ROOT::RVec<ROOT::RVec<ROOT::RVecF>>{{v * 0.9, v * 1.1}, {w * 0.9, w * 1.1}}; }, {"v", "w"}, {"down", "up"}, "variation");
        return 0;
}

ROOT version

Any

Installation method

Any

Operating system

Any

Additional context

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: No status
Development

Successfully merging a pull request may close this issue.

1 participant