Howdy folks, I’ve been struggling with these for a while and figured it might be easier and useful here.
Imagine I have a file with events that contain two containers leptons and jets. there can be x
leptons and y
each container contains the inputs for a TLorentzVector Pt, Eta, Phi, M
accessed as:
for event in file.tree:
nleptons = 0
for lepton in lepton_collection:
if lepton.pt > 10:
nleptons += 1
for jet in jet_collection:
if jet.pt > 30
njets += 1
I can get the invariant mass of all leptons with the super useful invariantmass(lepton.Pt,lepton.Eta,lepton.Phi,lepton.M)
command. This is the functionality I see in the tutorials that id like to understand.
How do I define the pt of the TLorentzVector of the two highest pT leptons? eg in the crappy non-RDataFrame way, if they are already pre-sorted would look like:
l0 = TLorentzVector(0,0,0,0)
l0.SetPtEtaPhi(lepton[0].Pt,lepton[0].Eta,lepton[0].Phi,lepton[0].M)
l1 = TLorentzVector(0,0,0,0)
l1.SetPtEtaPhi(lepton[1].Pt,lepton[1].Eta,lepton[1].Phi,lepton[1].M)
return (l0+l1).Pt()
this question extends to moving between containers e.g. working out the angular distance between the highest pT lepton and the second highest pT jet but what about calculating the possible angles between a lepton and the jets in the event in order to select the smallest one? I guess this question also includes defining TLorentzVectors as objects in the Tree and being able to sort them… but you are the experts.
I think that if I can grasp this concept I would never use root without RDF but until then I end up searching the example directory daily then either writing it as a loop inside my definitions or or giving up and doing it the old fashioned way.