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

Classes

class  FakeTrack
class  FakeTracker

Functions

 make_hit (detector_id, station, view, layer, z, drift=0.5, track_id=0)
 test_candidate_hits_are_ordered_in_z_with_one_per_layer ()
 test_drift_distances_are_passed_unsigned ()
 test_too_few_hits_are_not_fitted ()
 test_found_tracks_map_back_to_hits ()
 test_vertices_are_fitted_for_opposite_charge_pairs ()

Variables

int UNKNOWN_STRAW = -1

Detailed Description

Hit bookkeeping of the ACTS straw reconstruction, with a stand-in tracker.

Function Documentation

◆ make_hit()

test_straw_reco.make_hit ( detector_id,
station,
view,
layer,
z,
drift = 0.5,
track_id = 0 )

Definition at line 12 of file test_straw_reco.py.

12def make_hit(detector_id, station, view, layer, z, drift=0.5, track_id=0):
13 return StrawHit(
14 detector_id=detector_id,
15 station=station,
16 view=view,
17 layer=layer,
18 track_id=track_id,
19 z=z,
20 drift=drift,
21 )
22
23

◆ test_candidate_hits_are_ordered_in_z_with_one_per_layer()

test_straw_reco.test_candidate_hits_are_ordered_in_z_with_one_per_layer ( )

Definition at line 89 of file test_straw_reco.py.

89def test_candidate_hits_are_ordered_in_z_with_one_per_layer():
90 # Hit 0 is an unknown straw, so measurement indices are hit indices - 1.
91 # The last hit shares a straw layer with hit 2 but sits at smaller z, so
92 # it is kept and hit 2 is not.
93 hits = [make_hit(UNKNOWN_STRAW, 1, 0, 0, z=0.0)]
94 hits += [make_hit(1000 + i, 1, i // 2, i % 2, z=10.0 * i) for i in range(MIN_HITS_PER_TRACK + 1)]
95 hits.append(make_hit(9999, 1, 0, 1, z=5.0))
96 tracker = FakeTracker()
97 tracks, vertices, hit_indices = runTracking(
98 tracker, [{"indices": list(reversed(range(len(hits))))}], hits, 0.012, fit_vertex=False
99 )
100
101 assert len(tracks) == 1
102 assert vertices == []
103 used = [m + 1 for m in tracker.candidates[0]]
104 assert used == sorted(used, key=lambda i: hits[i].z)
105 assert 0 not in used
106 assert len({hits[i].layer_key for i in used}) == len(used)
107 assert len(hits) - 1 in used and 2 not in used
108 # The hit indices of the track are those the tracker kept
109 assert hit_indices[0] == used[:-1]
110
111

◆ test_drift_distances_are_passed_unsigned()

test_straw_reco.test_drift_distances_are_passed_unsigned ( )

Definition at line 112 of file test_straw_reco.py.

112def test_drift_distances_are_passed_unsigned():
113 hits = [make_hit(1000 + i, 1, i // 2, i % 2, z=float(i), drift=0.1 * i) for i in range(MIN_HITS_PER_TRACK)]
114 tracker = FakeTracker()
115 runTracking(tracker, [{"indices": list(range(len(hits)))}], hits, 0.012, fit_vertex=False)
116 assert [m[1] for m in tracker.measurements] == [h.drift for h in hits]
117
118

◆ test_found_tracks_map_back_to_hits()

test_straw_reco.test_found_tracks_map_back_to_hits ( )

Definition at line 126 of file test_straw_reco.py.

126def test_found_tracks_map_back_to_hits():
127 # With no candidates, the tracker finds the tracks itself
128 hits = [make_hit(UNKNOWN_STRAW, 1, 0, 0, z=0.0)] + [make_hit(1000 + i, 1, 0, 0, z=float(i)) for i in range(4)]
129 tracker = FakeTracker(found=[[0, 2], [1, 3]])
130 tracks, _, hit_indices = runTracking(tracker, None, hits, 0.012, fit_vertex=False)
131 assert len(tracks) == 2
132 assert hit_indices == [[1, 3], [2, 4]]
133
134

◆ test_too_few_hits_are_not_fitted()

test_straw_reco.test_too_few_hits_are_not_fitted ( )

Definition at line 119 of file test_straw_reco.py.

119def test_too_few_hits_are_not_fitted():
120 hits = [make_hit(1000 + i, 1, 0, i, z=float(i)) for i in range(2)]
121 tracker = FakeTracker()
122 tracks, _, hit_indices = runTracking(tracker, [{"indices": [0, 1]}], hits, 0.012, fit_vertex=False)
123 assert tracks == [] and hit_indices == [] and tracker.candidates == []
124
125

◆ test_vertices_are_fitted_for_opposite_charge_pairs()

test_straw_reco.test_vertices_are_fitted_for_opposite_charge_pairs ( )

Definition at line 135 of file test_straw_reco.py.

135def test_vertices_are_fitted_for_opposite_charge_pairs():
136 hits = [make_hit(1000 + i, 1, 0, 0, z=float(i)) for i in range(3)]
137 tracker = FakeTracker(found=[[0], [1], [2]], charges=[1, -1, 1])
138 _, vertices, _ = runTracking(tracker, None, hits, 0.012, fit_vertex=True)
139 assert tracker.vertices == [[0, 1], [1, 2]]
140 assert len(vertices) == 2

Variable Documentation

◆ UNKNOWN_STRAW

int test_straw_reco.UNKNOWN_STRAW = -1

Definition at line 9 of file test_straw_reco.py.