RDataFrame::Foreach with array branch


_ROOT Version:6.15


Hi all;

if aTree with Branch array.
TTree::Branch(“a”, “&a”, “a[30]/D”);

RDataFrame aData("…","…");
aData.ForEach([](double * a){cout<<a<<endl;}, “a”)

error
Error in TTreeReaderValueBase::GetBranchDataType(): Must use TTreeReaderArray to read branch fptcl_r: it contains an array or a collection.
Error in TTreeReaderValueBase::CreateProxy(): The template argument type T of double* accessing branch fptcl_r (which contains data of type (null)) is not known to ROOT. You will need to create a dictionary for it.

how should I do?

using RVec solve this problem

1 Like

Yep, that’s it, you have to use RVec to read arrays from RDataFrame.

Cheers,
Enrico

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