File indexing completed on 2025-06-30 07:56:04
0001
0002
0003
0004
0005 import os
0006 import argparse
0007
0008 import acts
0009 from acts.examples import JsonFormat
0010
0011 import epic
0012 from material_mapping import runMaterialMapping
0013
0014 if "__main__" == __name__:
0015
0016 p = argparse.ArgumentParser(
0017 description="Script to generate material map for ePIC geometry"
0018 )
0019 p.add_argument(
0020 "--xmlFile",
0021 default=os.environ.get("DETECTOR_PATH", "")+"epic_craterlake.xml",
0022 help="input xml file containing ePIC geometry",
0023 )
0024 p.add_argument(
0025 "--geoFile",
0026 type=str,
0027 default="geometry-map.json",
0028 help="input json file to define volumes and layers used in material mapping",
0029 )
0030 p.add_argument(
0031 "--matFile",
0032 type=str,
0033 default="material-map.json",
0034 help="output filename for the generated material map, can be json and cbor formats",
0035 )
0036 args = p.parse_args()
0037
0038 mapName = args.matFile.split('.')[0]
0039 if '.json' in args.matFile:
0040 mapFormat = JsonFormat.Json
0041 elif '.cbor' in args.matFile:
0042 mapFormat = JsonFormat.Cbor
0043 else:
0044 print('ERROR(material_mapping_epic.py): please provide a material map file in .json or .cbor format')
0045 exit()
0046
0047 detector, trackingGeometry, decorators = epic.getDetector(
0048 args.xmlFile, args.geoFile)
0049
0050
0051 runMaterialMapping(
0052 trackingGeometry,
0053 decorators,
0054 outputDir = os.getcwd(),
0055 inputDir = os.getcwd(),
0056 readCachedSurfaceInformation=False,
0057 mapVolume= False,
0058 mapName = mapName,
0059 mapFormat = mapFormat,
0060 ).run()