Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-11-05 10:27: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/em/xs/GammaNuclearMicroXsCalculator.hh
0006 //---------------------------------------------------------------------------//
0007 #pragma once
0008 
0009 #include "corecel/Macros.hh"
0010 #include "corecel/Types.hh"
0011 #include "celeritas/Quantities.hh"
0012 #include "celeritas/Types.hh"
0013 #include "celeritas/em/data/GammaNuclearData.hh"
0014 #include "celeritas/grid/NonuniformGridCalculator.hh"
0015 
0016 namespace celeritas
0017 {
0018 //---------------------------------------------------------------------------//
0019 /*!
0020  * Calculate gamma-nuclear cross sections using the gamma-nuclear data.
0021  */
0022 class GammaNuclearMicroXsCalculator
0023 {
0024   public:
0025     //!@{
0026     //! \name Type aliases
0027     using ParamsRef = NativeCRef<GammaNuclearData>;
0028     using Energy = units::MevEnergy;
0029     using BarnXs = units::BarnXs;
0030     //!@}
0031 
0032   public:
0033     // Construct with shared and state data
0034     inline CELER_FUNCTION GammaNuclearMicroXsCalculator(
0035         ParamsRef const& shared, Energy energy);
0036 
0037     // Compute cross section
0038     inline CELER_FUNCTION BarnXs operator()(ElementId el_id) const;
0039 
0040   private:
0041     // Shared cross section data
0042     ParamsRef const& data_;
0043     // Incident photon energy
0044     real_type const inc_energy_;
0045 };
0046 
0047 //---------------------------------------------------------------------------//
0048 // INLINE DEFINITIONS
0049 //---------------------------------------------------------------------------//
0050 /*!
0051  * Construct with shared and state data.
0052  */
0053 CELER_FUNCTION GammaNuclearMicroXsCalculator::GammaNuclearMicroXsCalculator(
0054     ParamsRef const& data, Energy energy)
0055     : data_(data), inc_energy_(energy.value())
0056 {
0057 }
0058 
0059 //---------------------------------------------------------------------------//
0060 /*!
0061  * Compute microscopic gamma-nuclear cross section at the given gamma energy.
0062  */
0063 CELER_FUNCTION auto GammaNuclearMicroXsCalculator::operator()(
0064     ElementId el_id) const -> BarnXs
0065 {
0066     NonuniformGridRecord grid;
0067 
0068     // Use G4PARTICLEXS gamma-nuclear cross sections at low energy and CHIPS
0069     // parameterized cross sections at high energy.
0070 
0071     if (inc_energy_ <= data_.reals[data_.xs_iaea[el_id].grid.back()])
0072     {
0073         CELER_EXPECT(el_id < data_.xs_iaea.size());
0074         grid = data_.xs_iaea[el_id];
0075     }
0076     else
0077     {
0078         CELER_EXPECT(el_id < data_.xs_chips.size());
0079         grid = data_.xs_chips[el_id];
0080     }
0081 
0082     // Calculate micro cross section at the given energy
0083     NonuniformGridCalculator calc_xs(grid, data_.reals);
0084     real_type result = calc_xs(inc_energy_);
0085 
0086     return BarnXs{result};
0087 }
0088 
0089 //---------------------------------------------------------------------------//
0090 }  // namespace celeritas