Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-26 08:02:51

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 argparse
0010 
0011 # ------------------------------------------------------------------------------
0012 # Options parsing
0013 # ------------------------------------------------------------------------------
0014 
0015 
0016 def toy_detector_options():
0017     """Parent parser that contains the toy detector options."""
0018 
0019     parser = argparse.ArgumentParser(add_help=False)
0020 
0021     parser.add_argument(
0022         "--barrel_layers",
0023         help=("Number of barrel layers [0-4]"),
0024         default=4,
0025         type=int,
0026     )
0027     parser.add_argument(
0028         "--endcap_layers",
0029         help=("Number of endcap layers on either side [0-7]"),
0030         default=3,
0031         type=int,
0032     )
0033     parser.add_argument(
0034         "--homogeneous_material",
0035         help=("Generate homogeneous material description (default)"),
0036         action="store_true",
0037     )
0038     parser.add_argument(
0039         "--material_maps", help=("Generate material maps"), action="store_true"
0040     )
0041 
0042     return parser
0043 
0044 
0045 def fill_toy_detector_config(args, config):
0046     """Fill a toy detector config from the parsed commandline options."""
0047 
0048     if args.homogeneous_material and args.material_maps:
0049         raise ValueError("Please specify only one material description")
0050 
0051     config.nBarrelLayers = args.barrel_layers
0052     config.nEndcapLayers = args.endcap_layers
0053 
0054     if args.homogeneous_material:
0055         config.useMaterialMaps = False
0056     if args.material_maps:
0057         config.useMaterialMaps = True
0058 
0059     return config