What is the recommended way to retrieve the weighted number of entries in a TTree?
I could, for example, do
nEntEffective = sum(ent.SomeWeight for ent in t if ent.SomeBranch > SomeCutValue)
but I wondered if I had overlooked some utility function a la t.GetEntries('SomeBranch > SomeCutValue') that would take weights into account.
ROOT Version: 6.19/01
Platform: macOS
Compiler: Not Provided
Hi,
maybe
df.Filter("x > y").Sum("weight")
?
Thank you. From my cursory study, these methods appear comparably fast if one has to make the data frame (i.e., RDataFrame(t).Filter('SomeBranch > SomeCutValue').Sum('SomeWeight')), while the data frame method appears much faster if one has already created the filtered data frame (df.Sum('SomeWeight')).
See this thread, the event loop is much faster with RDF, but for small datasets you’ll spend most of the time setting up RDF.