1 from pathlib
import Path
11 logLevel=acts.logging.INFO,
18 odd_xml = odd_dir /
"xml" /
"OpenDataDetector.xml"
19 if not odd_xml.exists():
20 raise RuntimeError(f
"OpenDataDetector.xml not found at {odd_xml}")
23 map_name =
"libOpenDataDetector.components"
25 if sys.platform ==
"linux":
26 env_vars = [
"LD_LIBRARY_PATH"]
27 lib_name =
"libOpenDataDetector.so"
28 elif sys.platform ==
"darwin":
29 env_vars = [
"DYLD_LIBRARY_PATH",
"DD4HEP_LIBRARY_PATH"]
30 lib_name =
"libOpenDataDetector.dylib"
32 if lib_name
is not None and len(env_vars) > 0:
34 for env_var
in env_vars:
35 for lib_dir
in os.environ.get(env_var,
"").split(
":"):
36 lib_dir = Path(lib_dir)
37 if (lib_dir / map_name).
exists()
and (lib_dir / lib_name).
exists():
42 "Unable to find OpenDataDetector factory library. "
43 f
"You might need to point {'/'.join(env_vars)} to build/thirdparty/OpenDataDetector/factory or other ODD install location"
45 raise RuntimeError(msg)
47 volumeRadiusCutsMap = {
56 def geoid_hook(geoid, surface):
57 if geoid.volume()
in volumeRadiusCutsMap:
58 r = sqrt(surface.center()[0] ** 2 + surface.center()[1] ** 2)
61 for cut
in volumeRadiusCutsMap[geoid.volume()]:
63 geoid.setExtra(geoid.extra() + 1)
67 dd4hepConfig = acts.examples.dd4hep.DD4hepGeometryService.Config(
68 xmlFileNames=[
str(odd_xml)],
69 logLevel=customLogLevel(),
70 dd4hepLogLevel=customLogLevel(),
71 geometryIdentifierHook=acts.GeometryIdentifierHook(geoid_hook),
73 detector = acts.examples.dd4hep.DD4hepDetector()
75 config = acts.MaterialMapJsonConverter.Config()
76 if mdecorator
is None:
77 mdecorator = acts.JsonMaterialDecorator(
79 jFileName=
str(odd_dir /
"config/odd-material-mapping-config.json"),
80 level=customLogLevel(minLevel=acts.logging.WARNING),
83 trackingGeometry, deco = detector.finalize(dd4hepConfig, mdecorator)
85 return detector, trackingGeometry, deco