50def track_info(track, acts: bool) -> TrackInfo:
51 """Summarize a fitted track from either fitter into a TrackInfo."""
52 if acts:
53 mom = ROOT.TVector3(track.px(), track.py(), track.pz())
54 cov = track.GetCovarianceElements()
56 converged=True,
57 ndf=track.nDoF(),
58 chi2=track.chi2(),
59 n_points=track.nMeasurements(),
60 mom=mom,
61 dir=mom.Unit(),
62 pos=ROOT.TVector3(track.x(), track.y(), track.z()),
63 sigma_px=math.sqrt(cov[15]),
64 sigma_py=math.sqrt(cov[18]),
65 sigma_pz=math.sqrt(cov[20]),
66 )
67 fit_status = track.getFitStatus()
69 converged=fit_status.isFitConverged(),
70 ndf=fit_status.getNdf(),
71 chi2=fit_status.getChi2(),
72 n_points=track.getNumPoints(),
73 )
74 try:
75 fitted_state = track.getFittedState()
76 except Exception:
77 return info
78 cov = fitted_state.get6DCov()
79 info.mom = ROOT.TVector3(fitted_state.getMom())
80 info.dir = ROOT.TVector3(fitted_state.getDir())
81 info.pos = ROOT.TVector3(fitted_state.getPos())
82 info.sigma_px = math.sqrt(cov[3][3])
83 info.sigma_py = math.sqrt(cov[4][4])
84 info.sigma_pz = math.sqrt(cov[5][5])
85 return info