Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-18 09:09:03

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 celeritas/ext/GeantVolumeMapper.hh
0006 //---------------------------------------------------------------------------//
0007 #pragma once
0008 
0009 #include <vector>
0010 
0011 #include "corecel/Config.hh"
0012 
0013 #include "corecel/io/Label.hh"
0014 #include "geocel/GeoParamsInterface.hh"
0015 #include "celeritas/Types.hh"
0016 
0017 // Geant4 forward declaration
0018 class G4VPhysicalVolume;  // IWYU pragma: keep
0019 class G4LogicalVolume;  // IWYU pragma: keep
0020 
0021 namespace celeritas
0022 {
0023 //---------------------------------------------------------------------------//
0024 /*!
0025  * Map a Geant4 logical volume to a Celeritas volume ID.
0026  */
0027 class GeantVolumeMapper
0028 {
0029   public:
0030     // Convert to target geometry from geant4 transportation world
0031     explicit GeantVolumeMapper(GeoParamsInterface const& tgt);
0032 
0033     // Convert from Geant4 world *to* geometry interface ID
0034     GeantVolumeMapper(G4VPhysicalVolume const& world,
0035                       GeoParamsInterface const& tgt);
0036 
0037     // Convert a volume; null if not found; warn if inexact match
0038     VolumeId operator()(G4LogicalVolume const&);
0039 
0040   private:
0041     G4VPhysicalVolume const* world_;
0042     GeoParamsInterface const& geo_;
0043     std::vector<Label> labels_;
0044 };
0045 
0046 #if !CELERITAS_USE_GEANT4
0047 inline GeantVolumeMapper::GeantVolumeMapper(GeoParamsInterface const& geo)
0048     : geo_{geo}
0049 {
0050     CELER_DISCARD(labels_);
0051     CELER_DISCARD(world_);
0052     CELER_DISCARD(geo_);
0053     CELER_NOT_CONFIGURED("Geant4");
0054 }
0055 
0056 inline GeantVolumeMapper::GeantVolumeMapper(G4VPhysicalVolume const&,
0057                                             GeoParamsInterface const& geo)
0058     : geo_{geo}
0059 {
0060     CELER_NOT_CONFIGURED("Geant4");
0061 }
0062 
0063 inline VolumeId GeantVolumeMapper::operator()(G4LogicalVolume const&)
0064 {
0065     CELER_ASSERT_UNREACHABLE();
0066 }
0067 #endif
0068 
0069 //---------------------------------------------------------------------------//
0070 }  // namespace celeritas