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/algebra.hpp"
0011 #include "detray/definitions/units.hpp"
0012 #include "detray/geometry/shapes/line.hpp"
0013 
0014 // Detray IO include(s)
0015 #include "detray/io/frontend/detector_writer.hpp"
0016 
0017 // Detray test include(s)
0018 #include "detray/options/detector_io_options.hpp"
0019 #include "detray/options/parse_options.hpp"
0020 #include "detray/options/wire_chamber_options.hpp"
0021 #include "detray/test/common/build_wire_chamber.hpp"
0022 #include "detray/test/framework/types.hpp"
0023 
0024 // Vecmem include(s)
0025 #include <vecmem/memory/host_memory_resource.hpp>
0026 #include <vecmem/memory/memory_resource.hpp>
0027 
0028 // Boost
0029 #include "detray/options/boost_program_options.hpp"
0030 
0031 namespace po = boost::program_options;
0032 
0033 namespace detray::detail {
0034 
0035 /// Build and write the wire chamber according to command line options
0036 template <concepts::scalar scalar_t, typename wire_shape_t>
0037 void write_wire_chamber(int argc, char **argv,
0038                         boost::program_options::options_description &desc,
0039                         vecmem::memory_resource *host_mr,
0040                         detray::io::detector_writer_config &writer_cfg) {
0041   detray::wire_chamber_config<scalar_t, wire_shape_t> wire_cfg{};
0042 
0043   po::variables_map vm_wire =
0044       detray::options::parse_options(desc, argc, argv, wire_cfg);
0045 
0046   auto [wire_chamber, names] =
0047       build_wire_chamber<test::algebra>(*host_mr, wire_cfg);
0048   detray::io::write_detector(wire_chamber, names, writer_cfg);
0049 }
0050 
0051 }  // namespace detray::detail
0052 
0053 using namespace detray;
0054 
0055 int main(int argc, char **argv) {
0056   // Options parsing
0057   po::options_description desc("\nWire chamber generation options");
0058 
0059   desc.add_options()("write_volume_graph", "writes the volume graph to file");
0060   desc.add_options()("straw_tubes", "build the detector using straw tubes");
0061   desc.add_options()("drift_cells",
0062                      "build the detector using wire chamber cells");
0063 
0064   // Configuration
0065   detray::io::detector_writer_config writer_cfg{};
0066   writer_cfg.format(detray::io::format::json).replace_files(false);
0067   // Default output path
0068   writer_cfg.path("./wire_chamber/");
0069 
0070   // Parse general options
0071   po::variables_map vm =
0072       detray::options::parse_options(desc, argc, argv, writer_cfg);
0073 
0074   // General options
0075   if (vm.count("write_volume_graph") != 0u) {
0076     throw std::invalid_argument("Writing of volume graph not implemented");
0077   }
0078 
0079   // Determine the wire shape
0080   if (vm.count("straw_tubes") != 0u && vm.count("drift_cells") != 0u) {
0081     throw std::invalid_argument(
0082         "Cannot build straw tubes and wire cells together");
0083   }
0084 
0085   // Build the geometry
0086   vecmem::host_memory_resource host_mr;
0087   if (vm.count("straw_tubes") != 0u) {
0088     detail::write_wire_chamber<detray::test::scalar, detray::line_circular>(
0089         argc, argv, desc, &host_mr, writer_cfg);
0090   } else {
0091     detail::write_wire_chamber<detray::test::scalar, detray::line_square>(
0092         argc, argv, desc, &host_mr, writer_cfg);
0093   }
0094 }