From b46d4256e741788f4294ba54cce7c351aaebabe6 Mon Sep 17 00:00:00 2001 From: Benjamin Huth <37871400+benjaminhuth@users.noreply.github.com> Date: Fri, 19 Jul 2024 19:07:35 +0200 Subject: [PATCH] refactor: RootMaterialDecorator as default for the ODD (#3415) `getOpenDataDetector()` gives by default the `JsonMaterialDecorator`, which does not give good results (at least in my use cases), and for most usecases, we anyways give directly the Root based one. --- Examples/Python/python/acts/examples/odd.py | 13 +++++++++---- Examples/Python/tests/test_examples.py | 11 +++++++++-- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/Examples/Python/python/acts/examples/odd.py b/Examples/Python/python/acts/examples/odd.py index c66eaf979fc..ec8cbcb9438 100644 --- a/Examples/Python/python/acts/examples/odd.py +++ b/Examples/Python/python/acts/examples/odd.py @@ -20,6 +20,13 @@ def getOpenDataDetector( odd_dir: Optional[Path] = None, logLevel=acts.logging.INFO, ): + """This function sets up the open data detector. Requires DD4hep. + Parameters + ---------- + mdecorator: Material Decorator, take RootMaterialDecorator if non is given + odd_dir: if not given, try to get via ODD_PATH environment variable + logLevel: logging level + """ import acts.examples.dd4hep customLogLevel = acts.examples.defaultLogging(logLevel=logLevel) @@ -86,11 +93,9 @@ def geoid_hook(geoid, surface): ) detector = acts.examples.dd4hep.DD4hepDetector() - config = acts.MaterialMapJsonConverter.Config() if mdecorator is None: - mdecorator = acts.JsonMaterialDecorator( - rConfig=config, - jFileName=str(odd_dir / "config/odd-material-mapping-config.json"), + mdecorator = acts.examples.RootMaterialDecorator( + fileName=str(odd_dir / "data/odd-material-maps.root"), level=customLogLevel(minLevel=acts.logging.WARNING), ) diff --git a/Examples/Python/tests/test_examples.py b/Examples/Python/tests/test_examples.py index 1447f98adf7..b1a669f0dd4 100644 --- a/Examples/Python/tests/test_examples.py +++ b/Examples/Python/tests/test_examples.py @@ -28,7 +28,7 @@ GenericDetector, AlignedDetector, ) -from acts.examples.odd import getOpenDataDetector +from acts.examples.odd import getOpenDataDetector, getOpenDataDetectorDirectory u = acts.UnitConstants @@ -678,7 +678,14 @@ def test_material_mapping(material_recording, tmp_path, assert_root_hash): s = Sequencer(numThreads=1) - detector, trackingGeometry, decorators = getOpenDataDetector() + odd_dir = getOpenDataDetectorDirectory() + config = acts.MaterialMapJsonConverter.Config() + mdecorator = acts.JsonMaterialDecorator( + level=acts.logging.INFO, + rConfig=config, + jFileName=str(odd_dir / "config/odd-material-mapping-config.json"), + ) + detector, trackingGeometry, decorators = getOpenDataDetector(mdecorator) from material_mapping import runMaterialMapping