File indexing completed on 2026-07-16 08:08:21
0001 import acts
0002 import argparse
0003 from acts import (
0004 logging,
0005 GeometryContext,
0006 )
0007 from acts import geomodel as gm
0008 from acts import examples
0009
0010
0011 def main():
0012 p = argparse.ArgumentParser()
0013
0014 p.add_argument("-i", "--input", type=str, default="", help="Input SQL file")
0015
0016 p.add_argument(
0017 "-q",
0018 "--queries",
0019 type=str,
0020 nargs="+",
0021 default="GeoModelXML",
0022 help="List of Queries for Published full phys volumes",
0023 )
0024
0025 p.add_argument(
0026 "-n",
0027 "--name-list",
0028 type=str,
0029 nargs="+",
0030 default=[],
0031 help="List of Name List for the Surface Factory",
0032 )
0033
0034 p.add_argument(
0035 "-ml",
0036 "--material-list",
0037 type=str,
0038 nargs="+",
0039 default=[],
0040 help="List of Material List for the Surface Factory",
0041 )
0042
0043 p.add_argument(
0044 "--table-name",
0045 type=str,
0046 default="ActsBlueprint",
0047 help="Name of the blueprint table",
0048 )
0049
0050 p.add_argument(
0051 "-t",
0052 "--top-node",
0053 type=str,
0054 default="",
0055 help="Name of the top node in the blueprint tree",
0056 )
0057
0058 p.add_argument(
0059 "-b",
0060 "--top-node-bounds",
0061 type=str,
0062 default="",
0063 help="Table entry string overriding the top node bounds",
0064 )
0065
0066 p.add_argument(
0067 "-m", "--map", type=str, default="", help="Input file for the material map"
0068 )
0069
0070 p.add_argument(
0071 "--convert-subvols",
0072 help="Convert the children of the top level full phys vol",
0073 action="store_true",
0074 default=False,
0075 )
0076
0077 p.add_argument(
0078 "--enable-blueprint",
0079 help="Enable the usage of the blueprint",
0080 action="store_true",
0081 default=False,
0082 )
0083
0084 args = p.parse_args()
0085
0086 gContext = acts.GeometryContext.dangerouslyDefaultConstruct()
0087 logLevel = logging.INFO
0088
0089 materialDecorator = None
0090 if args.map != "":
0091 print("Loading a material decorator from file:", args.map)
0092 materialDecorator = acts.IMaterialDecorator.fromFile(args.map)
0093
0094
0095 gmTree = acts.geomodel.readFromDb(args.input)
0096
0097 gmFactoryConfig = gm.GeoModelDetectorObjectFactory.Config()
0098 gmFactoryConfig.materialList = args.material_list
0099 gmFactoryConfig.nameList = args.name_list
0100 gmFactoryConfig.convertSubVolumes = args.convert_subvols
0101 gmFactory = gm.GeoModelDetectorObjectFactory(gmFactoryConfig, logLevel)
0102
0103 gmFactoryOptions = gm.GeoModelDetectorObjectFactory.Options()
0104 gmFactoryOptions.queries = args.queries
0105
0106 gmFactoryCache = gm.GeoModelDetectorObjectFactory.Cache()
0107 gmFactory.construct(gmFactoryCache, gContext, gmTree, gmFactoryOptions)
0108
0109
0110 gmSurfaces = [ss[1] for ss in gmFactoryCache.sensitiveSurfaces]
0111
0112
0113 gmBlueprintConfig = gm.GeoModelBlueprintCreater.Config()
0114 gmBlueprintConfig.detectorSurfaces = gmSurfaces
0115 gmBlueprintConfig.kdtBinning = [acts.Binning.z, acts.Binning.r]
0116
0117 gmBlueprintOptions = gm.GeoModelBlueprintCreater.Options()
0118 gmBlueprintOptions.table = args.table_name
0119 gmBlueprintOptions.topEntry = args.top_node
0120 if len(args.top_node_bounds) > 0:
0121 gmBlueprintOptions.topBoundsOverride = args.top_node_bounds
0122
0123 gmBlueprintCreater = gm.GeoModelBlueprintCreater(gmBlueprintConfig, logLevel)
0124 gmBlueprint = gmBlueprintCreater.create(gContext, gmTree, gmBlueprintOptions)
0125
0126 gmCylindricalBuilder = gmBlueprint.convertToBuilder(logLevel)
0127
0128
0129 gmGeoIdConfig = GeometryIdGenerator.Config()
0130 gmGeoIdGenerator = GeometryIdGenerator(
0131 gmGeoIdConfig, "GeoModelGeoIdGenerator", logLevel
0132 )
0133
0134
0135 gmDetectorConfig = DetectorBuilder.Config()
0136 gmDetectorConfig.name = args.top_node + "_DetectorBuilder"
0137 gmDetectorConfig.builder = gmCylindricalBuilder
0138 gmDetectorConfig.geoIdGenerator = gmGeoIdGenerator
0139 gmDetectorConfig.materialDecorator = materialDecorator
0140 gmDetectorConfig.auxiliary = (
0141 "GeoModel based Acts::Detector from '" + args.input + "'"
0142 )
0143
0144 gmDetectorBuilder = DetectorBuilder(gmDetectorConfig, args.top_node, logLevel)
0145 detector = gmDetectorBuilder.construct(gContext)
0146
0147 return
0148
0149
0150 if "__main__" == __name__:
0151 main()