I have been trying to learn RDataFrame using a simple test case with a tree of simple Event objects, each of which contains a vector of simple Hit objects.
Using the Tree::Draw interface, I can easily histogram and cut on hit members like so:
t->Draw("events.hits.val", "events.hits.id==5");
This works when the tree is saved at splitlevel=0 or 1 or 2.
Using RDataFrame, I can achieve the same thing like so:
auto df2 = df.Define("mask", "hits.id==5").Define("valAtID", "hits.val[mask]");
df2.Histo1D("valAtID")->Draw()
However, this only works when the tree is saved with splitlevel=2, where all members are visible in branches. For smaller splitlevels, an error is thrown:
input_line_66:2:55: error: no member named 'id' in 'ROOT::VecOps::RVec<Hit>'
auto func0(ROOT::VecOps::RVec<Hit>& var0){return var0.id==5
What would be the appropriate RDataFrame constructions to use to achieve the same thing I can do with TTree::Draw for my example tree in splitlevel 1 or 0?
sorry for the high latency, both Vincenzo and I have been off.
You can check which columns are available through RDF with df.GetColumnNames(), their type with df.GetColumnType(...) and go from there. It looks like the type of hits for smaller splitlevels is RVec<Hit>, which of course does not have a data member id. In that case you might have to use one of the RVec helper functions to perform the transformation you want, e.g. (not tested, but it should give you an idea)