There does not appear to be a way to sumEntries in a range directly using pyROOT. Calling
data.sumEntries('', 'somerange')
results in a complaint that the formula cannot compile:
Error in <RooFormula::Compile>: Empty String
[#0] ERROR:InputArguments -- RooFormula::RooFormula(select): compile error
[#0] ERROR:Eval -- RooFormula::eval(select): Formula doesn't compile:
[#0] ERROR:Eval -- RooFormula::eval(select): Formula doesn't compile:
ad infinitum.
But I also cannot just pass 0 as in C++ because it throws a TypeError:
data.sumEntries(0, 'somerange')
TypeError: none of the 2 overloaded methods succeeded. Full details:
double RooDataSet::sumEntries() =>
takes at most 0 arguments (2 given)
double RooDataSet::sumEntries(const char* cutSpec, const char* cutRange = 0) =>
could not convert argument 1 (expected string or Unicode object, int found)
I can manually construct the range as a cutSpec, but this is, for obvious reasons, not preferable. Any advice?
Ok, that will only work with the new cppyy. I can add a fix that it also handles an empty string gracefully. That can be released in the next version of ROOT 6.16 and ROOT 6.18.
You might be able to pass something that evaluates to a true value. Try “1” as selection formula.