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 Shape, Accelerator, GridBin, GridSerializer
0013 from detray.detectors import add_silicon_tracker_defaults
0014 
0015 import argparse
0016 import logging
0017 import sys
0018 
0019 # --------------------------------------------------------------------------
0020 # Generate the toy detector metadata type
0021 # --------------------------------------------------------------------------
0022 
0023 """ Add all types needed to describe the detray toy detector """
0024 
0025 
0026 def add_toy_types(md: metadata):
0027     logger = logging.getLogger(__name__)
0028     logger.info("Define types required by the toy detector:")
0029 
0030     # Add default types for silicon trackers (cylindrical detector shape)
0031     add_silicon_tracker_defaults(
0032         metadata=md, use_homogeneous_mat=True, use_mat_maps=True, add_trapezoid=True
0033     )
0034 
0035     # Add surface grids with static bin capacity
0036     toy_grid_bin = GridBin.STATIC
0037     toy_grid_bin.param["capacity"] = 1
0038 
0039     md.add_accel_struct(
0040         Accelerator.CONCENTRIC_CYLINDER_GRID2D,
0041         "sensitive",
0042         grid_bin=toy_grid_bin,
0043         type_id=1,
0044     )
0045 
0046     md.add_accel_struct(
0047         Accelerator.DISC_GRID2D, "sensitive", grid_bin=toy_grid_bin, type_id=2
0048     )
0049 
0050     logger.info("Done")
0051 
0052 
0053 def __main__():
0054     # Commandline options
0055     parser = argparse.ArgumentParser(prog=sys.argv[0])
0056     detray.detectors.add_logging_options(parser)
0057     detray.detectors.add_io_options(parser)
0058 
0059     args = parser.parse_args()
0060     detray.detectors.parse_logging_options(args)
0061     detray.detectors.parse_io_options(args)
0062 
0063     md = metadata("toy")
0064 
0065     add_toy_types(md)
0066 
0067     # Dump the metadata to header file
0068     if args.output:
0069         metadata_generator(md, args.output)
0070     else:
0071         metadata_generator(md)
0072 
0073 
0074 if __name__ == "__main__":
0075     __main__()