Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-06 08:17:53

0001 /*!
0002  * \file MicromegasDefs.cc
0003  * \author Hugo Pereira Da Costa <hugo.pereira-da-costa@cea.fr>
0004  */
0005 
0006 #include "MicromegasDefs.h"
0007 
0008 namespace
0009 {
0010    //* converninece trait for underlying type
0011   template<class T>
0012     using underlying_type_t = typename std::underlying_type<T>::type;
0013 
0014   //* convert an strong type enum to integral type
0015   template<class T>
0016     constexpr underlying_type_t<T>
0017     to_underlying_type(T value) noexcept
0018   { return static_cast<underlying_type_t<T>>(value);}
0019 
0020   /*!
0021    * hitsetkey layout:
0022    * Micromegas specific lower 16 bits
0023    * 24 - 32  tracker id
0024    * 16 - 24  layer
0025    * 8 - 16 segmentation type
0026    * 0 - 8 tile id
0027    */
0028   static constexpr unsigned int kBitShiftSegmentation = 8;
0029   static constexpr unsigned int kBitShiftTileId = 0;
0030 
0031   //! bit shift for hit key
0032   static constexpr unsigned int kBitShiftStrip = 0;
0033 
0034 }
0035 
0036 namespace MicromegasDefs
0037 {
0038 
0039   //________________________________________________________________
0040   TrkrDefs::hitsetkey genHitSetKey(uint8_t layer, SegmentationType type, uint8_t tile )
0041   {
0042     TrkrDefs::hitsetkey key = TrkrDefs::genHitSetKey(TrkrDefs::TrkrId::micromegasId, layer);
0043 
0044     TrkrDefs::hitsetkey tmp = to_underlying_type(type);
0045     key |= (tmp << kBitShiftSegmentation);
0046 
0047     tmp = tile;
0048     key |= (tmp << kBitShiftTileId);
0049 
0050     return key;
0051   }
0052 
0053   //________________________________________________________________
0054   SegmentationType getSegmentationType(TrkrDefs::hitsetkey key)
0055   {
0056     TrkrDefs::hitsetkey tmp = (key >> kBitShiftSegmentation);
0057     return static_cast<SegmentationType>(tmp);
0058   }
0059 
0060   //________________________________________________________________
0061   uint8_t getTileId(TrkrDefs::hitsetkey key)
0062   {
0063     TrkrDefs::hitsetkey tmp = (key >> kBitShiftTileId);
0064     return tmp;
0065   }
0066 
0067   //________________________________________________________________
0068   TrkrDefs::hitkey genHitKey(uint16_t strip)
0069   {
0070     TrkrDefs::hitkey key = strip << kBitShiftStrip;
0071     return key;
0072   }
0073 
0074   //________________________________________________________________
0075   uint16_t getStrip( TrkrDefs::hitkey key )
0076   {
0077     TrkrDefs::hitkey tmp = (key >> kBitShiftStrip);
0078     return tmp;
0079   }
0080 
0081   //________________________________________________________________
0082   SegmentationType getSegmentationType(TrkrDefs::cluskey key)
0083   {
0084     const TrkrDefs::hitsetkey tmp = TrkrDefs::getHitSetKeyFromClusKey(key);
0085     return getSegmentationType( tmp );
0086   }
0087 
0088   //________________________________________________________________
0089   uint8_t getTileId(TrkrDefs::cluskey key)
0090   {
0091     const TrkrDefs::hitsetkey tmp = TrkrDefs::getHitSetKeyFromClusKey(key);
0092     return getTileId( tmp );
0093   }
0094 
0095 }