Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-22 10:31:18

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