有没有更好的方法来做这个逻辑?我想从仅在内部元素子集上可用的较低级别选择中传播选择
具体来说,我希望降低带相反电荷的 μ 电子对的事件水平。
req_mu = (events.Muon.counts >= 1)
req_ele = (events.Electron.counts >= 1)
req = req_ele & req_mu
def propagate_up(subset, selection):
'''
subset: bool array slice on upper level
'''
dummy = np.zeros_like(subset)
dummy[subset] = selection
return dummy
req_opposite_charge = propagate_up(req, events[req].Muon[:, 0].charge * events[req].Electron[:, 0].charge == -1)