Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-11-26 09:23:20

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 import tempfile
0011 
0012 import detray.core
0013 import detray.io
0014 import detray.tests
0015 
0016 
0017 def test_generate_and_read_detector():
0018     # Use the toy generator to produce detector files to read back.
0019     out_dir = tempfile.mkdtemp() + os.sep
0020 
0021     det, det_names = detray.tests.build_toy_detector(
0022         detray.core.HostMemoryResource(), detray.tests.ToyDetectorConfig()
0023     )
0024 
0025     writer_config = detray.io.DetectorWriterConfig()
0026     writer_config.path = out_dir
0027     detray.io.write_detector_json(det, det_names, writer_config)
0028 
0029     geometry_file = os.path.join(out_dir, "toy_detector_geometry.json")
0030     assert os.path.exists(geometry_file)
0031 
0032     reader_config = detray.io.DetectorReaderConfig().add_file(geometry_file)
0033 
0034     detector, names = detray.io.read_detector_json(
0035         detray.core.HostMemoryResource(), reader_config
0036     )
0037     assert isinstance(names, detray.core.NameMap)
0038     assert len(detector.volumes) == 22
0039     assert len(detector.surfaces) == 3230