I am trying to use a python function as a way to cut on a pyROOT drawn histogram. The idea goes something like this:
def cutting_fun(dep,xm):
“some conditions”
tree.Draw(“energy”,“cutting_fun(dep,xm)”)
Is this possible with pyROOT?
Please read tips for efficient and successful posting and posting code
ROOT Version: Not Provided
Platform: Not Provided
Compiler: Not Provided
More information: I am able to get C++ code to work, so if all else fails I can just remake the python cut function as a C++ function.
Hello,
Since cutting_fun is function that only exists in Python, unfortunately you can’t call it directly from an expression of TTree::Draw.
You can write the function in C++ yourself, as you mentioned, or try with NumbaDeclare, e.g. see this tutorial:
In short, you decorate your Python function and, under the hood, a C++ wrapper for it is generated so you can call it as Numba::cutting_fun in your case.
This is only available since ROOT 6.22, though.