gordonwatts / BDTTrainingAnalysisLanguage

Pull from ATLAS EXOT 15 Derivation, columnar data, and flat rootutples with RDF to scikitlearn in one nice fast swoop
0 stars 2 forks source link

Chained functions with the same parameter names seem to interfere #81

Open gordonwatts opened 5 years ago

gordonwatts commented 5 years ago

In the following code (found in the output_z_peak.py file), note the parameter names for the Where on the cut on electron and muon quality:

event_info = events \
    .Select(r'''lambda e: (
        e.EventInfo('EventInfo'),
        e.Jets('AntiKt4EMTopoJets'),
        e.TruthParticles('TruthParticles').Where(lambda tp1: abs(tp1.pdgId()) == 11 or abs(tp1.pdgId()) == 13),
        e.MissingET('MET_Core_AntiKt4EMTopo').First(),
        e.Electrons("Electrons").Where(lambda ele: ele.pt()/1000.0 > 10),
        e.Muons("Muons").Where(lambda mu: mu.pt()/1000.0 < 5000.0 and mu.pt()/1000.0 > 10.0),
        )
    ''')

Later on, when the columns are created:

# Electron info
tc.add_col('ele_pt', 'ji[4].Select(lambda e: e.pt()/1000.0)')
tc.add_col('ele_eta', 'ji[4].Select(lambda e: e.eta()/1000.0)')
tc.add_col('ele_phi', 'ji[4].Select(lambda e: e.phi()/1000.0)')

It would seem if the "ele" in the first block is replaced with "e", then the two things stomp on each other and we get bad code. Not obvious why this is happening, though it is totally clear it should not be!

Two solutions: