Back to home page

EIC code displayed by LXR

 
 

    


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

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