Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 10:17:10

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