Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-22 09:54:43

0001 //----------------------------------*-C++-*----------------------------------//
0002 // Copyright 2023-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 accel/detail/SensDetInserter.hh
0007 //---------------------------------------------------------------------------//
0008 #pragma once
0009 
0010 #include <map>
0011 #include <unordered_set>
0012 #include <vector>
0013 
0014 #include "corecel/Assert.hh"
0015 #include "geocel/GeoParamsInterface.hh"
0016 #include "celeritas/ext/GeantVolumeMapper.hh"
0017 
0018 class G4LogicalVolume;
0019 class G4VSensitiveDetector;
0020 
0021 namespace celeritas
0022 {
0023 namespace detail
0024 {
0025 //---------------------------------------------------------------------------//
0026 /*!
0027  * Map logical volumes to native geometry and log potential issues.
0028  *
0029  * This is an implementation detail of \c HitManager .
0030  */
0031 class SensDetInserter
0032 {
0033   public:
0034     //!@{
0035     //! \name Type aliases
0036     using SetLV = std::unordered_set<G4LogicalVolume const*>;
0037     using VecLV = std::vector<G4LogicalVolume const*>;
0038     using MapIdLv = std::map<VolumeId, G4LogicalVolume const*>;
0039     //!@}
0040 
0041   public:
0042     // Construct with defaults
0043     inline SensDetInserter(GeoParamsInterface const& geo,
0044                            SetLV const& skip_volumes,
0045                            MapIdLv* found,
0046                            VecLV* missing);
0047 
0048     // Save a sensitive detector
0049     void operator()(G4LogicalVolume const* lv, G4VSensitiveDetector const* sd);
0050 
0051     // Forcibly add the given volume
0052     void operator()(G4LogicalVolume const* lv);
0053 
0054   private:
0055     GeoParamsInterface const& geo_;
0056     GeantVolumeMapper g4_to_celer_;
0057     SetLV const& skip_volumes_;
0058     MapIdLv* found_;
0059     VecLV* missing_;
0060 
0061     VolumeId insert_impl(G4LogicalVolume const* lv);
0062 };
0063 
0064 //---------------------------------------------------------------------------//
0065 // INLINE DEFINITIONS
0066 //---------------------------------------------------------------------------//
0067 /*!
0068  * Construct with references to the inserted data.
0069  */
0070 SensDetInserter::SensDetInserter(GeoParamsInterface const& geo,
0071                                  SetLV const& skip_volumes,
0072                                  MapIdLv* found,
0073                                  VecLV* missing)
0074     : geo_(geo)
0075     , g4_to_celer_{geo}
0076     , skip_volumes_{skip_volumes}
0077     , found_{found}
0078     , missing_{missing}
0079 {
0080     CELER_EXPECT(found_);
0081     CELER_EXPECT(missing_);
0082 }
0083 
0084 //---------------------------------------------------------------------------//
0085 }  // namespace detail
0086 }  // namespace celeritas