Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-22 10:31:31

0001 //----------------------------------*-C++-*----------------------------------//
0002 // Copyright 2023-2024 UT-Battelle, LLC, and other Celeritas developers.
0003 // See the top-level COPYRIGHT file for details.
0004 // SPDX-License-Identifier: (Apache-2.0 OR MIT)
0005 //---------------------------------------------------------------------------//
0006 //! \file celeritas/track/SortTracksAction.hh
0007 //---------------------------------------------------------------------------//
0008 #pragma once
0009 
0010 #include "celeritas/global/ActionInterface.hh"
0011 
0012 namespace celeritas
0013 {
0014 //---------------------------------------------------------------------------//
0015 /*!
0016  * Sort tracks according to a given strategy specified by TrackOrder.
0017  *
0018  * This action can be applied at different stage of a simulation step,
0019  * automatically determined by TrackOrder. This should not have any impact on
0020  * simulation output: it is only useful for GPU device optimizations.
0021  *
0022  * \todo Keep weak pointer to actions? Use aux data?
0023  */
0024 class SortTracksAction final : public CoreStepActionInterface,
0025                                public CoreBeginRunActionInterface
0026 {
0027   public:
0028     // Construct with action ID and sort criteria
0029     SortTracksAction(ActionId id, TrackOrder track_order);
0030 
0031     //! Default destructor
0032     ~SortTracksAction() = default;
0033 
0034     //! Execute the action with host data
0035     void step(CoreParams const& params, CoreStateHost& state) const final;
0036 
0037     //! Execute the action with device data
0038     void step(CoreParams const& params, CoreStateDevice& state) const final;
0039 
0040     //! Set host data at the beginning of a run
0041     void begin_run(CoreParams const&, CoreStateHost&) final;
0042 
0043     //! Set device data at the beginning of a run
0044     void begin_run(CoreParams const&, CoreStateDevice&) final;
0045 
0046     //! ID of the action
0047     ActionId action_id() const final { return id_; }
0048 
0049     //! Short name for the action
0050     std::string_view label() const final;
0051 
0052     //! Description of the action for user interaction
0053     std::string_view description() const final { return "sort tracks states"; }
0054 
0055     //! Dependency ordering of the action
0056     StepActionOrder order() const final { return action_order_; }
0057 
0058   private:
0059     ActionId id_;
0060     StepActionOrder action_order_{StepActionOrder::size_};
0061     TrackOrder track_order_;
0062 };
0063 
0064 //---------------------------------------------------------------------------//
0065 }  // namespace celeritas