Getting value from TBranch is extremely slow

The way you were doing it in GetValue.C is totally fine. RDataFrame can count entries but it does not offer a method to retrieve the number directly from TTree.

With RDF, you can use Take:

auto vectorPtr = df.Take<double>("columnName");

vectorPtr is a RResultPtr<std::vector<double>>, i.e. a pointer to your vector.

Cheers,
Enrico