File indexing completed on 2026-09-26 08:02:51
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 from options import (
0011 common_options,
0012 detector_writer_options,
0013 toy_detector_options,
0014 )
0015 from options import (
0016 parse_common_options,
0017 fill_toy_detector_config,
0018 fill_writer_config,
0019 )
0020
0021
0022 import detray.core
0023 import detray.io
0024 import detray.tests
0025
0026
0027 import argparse
0028
0029
0030 def run_generate_toy_detector(args):
0031
0032
0033 toy_cfg = fill_toy_detector_config(args, detray.tests.ToyDetectorConfig())
0034 det, names = detray.tests.buildToyDetector(
0035 detray.core.HostMemoryResource(), toy_cfg
0036 )
0037
0038
0039 writer_cfg = fill_writer_config(args, detray.io.DetectorWriterConfig())
0040
0041
0042 writer_cfg.writeMaterial = (
0043 args.homogeneous_material or args.material_maps or args.write_material
0044 )
0045
0046 detray.io.writeDetector(det, names, writer_cfg)
0047
0048
0049 def __main__():
0050
0051
0052
0053 descr = "Detray Toy Detector Generation"
0054
0055
0056 parent_parsers = [
0057 common_options(descr),
0058 toy_detector_options(),
0059 detector_writer_options(),
0060 ]
0061
0062 parser = argparse.ArgumentParser(description=descr, parents=parent_parsers)
0063
0064 parser.add_argument(
0065 "--write_volume_graph",
0066 help=("Write the volume graph to file"),
0067 action="store_true",
0068 )
0069
0070 args = parser.parse_args()
0071
0072 logging = parse_common_options(args, descr)
0073
0074
0075
0076 logging.debug("Generating the toy detector")
0077 run_generate_toy_detector(args)
0078
0079 logging.info(f"Wrote the detector files to '{args.outdir}'")
0080
0081
0082 if args.write_volume_graph:
0083 raise NotImplementedError("Writing of volume graph not implemented")
0084
0085
0086
0087
0088 if __name__ == "__main__":
0089 __main__()
0090
0091