Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-17 08:35:33

0001 #ifndef VECGEOM_SURFACE_SPHERECONVERTER_H_
0002 #define VECGEOM_SURFACE_SPHERECONVERTER_H_
0003 
0004 #include <VecGeom/surfaces/conv/Builder.h>
0005 #include <VecGeom/surfaces/Model.h>
0006 
0007 #include <VecGeom/volumes/Sphere.h>
0008 #include <VecGeom/volumes/UnplacedOrb.h>
0009 
0010 namespace vgbrep {
0011 namespace conv {
0012 
0013 /// @brief Converter for a sphere
0014 /// @tparam Real_t Precision type
0015 /// @param sph Sphere solid to be converted
0016 /// @param logical_id Id of the logical volume
0017 /// @return Conversion success
0018 template <typename Real_t>
0019 bool CreateSphereSurfaces(vecgeom::UnplacedSphere const &sph, int logical_id, bool intersection = false)
0020 {
0021   // using Vector3D     = vecgeom::Vector3D<Real_t>;
0022   // const auto &sphstr = sph.GetStruct();
0023   auto rmax = sph.GetRmax();
0024   int isurf;
0025   LogicExpressionCPU logic; // AND logic: 0 (just Rmax supported for the moment)
0026   vecgeom::Transformation3DMP<Real_t> identity;
0027 
0028   vecgeom::Precision surfdata[1];
0029   surfdata[0] = rmax;
0030   isurf       = builder::CreateLocalSurface<Real_t>(
0031       builder::CreateUnplacedSurface<Real_t>(SurfaceType::kSpherical, surfdata, /*flipped=*/false),
0032       builder::CreateFrame<Real_t>(FrameType::kZPhi,
0033                                    ZPhiMask<Real_t>{-rmax, rmax, true, 0., rmax, 0., vecgeom::kTwoPi}),
0034       /*identity transformation*/ identity);
0035   builder::AddSurfaceToShell<Real_t>(logical_id, isurf);
0036   if (intersection) builder::GetSurface<Real_t>(isurf).fSkipConvexity = true;
0037   logic.push_back(isurf);
0038 
0039   builder::AddLogicToShell<Real_t>(logical_id, logic);
0040   return true;
0041 }
0042 
0043 /// @brief Converter for an orb
0044 /// @tparam Real_t Precision type
0045 /// @param orb Orb to be converted by way of sphere
0046 /// @param logical_id Id of the logical volume
0047 /// @return Conversion success
0048 template <typename Real_t>
0049 bool CreateSphereSurfaces(vecgeom::UnplacedOrb const &orb, int logical_id, bool intersection = false)
0050 {
0051   vecgeom::UnplacedSphere temp_sph(0, orb.GetRadius());
0052   return CreateSphereSurfaces<Real_t>(temp_sph, logical_id, intersection);
0053 }
0054 
0055 } // namespace conv
0056 } // namespace vgbrep
0057 #endif