Is there a simple way to transform the const array obtained by take() into an ordinary editable array?

Hello, everyone.

e.g.

auto eventID1 = d.Take<int>("eventID");

I want to transform eventID1 to a normal array so that I can make some changes to it later.
There are some clunky methods like:

vector<int>eventID1_;
int n=end(eventID1)-begin(eventID1);
for(int i=0;i<n;i++){
   eventID1_.push_back(eventID1.GetValue()[i]);
}

So I wonder if there is a simple way to transform the const array obtained by take() into an ordinary editable array?
Thanks!

ROOT Version: 6.24/02

Hi @CY_Han ,
RResultPtr::GetValue returns a const reference to the result, but e.g. operator* does not:

auto resptr = ROOT::RDataFrame(10).Take<ULong64_t>("rdfentry_");
std::vector<ULong64_t> &vec = *resptr;
vec[0] = 42;

See also ROOT: ROOT::RDF::RResultPtr< T > Class Template Reference

Cheers,
Enrico

1 Like

Cool.
Thanks! :grinning:

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