File indexing completed on 2026-05-27 07:24:26
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #include "detray/definitions/units.hpp"
0011 #include "detray/geometry/mask.hpp"
0012 #include "detray/navigation/volume_graph.hpp"
0013 #include "detray/test/common/build_telescope_detector.hpp"
0014 #include "detray/test/common/build_toy_detector.hpp"
0015 #include "detray/tracks/tracks.hpp"
0016 #include "detray/tracks/trajectories.hpp"
0017
0018
0019 #include "detray/tutorial/types.hpp"
0020
0021
0022 #include <vecmem/memory/host_memory_resource.hpp>
0023
0024
0025 #include <cstdlib>
0026 #include <iostream>
0027
0028
0029
0030
0031
0032
0033 int main(int argc, char** argv) {
0034 using algebra_t = detray::tutorial::algebra_t;
0035 using scalar = detray::tutorial::scalar;
0036
0037 std::clog << "Detector Tutorial\n=================\n\n";
0038
0039
0040 vecmem::host_memory_resource host_mr;
0041
0042
0043
0044
0045 detray::toy_det_config<scalar> toy_cfg{};
0046
0047 toy_cfg.n_brl_layers(4u);
0048
0049
0050
0051 toy_cfg.n_edc_layers(1u);
0052
0053
0054 if (argc == 3) {
0055 toy_cfg.n_brl_layers(
0056 static_cast<unsigned int>(std::abs(std::atoi(argv[1]))));
0057 toy_cfg.n_edc_layers(
0058 static_cast<unsigned int>(std::abs(std::atoi(argv[2]))));
0059 }
0060
0061
0062 const auto [toy_det, names] =
0063 detray::build_toy_detector<algebra_t>(host_mr, toy_cfg);
0064
0065
0066 std::clog << "\nToy detector:\n"
0067 << "-------------\n"
0068 << detray::volume_graph{toy_det}.to_string() << std::endl;
0069
0070
0071
0072
0073
0074
0075
0076
0077
0078
0079
0080
0081 constexpr detray::dindex vol_nav_link{0u};
0082
0083
0084 std::vector<scalar> positions = {
0085 0.f * detray::unit<scalar>::mm, 50.f * detray::unit<scalar>::mm,
0086 100.f * detray::unit<scalar>::mm, 150.f * detray::unit<scalar>::mm,
0087 200.f * detray::unit<scalar>::mm, 250.f * detray::unit<scalar>::mm,
0088 300.f * detray::unit<scalar>::mm, 350.f * detray::unit<scalar>::mm,
0089 400.f * detray::unit<scalar>::mm, 450.f * detray::unit<scalar>::mm,
0090 500.f * detray::unit<scalar>::mm};
0091
0092
0093
0094
0095
0096 const auto [tel_det1, tel_names1] =
0097 detray::build_telescope_detector<algebra_t, detray::rectangle2D>(host_mr);
0098
0099 std::clog << "\nTelescope detector - case 1:\n"
0100 << "----------------------------\n"
0101 << detray::volume_graph{tel_det1}.to_string() << std::endl;
0102
0103
0104
0105
0106
0107
0108 using trapezoid_t = detray::mask<detray::trapezoid2D, algebra_t>;
0109
0110 constexpr scalar hx_min_y{10.f * detray::unit<scalar>::mm};
0111 constexpr scalar hx_max_y{30.f * detray::unit<scalar>::mm};
0112 constexpr scalar hy{20.f * detray::unit<scalar>::mm};
0113 constexpr scalar divisor{10.f / (20.f * hy)};
0114 trapezoid_t trapezoid{vol_nav_link, hx_min_y, hx_max_y, hy, divisor};
0115
0116 detray::tel_det_config trp_cfg{trapezoid};
0117 trp_cfg.n_surfaces(15).length(2000.f * detray::unit<scalar>::mm);
0118
0119 const auto [tel_det2, tel_names2] =
0120 detray::build_telescope_detector<algebra_t>(host_mr, trp_cfg);
0121
0122 std::clog << "\nTelescope detector - case 2:\n"
0123 << "----------------------------\n"
0124 << detray::volume_graph{tel_det2}.to_string() << std::endl;
0125
0126
0127
0128
0129
0130
0131
0132 detray::mask<detray::rectangle2D, algebra_t> rectangle{
0133 vol_nav_link, 20.f * detray::unit<scalar>::mm,
0134 20.f * detray::unit<scalar>::mm};
0135
0136
0137 detray::detail::ray<algebra_t> x_track{
0138 {0.f, 0.f, 0.f}, 0.f, {1.f, 0.f, 0.f}, -1.f};
0139
0140 detray::tel_det_config rct_cfg{rectangle};
0141 rct_cfg.positions(positions).pilot_track(x_track);
0142
0143 const auto [tel_det3, tel_names3] =
0144 build_telescope_detector<algebra_t>(host_mr, rct_cfg);
0145
0146 std::clog << "\nTelescope detector - case 3:\n"
0147 << "----------------------------\n"
0148 << detray::volume_graph{tel_det3}.to_string() << std::endl;
0149
0150
0151
0152
0153
0154
0155
0156 detray::free_track_parameters<algebra_t> y_track{
0157 {0.f, 0.f, 0.f}, 0.f, {1.f, 0.f, 0.f}, -1.f};
0158
0159
0160 using helix_t = detray::detail::helix<algebra_t>;
0161 detray::tutorial::vector3 B_z{0.f, 0.f, 1.f * detray::unit<scalar>::T};
0162 helix_t helix(y_track, B_z);
0163
0164 detray::tel_det_config htrp_cfg{trapezoid, helix};
0165 htrp_cfg.positions(positions);
0166
0167 const auto [tel_det4, tel_names4] =
0168 detray::build_telescope_detector<algebra_t>(host_mr, htrp_cfg);
0169
0170 std::clog << "\nTelescope detector - case 4:\n"
0171 << "----------------------------\n"
0172 << detray::volume_graph{tel_det4}.to_string() << std::endl;
0173 }