Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-16 09:19:32

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 orange/g4org/LogicalVolumeConverter.hh
0006 //---------------------------------------------------------------------------//
0007 #pragma once
0008 
0009 #include <memory>
0010 #include <unordered_map>
0011 #include <vector>
0012 
0013 #include "corecel/io/Label.hh"
0014 #include "geocel/Types.hh"
0015 #include "orange/orangeinp/ObjectInterface.hh"
0016 
0017 //---------------------------------------------------------------------------//
0018 // Forward declarations
0019 //---------------------------------------------------------------------------//
0020 
0021 class G4LogicalVolume;
0022 
0023 namespace celeritas
0024 {
0025 class GeantGeoParams;
0026 namespace g4org
0027 {
0028 //---------------------------------------------------------------------------//
0029 struct LogicalVolume;
0030 class SolidConverter;
0031 
0032 //---------------------------------------------------------------------------//
0033 /*!
0034  * Convert a Geant4 base LV to an ORANGE temporary LV.
0035  *
0036  * This does not convert or add any of the daughters, which must be placed as
0037  * physical volumes.
0038  */
0039 class LogicalVolumeConverter
0040 {
0041   public:
0042     //!@{
0043     //! \name Type aliases
0044     using arg_type = G4LogicalVolume const&;
0045     using VecLabel = std::vector<Label>;
0046     using SPLV = std::shared_ptr<LogicalVolume>;
0047     using result_type = std::pair<SPLV, bool>;
0048     //!@}
0049 
0050   public:
0051     LogicalVolumeConverter(GeantGeoParams const& geo,
0052                            SolidConverter& convert_solid);
0053 
0054     // Convert a volume, return result plus insertion
0055     result_type operator()(arg_type);
0056 
0057   private:
0058     using WPLV = std::weak_ptr<LogicalVolume>;
0059 
0060     //// DATA ////
0061 
0062     GeantGeoParams const& geo_;
0063     SolidConverter& convert_solid_;
0064     std::unordered_map<G4LogicalVolume const*, WPLV> cache_;
0065 
0066     //// HELPER FUNCTIONS ////
0067 
0068     // Convert an LV that's not in the cache
0069     SPLV construct_impl(arg_type);
0070 };
0071 
0072 //---------------------------------------------------------------------------//
0073 }  // namespace g4org
0074 }  // namespace celeritas