Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-16 09:03:15

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 namespace g4org
0026 {
0027 //---------------------------------------------------------------------------//
0028 struct LogicalVolume;
0029 class SolidConverter;
0030 
0031 //---------------------------------------------------------------------------//
0032 /*!
0033  * Convert a Geant4 base LV to an ORANGE temporary LV.
0034  *
0035  * This does not convert or add any of the daughters, which must be placed as
0036  * physical volumes.
0037  */
0038 class LogicalVolumeConverter
0039 {
0040   public:
0041     //!@{
0042     //! \name Type aliases
0043     using arg_type = G4LogicalVolume const&;
0044     using VecLabel = std::vector<Label>;
0045     using SPLV = std::shared_ptr<LogicalVolume>;
0046     using result_type = std::pair<SPLV, bool>;
0047     //!@}
0048 
0049   public:
0050     LogicalVolumeConverter(VecLabel const& labels,
0051                            SolidConverter& convert_solid);
0052 
0053     // Convert a volume, return result plus insertion
0054     result_type operator()(arg_type);
0055 
0056   private:
0057     using WPLV = std::weak_ptr<LogicalVolume>;
0058 
0059     //// DATA ////
0060 
0061     VecLabel const& labels_;
0062     SolidConverter& convert_solid_;
0063     std::unordered_map<G4LogicalVolume const*, WPLV> cache_;
0064 
0065     //// HELPER FUNCTIONS ////
0066 
0067     // Convert an LV that's not in the cache
0068     SPLV construct_impl(arg_type);
0069 };
0070 
0071 //---------------------------------------------------------------------------//
0072 }  // namespace g4org
0073 }  // namespace celeritas