Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-17 08:53:48

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/user/detail/StepParams.hh
0006 //---------------------------------------------------------------------------//
0007 #pragma once
0008 
0009 #include "corecel/data/AuxInterface.hh"
0010 #include "corecel/data/CollectionMirror.hh"
0011 #include "corecel/data/ParamsDataInterface.hh"
0012 #include "celeritas/geo/GeoFwd.hh"
0013 
0014 #include "../StepData.hh"
0015 
0016 namespace celeritas
0017 {
0018 class AuxStateVec;
0019 class StepInterface;
0020 
0021 namespace detail
0022 {
0023 //---------------------------------------------------------------------------//
0024 /*!
0025  * Manage params and state data for step collector.
0026  *
0027  * \todo Move out of detail, take core params/state to copy detector steps? Not
0028  * currently possible right now because the step interface doesn't take params.
0029  */
0030 class StepParams : public ParamsDataInterface<StepParamsData>,
0031                    public AuxParamsInterface
0032 {
0033   public:
0034     //!@{
0035     //! \name Type aliases
0036     using SPStepInterface = std::shared_ptr<StepInterface>;
0037     using VecInterface = std::vector<SPStepInterface>;
0038     //!@}
0039 
0040   public:
0041     // Construct from data IDs and interfaces
0042     StepParams(AuxId aux_id,
0043                GeoParams const& geo,
0044                VecInterface const& interfaces);
0045 
0046     //!@{
0047     //! \name Aux interface
0048 
0049     //! Short name for the aux data
0050     std::string_view label() const final { return "detector-step"; }
0051     //! Index of this class instance in its registry
0052     AuxId aux_id() const final { return aux_id_; }
0053     // Build core state data for a stream
0054     UPState create_state(MemSpace, StreamId, size_type) const final;
0055     //!@}
0056 
0057     //!@{
0058     //! \name Data interface
0059 
0060     //! Access physics properties on the host
0061     HostRef const& host_ref() const final { return mirror_.host_ref(); }
0062     //! Access physics properties on the device
0063     DeviceRef const& device_ref() const final { return mirror_.device_ref(); }
0064     //!@}
0065 
0066     // Access state
0067     template<MemSpace M>
0068     StepStateData<Ownership::reference, M>& state_ref(AuxStateVec&) const;
0069 
0070     // Access data selection
0071     inline StepSelection const& selection() const;
0072 
0073     // Whether detectors are defined (false to gather *all* data)
0074     inline bool has_detectors() const;
0075 
0076   private:
0077     AuxId aux_id_;
0078     CollectionMirror<StepParamsData> mirror_;
0079 };
0080 
0081 //---------------------------------------------------------------------------//
0082 /*!
0083  * See which data are being gathered.
0084  */
0085 StepSelection const& StepParams::selection() const
0086 {
0087     return this->host_ref().selection;
0088 }
0089 //---------------------------------------------------------------------------//
0090 /*!
0091  * Whether detectors are defined (false to gather *all* data).
0092  */
0093 bool StepParams::has_detectors() const
0094 {
0095     return !this->host_ref().detector.empty();
0096 }
0097 
0098 //---------------------------------------------------------------------------//
0099 }  // namespace detail
0100 }  // namespace celeritas