Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-03-13 09:12:19

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 geocel/g4vg/LogicalVolumeConverter.hh
0007 //---------------------------------------------------------------------------//
0008 #pragma once
0009 
0010 #include <unordered_map>
0011 
0012 #include "geocel/Types.hh"
0013 
0014 //---------------------------------------------------------------------------//
0015 // Forward declarations
0016 //---------------------------------------------------------------------------//
0017 
0018 class G4LogicalVolume;
0019 
0020 namespace vecgeom
0021 {
0022 inline namespace cxx
0023 {
0024 class LogicalVolume;
0025 }
0026 }  // namespace vecgeom
0027 //---------------------------------------------------------------------------//
0028 
0029 namespace celeritas
0030 {
0031 namespace g4vg
0032 {
0033 //---------------------------------------------------------------------------//
0034 class SolidConverter;
0035 
0036 //---------------------------------------------------------------------------//
0037 /*!
0038  * Convert a Geant4 base LV to a VecGeom LV.
0039  *
0040  * This does not convert or add any of the daughters, which must be placed as
0041  * physical volumes.
0042  */
0043 class LogicalVolumeConverter
0044 {
0045   public:
0046     //!@{
0047     //! \name Type aliases
0048     using arg_type = G4LogicalVolume const&;
0049     using result_type = vecgeom::LogicalVolume*;
0050     using MapLvVolId = std::unordered_map<G4LogicalVolume const*, VolumeId>;
0051     //!@}
0052 
0053   public:
0054     explicit LogicalVolumeConverter(SolidConverter& convert_solid);
0055 
0056     // Convert a volume
0057     result_type operator()(arg_type);
0058 
0059     // Construct a mapping from G4 logical volume to VolumeId
0060     MapLvVolId make_volume_map() const;
0061 
0062   private:
0063     //// DATA ////
0064 
0065     SolidConverter& convert_solid_;
0066     std::unordered_map<G4LogicalVolume const*, result_type> cache_;
0067 
0068     //// HELPER FUNCTIONS ////
0069 
0070     // Convert an LV that's not in the cache
0071     result_type construct_base(arg_type);
0072 };
0073 
0074 //---------------------------------------------------------------------------//
0075 }  // namespace g4vg
0076 }  // namespace celeritas