Perhaps whilst we wait for @pcanal to get back on the shared library bit I can ask one of my others.
My idea for the classes was to try to make the programming logic simpler for me. To check that my logic is working correctly (in an event I want to loop over each jet and then each truth_jet to get the one with the smallest deltaR) I’d like to create a small data frame with my own events. I have the following test script in python:
### Helper functions and classes
class jet:
def __init__(self,pt,eta,phi):
self.pt = pt
self.eta = eta
self.phi = phi
def set_match(self, match):
self.matched = match
def get_dr(self, seed):
self.dr = dr(seed,self)
### (I know this isn't how dR works)
def dr(jet1,jet2):
dphi = jet1.phi-jet2.phi
deta = jet1.eta-jet2.eta
return abs(dphi+deta)
### one event
reco_jets = [jet(1,1,1),jet(2,2,1)]
truth_jets = [jet(1,3,1),jet(2,1,1),jet(3,2,1)]
event1 = {'reco_jets':reco_jets,'truth_jets':truth_jets}
### analysis logic
#### for each jet
for j in event1['reco_jets']:
#### find distances of this jet to all truth jets
for k in event1['truth_jets']:
k.get_dr(j)
#### sort truth jets based on this value
sorted_truth = sorted(event1['truth_jets'], key=lambda x: x.dr)
#### if value is below a threshold return it
if sorted_truth[0].dr < 2:
j.set_match(sorted_truth[0])
### test logic worked
for j in event1['reco_jets']:
print(j.matched.pt)
so I’d like to first know how to create a test data frame eg df = ROOT.RDataFrame([event1])
such that I can then work out how to create a vector of vectors needed to recreate the logic represented above.
(something along the lines of)
df0 = ROOT.RDataFrame(event1)
df = df.Define('drs',DeltaR(reco_eta,reco_phi,truth_eta,truth_phi))
df = df.Define('matched_truth','ArgSort(drs)')
df = df.Filter(drs<2)
df = df.Define('lead_matched','truth_pt[Take(matched_truth,1)]')
h = df.Histo1D('lead_matched')
…or whatever…
in any case my question is about building a simple data frame in order to test this logic and hopefully that gives me some insight into creating and sorting the members within.