22def extrapolateToPlane(fT, z):
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 NewPosition = ROOT.TVector3(0.0, 0.0, zs)
37 rep = ROOT.genfit.RKTrackRep(13 * cmp(fstate.getPDG(), 0))
38 state = ROOT.genfit.StateOnPlane(rep)
39 pos, mom = fstate.getPos(), fstate.getMom()
40 rep.setPosMom(state, pos, mom)
41 try:
42 rep.extrapolateToPlane(state, NewPosition, parallelToZ)
43 pos, mom = state.getPos(), state.getMom()
44 rc = True
45 except Exception:
46
47 pass
48 if not rc or z > z_ecal:
49
50 px, py, pz = mom.X(), mom.Y(), mom.Z()
51 lam = (z - pos.Z()) / pz
52 pos = ROOT.TVector3(pos.X() + lam * px, pos.Y() + lam * py, z)
53 return rc, pos, mom