Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-11-08 10:11:14

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/ext/detail/GeantPhysicsLoader.hh
0006 //! \sa test/celeritas/ext/GeantImporter.test.cc
0007 //---------------------------------------------------------------------------//
0008 #pragma once
0009 
0010 #include <string>
0011 #include <unordered_set>
0012 #include <vector>
0013 
0014 #include "geocel/GeoOpticalIdMap.hh"
0015 #include "celeritas/Types.hh"
0016 #include "celeritas/inp/OpticalPhysics.hh"
0017 
0018 class G4VProcess;
0019 class G4MaterialPropertiesTable;
0020 
0021 namespace celeritas
0022 {
0023 struct ImportData;
0024 class GeantParticleView;
0025 
0026 namespace detail
0027 {
0028 class GeantMaterialPropertyGetter;
0029 //---------------------------------------------------------------------------//
0030 /*!
0031  * Load data from Geant4 physics processes and models.
0032  *
0033  * One process can be shared by multiple particles. Only handles special cases
0034  * (non-EM, non-MSC processes): optical processes, Cerenkov, scintillation,
0035  * and muon-catalyzed fusion capture. Returns \c true if the process was
0036  * recognized (even if no data required import), \c false otherwise.
0037  *
0038  * \todo When import data is refactored this will replace \em all G4 process
0039  * importing.
0040  */
0041 class GeantPhysicsLoader
0042 {
0043   public:
0044     // Construct with reference to data being loaded
0045     GeantPhysicsLoader(ImportData& imported,
0046                        GeoOpticalIdMap const& optical_ids);
0047 
0048     // Load if possible, returning whether we handled it
0049     bool operator()(G4VProcess const& p);
0050 
0051     // Load per-particle data if possible, returning whether we handled it
0052     bool operator()(GeantParticleView const& particle, G4VProcess const& p);
0053 
0054   private:
0055     //// TYPES ////
0056 
0057     using PropGetter = GeantMaterialPropertyGetter;
0058 
0059     //// DATA ////
0060 
0061     ImportData& imported_;
0062     GeoOpticalIdMap const& optical_ids_;
0063     std::vector<G4Material const*> optical_g4mat_;
0064     std::unordered_set<G4VProcess const*> visited_;
0065 
0066     //// PHYSICS LOADERS ////
0067 
0068     // EM particles (once per process)
0069     size_type cerenkov(G4VProcess const& p);
0070     size_type muon_minus_atomic_capture(G4VProcess const& p);
0071     size_type scintillation(G4VProcess const& p);
0072 
0073     // Optical photons (once per process)
0074     size_type op_absorption(G4VProcess const& p);
0075     size_type op_boundary(G4VProcess const& p);
0076     size_type op_mie_hg(G4VProcess const& p);
0077     size_type op_rayleigh(G4VProcess const& p);
0078     size_type op_wls(G4VProcess const& p);
0079     size_type op_wls2(G4VProcess const& p);
0080 
0081     // Per-particle loaders
0082     size_type mu_pair_production(GeantParticleView const&, G4VProcess const&);
0083 
0084     //// HELPERS ////
0085 
0086     // Make a material table accessor for an optical material
0087     PropGetter property_getter(OptMatId) const;
0088 
0089     inp::Grid load_mfp(OptMatId opt_id, std::string const& prop_name) const;
0090 };
0091 
0092 //---------------------------------------------------------------------------//
0093 }  // namespace detail
0094 }  // namespace celeritas