![]() |
|
|||
File indexing completed on 2025-09-16 09:13:23
0001 //------------------------------- -*- C++ -*- -------------------------------// 0002 // Copyright G4VG contributors: see top-level COPYRIGHT file for details 0003 // SPDX-License-Identifier: (Apache-2.0 OR MIT) 0004 //---------------------------------------------------------------------------// 0005 //! \file G4VG.hh 0006 //---------------------------------------------------------------------------// 0007 #pragma once 0008 0009 #include <vector> 0010 0011 //---------------------------------------------------------------------------// 0012 // FORWARD DECLARATIONS 0013 //---------------------------------------------------------------------------// 0014 0015 class G4LogicalVolume; 0016 class G4VPhysicalVolume; 0017 0018 namespace vecgeom 0019 { 0020 inline namespace cxx 0021 { 0022 class LogicalVolume; 0023 class VPlacedVolume; 0024 } // namespace cxx 0025 } // namespace vecgeom 0026 0027 //---------------------------------------------------------------------------// 0028 0029 namespace g4vg 0030 { 0031 //---------------------------------------------------------------------------// 0032 /*! 0033 * Construction options to pass to the converter. 0034 * 0035 * Note: next version will change the defaults of \c append_pointers and \c 0036 * map_reflected . 0037 */ 0038 struct Options 0039 { 0040 //! Print extra messages for debugging 0041 bool verbose{false}; 0042 0043 //! Perform conversion checks 0044 bool compare_volumes{false}; 0045 0046 //! Append pointer addresses from associated Geant4 LV 0047 bool append_pointers{true}; 0048 0049 //! Use reflection factory for backward compatibility (Celeritas) 0050 bool reflection_factory{true}; 0051 0052 //! Value of 1mm in native unit system (0.1 for cm) 0053 double scale = 1; 0054 }; 0055 0056 //---------------------------------------------------------------------------// 0057 /*! 0058 * Result from converting from Geant4 to VecGeom. 0059 * 0060 * The output of this struct can be used to map back and forth between the 0061 * constructed VecGeom and underlying Geant4 geometry. Because VecGeom will 0062 * "stamp" replicated or parameterized volumes such that multiple vecgeom 0063 * placed volumes correspond to a single G4VPV pointer, we provide an 0064 * additional set with IDs of such volumes. The copy number of each of those 0065 * PVs corresponds to the Geant4 replica/parameterization number and can be 0066 * used to reconstruct the corresponding instance: 0067 * \code 0068 auto* vgpv = vecgeom::GeoManager::Instance().FindPlacedVolume(pv_id); 0069 auto* g4pv = const_cast<G4VPhysicalVolume*>(c.physical_volumes[pv_id]); 0070 int copy_no = vgpv->GetCopyNo(); 0071 auto vol_type = g4pv->pv->VolumeType(); 0072 if (vol_type == EVolume::kReplica) 0073 { 0074 G4ReplicaNavigation replica_navigator; 0075 replica_navigator.ComputeTransformation(copy_no, g4pv); 0076 g4pv->SetCopyNo(copy_no); 0077 } 0078 else if (vol_type == EVolume::kParameterised) 0079 { 0080 g4pv->GetParameterisation()->ComputeTransformation(copy_no, g4pv); 0081 g4pv->SetCopyNo(copy_no); 0082 } 0083 * \endcode 0084 */ 0085 struct Converted 0086 { 0087 using VGPlacedVolume = vecgeom::VPlacedVolume; 0088 using VecLv = std::vector<G4LogicalVolume const*>; 0089 using VecPv = std::vector<G4VPhysicalVolume const*>; 0090 0091 //! World pointer (host) corresponding to input Geant4 world 0092 VGPlacedVolume* world{nullptr}; 0093 0094 //! Geant4 LVs indexed by VecGeom LogicalVolume ID 0095 VecLv logical_volumes; 0096 //! Geant4 PVs indexed by VecGeom PlacedVolume ID 0097 VecPv physical_volumes; 0098 }; 0099 0100 //---------------------------------------------------------------------------// 0101 // Convert a Geant4 geometry to a VecGeom geometry. 0102 Converted convert(G4VPhysicalVolume const* world); 0103 0104 // Convert with custom options 0105 Converted convert(G4VPhysicalVolume const* world, Options const& options); 0106 0107 //---------------------------------------------------------------------------// 0108 } // namespace g4vg
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |