Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:27:41

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