Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-18 09:09:12

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/phys/CutoffData.hh
0006 //---------------------------------------------------------------------------//
0007 #pragma once
0008 
0009 #include "corecel/data/Collection.hh"
0010 #include "celeritas/Quantities.hh"
0011 #include "celeritas/Types.hh"
0012 
0013 namespace celeritas
0014 {
0015 //---------------------------------------------------------------------------//
0016 /*!
0017  * Store secondary cutoff information.
0018  */
0019 struct ParticleCutoff
0020 {
0021     units::MevEnergy energy{};  //!< Converted range value
0022     real_type range{};  //!< [len]
0023 };
0024 
0025 //---------------------------------------------------------------------------//
0026 /*!
0027  * IDs of particles that can be killed post-interaction.
0028  *
0029  * The ID will be valid if the \c apply_post_interaction option is enabled and
0030  * the particle is present in the problem.
0031  */
0032 struct CutoffIds
0033 {
0034     ParticleId gamma;
0035     ParticleId electron;
0036     ParticleId positron;
0037 };
0038 
0039 //---------------------------------------------------------------------------//
0040 /*!
0041  * Persistent shared cutoff data.
0042  *
0043  * Secondary production cuts are stored for every material and for only the
0044  * particle types to which production cuts apply. Positron production cuts are
0045  * only used when the post-interaction cutoff is enabled. Proton production
0046  * cuts are currently unused.
0047  *
0048  * \sa CutoffView
0049  * \sa CutoffParams
0050  */
0051 template<Ownership W, MemSpace M>
0052 struct CutoffParamsData
0053 {
0054     template<class T>
0055     using Items = Collection<T, W, M>;
0056     template<class T>
0057     using ParticleItems = Collection<T, W, M, ParticleId>;
0058 
0059     // Backend storage
0060     Items<ParticleCutoff> cutoffs;  //!< [num_materials][num_particles]
0061 
0062     // Direct address table for mapping particle ID to index in cutoffs
0063     ParticleItems<size_type> id_to_index;
0064 
0065     ParticleId::size_type num_particles;  //!< Particles with production cuts
0066     PhysMatId::size_type num_materials;  //!< All materials in the problem
0067 
0068     bool apply_post_interaction{false};  //!< Apply cutoff post-interaction
0069     CutoffIds ids;  //!< Secondaries that can be killed post-interaction if
0070                     //!< their energy is below the production cut
0071 
0072     //// MEMBER FUNCTIONS ////
0073 
0074     //! True if assigned
0075     explicit CELER_FUNCTION operator bool() const
0076     {
0077         return cutoffs.size() == num_particles * num_materials
0078                && !cutoffs.empty() && !id_to_index.empty();
0079     }
0080 
0081     //! Assign from another set of data
0082     template<Ownership W2, MemSpace M2>
0083     CutoffParamsData& operator=(CutoffParamsData<W2, M2> const& other)
0084     {
0085         CELER_EXPECT(other);
0086 
0087         this->cutoffs = other.cutoffs;
0088         this->id_to_index = other.id_to_index;
0089         this->num_particles = other.num_particles;
0090         this->num_materials = other.num_materials;
0091         this->apply_post_interaction = other.apply_post_interaction;
0092         this->ids = other.ids;
0093 
0094         return *this;
0095     }
0096 };
0097 
0098 //---------------------------------------------------------------------------//
0099 }  // namespace celeritas