Let’s say I have a ROOT file containing a tree of variables that have been selected for the purposes of creating a Z invariant mass plot (i.e. leptons of opposite sign charge etc.). The variables in the tree are el_pt, el_eta, el_phi, el_e and so on (for the electron case).
For each event, one could create a TLorentzVector for each electron, add them and then get the invariant mass using the M2 function of the resultant TLorentzVector. These invariant mass values could be appended to a list and then plotted in a histogram.
In PyROOT, this approach could be slow and memory intensive. So, is there a more efficient way to do something like this? It appears appealing to use the machinery behind the tree “project” functionality (root.cern.ch/root/html/TTree.html#TTree:Project), but it is not obvious to me how something like an invariant mass calculation could be specified for it. Do you have any suggestions for this or another approach?