def track_residuals(hits, tvtx, tdir, t0=1000.0, n=1.33): residuals = [] for t,q,(ploc, pdir) in hits: td = track_distance(tvtx, tdir, ploc) ray = [ploc[i] - (tvtx[i] + td*tdir[i]) for i in range(3)] light = math.sqrt(sum([ray[i]*ray[i] for i in range(3)])) res = t - (t0 + td/light_speed + light*n/light_speed) residuals.append(res) return residuals
def test_track_distance(): td = track_distance([0,0,0], # vertex [0,0,1], # track direction [1,0,1], # pmt "position" angle = 45.0/180*math.pi) assert abs(td) < 0.00001