Skip to content

Commit

Permalink
refactor: RootMaterialDecorator as default for the ODD (#3415)
Browse files Browse the repository at this point in the history
`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.
  • Loading branch information
benjaminhuth authored Jul 19, 2024
1 parent d493563 commit b46d425
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
13 changes: 9 additions & 4 deletions Examples/Python/python/acts/examples/odd.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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),
)

Expand Down
11 changes: 9 additions & 2 deletions Examples/Python/tests/test_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
GenericDetector,
AlignedDetector,
)
from acts.examples.odd import getOpenDataDetector
from acts.examples.odd import getOpenDataDetector, getOpenDataDetectorDirectory


u = acts.UnitConstants
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit b46d425

Please sign in to comment.