Back to home page

EIC code displayed by LXR

 
 

    


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

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 import os
0011 import sys
0012 
0013 # ------------------------------------------------------------------------------
0014 # Options parsing
0015 # ------------------------------------------------------------------------------
0016 
0017 """ Parent detector reader options that contain common options """
0018 
0019 
0020 def detector_io_options():
0021 
0022     parser = argparse.ArgumentParser(add_help=False)
0023 
0024     parser.add_argument(
0025         "--geometry_file",
0026         "-geo",
0027         help=("Detector geometry file"),
0028         default="",
0029         type=str,
0030         required=True,
0031     )
0032     parser.add_argument(
0033         "--grid_file",
0034         "-grid",
0035         help=("Detector surface grids file"),
0036         default="",
0037         type=str,
0038     )
0039     parser.add_argument(
0040         "--material_file", "-mat", help=("Detector material file"), default="", type=str
0041     )
0042 
0043     return parser
0044 
0045 
0046 """ Parse detector reader options from commandline """
0047 
0048 
0049 def parse_detector_io_options(args, logging):
0050 
0051     # Check detector files
0052     if not os.path.isfile(args.geometry_file):
0053         logging.error(f"Detector geometry file does not exist! ({args.geometry_file})")
0054         sys.exit(1)
0055 
0056     if args.grid_file and not os.path.isfile(args.grid_file):
0057         logging.error(f"Detector grid file does not exist! ({args.material_file})")
0058         sys.exit(1)
0059 
0060     if args.material_file and not os.path.isfile(args.material_file):
0061         logging.error(f"Detector material file does not exist! ({args.material_file})")
0062         sys.exit(1)