Dear experts,
I am trying to find a way to calculate event weights as a function of some variables defined in the Python scope as well as values already existing in some branches (columns) of the RDF.
The event loop equivalent would look somewhat like this:
x = loadSF("0-100")
y = loadSF("100-200")
z = loadSF("200-Inf")
for entry in tree:
if entry.A < 100: weight = x
elif entry.A > 100 and entry.A < 200: weight = y
else: weight = z
where loadSF is some Python function involving reading external files.
I have some ideas about how to proceed from seeing the C++ example of lambda captuing:
RDataFrame d(100); // a RDF that will generate 100 entries (currently empty)
int x = -1;
auto d_with_columns = d.Define("x", [&x] { return ++x; })
.Define("xx", [&x] { return x*x; });
but I am unable to reproduce this code in Python.
Is it possible to appropriate lambda capturing in Python, or even better, achieve the reweighting goal with external values in a straightforward way?
Best regards,
Spandan
ROOT Version: 6.16
Platform: SL7
Compiler: Not Provided