File indexing completed on 2025-09-14 08:16:13
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 = epic.getDetector(
0048 args.xmlFile, args.geoFile)
0049 trackingGeometry = detector.trackingGeometry()
0050 decorators = detector.contextDecorators()
0051
0052 runMaterialMapping(
0053 trackingGeometry,
0054 decorators,
0055 outputDir = os.getcwd(),
0056 inputDir = os.getcwd(),
0057 readCachedSurfaceInformation=False,
0058 mapVolume= False,
0059 mapName = mapName,
0060 mapFormat = mapFormat,
0061 ).run()