Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:12:08

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