Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-06 08:18:07

0001 /*!
0002  *  \file       ActsSurfaceMaps.cc
0003  *  \brief      maps hitsetids to Acts Surfaces
0004  *  \author Tony Frawley <afrawley@fsu.edu>, Joe Osborn <osbornjd@ornl.gov>, Hugo Pereira Da Costa <hugo.pereira-da-costa@cea.fr>
0005  */
0006 
0007 #include "ActsSurfaceMaps.h"
0008 #include "InttDefs.h"
0009 #include "MvtxDefs.h"
0010 #include "TrkrCluster.h"
0011 
0012 #include <Acts/Definitions/Units.hpp>
0013 #include <Acts/Surfaces/Surface.hpp>
0014 
0015 namespace
0016 {
0017   /// square
0018   template <class T>
0019   inline constexpr T square(const T& x)
0020   {
0021     return x * x;
0022   }
0023 
0024   /// get radius from coordinates
0025   template <class T>
0026   T radius(const T& x, const T& y)
0027   {
0028     return std::sqrt(square(x) + square(y));
0029   }
0030 }  // namespace
0031 
0032 bool ActsSurfaceMaps::isTpcSurface(const Acts::Surface* surface) const
0033 {
0034   return m_tpcVolumeIds.find(surface->geometryId().volume()) != m_tpcVolumeIds.end();
0035 }
0036 
0037 bool ActsSurfaceMaps::isMicromegasSurface(const Acts::Surface* surface) const
0038 {
0039   return m_micromegasVolumeIds.find(surface->geometryId().volume()) != m_micromegasVolumeIds.end();
0040 }
0041 
0042 Surface ActsSurfaceMaps::getSurface(TrkrDefs::cluskey key,
0043                                     TrkrCluster* cluster) const
0044 {
0045   const auto trkrid = TrkrDefs::getTrkrId(key);
0046   const auto hitsetkey = TrkrDefs::getHitSetKeyFromClusKey(key);
0047 
0048   switch (trkrid)
0049   {
0050   case TrkrDefs::TrkrId::micromegasId:
0051   {
0052     return getMMSurface(hitsetkey);
0053   }
0054 
0055   case TrkrDefs::TrkrId::tpcId:
0056   {
0057     const auto surfkey = cluster->getSubSurfKey();
0058     return getTpcSurface(hitsetkey, surfkey);
0059   }
0060 
0061   case TrkrDefs::TrkrId::mvtxId:
0062   case TrkrDefs::TrkrId::inttId:
0063   {
0064     return getSiliconSurface(hitsetkey);
0065   }
0066   }
0067 
0068   // unreachable
0069   return nullptr;
0070 }
0071 
0072 Surface ActsSurfaceMaps::getSiliconSurface(TrkrDefs::hitsetkey hitsetkey) const
0073 {
0074   unsigned int trkrid = TrkrDefs::getTrkrId(hitsetkey);
0075   TrkrDefs::hitsetkey tmpkey = hitsetkey;
0076 
0077   if (trkrid == TrkrDefs::inttId)
0078   {
0079     // Set the hitsetkey crossing to zero
0080     tmpkey = InttDefs::resetCrossing(hitsetkey);
0081   }
0082 
0083   if (trkrid == TrkrDefs::mvtxId)
0084   {
0085     // Set the hitsetkey crossing to zero
0086     tmpkey = MvtxDefs::resetStrobe(hitsetkey);
0087   }
0088 
0089   // std::cout << "tmpkey = " << tmpkey << std::endl;
0090 
0091   auto iter = m_siliconSurfaceMap.find(tmpkey);
0092   if (iter != m_siliconSurfaceMap.end())
0093   {
0094     // std::cout << "Found silicon surface for hitsetkey " << hitsetkey << " tmpkey " << tmpkey << std::endl;
0095     return iter->second;
0096   }
0097 
0098   /// If it can't be found, return nullptr
0099   {
0100     std::cout << "Failed to find silicon surface for hitsetkey " << hitsetkey << " tmpkey " << tmpkey << std::endl;
0101   }
0102   return nullptr;
0103 }
0104 
0105 Surface ActsSurfaceMaps::getTpcSurface(TrkrDefs::hitsetkey hitsetkey,
0106                                        TrkrDefs::subsurfkey surfkey) const
0107 {
0108   unsigned int layer = TrkrDefs::getLayer(hitsetkey);
0109   const auto iter = m_tpcSurfaceMap.find(layer);
0110 
0111   if (iter != m_tpcSurfaceMap.end())
0112   {
0113     auto surfvec = iter->second;
0114     return surfvec.at(surfkey);
0115   }
0116 
0117   /// If it can't be found, return nullptr to skip this cluster
0118   return nullptr;
0119 }
0120 
0121 Surface ActsSurfaceMaps::getMMSurface(TrkrDefs::hitsetkey hitsetkey) const
0122 {
0123   const auto iter = m_mmSurfaceMap.find(hitsetkey);
0124   return (iter == m_mmSurfaceMap.end()) ? nullptr : iter->second;
0125 }