Back to home page

EIC code displayed by LXR

 
 

    


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

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/Applicability.hh
0006 //---------------------------------------------------------------------------//
0007 #pragma once
0008 
0009 #include <functional>
0010 #include <tuple>
0011 
0012 #include "corecel/Assert.hh"
0013 #include "corecel/OpaqueId.hh"
0014 #include "corecel/Types.hh"
0015 #include "celeritas/Quantities.hh"
0016 #include "celeritas/Types.hh"
0017 
0018 namespace celeritas
0019 {
0020 //---------------------------------------------------------------------------//
0021 /*!
0022  * Range where a model and/or process is valid.
0023  *
0024  * This class is used during setup for specifying the ranges of applicability
0025  * for a physics model or process. The interval is *closed* on the lower energy
0026  * range and *open* on the upper energy. So a threshold reaction should have
0027  * the lower energy set to the threshold.
0028  *
0029  * An unset value for "material" means it applies to all materials; however,
0030  * the particle ID should always be set.
0031  */
0032 struct Applicability
0033 {
0034     using EnergyUnits = units::Mev;
0035     using Energy = RealQuantity<EnergyUnits>;
0036 
0037     PhysMatId material{};
0038     ParticleId particle{};
0039     Energy lower = zero_quantity();
0040     Energy upper = max_quantity();
0041 
0042     //! Whether applicability is in a valid state
0043     inline explicit operator bool() const
0044     {
0045         return static_cast<bool>(particle) && lower < upper;
0046     }
0047 };
0048 
0049 //!@{
0050 //! Comparators
0051 inline bool operator==(Applicability const& lhs, Applicability const& rhs)
0052 {
0053     return std::make_tuple(lhs.material, lhs.particle, lhs.lower, lhs.upper)
0054            == std::make_tuple(rhs.material, rhs.particle, rhs.lower, rhs.upper);
0055 }
0056 
0057 inline bool operator<(Applicability const& lhs, Applicability const& rhs)
0058 {
0059     return std::make_tuple(lhs.material, lhs.particle, lhs.lower, lhs.upper)
0060            < std::make_tuple(rhs.material, rhs.particle, rhs.lower, rhs.upper);
0061 }
0062 //!@}
0063 
0064 //---------------------------------------------------------------------------//
0065 }  // namespace celeritas