Back to home page

EIC code displayed by LXR

 
 

    


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

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 import detray
0010 
0011 from detray.detectors import metadata, metadata_generator
0012 from detray.detectors import Type, Algebra, Shape, Material, Accelerator
0013 from detray.detectors import (
0014     add_silicon_tracker_defaults,
0015     add_calorimeter_defaults,
0016     add_telescope_detector_defaults,
0017     add_wire_chamber_defaults,
0018 )
0019 
0020 from itk_metadata import add_itk_types
0021 from odd_metadata import add_odd_types
0022 
0023 import argparse
0024 import logging
0025 import sys
0026 
0027 # --------------------------------------------------------------------------
0028 # Generate the default metadata type (can represent all detectors)
0029 # --------------------------------------------------------------------------
0030 
0031 
0032 def __main__():
0033     # Commandline options
0034     parser = argparse.ArgumentParser(prog=sys.argv[0])
0035     detray.detectors.add_logging_options(parser)
0036     detray.detectors.add_io_options(parser)
0037 
0038     args = parser.parse_args()
0039     detray.detectors.parse_logging_options(args)
0040     detray.detectors.parse_io_options(args)
0041 
0042     logger = logging.getLogger(__name__)
0043 
0044     # Collect the types required for a detector that can hold all detector types
0045     md = metadata("default")
0046 
0047     # Specify a particular algebra plugin (otherwise left as template param.)
0048     # md.set_algebra_plugin(Algebra.ARRAY, Type.SINGLE)
0049 
0050     # Make sure all of the defaults are added
0051     add_telescope_detector_defaults(md, use_mat_maps=True, use_homogeneous_mat=True)
0052     add_wire_chamber_defaults(md, use_mat_maps=True, use_homogeneous_mat=True)
0053     add_calorimeter_defaults(md, use_mat_maps=True, use_homogeneous_mat=True)
0054     add_silicon_tracker_defaults(
0055         md, use_mat_maps=True, use_homogeneous_mat=True, add_trapezoid=True
0056     )
0057 
0058     # Make sure all detectors can be represented by this metadata
0059     add_odd_types(md)
0060     add_itk_types(md)
0061 
0062     # Extra passive surface shapes (cylinder with two intersection solutions)
0063     md.add_passive(Shape.CYLINDER2D)
0064     md.add_passive(Shape.RING)
0065 
0066     # Add an acceleration struct and material map for generic 2D cylinders
0067     md.add_accel_struct(Accelerator.CYLINDER_GRID2D)
0068     md.add_material(Material.CYLINDER_MAP2D)
0069 
0070     #
0071     # Add some special types (e.g. for detector R&D)
0072 
0073     # Special surface types
0074     # md.add_sensitive(Shape.UNMASKED)
0075 
0076     # Add more material types for testing
0077     md.add_material(Material.ANNULUS_MAP2D)
0078     md.add_material(Material.TRAPEZOID_MAP2D)
0079     md.add_material(Material.CUBOID_MAP3D)
0080     md.add_material(Material.CYLINDER_MAP2D)
0081 
0082     # Make sure a default acceleration struct is chosen that can be used in all
0083     # detector types
0084     logger.info(
0085         "Overwrite default acceleration structures to use most generic types as defaults"
0086     )
0087     md.set_default_accel_struct(Accelerator.BRUTE_FORCE, "portal")
0088     md.set_default_accel_struct(Accelerator.CYLINDER_GRID3D, "volume")
0089 
0090     # Dump the metadata to header file
0091     if args.output:
0092         metadata_generator(md, args.output)
0093     else:
0094         metadata_generator(md)
0095 
0096 
0097 if __name__ == "__main__":
0098     __main__()