-
Notifications
You must be signed in to change notification settings - Fork 1.5k
TChain doesn't recognise ROOT::VecOps::RVec<double> as a column type #10225
Copy link
Copy link
Closed
Description
- Checked for duplicates
Describe the bug
TChain doesn't recognise ROOT::VecOps::RVec as a column type. "Error in TBranch::TLeaf: Illegal data type for ..."
Expected behavior
I would expect TChain to recognize ROOT::VecOps::RVec.
To Reproduce
bool flag = false;
struct vecMaker
{
std::vector<Double_t> operator()()
{
std::vector<Double_t> myVec{0,1,2,3,4,5};
return myVec;
}
};
ROOT::RDF::RNode ApplyDefines(ROOT::RDF::RNode df)
{
if (flag)
{
return df.Define("y", [](){ return gRandom->Rndm(); });
}
flag = true;
return ApplyDefines(df.Define("RVecColumn", vecMaker()));
}
void clipboard()
{
ROOT::EnableImplicitMT();
//first part of the
auto unifGen = [](double) { return gRandom->Uniform(-1.0, 1.0); };
auto vGen = [&](int len)
{
ROOT::VecOps::RVec<Double_t> v(len);
std::transform(v.begin(), v.end(), v.begin(), unifGen);
return v;
};
ROOT::RDataFrame d(1024);
auto outDF = d.Define("len", []() { return (int)gRandom->Uniform(0, 16); })
.Define("x", vGen, {"len"});
//ApplyDefines forces RDataFrame to save a column as a ROOT::VecOps::RVec<double>
auto myNewDF = ApplyDefines(outDF);
myNewDF.Snapshot("myDF", "mydf.root");
TChain dEChain("myDF");
dEChain.Add("mydf.root");
ROOT::RDataFrame dEDF(dEChain);
dEDF.Snapshot("analyzed", "newdf.root");
}
Setup
- ROOT version: 6.26/00
- Operating system: Ubuntu 20.04
- How you obtained ROOT, such as
dnf install/ binary download / you built it yourself: built from source
Additional context
In the reproducer code, I forced RDataFrame to save a column as a "ROOT::VecOps::RVec". This is a solution I am actually using in my code: https://root-forum.cern.ch/t/passing-arguments-to-function-called-by-define-in-rdataframe/42208/3
Reactions are currently unavailable