Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-06-30 08:06:59

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/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   ActsScalar 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   ActsScalar 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>, ActsScalar> 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>, ActsScalar> 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>, ActsScalar>
0126   rectangleBounds(const G4Box& g4Box);
0127 
0128   /// @brief Convert to trapezoid bounds - from Trap
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>, ActsScalar>
0134   trapezoidBounds(const G4Trd& g4Trd);
0135 
0136   /// @brief Convert to general solid into a planar shape
0137   ///
0138   /// @param g4Solid a Geant4 solid shape
0139   ///
0140   /// @return an ACTS Planar bounds object,
0141   /// the axes, and the thickness of the compressed dimension
0142   std::tuple<std::shared_ptr<PlanarBounds>, std::array<int, 2u>, ActsScalar>
0143   planarBounds(const G4VSolid& g4Solid);
0144 };
0145 
0146 struct Geant4PhysicalVolumeConverter {
0147   /// Optionally allow to foce a type, throws exception if not possible
0148   Surface::SurfaceType forcedType = Surface::SurfaceType::Other;
0149 
0150   /// @brief Convert a Geant4 phsyical volume to a surface
0151   ///
0152   /// @param g4PhysVol the physical volume to be constructed
0153   /// @param toGlobal the global transformation before the volume
0154   /// @param convertMaterial a material conversion flag
0155   /// @param compressed the compressed thickness of the converted material
0156   ///
0157   /// @return a shared surface object
0158   std::shared_ptr<Surface> surface(const G4VPhysicalVolume& g4PhysVol,
0159                                    const Transform3& toGlobal,
0160                                    bool convertMaterial = false,
0161                                    ActsScalar compressed = 0.);
0162 };
0163 
0164 class Material;
0165 class HomogeneousSurfaceMaterial;
0166 class HomogeneousVolumeMaterial;
0167 
0168 struct Geant4MaterialConverter {
0169   Material material(const G4Material& g4Material, ActsScalar compression = 1);
0170 
0171   /// @brief Convert a Geant4 material to a surface material description
0172   ///
0173   /// @param g4Material the geant4 material description
0174   /// @param original the original thickness
0175   /// @param compressed the compressed thickness
0176   ///
0177   std::shared_ptr<HomogeneousSurfaceMaterial> surfaceMaterial(
0178       const G4Material& g4Material, ActsScalar original, ActsScalar compressed);
0179 };
0180 
0181 class CylinderVolumeBounds;
0182 
0183 struct Geant4VolumeConverter {
0184   /// @brief Convert to cylinder bounds
0185   ///
0186   /// @param g4Tubs a Geant4 tube shape
0187   ///
0188   /// @return an Acts Cylinder bounds object
0189   std::shared_ptr<CylinderVolumeBounds> cylinderBounds(const G4Tubs& g4Tubs);
0190 };
0191 
0192 }  // namespace Acts