Back to home page

EIC code displayed by LXR

 
 

    


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

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/model/detail/MuHadIonizationBuilder.hh
0006 //---------------------------------------------------------------------------//
0007 #pragma once
0008 
0009 #include <set>
0010 #include <string_view>
0011 
0012 #include "celeritas/Quantities.hh"
0013 #include "celeritas/em/data/MuHadIonizationData.hh"
0014 #include "celeritas/phys/Applicability.hh"
0015 #include "celeritas/phys/ParticleParams.hh"
0016 
0017 namespace celeritas
0018 {
0019 namespace detail
0020 {
0021 //---------------------------------------------------------------------------//
0022 /*!
0023  * Construct muon and hadron ionization data.
0024  *
0025  * This small helper class constructs and validates the data for the muon and
0026  * hadron ionization models.
0027  */
0028 class MuHadIonizationBuilder
0029 {
0030   public:
0031     //!@{
0032     //! \name Type aliases
0033     using Energy = units::MevEnergy;
0034     using SetApplicability = std::set<Applicability>;
0035     //!@}
0036 
0037   public:
0038     // Construct with shared particle data and model label
0039     inline MuHadIonizationBuilder(ParticleParams const& particles,
0040                                   std::string_view label);
0041 
0042     // Construct model data from applicability
0043     inline MuHadIonizationData operator()(SetApplicability const&) const;
0044 
0045   private:
0046     ParticleParams const& particles_;
0047     std::string_view label_;
0048 };
0049 
0050 //---------------------------------------------------------------------------//
0051 // INLINE DEFINITIONS
0052 //---------------------------------------------------------------------------//
0053 /*!
0054  * Construct with shared particle data and model label.
0055  */
0056 MuHadIonizationBuilder::MuHadIonizationBuilder(ParticleParams const& particles,
0057                                                std::string_view label)
0058     : particles_(particles), label_(label)
0059 {
0060 }
0061 
0062 //---------------------------------------------------------------------------//
0063 /*!
0064  * Construct model data from applicability.
0065  */
0066 MuHadIonizationData
0067 MuHadIonizationBuilder::operator()(SetApplicability const& applicability) const
0068 {
0069     CELER_EXPECT(!applicability.empty());
0070 
0071     MuHadIonizationData data;
0072 
0073     for (auto const& applic : applicability)
0074     {
0075         CELER_VALIDATE(
0076             applic,
0077             << "invalid applicability with particle `"
0078             << (applic.particle ? particles_.id_to_label(applic.particle) : "")
0079             << "' and energy limits (" << value_as<Energy>(applic.lower)
0080             << ", " << value_as<Energy>(applic.upper) << ") [MeV] for model '"
0081             << label_ << "'");
0082     }
0083 
0084     data.electron = particles_.find(pdg::electron());
0085     CELER_VALIDATE(data.electron,
0086                    << "missing electron (required for model '" << label_
0087                    << "')");
0088 
0089     data.electron_mass = particles_.get(data.electron).mass();
0090 
0091     CELER_ENSURE(data);
0092     return data;
0093 }
0094 
0095 //---------------------------------------------------------------------------//
0096 }  // namespace detail
0097 }  // namespace celeritas