Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-17 08:21:26

0001 // This file is part of the ACTS project.
0002 //
0003 // Copyright (C) 2016 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 https://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/Surfaces/Surface.hpp"
0014 
0015 #include <array>
0016 #include <memory>
0017 #include <tuple>
0018 
0019 namespace CLHEP {
0020 class Hep3Vector;
0021 class HepRotation;
0022 }  // namespace CLHEP
0023 
0024 namespace HepGeom {
0025 class Transform3D;
0026 }
0027 
0028 class G4Box;
0029 class G4Material;
0030 class G4Trd;
0031 class G4Trap;
0032 class G4Tubs;
0033 class G4VSolid;
0034 class G4VPhysicalVolume;
0035 using G4ThreeVector = CLHEP::Hep3Vector;
0036 using G4RotationMatrix = CLHEP::HepRotation;
0037 using G4Transform3D = HepGeom::Transform3D;
0038 
0039 namespace Acts {
0040 struct Geant4AlgebraConverter {
0041   // A potential scalar between Geant4 and ACTS
0042   double scale = 1.;
0043 
0044   /// @brief Translate a geometry transform: translation only
0045   ///
0046   /// @param g4Trans the translation of the Geant4 object
0047   ///
0048   /// @return a Acts transform
0049   Transform3 transform(const G4ThreeVector& g4Trans);
0050 
0051   /// @brief Translate a geometry transform
0052   ///
0053   /// @param g4Rot the rotation of the Geant4 object
0054   /// @param g4Trans the translation of the Geant4 object
0055   ///
0056   /// @return a Acts transform
0057   Transform3 transform(const G4RotationMatrix& g4Rot,
0058                        const G4ThreeVector& g4Trans);
0059 
0060   /// @brief Translate a geometry transform
0061   ///
0062   /// @param g4Trf the Geant4 transform object
0063   ///
0064   /// @return a Acts transform
0065   Transform3 transform(const G4Transform3D& g4Trf);
0066 
0067   /// @brief Translate a geometry transform from a G4 physical volume
0068   ///
0069   /// @param g4PhysVol the Geant4 physical volume
0070   ///
0071   /// @return a Acts transform
0072   Transform3 transform(const G4VPhysicalVolume& g4PhysVol);
0073 };
0074 
0075 class AnnulusBounds;
0076 class CylinderBounds;
0077 class RadialBounds;
0078 class RectangleBounds;
0079 class TrapezoidBounds;
0080 class PlanarBounds;
0081 class LineBounds;
0082 
0083 // The following set of converters convert a Geant4 volume shape
0084 // to an ACTS surface bounds object, this is for converting the volume
0085 // based geometry into a surfaced based one.
0086 //
0087 // The obviously smallest expansion/extrusion is condensed to the epsilon
0088 // thin surface.
0089 struct Geant4ShapeConverter {
0090   /// A scale between Geant4 and ACTS
0091   double scale = 1.;
0092   /// A description to keep the axis order, if it is set to false
0093   /// cyclic re-ordering will happen, otherwise axis flip if needed in
0094   /// order to keep the system right-handed
0095   bool keepAxisOrder = false;
0096 
0097   /// @brief Convert to cylinder bounds
0098   ///
0099   /// @param g4Tubs a Geant4 tube shape
0100   ///
0101   /// @return an Acts Cylinder bounds object, and thickness
0102   std::tuple<std::shared_ptr<CylinderBounds>, double> cylinderBounds(
0103       const G4Tubs& g4Tubs);
0104 
0105   /// @brief Convert to radial bounds
0106   ///
0107   /// @param g4Tubs a Geant4 tube shape
0108   ///
0109   /// @return an Acts Radial bounds object and thickness
0110   std::tuple<std::shared_ptr<RadialBounds>, double> radialBounds(
0111       const G4Tubs& g4Tubs);
0112 
0113   /// @brief Convert to line/straw bounds
0114   ///
0115   /// @param g4Tubs a Geant4 tube shape
0116   ///
0117   /// @return an Acts line bounds object and thickness
0118   std::shared_ptr<LineBounds> lineBounds(const G4Tubs& g4Tubs);
0119 
0120   /// @brief Convert to rectangle bounds
0121   ///
0122   /// @param g4Box a Geant4 box shape
0123   ///
0124   /// @return an ACTS Rectangle bounds shape,  axis orientation, and thickness
0125   std::tuple<std::shared_ptr<RectangleBounds>, std::array<int, 2u>, double>
0126   rectangleBounds(const G4Box& g4Box);
0127 
0128   /// @brief Convert to trapezoid bounds - from Trd
0129   ///
0130   /// @param g4Trd a Geant4 trapezoid shape
0131   ///
0132   /// @return an ACTS Trapezoid bounds object, axis orientation, and thickness
0133   std::tuple<std::shared_ptr<TrapezoidBounds>, std::array<int, 2u>, double>
0134   trapezoidBounds(const G4Trd& g4Trd);
0135 
0136   /// @brief Convert to trapezoid bounds - from Trap
0137   ///
0138   /// @param g4Trap a Geant4 trapezoid shape
0139   ///
0140   /// @return an ACTS Trapezoid bounds object, axis orientation, and thickness
0141   std::tuple<std::shared_ptr<TrapezoidBounds>, std::array<int, 2u>, double>
0142   trapezoidBounds(const G4Trap& g4Trap);
0143 
0144   /// @brief Convert to general solid into a planar shape
0145   ///
0146   /// @param g4Solid a Geant4 solid shape
0147   ///
0148   /// @return an ACTS Planar bounds object,
0149   /// the axes, and the thickness of the compressed dimension
0150   std::tuple<std::shared_ptr<PlanarBounds>, std::array<int, 2u>, double>
0151   planarBounds(const G4VSolid& g4Solid);
0152 };
0153 
0154 struct Geant4PhysicalVolumeConverter {
0155   /// Optionally allow to foce a type, throws exception if not possible
0156   Surface::SurfaceType forcedType = Surface::SurfaceType::Other;
0157 
0158   /// @brief Convert a Geant4 phsyical volume to a surface
0159   ///
0160   /// @param g4PhysVol the physical volume to be constructed
0161   /// @param toGlobal the global transformation before the volume
0162   /// @param convertMaterial a material conversion flag
0163   /// @param compressed the compressed thickness of the converted material
0164   ///
0165   /// @return a shared surface object
0166   std::shared_ptr<Surface> surface(const G4VPhysicalVolume& g4PhysVol,
0167                                    const Transform3& toGlobal,
0168                                    bool convertMaterial = false,
0169                                    double compressed = 0.);
0170 };
0171 
0172 class Material;
0173 class HomogeneousSurfaceMaterial;
0174 class HomogeneousVolumeMaterial;
0175 
0176 struct Geant4MaterialConverter {
0177   Material material(const G4Material& g4Material, double compression = 1);
0178 
0179   /// @brief Convert a Geant4 material to a surface material description
0180   ///
0181   /// @param g4Material the geant4 material description
0182   /// @param original the original thickness
0183   /// @param compressed the compressed thickness
0184   ///
0185   std::shared_ptr<HomogeneousSurfaceMaterial> surfaceMaterial(
0186       const G4Material& g4Material, double original, double compressed);
0187 };
0188 
0189 class CylinderVolumeBounds;
0190 
0191 struct Geant4VolumeConverter {
0192   /// @brief Convert to cylinder bounds
0193   ///
0194   /// @param g4Tubs a Geant4 tube shape
0195   ///
0196   /// @return an Acts Cylinder bounds object
0197   std::shared_ptr<CylinderVolumeBounds> cylinderBounds(const G4Tubs& g4Tubs);
0198 };
0199 
0200 }  // namespace Acts