Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2024-06-26 07:06:10

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 from acts import (
0015     Vector4,
0016     MaterialMapJsonConverter
0017 )
0018 
0019 import json
0020 
0021 def getDetector(
0022     xmlFile,
0023     jsonFile="",
0024     logLevel=acts.logging.WARNING,
0025 ):
0026     customLogLevel = acts.examples.defaultLogging(logLevel=logLevel)
0027     logger = acts.logging.getLogger("epic.getDetector")
0028 
0029     matDeco = None
0030     if len(jsonFile)>0:
0031         file = Path(jsonFile)
0032         logger.info("Adding material from %s", file.absolute())
0033         matDeco = acts.IMaterialDecorator.fromFile(
0034             file,
0035             level=customLogLevel(maxLevel=acts.logging.INFO),
0036         )
0037 
0038     dd4hepConfig = acts.examples.dd4hep.DD4hepGeometryService.Config(
0039         xmlFileNames=[xmlFile],
0040         logLevel=logLevel,
0041         dd4hepLogLevel=customLogLevel(),
0042     )
0043     detector = acts.examples.dd4hep.DD4hepDetector()
0044 
0045     config = acts.MaterialMapJsonConverter.Config()
0046 
0047     trackingGeometry, deco = detector.finalize(dd4hepConfig, matDeco)
0048 
0049     return detector, trackingGeometry, deco