@@ -12,6 +12,9 @@ class FakeMeta:
1212 def to_cm (self , points , center = True ):
1313 return points + 1.0
1414
15+ def to_px (self , points ):
16+ return points - 1.0
17+
1518
1619def test_manager_parses_labels_and_explicit_names (monkeypatch , fake_geo ):
1720 monkeypatch .setattr (manager_mod .GeoManager , "get_instance" , lambda : fake_geo )
@@ -50,7 +53,7 @@ def test_manager_applies_modules_in_config_order(monkeypatch, fake_geo):
5053 values = np .array ([10.0 , 10.0 ])
5154 sources = np .array ([[0 , 0 ], [0 , 1 ]])
5255
53- corrected = manager (points , values , sources = sources )
56+ _ , corrected = manager (points , values , sources = sources )
5457
5558 assert np .allclose (corrected , [20.0 , 30.0 ])
5659
@@ -59,7 +62,7 @@ def test_manager_can_infer_tpc_indexes_without_sources(monkeypatch, fake_geo):
5962 monkeypatch .setattr (manager_mod .GeoManager , "get_instance" , lambda : fake_geo )
6063 manager = CalibrationManager (gain = {"gain" : [2.0 , 3.0 ]})
6164
62- corrected = manager (
65+ _ , corrected = manager (
6366 np .array ([[1.0 , 0.0 , 0.0 ], [8.0 , 0.0 , 0.0 ]]),
6467 np .array ([10.0 , 10.0 ]),
6568 )
@@ -71,7 +74,7 @@ def test_manager_applies_meta_module_translation_and_empty_tpc(monkeypatch, fake
7174 monkeypatch .setattr (manager_mod .GeoManager , "get_instance" , lambda : fake_geo )
7275 manager = CalibrationManager (gain = {"gain" : [2.0 , 3.0 ]})
7376
74- corrected = manager (
77+ _ , corrected = manager (
7578 np .array ([[1.0 , 0.0 , 0.0 ]]),
7679 np .array ([10.0 ]),
7780 sources = np .array ([[0 , 0 ]]),
@@ -86,7 +89,7 @@ def test_manager_dispatches_lifetime_and_unknown_modules(monkeypatch, fake_geo):
8689 monkeypatch .setattr (manager_mod .GeoManager , "get_instance" , lambda : fake_geo )
8790 manager = CalibrationManager (lifetime = {"lifetime" : 10.0 , "driftv" : 2.0 })
8891
89- corrected = manager (
92+ _ , corrected = manager (
9093 np .array ([[4.0 , 0.0 , 0.0 ]]),
9194 np .array ([1.0 ]),
9295 sources = np .array ([[0 , 0 ]]),
@@ -115,7 +118,7 @@ def test_manager_dispatches_recombination(monkeypatch, fake_geo):
115118 recombination = {"efield" : 0.5 },
116119 )
117120
118- corrected = manager (
121+ _ , corrected = manager (
119122 np .array ([[1.0 , 0.0 , 0.0 ]]),
120123 np .array ([1000.0 ]),
121124 sources = np .array ([[0 , 0 ]]),
@@ -131,7 +134,7 @@ def test_manager_dispatches_transparency(monkeypatch, fake_geo, transparency_db)
131134 transparency = {"transparency_db" : str (transparency_db ), "run_id" : 100 }
132135 )
133136
134- corrected = manager (
137+ _ , corrected = manager (
135138 np .array ([[0.0 , 1.25 , 1.25 ]]),
136139 np .array ([12.0 ]),
137140 sources = np .array ([[0 , 1 ]]),
@@ -151,10 +154,47 @@ def test_manager_dispatches_field_before_lifetime(monkeypatch, fake_geo):
151154 lifetime = {"lifetime" : 10.0 , "driftv" : 2.0 },
152155 )
153156
154- corrected = manager (
157+ _ , corrected = manager (
155158 np .array ([[1.0 , 0.0 , 0.0 ]]),
156159 np .array ([1.0 ]),
157160 sources = np .array ([[0 , 0 ]]),
158161 )
159162
160163 assert np .allclose (corrected , [np .exp (3.0 / 20.0 )])
164+
165+
166+ def test_manager_can_return_field_corrected_points (monkeypatch , fake_geo ):
167+ monkeypatch .setattr (manager_mod .GeoManager , "get_instance" , lambda : fake_geo )
168+ field_map = FieldMap (
169+ np .full ((1 , 1 , 1 , 3 ), [2.0 , 0.0 , 0.0 ], dtype = float ),
170+ [[0.0 , 10.0 ], [- 1.0 , 1.0 ], [- 1.0 , 1.0 ]],
171+ )
172+ manager = CalibrationManager (field = {"field_map" : field_map })
173+
174+ points , values = manager (
175+ np .array ([[1.0 , 0.0 , 0.0 ]]),
176+ np .array ([1.0 ]),
177+ sources = np .array ([[0 , 0 ]]),
178+ )
179+
180+ assert np .allclose (points , [[3.0 , 0.0 , 0.0 ]])
181+ assert np .allclose (values , [1.0 ])
182+
183+
184+ def test_manager_returns_field_corrected_points_in_input_units (monkeypatch , fake_geo ):
185+ monkeypatch .setattr (manager_mod .GeoManager , "get_instance" , lambda : fake_geo )
186+ field_map = FieldMap (
187+ np .full ((1 , 1 , 1 , 3 ), [2.0 , 0.0 , 0.0 ], dtype = float ),
188+ [[0.0 , 10.0 ], [- 1.0 , 1.0 ], [- 1.0 , 1.0 ]],
189+ )
190+ manager = CalibrationManager (field = {"field_map" : field_map })
191+
192+ points , values = manager (
193+ np .array ([[1.0 , - 0.5 , - 0.5 ]]),
194+ np .array ([1.0 ]),
195+ sources = np .array ([[0 , 0 ]]),
196+ meta = FakeMeta (),
197+ )
198+
199+ assert np .allclose (points , [[3.0 , - 0.5 , - 0.5 ]])
200+ assert np .allclose (values , [1.0 ])
0 commit comments