Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-11-07 10:11:36

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/mucf/interactor/TTMucfInteractor.hh
0006 //---------------------------------------------------------------------------//
0007 #pragma once
0008 
0009 #include "corecel/Macros.hh"
0010 #include "corecel/data/StackAllocator.hh"
0011 #include "celeritas/mat/ElementView.hh"
0012 #include "celeritas/mat/MaterialView.hh"
0013 #include "celeritas/mucf/data/DTMixMucfData.hh"
0014 #include "celeritas/phys/Interaction.hh"
0015 #include "celeritas/phys/ParticleTrackView.hh"
0016 #include "celeritas/phys/Secondary.hh"
0017 
0018 namespace celeritas
0019 {
0020 //---------------------------------------------------------------------------//
0021 /*!
0022  * Muon-catalyzed fusion of \f$ (tt)_\mu \f$ molecules.
0023  *
0024  * Fusion channels:
0025  * - \f$ \alpha + \mu + n + n \f$
0026  * - \f$ (\alpha)_\mu + n + n \f$
0027  */
0028 class TTMucfInteractor
0029 {
0030   public:
0031     enum class Channel
0032     {
0033         alpha_muon_neutron_neutron,  //!< \f$ \alpha + \mu + n + n \f$
0034         muonicalpha_neutron_neutron,  //!< \f$ (\alpha)_\mu + n + n \f$
0035         size_
0036     };
0037 
0038     // Construct from shared and state data
0039     inline CELER_FUNCTION TTMucfInteractor(
0040         NativeCRef<DTMixMucfData> const& data,
0041         Channel channel,
0042         StackAllocator<Secondary>& allocate);
0043 
0044     // Sample an interaction with the given RNG
0045     template<class Engine>
0046     inline CELER_FUNCTION Interaction operator()(Engine& rng);
0047 
0048   private:
0049     // Shared constant physics properties
0050     NativeCRef<DTMixMucfData> const& data_;
0051     // Selected fusion channel
0052     Channel channel_{Channel::size_};
0053     // Allocate space for secondary particles
0054     StackAllocator<Secondary>& allocate_;
0055     // Number of secondaries per channel
0056     EnumArray<Channel, size_type> num_secondaries_{
0057         4,  // alpha_muon_neutron_neutron
0058         3  // muonicalpha_neutron_neutron
0059     };
0060 
0061     // Sample Interaction secondaries
0062     template<class Engine>
0063     inline CELER_FUNCTION Span<Secondary> sample_secondaries(
0064         Secondary* secondaries /*, other args */, Engine&);
0065 };
0066 
0067 //---------------------------------------------------------------------------//
0068 // INLINE DEFINITIONS
0069 //---------------------------------------------------------------------------//
0070 /*!
0071  * Construct with shared and state data.
0072  */
0073 CELER_FUNCTION TTMucfInteractor::TTMucfInteractor(
0074     NativeCRef<DTMixMucfData> const& data,
0075     Channel const channel,
0076     StackAllocator<Secondary>& allocate)
0077     : data_(data), channel_(channel), allocate_(allocate)
0078 {
0079     CELER_EXPECT(data_);
0080     CELER_EXPECT(channel_ < Channel::size_);
0081 }
0082 
0083 //---------------------------------------------------------------------------//
0084 /*!
0085  * Sample a tt muonic molecule fusion.
0086  */
0087 template<class Engine>
0088 CELER_FUNCTION Interaction TTMucfInteractor::operator()(Engine& rng)
0089 {
0090     // Allocate space for the final fusion channel
0091     Secondary* secondaries = allocate_(num_secondaries_[channel_]);
0092     if (secondaries == nullptr)
0093     {
0094         // Failed to allocate space for secondaries
0095         return Interaction::from_failure();
0096     }
0097 
0098     // Kill primary and generate secondaries
0099     Interaction result = Interaction::from_absorption();
0100     result.secondaries = this->sample_secondaries(secondaries, rng);
0101 
0102     return result;
0103 }
0104 
0105 //---------------------------------------------------------------------------//
0106 /*!
0107  * Sample the secondaries of the selected channel.
0108  *
0109  * Since secondaries come from an at rest interaction, their final state is
0110  * a simple combination of random direction + momentum conservation
0111  */
0112 template<class Engine>
0113 CELER_FUNCTION Span<Secondary> TTMucfInteractor::sample_secondaries(
0114     Secondary* secondaries /*, other args */, Engine&)
0115 {
0116     // TODO: switch on channel_
0117     CELER_ASSERT_UNREACHABLE();
0118 
0119     return Span<Secondary>{secondaries, num_secondaries_[channel_]};
0120 }
0121 
0122 //---------------------------------------------------------------------------//
0123 }  // namespace celeritas