Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-05 08:18:37

0001 # This file is part of the ACTS project.
0002 #
0003 # Copyright (C) 2016 CERN for the benefit of the ACTS project
0004 #
0005 # This Source Code Form is subject to the terms of the Mozilla Public
0006 # License, v. 2.0. If a copy of the MPL was not distributed with this
0007 # file, You can obtain one at https://mozilla.org/MPL/2.0/.
0008 
0009 import os
0010 
0011 import pytest
0012 
0013 import detray.core
0014 import detray.examples
0015 import detray.io
0016 
0017 
0018 @pytest.fixture(scope="session")
0019 def toy_detector_files(tmp_path_factory):
0020     """Write a toy detector to disk."""
0021     out_dir = str(tmp_path_factory.mktemp("toy_detector")) + os.sep
0022     detray.examples.generateToyDetector(outputDir=out_dir)
0023 
0024     files = {
0025         "geometry": os.path.join(out_dir, "toy_detector_geometry.json"),
0026         "material": os.path.join(out_dir, "toy_detector_homogeneous_material.json"),
0027     }
0028     for path in files.values():
0029         assert os.path.exists(path)
0030     return files
0031 
0032 
0033 @pytest.fixture(scope="session")
0034 def detector(toy_detector_files):
0035     """Read the toy detector."""
0036     reader_config = (
0037         detray.io.DetectorReaderConfig()
0038         .addFile(toy_detector_files["geometry"])
0039         .addFile(toy_detector_files["material"])
0040     )
0041     return detray.io.readDetector(detray.core.HostMemoryResource(), reader_config)