Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/celeritas/optical/action/detail/InitTracksExecutor.hh was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 //------------------------------- -*- C++ -*- -------------------------------//
0002 // Copyright Celeritas contributors: see top-level COPYRIGHT file for details
0003 // SPDX-License-Identifier: (Apache-2.0 OR MIT)
0004 //---------------------------------------------------------------------------//
0005 //! \file celeritas/optical/action/detail/InitTracksExecutor.hh
0006 //---------------------------------------------------------------------------//
0007 #pragma once
0008 
0009 #include "corecel/Assert.hh"
0010 #include "corecel/Macros.hh"
0011 #include "celeritas/Types.hh"
0012 #include "celeritas/optical/CoreTrackData.hh"
0013 #include "celeritas/optical/CoreTrackView.hh"
0014 #include "celeritas/track/CoreStateCounters.hh"
0015 
0016 namespace celeritas
0017 {
0018 namespace optical
0019 {
0020 namespace detail
0021 {
0022 //---------------------------------------------------------------------------//
0023 /*!
0024  * Initialize the track states.
0025  *
0026  * The track initializers are created from either primary particles or
0027  * secondaries. The new tracks are inserted into the vacancies in the track
0028  * vector.
0029  */
0030 struct InitTracksExecutor
0031 {
0032     //// TYPES ////
0033 
0034     using ParamsPtr = CRefPtr<CoreParamsData, MemSpace::native>;
0035     using StatePtr = RefPtr<CoreStateData, MemSpace::native>;
0036 
0037     //// DATA ////
0038 
0039     ParamsPtr params;
0040     StatePtr state;
0041     CoreStateCounters counters;
0042 
0043     //// FUNCTIONS ////
0044 
0045     // Initialize track states
0046     inline CELER_FUNCTION void operator()(TrackSlotId tid) const;
0047 
0048     CELER_FORCEINLINE_FUNCTION void operator()(ThreadId tid) const
0049     {
0050         return (*this)(TrackSlotId{tid.unchecked_get()});
0051     }
0052 };
0053 
0054 //---------------------------------------------------------------------------//
0055 /*!
0056  * Initialize the track states.
0057  */
0058 CELER_FUNCTION void InitTracksExecutor::operator()(TrackSlotId tid) const
0059 {
0060     CELER_EXPECT(tid < counters.num_initializers);
0061     CELER_EXPECT(tid < counters.num_vacancies);
0062 
0063     // Create the view to the new track to be initialized
0064     CoreTrackView vacancy{*params, *state, state->init.vacancies[tid]};
0065 
0066     // Get the initializer from the back of the vector and initialize the track
0067     vacancy = state->init.initializers[ItemId<TrackInitializer>(
0068         counters.num_initializers - tid.get() - 1)];
0069 }
0070 
0071 //---------------------------------------------------------------------------//
0072 }  // namespace detail
0073 }  // namespace optical
0074 }  // namespace celeritas