File indexing completed on 2025-01-30 09:14:56
0001 import pytest
0002
0003 import acts
0004
0005 mm = acts.UnitConstants.mm
0006 m = acts.UnitConstants.m
0007 degree = acts.UnitConstants.degree
0008
0009 bv = acts.AxisDirection
0010
0011 gctx = acts.GeometryContext()
0012 logLevel = acts.logging.VERBOSE
0013
0014
0015 def test_zdirection_container_blueprint(tmp_path):
0016
0017 def write(root: acts.BlueprintNode, stage: int):
0018 gz = tmp_path / f"blueprint_{stage}.dot"
0019 print(gz)
0020 with gz.open("w") as fh:
0021 root.graphviz(fh)
0022
0023 base = acts.Transform3.Identity()
0024
0025 root = acts.Blueprint(envelope=acts.ExtentEnvelope(r=[10 * mm, 10 * mm]))
0026 assert root.depth == 0
0027
0028 barrel = root.addCylinderContainer("Barrel", direction=bv.AxisR)
0029
0030 assert barrel.depth == 1
0031
0032 r = 25 * mm
0033 for i in range(1, 3):
0034 r += 50 * mm
0035 bounds = acts.CylinderVolumeBounds(r, r + 20 * mm, 200 * mm)
0036 vol = barrel.addStaticVolume(base, bounds, name=f"Barrel_{i}")
0037 assert vol.depth == 2
0038
0039 write(barrel, 1)
0040
0041 root.clearChildren()
0042
0043 assert barrel.depth == 0
0044
0045 det = root.addCylinderContainer("Detector", direction=bv.AxisZ)
0046
0047 assert det.depth == 1
0048
0049 with det.CylinderContainer("nEC", direction=bv.AxisZ) as ec:
0050 assert ec.depth == 2
0051 z = -200
0052 for i in range(1, 3):
0053 z -= 200 * mm
0054 bounds = acts.CylinderVolumeBounds(100 * mm, 150 * mm, 50 * mm)
0055
0056 trf = base * acts.Translation3(acts.Vector3(0, 0, z))
0057
0058 vol = ec.addStaticVolume(trf, bounds, name=f"nEC_{i}")
0059 assert vol.depth == 3
0060
0061 write(ec, 2)
0062
0063 det.addChild(barrel)
0064 assert barrel.depth == 2
0065
0066 write(det, 3)
0067
0068 with det.CylinderContainer("pEC", direction=bv.AxisZ) as ec:
0069 assert ec.depth == 2
0070 z = 200
0071 for i in range(1, 3):
0072 z += 200 * mm
0073 bounds = acts.CylinderVolumeBounds(100 * mm, 150 * mm, 50 * mm)
0074
0075 trf = base * acts.Translation3(acts.Vector3(0, 0, z))
0076
0077 vol = ec.addStaticVolume(trf, bounds, name=f"pEC_{i}")
0078 assert vol.depth == 3
0079
0080 write(root, 4)