Does RDataFrame support std::vector or only VecOps::RVec?


ROOT Version: v6.14/04
Platform: Ubuntu 18.04
Compiler: Not Provided


Hi all,

I want to do the define a new branch based on C++ function with RDataFrame in python using

df.Define('new_branch','my_func(input_vector_branch)')

Where my function my_func(vec_in) is defined as follow and input_vector_branch is the name of a vector branch of my dataset.

vector<int> my_func(const vector<float> &input){
 vector<float> output;

 // Do stuff
 // ...

 return output;
}

When I do this in ROOT v6.14/04, I get the following error message:

input_line_27:15:13: note: candidate function not viable: no known conversion from 'ROOT::VecOps::RVec<float>' to 'const vector<float>' for 1st
      argument
vector<int> JetIndex_RankedBtagWeight(const vector<float> &btagg_weight){

which I understand as "please use ROOT::VecOps::RVec<float> instead of std::vector".

My question: is there a way to use this workflow and std::vector in ROOT v6.14/04?

Thanks,
Romain

It supports std::vector. The problem is you’re giving Define a string expression, and when RDataFrame turns this into a lambda it reads input_vector_branch as an RVec. In this case, you could simply do df.Define('new_branch', my_func);.

Hi Romain,

for jitted strings, the collections are served as RVec instances.
One thing which may be done, is to have a template of my_func since the interface of RVec and std::vector is basically identical.

Cheers,
D

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.