FairShip
Loading...
Searching...
No Matches
shipTrackAccess Namespace Reference

Classes

class  TrackInfo

Functions

bool uses_acts (tree)
 get_tracks (tree)
TrackInfo track_info (track, bool acts)

Detailed Description

Unified access to GenFit and ACTS fitted-track branches.

Reconstruction writes either GenFit tracks (branch ``FitTracks``, default)
or ACTS tracks (branch ``RecoTracks``, with ``--trackFitter acts``).
Analysis code can use these helpers to support both output formats without
caring which fitter produced the file.

Function Documentation

◆ get_tracks()

shipTrackAccess.get_tracks ( tree)
Return the fitted-track branch, whichever fitter produced it.

Definition at line 45 of file shipTrackAccess.py.

45def get_tracks(tree):
46 """Return the fitted-track branch, whichever fitter produced it."""
47 return tree.RecoTracks if uses_acts(tree) else tree.FitTracks
48
49

◆ track_info()

TrackInfo shipTrackAccess.track_info ( track,
bool acts )
Summarize a fitted track from either fitter into a TrackInfo.

Definition at line 50 of file shipTrackAccess.py.

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()
55 return TrackInfo(
56 converged=True, # only successful ACTS fits are persisted
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()
68 info = TrackInfo(
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

◆ uses_acts()

bool shipTrackAccess.uses_acts ( tree)
Return True if the tree holds ACTS tracks (RecoTracks branch).

Definition at line 40 of file shipTrackAccess.py.

40def uses_acts(tree) -> bool:
41 """Return True if the tree holds ACTS tracks (RecoTracks branch)."""
42 return bool(tree.GetBranch("RecoTracks"))
43
44