Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-27 07:24:19

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 // Project include(s)
0010 #include "detray/definitions/units.hpp"
0011 
0012 // Detray IO include(s)
0013 #include "detray/io/frontend/detector_writer.hpp"
0014 
0015 // Detray test include(s)
0016 #include "detray/options/detector_io_options.hpp"
0017 #include "detray/options/parse_options.hpp"
0018 #include "detray/options/toy_detector_options.hpp"
0019 #include "detray/test/common/build_toy_detector.hpp"
0020 #include "detray/test/framework/types.hpp"
0021 
0022 // Vecmem include(s)
0023 #include <vecmem/memory/host_memory_resource.hpp>
0024 
0025 // Boost
0026 #include "detray/options/boost_program_options.hpp"
0027 
0028 namespace po = boost::program_options;
0029 
0030 using namespace detray;
0031 
0032 int main(int argc, char **argv) {
0033   // Configuration
0034   detray::toy_det_config<test::scalar> toy_cfg{};
0035   detray::io::detector_writer_config writer_cfg{};
0036   writer_cfg.format(detray::io::format::json).replace_files(false);
0037   // Default output path
0038   writer_cfg.path("./toy_detector/");
0039 
0040   // Specific options for this test
0041   po::options_description desc("\nToy detector generation options");
0042 
0043   desc.add_options()("write_volume_graph", "Write the volume graph to file");
0044 
0045   po::variables_map vm =
0046       detray::options::parse_options(desc, argc, argv, toy_cfg, writer_cfg);
0047 
0048   // Make sure material is written to file, if it was requested
0049   writer_cfg.write_material(vm.count("homogeneous_material") != 0u ||
0050                             vm.count("material_maps") != 0u ||
0051                             vm.count("write_material") != 0u);
0052 
0053   // Build the geometry
0054   vecmem::host_memory_resource host_mr;
0055   auto [toy_det, toy_names] =
0056       build_toy_detector<test::algebra>(host_mr, toy_cfg);
0057 
0058   // Write to file
0059   detray::io::write_detector(toy_det, toy_names, writer_cfg);
0060 
0061   // General options
0062   if (vm.count("write_volume_graph") != 0u) {
0063     throw std::invalid_argument("Writing of volume graph not implemented");
0064   }
0065 }