From 2045800496a8b90376abf6c86a93dab80d1eaa62 Mon Sep 17 00:00:00 2001 From: Andreas Salzburger Date: Thu, 10 Oct 2024 21:34:33 +0200 Subject: [PATCH] fix: adapt scripts to GeoModel updates (#3711) This PR adapts the scripts for material mapping to the recent changes in GeoModel (-> `ObjectFactory`) --- .../Scripts/Python/material_mapping_core.py | 45 ++++++++++++++----- .../Python/material_validation_core.py | 45 ++++++++++++++----- 2 files changed, 68 insertions(+), 22 deletions(-) diff --git a/Examples/Scripts/Python/material_mapping_core.py b/Examples/Scripts/Python/material_mapping_core.py index 9a9801b50af..0bd9a7415de 100644 --- a/Examples/Scripts/Python/material_mapping_core.py +++ b/Examples/Scripts/Python/material_mapping_core.py @@ -156,6 +156,29 @@ def runMaterialMapping(surfaces, inputFile, outputFile, outputMap, loglevel): help="Construct experimental geometry from GeoModel", ) + p.add_argument( + "--geomodel-name-list", + type=str, + nargs="+", + default=[], + help="List of Name List for the Surface Factory", + ) + + p.add_argument( + "--geomodel-material-list", + type=str, + nargs="+", + default=[], + help="List of Material List for the Surface Factory", + ) + + p.add_argument( + "--geomodel-convert-subvols", + help="Convert the children of the top level full phys vol", + action="store_true", + default=False, + ) + p.add_argument( "--geomodel-top-node", type=str, @@ -189,19 +212,16 @@ def runMaterialMapping(surfaces, inputFile, outputFile, outputMap, loglevel): # Read the geometry model from the database gmTree = acts.geomodel.readFromDb(args.geomodel_input) - gmFactoryConfig = gm.GeoModelDetectorSurfaceFactory.Config() - gmFactoryConfig.shapeConverters = [ - gm.GeoBoxConverter(), - gm.GeoTrdConverter(), - gm.GeoIntersectionAnnulusConverter(), - ] - - gmFactory = gm.GeoModelDetectorSurfaceFactory(gmFactoryConfig, logLevel) + gmFactoryConfig = gm.GeoModelDetectorObjectFactory.Config() + gmFactoryConfig.materialList = args.geomodel_material_list + gmFactoryConfig.nameList = args.geomodel_name_list + gmFactoryConfig.convertSubVolumes = args.geomodel_convert_subvols + gmFactory = gm.GeoModelDetectorObjectFactory(gmFactoryConfig, logLevel) # The options - gmFactoryOptions = gm.GeoModelDetectorSurfaceFactory.Options() + gmFactoryOptions = gm.GeoModelDetectorObjectFactory.Options() gmFactoryOptions.queries = args.geomodel_queries # The Cache & construct call - gmFactoryCache = gm.GeoModelDetectorSurfaceFactory.Cache() + gmFactoryCache = gm.GeoModelDetectorObjectFactory.Cache() gmFactory.construct(gmFactoryCache, gContext, gmTree, gmFactoryOptions) # All surfaces from GeoModel @@ -210,7 +230,10 @@ def runMaterialMapping(surfaces, inputFile, outputFile, outputMap, loglevel): # Construct the building hierarchy gmBlueprintConfig = gm.GeoModelBlueprintCreater.Config() gmBlueprintConfig.detectorSurfaces = gmSurfaces - gmBlueprintConfig.kdtBinning = [acts.Binning.z, acts.Binning.r] + gmBlueprintConfig.kdtBinning = [ + acts.BinningValue.binZ, + acts.BinningValue.binR, + ] gmBlueprintOptions = gm.GeoModelBlueprintCreater.Options() gmBlueprintOptions.table = args.geomodel_table_name diff --git a/Examples/Scripts/Python/material_validation_core.py b/Examples/Scripts/Python/material_validation_core.py index e696f704a5f..7e2ae129dcf 100644 --- a/Examples/Scripts/Python/material_validation_core.py +++ b/Examples/Scripts/Python/material_validation_core.py @@ -92,6 +92,29 @@ def runMaterialValidation(s, ntracks, surfaces, outputFile, seed, loglevel): help="Construct experimental geometry from GeoModel", ) + p.add_argument( + "--geomodel-name-list", + type=str, + nargs="+", + default=[], + help="List of Name List for the Surface Factory", + ) + + p.add_argument( + "--geomodel-material-list", + type=str, + nargs="+", + default=[], + help="List of Material List for the Surface Factory", + ) + + p.add_argument( + "--geomodel-convert-subvols", + help="Convert the children of the top level full phys vol", + action="store_true", + default=False, + ) + p.add_argument( "--geomodel-top-node", type=str, @@ -129,19 +152,16 @@ def runMaterialValidation(s, ntracks, surfaces, outputFile, seed, loglevel): # Read the geometry model from the database gmTree = acts.geomodel.readFromDb(args.geomodel_input) - gmFactoryConfig = gm.GeoModelDetectorSurfaceFactory.Config() - gmFactoryConfig.shapeConverters = [ - gm.GeoBoxConverter(), - gm.GeoTrdConverter(), - gm.GeoIntersectionAnnulusConverter(), - ] - - gmFactory = gm.GeoModelDetectorSurfaceFactory(gmFactoryConfig, logLevel) + gmFactoryConfig = gm.GeoModelDetectorObjectFactory.Config() + gmFactoryConfig.materialList = args.geomodel_material_list + gmFactoryConfig.nameList = args.geomodel_name_list + gmFactoryConfig.convertSubVolumes = args.geomodel_convert_subvols + gmFactory = gm.GeoModelDetectorObjectFactory(gmFactoryConfig, logLevel) # The options - gmFactoryOptions = gm.GeoModelDetectorSurfaceFactory.Options() + gmFactoryOptions = gm.GeoModelDetectorObjectFactory.Options() gmFactoryOptions.queries = args.geomodel_queries # The Cache & construct call - gmFactoryCache = gm.GeoModelDetectorSurfaceFactory.Cache() + gmFactoryCache = gm.GeoModelDetectorObjectFactory.Cache() gmFactory.construct(gmFactoryCache, gContext, gmTree, gmFactoryOptions) # All surfaces from GeoModel @@ -150,7 +170,10 @@ def runMaterialValidation(s, ntracks, surfaces, outputFile, seed, loglevel): # Construct the building hierarchy gmBlueprintConfig = gm.GeoModelBlueprintCreater.Config() gmBlueprintConfig.detectorSurfaces = gmSurfaces - gmBlueprintConfig.kdtBinning = [acts.Binning.z, acts.Binning.r] + gmBlueprintConfig.kdtBinning = [ + acts.BinningValue.binZ, + acts.BinningValue.binR, + ] gmBlueprintOptions = gm.GeoModelBlueprintCreater.Options() gmBlueprintOptions.table = args.geomodel_table_name