def __init__(self):
     self.p4 = thep4
     self.px = px
     self.py = py
     self.pz = pz
     self.en = energy
     self.pt = np.hypot(px, py)
     self.phi = np.arctan2(py, px)
     self.eta = np.arctanh(pz / np.sqrt(px * px + py * py + pz * pz))
     self.mass = np.sqrt(
         np.abs(energy * energy - (px * px + py * py + pz * pz)))
     self.blah = energy * px
     self.count = counts
def _fast_eta(p4):
    """ quick eta calculation for caching """
    px = p4.x
    py = p4.y
    pz = p4.z
    pT = np.sqrt(px * px + py * py)
    return np.arcsinh(pz / pT)
def _fast_mass(p4):
    """ quick mass calculation for caching """
    px = p4.x
    py = p4.y
    pz = p4.z
    en = p4.t
    p3mag2 = (px * px + py * py + pz * pz)
    return np.sqrt(np.abs(en * en - p3mag2))
def dummy_four_momenta():
    np.random.seed(12345)
    nrows = 1000
    counts = np.minimum(np.random.exponential(0.5, size=nrows).astype(int), 20)

    px = np.random.normal(loc=20.0, scale=5.0, size=np.sum(counts))
    py = np.random.normal(loc=20.0, scale=5.0, size=np.sum(counts))
    pz = np.random.normal(loc=0, scale=55, size=np.sum(counts))
    m_pi = np.full_like(px, fill_value=0.135)
    energy = np.sqrt(px * px + py * py + pz * pz + m_pi * m_pi)
    return (counts, px, py, pz, energy)
def convert_histo_root_file(file):
    converted_file = {}
    fin = uproot.open(file.strip())
    for path, item in fin.iteritems(recursive=True):
        nicepath = killcycle(path)
        rootclass = item._classname
        if rootclass in histTypes:
            converted_file[(nicepath, 'dense_lookup')] = item.values, item.edges
            if hasattr(item,'variances'):
                converted_file[(nicepath+'_error'.encode(), 'dense_lookup')] = np.sqrt(item.variances), item.edges
        elif rootclass in graphTypes:
            # TODO: convert TGraph into interpolated lookup
            continue
        elif hasattr(item, '_fEX') and hasattr(item, '_fEY'):
            # TODO what is this?
            tempArrX = item._fEX
            tempArrY = item._fEY
            converted_file[(nicepath, 'dense_lookup')] = [tempArrX, tempArrY]

    return converted_file
Example #6
0
def calculateTopKFactor(top_pts, antitop_pts):
    w1 = np.exp(0.0615 - 0.0005 * top_pts)
    w2 = np.exp(0.0615 - 0.0005 * antitop_pts)

    return np.sqrt(w1 * w2).content