Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-03-30 07:48:55

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     jsonFile="",
0017     logLevel=acts.logging.WARNING,
0018 ):
0019     customLogLevel = acts.examples.defaultLogging(logLevel=logLevel)
0020     logger = acts.logging.getLogger("epic.getDetector")
0021 
0022     matDeco = None
0023     if len(jsonFile)>0:
0024         file = Path(jsonFile)
0025         logger.info("Adding material from %s", file.absolute())
0026         matDeco = acts.IMaterialDecorator.fromFile(
0027             file,
0028             level=customLogLevel(maxLevel=acts.logging.WARNING),
0029         )
0030 
0031     dd4hepConfig = acts.examples.dd4hep.DD4hepDetector.Config(
0032         xmlFileNames=[xmlFile],
0033         logLevel=logLevel,
0034         dd4hepLogLevel=customLogLevel(),
0035         materialDecorator=matDeco,
0036     )
0037     detector = acts.examples.dd4hep.DD4hepDetector(dd4hepConfig)
0038 
0039     return detector