Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-07-01 08:07:51

0001 // This file is part of the Acts project.
0002 //
0003 // Copyright (C) 2022 CERN for the benefit of the Acts project
0004 //
0005 // This Source Code Form is subject to the terms of the Mozilla Public
0006 // License, v. 2.0. If a copy of the MPL was not distributed with this
0007 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
0008 
0009 #pragma once
0010 
0011 #include "Acts/Definitions/Algebra.hpp"
0012 #include "Acts/Definitions/Common.hpp"
0013 #include "Acts/Plugins/Geant4/Geant4PhysicalVolumeSelectors.hpp"
0014 #include "Acts/Surfaces/Surface.hpp"
0015 
0016 #include <cstddef>
0017 #include <memory>
0018 #include <tuple>
0019 #include <vector>
0020 
0021 namespace HepGeom {
0022 class Transform3D;
0023 }
0024 
0025 class G4VPhysicalVolume;
0026 using G4Transform3D = HepGeom::Transform3D;
0027 
0028 namespace Acts {
0029 
0030 class Geant4DetectorElement;
0031 class IGeant4PhysicalVolumeSelector;
0032 class Surface;
0033 
0034 /// A factory to convert Geant4 physical volumes
0035 /// into Geant4 detector elements
0036 ///
0037 class Geant4DetectorSurfaceFactory {
0038  public:
0039   /// Nested configuration struct that holds
0040   /// global lifetime configuration
0041   struct Config {};
0042 
0043   // Collect the sensitive surfaces
0044   using Geant4SensitiveSurface =
0045       std::tuple<std::shared_ptr<Geant4DetectorElement>,
0046                  std::shared_ptr<Surface>>;
0047 
0048   // Collect the passive surfaces
0049   using Geant4PassiveSurface = std::shared_ptr<Surface>;
0050 
0051   /// Nested cache that records the conversion status
0052   struct Cache {
0053     /// The created detector elements - for the detector store
0054     std::vector<Geant4SensitiveSurface> sensitiveSurfaces;
0055     /// The created non-const surfaces - for further processing,
0056     std::vector<Geant4PassiveSurface> passiveSurfaces;
0057     /// matching and conversion statistics: volumes
0058     std::size_t matchedG4Volumes = 0;
0059     /// matching and conversion statistics: surfaces
0060     std::size_t convertedSurfaces = 0;
0061     /// matching and conversion statistics: materials
0062     std::size_t convertedMaterials = 0;
0063   };
0064 
0065   /// Nested option struct that allows per call changeable configuration
0066   struct Options {
0067     /// Convert the length scale
0068     ActsScalar scaleConversion = 1.;
0069     /// Convert the material
0070     bool convertMaterial = true;
0071     /// Converted material thickness (< 0 indicates keeping original thickness)
0072     ActsScalar convertedMaterialThickness = -1;
0073     /// A selector for sensitive surfaces
0074     std::shared_ptr<IGeant4PhysicalVolumeSelector> sensitiveSurfaceSelector =
0075         nullptr;
0076     /// A selector for passive surfaces
0077     std::shared_ptr<IGeant4PhysicalVolumeSelector> passiveSurfaceSelector =
0078         nullptr;
0079   };
0080 
0081   /// The Geant4 detector element factory
0082   Geant4DetectorSurfaceFactory() = default;
0083 
0084   /// Construction method of the detector elements
0085   ///
0086   /// @param cache [in,out] into which the Elements are filled
0087   /// @param g4ToGlobal the transformation to global
0088   /// @param g4PhysVol the current physical volume
0089   /// @param option the factory creation option
0090   ///
0091   void construct(Cache& cache, const G4Transform3D& g4ToGlobal,
0092                  const G4VPhysicalVolume& g4PhysVol, const Options& option);
0093 };
0094 }  // namespace Acts