Hello,
I would like to write a simple Kzero finder in RDataFrame. I have a vector of all tracks and I need to compute the invariant mass of all pairs.
Something like
for i in tracks:
for j in track:
mass=Mass(i,j)
push mass in vector of all Kzero candidates
I can not figure out how this can be efficiently done in RDataFrame.
Do you have an example ?
I saw a post where it was proposed to use the
Take
action and then do a nested for loop over these vectors.
How is this done ? Does anybody have an example ?
I am using the python setup.
Thank you for your help.
Regards,
Tancredi
Hi Tancredi,
if you want to perform an operation on a vector of tracks for each event, see #working with collections in the RDF users’ guide: you can inject your logic (expressed as a helper C++ function or a numba-compiled Python function) through a Define
. There are many examples of this in the tutorials, see e.g. df103_NanoAODHiggsAnalysis.py.
An example of numba-compiled RDF helper functions is ROOT: tutorials/pyroot/pyroot004_NumbaDeclare.py File Reference .
If you want to have all tracks from the whole dataset in a single vector, in Python I recommend using AsNumpy
and then flattening + possibly convert std::vectors to numpy arrays.
Cheers,
Enrico