Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-26 08:10:16

0001 #!/usr/bin/env python3
0002 # SPDX-License-Identifier: LGPL-3.0-or-later
0003 # Copyright (C) 2024 Shujie Li
0004 
0005 ## Stand alone function to build ePIC geometry with ACTS python bindings
0006 ## for material mapping
0007 ## Shujie Li, 03, 2024
0008 
0009 from pathlib import Path
0010 
0011 import acts
0012 import acts.examples.dd4hep
0013 
0014 def getDetector(
0015     xmlFile,
0016     matFile="",
0017     logLevel=acts.logging.WARNING,
0018 ):
0019     customLogLevel = acts.examples.defaultLogging(logLevel=logLevel)
0020     logger = acts.getDefaultLogger("epic.getDetector", logLevel)
0021 
0022     matDeco = None
0023     if len(matFile) > 0:
0024         file = Path(matFile)
0025         if file.exists():
0026             logger.info("Adding material from %s", file.absolute())
0027             matDeco = acts.IMaterialDecorator.fromFile(
0028                 file,
0029                 level=customLogLevel(maxLevel=acts.logging.WARNING),
0030             )
0031         else:
0032             logger.warning("Material map %s not found.", matFile)
0033 
0034     dd4hepConfig = acts.examples.dd4hep.DD4hepDetector.Config(
0035         xmlFileNames=[xmlFile],
0036         logLevel=logLevel,
0037         dd4hepLogLevel=customLogLevel(),
0038         materialDecorator=matDeco,
0039     )
0040     detector = acts.examples.dd4hep.DD4hepDetector(dd4hepConfig)
0041 
0042     return detector