Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-27 07:24:10

0001 # This file is part of the ACTS project.
0002 #
0003 # Copyright (C) 2016 CERN for the benefit of the ACTS project
0004 #
0005 # This Source Code Form is subject to the terms of the Mozilla Public
0006 # License, v. 2.0. If a copy of the MPL was not distributed with this
0007 # file, You can obtain one at https://mozilla.org/MPL/2.0/.
0008 
0009 # Project includes
0010 from .type_helpers import cpp_class
0011 
0012 # python includes
0013 from enum import Enum
0014 
0015 """ Fundamental types """
0016 
0017 
0018 class Type(Enum):
0019     SINGLE = "float"
0020     DOUBLE = "double"
0021     UINT_8 = "std::uint8_t"
0022     UINT_16 = "std::uint16_t"
0023     UINT_32 = "std::uint32_t"
0024     UINT_64 = "std::uint64_t"
0025     UINT_128 = "std::uint128_t"
0026     UINT_LEAST_8 = "std::uint_least8_t"
0027     UINT_LEAST_16 = "std::uint_least16_t"
0028     UINT_LEAST_32 = "std::uint_least32_t"
0029     UINT_LEAST_64 = "std::uint_least64_t"
0030     UINT_LEAST_128 = "std::uint_least128_t"
0031 
0032     def __str__(self) -> str:
0033         return self.value
0034 
0035 
0036 """ Available linear algebra bachends """
0037 
0038 
0039 class Algebra(Enum):
0040     ANY = "concepts::algebra algebra_t"
0041     ARRAY = "detray::array"
0042     EIGEN = "detray::eigen"
0043     FASTOR = "detray::fastor"
0044     SMATRIX = "detray::smatrix"
0045     VC_AOS = "detray::vc_aos"
0046     VC_SOA = "detray::vc_soa"
0047 
0048     def __str__(self) -> str:
0049         return self.value
0050 
0051 
0052 """ Available coordinate frame types """
0053 
0054 
0055 class Frame:
0056     # 2D Cartesian frame (x, y)
0057     CARTESIAN2D = cpp_class(specifier="detray::cartesian2D")
0058     # 3D Cartesian frame (x, y, z)
0059     CARTESIAN3D = cpp_class(specifier="detray::cartesian3D")
0060     # 2D concentric cylindrical frame (phi, z), no transformation
0061     CONCENTRIC_CYLINDRICAL2D = cpp_class(specifier="detray::concentric_cylindrical2D")
0062     # 2D cylindrical frame (phi, z), arbitrary placement
0063     CYLINDRICAL2D = cpp_class(specifier="detray::cylindrical2D")
0064     # 3D cylindrical frame (r, phi, z), arbitrary placement
0065     CYLINDRICAL3D = cpp_class(specifier="detray::cylindrical3D")
0066     # Linear frame (+-r, z)
0067     LINEAR2D = cpp_class(specifier="detray::line2D")
0068     # Polar frame (r, phi)
0069     POLAR2D = cpp_class(specifier="detray::polar2D")
0070 
0071 
0072 """ Available geometric shape types """
0073 
0074 
0075 class Shape:
0076     # ITk stereo annulus (r, phi)
0077     ANNULUS = cpp_class(specifier="detray::annulus2D")
0078     # 2D cylinder, at the origin, no rotation, single inters. sol. (r*phi, z)
0079     CONCENTRIC_CYLINDER = cpp_class(specifier="detray::concentric_cylinder2D")
0080     # 3D cubiod (x, y, z)
0081     CUBOID = cpp_class(specifier="detray::cuboid3D")
0082     # 2D cylinder (r*phi, z)
0083     CYLINDER2D = cpp_class(specifier="detray::cylinder2D")
0084     # 3D cylinder (r, phi, z)
0085     CYLINDER3D = cpp_class(specifier="detray::cylinder3D")
0086     # line, square cross sec, (+-r, z)
0087     DRIFT_CELL = cpp_class(specifier="detray::line_square")
0088     # line, circular cross sec, (+-r, z)
0089     STRAW_TUBE = cpp_class(specifier="detray::line_circular")
0090     # 2D rectangle (x, y)
0091     RECTANGLE = cpp_class(specifier="detray::rectangle2D")
0092     # 2D ring / disc (r, phi)
0093     RING = cpp_class(specifier="detray::ring2D")
0094     # 2D trapezoid (x, y)
0095     TRAPEZOID = cpp_class(specifier="detray::trapezoid2D")
0096     # Mask of any shape (to be added as 'param'), always 'inside'= true
0097     UNBOUNDED = cpp_class(specifier="detray::unbounded")
0098     # No shape
0099     UNMASKED = cpp_class(specifier="detray::unmasked")
0100 
0101 
0102 """ Grid bin types """
0103 
0104 
0105 class GridBin:
0106     # Single-entry bins
0107     SINGLE = cpp_class(specifier="detray::bins::single")
0108     # Satically sized bins: 9 (default)
0109     STATIC = cpp_class(specifier="detray::bins::static_array", param={"capacity": 9})
0110     # Dynamically sized bins
0111     DYNAMIC = cpp_class(specifier="detray::bins::dynamic_array")
0112 
0113 
0114 """ Grid serializer types """
0115 
0116 
0117 class GridSerializer:
0118     # Single-entry bins
0119     SIMPLE = cpp_class(specifier="detray::simple_serializer")
0120 
0121 
0122 MATERIAL_MAP_SPECIFIER = "detray::material_map"
0123 
0124 """ Available material types """
0125 
0126 
0127 class Material:
0128     # Slab of material of given thickness
0129     SLAB = cpp_class(specifier="detray::material_slab")
0130     # Material with round cross sec, of given r
0131     ROD = cpp_class(specifier="detray::material_rod")
0132     # Raw material type, used e.g. for homogeneous volume material
0133     RAW = cpp_class(specifier="detray::material")
0134     # Surface material map, annulus shape 2D
0135     ANNULUS_MAP2D = cpp_class(
0136         specifier=MATERIAL_MAP_SPECIFIER,
0137         param={"shape": Shape.ANNULUS, "frame": Frame.POLAR2D},
0138     )
0139     # Surface material map, concentric cyl.
0140     CONCENTIRC_CYLINDER_MAP2D = cpp_class(
0141         specifier=MATERIAL_MAP_SPECIFIER,
0142         param={
0143             "shape": Shape.CONCENTRIC_CYLINDER,
0144             "frame": Frame.CONCENTRIC_CYLINDRICAL2D,
0145         },
0146     )
0147     # Surface material map, cylindrical 2D
0148     CYLINDER_MAP2D = cpp_class(
0149         specifier=MATERIAL_MAP_SPECIFIER,
0150         param={"shape": Shape.CYLINDER2D, "frame": Frame.CYLINDRICAL2D},
0151     )
0152     # Volume material map, cylindrical 3D
0153     CYLINDER_MAP3D = cpp_class(
0154         specifier=MATERIAL_MAP_SPECIFIER,
0155         param={"shape": Shape.CYLINDER3D, "frame": Frame.CYLINDRICAL3D},
0156     )
0157     # Volume material map, cuboid 3D
0158     CUBOID_MAP3D = cpp_class(
0159         specifier=MATERIAL_MAP_SPECIFIER,
0160         param={"shape": Shape.CUBOID, "frame": Frame.CARTESIAN3D},
0161     )
0162     # Surface material map, rectangular 2D
0163     RECTANGLE_MAP2D = cpp_class(
0164         specifier=MATERIAL_MAP_SPECIFIER,
0165         param={"shape": Shape.RECTANGLE, "frame": Frame.CARTESIAN2D},
0166     )
0167     # Surface material map, disc 2D
0168     DISC_MAP2D = cpp_class(
0169         specifier=MATERIAL_MAP_SPECIFIER,
0170         param={"shape": Shape.RING, "frame": Frame.POLAR2D},
0171     )
0172     # Surface material map, trapezoidal 2D
0173     TRAPEZOID_MAP2D = cpp_class(
0174         specifier=MATERIAL_MAP_SPECIFIER,
0175         param={"shape": Shape.TRAPEZOID, "frame": Frame.CARTESIAN2D},
0176     )
0177 
0178 
0179 SPATIAL_GRID_SPECIFIER = "detray::spatial_grid"
0180 
0181 """ Available surface/volume acceleration structure types """
0182 
0183 
0184 class Accelerator:
0185     # Test all registered surfaces
0186     BRUTE_FORCE = cpp_class(specifier="detray::brute_force")
0187     # Surface grid, cylindrical 2D (barrel)
0188     CONCENTRIC_CYLINDER_GRID2D = cpp_class(
0189         specifier=SPATIAL_GRID_SPECIFIER,
0190         param={
0191             "shape": Shape.CONCENTRIC_CYLINDER,
0192             "frame": Frame.CONCENTRIC_CYLINDRICAL2D,
0193             "bin": GridBin.DYNAMIC,
0194             "serializer": GridSerializer.SIMPLE,
0195         },
0196     )
0197     # Surface grid, cylindrical 2D (barrel)
0198     CYLINDER_GRID2D = cpp_class(
0199         specifier=SPATIAL_GRID_SPECIFIER,
0200         param={
0201             "shape": Shape.CYLINDER2D,
0202             "frame": Frame.CYLINDRICAL2D,
0203             "bin": GridBin.DYNAMIC,
0204             "serializer": GridSerializer.SIMPLE,
0205         },
0206     )
0207     # Surface grid, cylindrical 3D (barrel)
0208     CYLINDER_GRID3D = cpp_class(
0209         specifier=SPATIAL_GRID_SPECIFIER,
0210         param={
0211             "shape": Shape.CYLINDER3D,
0212             "frame": Frame.CYLINDRICAL3D,
0213             "bin": GridBin.DYNAMIC,
0214             "serializer": GridSerializer.SIMPLE,
0215         },
0216     )
0217     # Surface grid, disc (endcap)
0218     DISC_GRID2D = cpp_class(
0219         specifier=SPATIAL_GRID_SPECIFIER,
0220         param={
0221             "shape": Shape.RING,
0222             "frame": Frame.POLAR2D,
0223             "bin": GridBin.DYNAMIC,
0224             "serializer": GridSerializer.SIMPLE,
0225         },
0226     )
0227     # Surface grid, reactangular (telescope)
0228     RECTANGLE_GRID2D = cpp_class(
0229         specifier=SPATIAL_GRID_SPECIFIER,
0230         param={
0231             "shape": Shape.RECTANGLE,
0232             "frame": Frame.CARTESIAN2D,
0233             "bin": GridBin.DYNAMIC,
0234             "serializer": GridSerializer.SIMPLE,
0235         },
0236     )
0237     # Surface grid, cuboid 3D (telescope)
0238     CUBOID_GRID3D = cpp_class(
0239         specifier=SPATIAL_GRID_SPECIFIER,
0240         param={
0241             "shape": Shape.CUBOID,
0242             "frame": Frame.CARTESIAN3D,
0243             "bin": GridBin.DYNAMIC,
0244             "serializer": GridSerializer.SIMPLE,
0245         },
0246     )