Skip to content

Commit

Permalink
fix: adapt scripts to GeoModel updates (#3711)
Browse files Browse the repository at this point in the history
This PR adapts the scripts for material mapping to the recent changes in GeoModel (-> `ObjectFactory`)
  • Loading branch information
asalzburger authored Oct 10, 2024
1 parent 0fa82af commit 2045800
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 22 deletions.
45 changes: 34 additions & 11 deletions Examples/Scripts/Python/material_mapping_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
45 changes: 34 additions & 11 deletions Examples/Scripts/Python/material_validation_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 2045800

Please sign in to comment.