21def extrapolateToPlane(fT, z) -> tuple[bool, Any, Any]:
22
23
24 rc, pos, mom = False, None, None
25 fst = fT.getFitStatus()
26 if fst.isFitConverged() and fst.getNdf() > minNdf:
27
28 if fT.getPoint(0).getFitterInfo() and fT.getPoint(1).getFitterInfo():
29 fstate0, fstate1 = fT.getFittedState(0), fT.getFittedState(1)
30 fPos0, fPos1 = fstate0.getPos(), fstate1.getPos()
31 if abs(z - fPos0.z()) < abs(z - fPos1.z()):
32 fstate = fstate0
33 else:
34 fstate = fstate1
35 zs = min(z, z_ecal)
36
37 rep = ROOT.genfit.RKTrackRep(13 if fstate.getCharge() < 0 else -13)
38 state = ROOT.genfit.StateOnPlane(rep)
39 rep.setPosMom(state, fstate.getPos(), fstate.getMom())
40 plane = ROOT.genfit.DetPlane(ROOT.TVector3(0.0, 0.0, zs), parallelToZ)
41 ROOT.SetOwnership(plane, False)
42 try:
43 rep.extrapolateToPlane(state, ROOT.genfit.SharedPlanePtr(plane))
44 except Exception:
45
46 return False, None, None
47 pos, mom = state.getPos(), state.getMom()
48 if z > z_ecal:
49
50 px, py, pz = mom.X(), mom.Y(), mom.Z()
51 if pz == 0:
52
53 return False, None, None
54 lam = (z - pos.Z()) / pz
55 pos = ROOT.TVector3(pos.X() + lam * px, pos.Y() + lam * py, z)
56 rc = True
57 return rc, pos, mom