Back to home page

EIC code displayed by LXR

 
 

    


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

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 "propagation.hpp"
0011 
0012 #include "detray/test/common/build_toy_detector.hpp"
0013 #include "detray/test/common/track_generators.hpp"
0014 
0015 // Vecmem include(s)
0016 #include <vecmem/memory/cuda/device_memory_resource.hpp>
0017 #include <vecmem/memory/cuda/managed_memory_resource.hpp>
0018 #include <vecmem/utils/cuda/copy.hpp>
0019 
0020 // System
0021 
0022 /// Prepare the data and move it to device
0023 int main() {
0024   std::clog << "Device Propagation Tutorial\n====================\n\n";
0025 
0026   // VecMem memory resource(s)
0027   vecmem::cuda::managed_memory_resource mng_mr;
0028 
0029   // Create the host bfield
0030   auto bfield = detray::create_inhom_field<detray::tutorial::scalar>();
0031 
0032   // Create the toy geometry
0033   auto [det, names] =
0034       detray::build_toy_detector<detray::tutorial::algebra_t>(mng_mr);
0035 
0036   // Create the vector of initial track parameters
0037   vecmem::vector<detray::tutorial::track_t> tracks(&mng_mr);
0038 
0039   // Track directions to be generated
0040   constexpr unsigned int theta_steps{10u};
0041   constexpr unsigned int phi_steps{10u};
0042   // Set momentum of tracks
0043   const detray::tutorial::scalar p_mag{
0044       10.f * detray::unit<detray::tutorial::scalar>::GeV};
0045 
0046   // Generate the tracks
0047   for (auto track : detray::uniform_track_generator<detray::tutorial::track_t>(
0048            phi_steps, theta_steps, p_mag)) {
0049     // Put it into vector of tracks
0050     tracks.push_back(track);
0051   }
0052 
0053   // Get data for device
0054   auto det_data = detray::get_data(det);
0055   covfie::field<detray::bfield::cuda::inhom_bknd_t<detray::tutorial::scalar>>
0056       device_bfield(bfield);
0057   auto tracks_data = detray::get_data(tracks);
0058 
0059   // Run the propagator test for GPU device
0060   detray::tutorial::propagation(det_data, device_bfield, tracks_data);
0061 }