Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-11 09:40:23

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