I’m having some issues when trying to Redefine()
a column in an RDataFrame.
At the moment, I have a dataframe with two columns, each a vector of floats of the same length:
RVec<float> jet_eta
RVec<float> jet_pt
I’d like to remove entries from those vectors where abs(jet_eta) < 2.5
. Based on a similar post “How to slim the branch array in RDataFrame” I figured I could do something like
RDataFrame df = RDataFrame("mytree", "myfile.root");
df.Define("mask", "abs(jet_eta) < 2.5")\
.Redefine("jet_pt", "jet_pt[mask]")\
.Redefine("jet_eta", "jet_eta[mask]");
Unfortunately, this results in a runtime error:
terminate called after throwing an instance of 'std::runtime_error'
what(): RDataFrame: type mismatch: column "jet_pt" is being used as vector<float> but the Define or Vary node advertises it as ROOT::VecOps::RVec<float>
I’ve also tried doing this with a lambda expression
auto mask_vector = [](const ROOT::RVecF &vector, const ROOT::RVecI &mask) {
return vector[mask];
};
RDataFrame df = RDataFrame("mytree", "myfile.root");
df.Define("mask", "abs(jet_eta) < 2.5")\
.Redefine("jet_pt", mask_vector, {"jet_pt", "mask"});
but this fails with the same runtime error as above.
Define()
-ing new columns works fine – am I stuck with that? Or is there another way to get Redefine()
to work in this scenario?
Thanks!
ROOT Version: v6.28.00
Platform: CentOS 7
Compiler: gcc12