Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:05:15

0001 #ifndef DataFormats_SiStripDetId_StripSubdetector_H
0002 #define DataFormats_SiStripDetId_StripSubdetector_H
0003 
0004 /**
0005  *  Enumeration for Strip Tracker Subdetectors
0006  *
0007  */
0008 
0009 #include "DataFormats/DetId/interface/DetId.h"
0010 #include "DataFormats/SiStripDetId/interface/SiStripEnums.h"
0011 
0012 class StripSubdetector : public DetId {
0013 public:
0014   using SubDetector = SiStripSubdetector::Subdetector;
0015   static constexpr auto UNKNOWN = SiStripSubdetector::UNKNOWN;
0016   static constexpr auto TIB = SiStripSubdetector::TIB;
0017   static constexpr auto TID = SiStripSubdetector::TID;
0018   static constexpr auto TOB = SiStripSubdetector::TOB;
0019   static constexpr auto TEC = SiStripSubdetector::TEC;
0020 
0021   /** Constructor from a raw value */
0022   StripSubdetector(uint32_t rawid) : DetId(rawid) {}
0023   /**Construct from generic DetId */
0024   StripSubdetector(const DetId &id) : DetId(id) {}
0025 
0026   /// glued
0027   /**
0028    * glued() = 0 it's not a glued module
0029    * glued() != 0 it's a glued module
0030    */
0031   unsigned int glued() const {
0032     if (((id_ >> sterStartBit_) & sterMask_) == 1) {
0033       return (id_ - 1);
0034     } else if (((id_ >> sterStartBit_) & sterMask_) == 2) {
0035       return (id_ - 2);
0036     } else {
0037       return 0;
0038     }
0039   }
0040 
0041   /// stereo
0042   /**
0043    * stereo() = 0 it's not a stereo module
0044    * stereo() = 1 it's a stereo module
0045    */
0046   unsigned int stereo() const {
0047     if (((id_ >> sterStartBit_) & sterMask_) == 1) {
0048       return ((id_ >> sterStartBit_) & sterMask_);
0049     } else {
0050       return 0;
0051     }
0052   }
0053 
0054   /**
0055    * If the DetId identify a glued module return
0056    * the DetId of your partner otherwise return 0
0057    */
0058 
0059   unsigned int partnerDetId() const {
0060     if (((id_ >> sterStartBit_) & sterMask_) == 1) {
0061       return (id_ + 1);
0062     } else if (((id_ >> sterStartBit_) & sterMask_) == 2) {
0063       return (id_ - 1);
0064     } else {
0065       return 0;
0066     }
0067   }
0068 
0069 private:
0070   static const unsigned int detStartBit_ = 2;
0071   static const unsigned int sterStartBit_ = 0;
0072 
0073   static const unsigned int detMask_ = 0x3;
0074   static const unsigned int sterMask_ = 0x3;
0075 };
0076 
0077 #endif