Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 09:14:56

0001 import pathlib, acts, acts.examples
0002 import pytest
0003 
0004 from helpers import covfieEnabled
0005 
0006 
0007 @pytest.mark.skipif(not covfieEnabled, reason="Covfie plugin not available")
0008 def test_constant_field_conversion():
0009     from acts import covfie
0010 
0011     v = acts.Vector3(1, 2, 3)
0012     af = acts.ConstantBField(v)
0013     cf = covfie.makeCovfieField(af)
0014     view = covfie.toView(cf)
0015     points = [(0, 0, 1), (1, 1, 1), (1, 0, 2)]
0016     for x, y, z in points:
0017         assert view.at(x, y, z) == [1, 2, 3]
0018 
0019 
0020 @pytest.mark.skipif(not covfieEnabled, reason="Covfie plugin not available")
0021 def test_root_field_conversion():
0022     from acts import covfie
0023 
0024     current_file_path = pathlib.Path(__file__).resolve().parent
0025     p = (
0026         current_file_path.parent.parent.parent
0027         / "thirdparty"
0028         / "OpenDataDetector"
0029         / "data"
0030         / "odd-bfield.root"
0031     )
0032 
0033     af = acts.examples.MagneticFieldMapXyz(str(p))
0034     bc = acts.MagneticFieldContext()
0035     fc = af.makeCache(bc)
0036 
0037     cf = covfie.makeCovfieField(af)
0038     view = covfie.toView(cf)
0039     points = [
0040         (9300.0, 4700.0, 11200.0),
0041         (9999.0, 9999.0, 14300.0),
0042         (-2900.0, -4700.0, 5200.0),
0043         (-2900.0, -4800.0, 9100.0),
0044         (-2900.0, -5200.0, -8800.0),
0045         (-4400.0, 4800.0, -12700.0),
0046         (-6600.0, 1900.0, 7700.0),
0047         (-9700.0, -900.0, 12700.0),
0048         (-9999.0, -9999.0, -13000.0),
0049         (9999.0, 0, 14900.0),
0050     ]
0051 
0052     error_margin_half_width = 0.0001
0053     for x, y, z in points:
0054         val = af.getField(acts.Vector3(x, y, z), fc)
0055         Bx1, By1, Bz1 = val[0], val[1], val[2]
0056 
0057         Bx2, By2, Bz2 = tuple(view.at(x, y, z))
0058 
0059         assert (
0060             abs(Bx1 - Bx2) < error_margin_half_width
0061             and abs(By1 - By2) < error_margin_half_width
0062             and abs(Bz1 - Bz2) < error_margin_half_width
0063         )