I have a very simple question with RDataFrames. I am trying to understand if I can extend a simple analysis framework to use RDataFrames, and one issue I’ve encountered is to access the number of elements in a vector branch. A variable like this might commonly be stored in the original TTree but it is also implicitly available if something like jet_pt or lep_pt is stored.
In the C++ ROOT interpreter, I can do something like this
rdf2 = rdf.Define("jet_n","jet_pt.size()")
but in pyROOT, this returns an error
Error in <TBranch::TLeaf>: Illegal data type for jet_n/jet_n/ which suggests that pyROOT is not able to assign a type to this variable? I could not find documentation on enforcing a type.
I have identified that I can do the following in pyROOT successfully:
rdf2 = rdf.Define("jet_n", "ROOT::VecOps::Sum(jet_pt > 0)")
but this feels excessive to filter and sum the passing jets (which will be all of them anyway). I was wondering if anyone has any input on this?
ROOT Version: 6.20/06
Built for linuxx8664gcc on Jun 10 2020, 06:10:57