Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:18:32

0001 ## Stand alone function to build ePIC geometry with ACTS python bindings
0002 ## for material mapping
0003 ## Shujie Li, 03, 2024
0004 #!/usr/bin/env python3
0005 import argparse
0006 from pathlib import Path
0007 
0008 # from acts.examples import (
0009 #     # Sequencer,
0010 #     # WhiteBoard,
0011 #     # AlgorithmContext,
0012 #     # ProcessCode,
0013 #     # RootMaterialTrackReader,
0014 #     # RootMaterialTrackWriter,
0015 #     # CsvTrackingGeometryWriter,
0016 #     # ObjTrackingGeometryWriter,
0017 #     MaterialMapping,
0018 #     JsonMaterialWriter,
0019 #     JsonSurfacesWriter,
0020 #     JsonFormat,
0021 # )
0022 
0023 import acts
0024 import acts.examples.dd4hep
0025 
0026 from acts import (
0027     Vector4,
0028     # UnitConstants as u,
0029     # SurfaceMaterialMapper,
0030     # VolumeMaterialMapper,
0031     # Navigator,
0032     # Propagator,
0033     # StraightLineStepper,
0034     MaterialMapJsonConverter
0035 )
0036 
0037 import json
0038 
0039 def buildePICGeometry(
0040     xmlFile,
0041     jsonFile="",
0042     logLevel=acts.logging.WARNING,
0043 ):
0044     customLogLevel = acts.examples.defaultLogging(logLevel=logLevel)
0045     logger = acts.logging.getLogger("BuildePICGeometry")
0046 
0047     matDeco = None
0048     if len(jsonFile)>0:
0049         file = Path(jsonFile)
0050         logger.info("Adding material from %s", file.absolute())
0051         matDeco = acts.IMaterialDecorator.fromFile(
0052             file,
0053             level=customLogLevel(maxLevel=acts.logging.INFO),
0054         )
0055 
0056     dd4hepConfig = acts.examples.dd4hep.DD4hepGeometryService.Config(
0057         xmlFileNames=[xmlFile],
0058         logLevel=logLevel,
0059         dd4hepLogLevel=customLogLevel(),
0060     )
0061     detector = acts.examples.dd4hep.DD4hepDetector()
0062 
0063     config = acts.MaterialMapJsonConverter.Config()
0064 
0065     trackingGeometry, deco = detector.finalize(dd4hepConfig, matDeco)
0066 
0067     return detector, trackingGeometry, deco