File indexing completed on 2025-01-30 09:14:59
0001
0002
0003 from pathlib import Path
0004
0005 import acts
0006
0007 mm = acts.UnitConstants.mm
0008 degree = acts.UnitConstants.degree
0009
0010 root = acts.Blueprint(envelope=acts.ExtentEnvelope(r=[10 * mm, 10 * mm]))
0011
0012
0013 pixel = root.addCylinderContainer(direction=acts.AxisDirection.AxisZ, name="Pixel")
0014 print(repr(pixel))
0015
0016 trf = acts.Transform3.Identity() * acts.Translation3(acts.Vector3(0, 0, 0 * mm))
0017
0018
0019 if True:
0020 barrel = acts.CylinderContainerBlueprintNode(
0021 "PixelBarrel",
0022 acts.AxisDirection.AxisR,
0023 attachmentStrategy=acts.CylinderVolumeStack.AttachmentStrategy.Gap,
0024 resizeStrategy=acts.CylinderVolumeStack.ResizeStrategy.Gap,
0025 )
0026 pixel.addChild(barrel)
0027
0028 print("Barrel")
0029 r = 25 * mm
0030 for i in range(0, 4):
0031 r += 50 * mm
0032 bounds = acts.CylinderVolumeBounds(r, r + 20 * mm, 200 * mm)
0033 print(bounds)
0034 brlLayer = barrel.addStaticVolume(trf, bounds, name=f"PixelBarrelLayer{i}")
0035 assert brlLayer.name == f"PixelBarrelLayer{i}"
0036
0037
0038 if True:
0039
0040 with pixel.CylinderContainer("PixelPosEndcap", acts.AxisDirection.AxisZ) as ec:
0041 print("Positive Endcap")
0042
0043 ec.attachmentStrategy = acts.CylinderVolumeStack.AttachmentStrategy.Gap
0044 ec.resizeStrategy = acts.CylinderVolumeStack.ResizeStrategy.Gap
0045
0046 z = 200
0047 for i in range(0, 4):
0048 z += 200 * mm
0049 bounds = acts.CylinderVolumeBounds(100 * mm, 150 * mm, 50 * mm)
0050 print(bounds)
0051
0052 trf = acts.Transform3.Identity() * acts.Translation3(acts.Vector3(0, 0, z))
0053
0054 with ec.StaticVolume(trf, bounds, name=f"PixelPosEndcapDisk{i}") as disc:
0055 print("Add disk", i)
0056
0057 assert disc.name == f"PixelPosEndcapDisk{i}"
0058
0059
0060 if True:
0061 with pixel.Material() as mat:
0062 with mat.CylinderContainer(
0063 direction=acts.AxisDirection.AxisZ, name="PixelNegEndcap"
0064 ) as ec:
0065 ec.attachmentStrategy = acts.CylinderVolumeStack.AttachmentStrategy.Gap
0066
0067 print("Negative Endcap")
0068
0069 z = -200
0070 for i in range(0, 4):
0071 z -= 200 * mm
0072 bounds = acts.CylinderVolumeBounds(200 * mm, 300 * mm, 50 * mm)
0073 print(bounds)
0074
0075 trf = acts.Transform3.Identity() * acts.Translation3(
0076 acts.Vector3(0, 0, z)
0077 )
0078
0079 with ec.StaticVolume(
0080 trf, bounds, name=f"PixelNegEndcapDisk{i}"
0081 ) as disk:
0082 print("Add disk", i)
0083 assert disk.name == f"PixelNegEndcapDisk{i}"
0084
0085
0086 with open("blueprint.dot", "w") as fh:
0087 root.graphviz(fh)
0088
0089
0090 gctx = acts.GeometryContext()
0091 trackingGeometry = root.construct(
0092 options=acts.BlueprintNode.Options(), gctx=gctx, level=acts.logging.VERBOSE
0093 )
0094
0095 vis = acts.ObjVisualization3D()
0096 trackingGeometry.visualize(vis, gctx)
0097 with Path("blueprint.obj").open("w") as fh:
0098 vis.write(fh)
0099