Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-12 08:27:10

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 
0013 #include <cmath>
0014 #include <memory>
0015 #include <numbers>
0016 #include <string>
0017 #include <tuple>
0018 
0019 #include "RtypesCore.h"
0020 
0021 class TGeoShape;
0022 class TGeoMatrix;
0023 
0024 namespace Acts {
0025 
0026 class CylinderBounds;
0027 class DiscBounds;
0028 class PlanarBounds;
0029 class Surface;
0030 class TGeoDetectorElement;
0031 
0032 /// Helper struct to convert TGeoShapes into Surface or Volume Bounds
0033 struct TGeoSurfaceConverter {
0034   /// Convert a TGeoShape into cylinder surface components
0035   ///
0036   /// @param tgShape The TGeoShape
0037   /// @param rotation The rotation matrix as Double_t* from root
0038   /// @param translation The translation vector as Double_t* from root
0039   /// @param axes The axes definition
0040   /// @param scalor The unit scalor between TGeo and Acts
0041   ///
0042   /// @return tuple of DiscBounds, Transform, thickness
0043   static std::tuple<std::shared_ptr<const CylinderBounds>, const Transform3,
0044                     double>
0045   cylinderComponents(const TGeoShape& tgShape, const Double_t* rotation,
0046                      const Double_t* translation, const std::string& axes,
0047                      double scalor = 10.) noexcept(false);
0048 
0049   /// Convert a TGeoShape into disk surface components
0050   ///
0051   /// @param tgShape The TGeoShape
0052   /// @param rotation The rotation matrix as Double_t* from root
0053   /// @param translation The translation vector as Double_t* from root
0054   /// @param axes The axes definition
0055   /// @param scalor The unit scalor between TGeo and Acts
0056   ///
0057   /// @return tuple of DiscBounds, Transform, thickness
0058   static std::tuple<std::shared_ptr<const DiscBounds>, const Transform3, double>
0059   discComponents(const TGeoShape& tgShape, const Double_t* rotation,
0060                  const Double_t* translation, const std::string& axes,
0061                  double scalor = 10.) noexcept(false);
0062 
0063   /// Convert a TGeoShape into plane surface components
0064   ///
0065   /// @param tgShape The TGeoShape
0066   /// @param rotation The rotation matrix as Double_t* from root
0067   /// @param translation The translation as a Double_t*
0068   /// @param axes The axes definition
0069   /// @param scalor The unit scalor between TGeo and Acts
0070   ///
0071   /// @return tuple of PlanarBounds, Transform, thickness
0072   static std::tuple<std::shared_ptr<const PlanarBounds>, const Transform3,
0073                     double>
0074   planeComponents(const TGeoShape& tgShape, const Double_t* rotation,
0075                   const Double_t* translation, const std::string& axes,
0076                   double scalor = 10.) noexcept(false);
0077 
0078   /// Convert a TGeoShape to a Surface
0079   ///
0080   /// @param tgShape The TGeoShape
0081   /// @param tgMatrix The matrix representing the transform
0082   /// @param axes The axes definition
0083   /// @param scalor The unit scalor between TGeo and Acts
0084   ///
0085   /// @return shared pointer to a surface and the original thickness that
0086   /// has been condensed to the surface
0087   static std::tuple<std::shared_ptr<Surface>, double> toSurface(
0088       const TGeoShape& tgShape, const TGeoMatrix& tgMatrix,
0089       const std::string& axes, double scalor = 10.) noexcept(false);
0090 
0091   /// Translate TGeo degree [0, 360) to radian
0092   /// * will correct to [-pi,pi)
0093   /// @param degree The input in degree
0094   /// @return angle in radians
0095   static double toRadian(double degree) {
0096     if (degree > 180. && degree < 360.) {
0097       degree -= 360.;
0098     }
0099     return degree / 180. * std::numbers::pi;
0100   }
0101 };
0102 
0103 }  // namespace Acts