CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch9/src/DataFormats/SiStripDetId/interface/SiStripDetId.h

Go to the documentation of this file.
00001 #ifndef DataFormats_SiStripDetId_SiStripDetId_h
00002 #define DataFormats_SiStripDetId_SiStripDetId_h
00003 
00004 #include "DataFormats/DetId/interface/DetId.h"
00005 #include <ostream>
00006 
00007 class SiStripDetId;
00008 
00010 std::ostream& operator<< ( std::ostream&, const SiStripDetId& );
00011 
00017 class SiStripDetId : public DetId {
00018   
00019  public:
00020 
00021   // ---------- Constructors, enumerated types ----------
00022   
00024   SiStripDetId();
00025 
00027   SiStripDetId( const uint32_t& raw_id );
00028 
00030   SiStripDetId( const DetId& );
00031 
00033   SiStripDetId( Detector det, int subdet );
00034 
00036   enum SubDetector { UNKNOWN=0, TIB=3, TID=4, TOB=5, TEC=6 };
00037   
00039   enum ModuleGeometry {UNKNOWNGEOMETRY, IB1, IB2, OB1, OB2, W1A, W2A, W3A, W1B, W2B, W3B, W4, W5, W6, W7};
00040 
00041   // ---------- Common methods ----------
00042 
00044   inline SubDetector subDetector() const;
00045   
00047   inline ModuleGeometry moduleGeometry() const;
00048 
00050   inline virtual uint32_t glued() const;
00051   
00053   inline virtual uint32_t stereo() const;
00054 
00056   inline virtual uint32_t partnerDetId() const;
00057  
00059   inline virtual double stripLength() const;
00060   
00062   //  inline virtual bool isDoubleSide() const;
00063   
00064   // ---------- Constructors that set "reserved" field ----------
00065   
00067   SiStripDetId( const uint32_t& raw_id, 
00068                 const uint16_t& reserved );
00069   
00071   SiStripDetId( const DetId& det_id, 
00072                 const uint16_t& reserved );
00073   
00075   inline uint16_t reserved() const;
00076   
00077  private:
00078   
00080   static const uint16_t reservedStartBit_ = 20;
00081 
00083   static const uint32_t sterStartBit_ = 0;
00084 
00086   static const uint16_t reservedMask_ = 0x7;
00087 
00089   static const uint32_t sterMask_ = 0x3;
00090 
00091   static const unsigned layerStartBit_ = 14;
00092   static const unsigned layerMask_ = 0x7;
00093   static const unsigned ringStartBitTID_= 9;
00094   static const unsigned ringMaskTID_= 0x3;
00095   static const unsigned ringStartBitTEC_= 5;
00096   static const unsigned ringMaskTEC_= 0x7;
00097   
00098 };
00099 
00100 // ---------- inline methods ----------
00101 
00102 SiStripDetId::SubDetector SiStripDetId::subDetector() const {
00103   if( det() == DetId::Tracker &&
00104       subdetId() == static_cast<int>(SiStripDetId::TIB) ) {
00105     return SiStripDetId::TIB;
00106   } else if ( det() == DetId::Tracker &&
00107               subdetId() == static_cast<int>(SiStripDetId::TID) ) {
00108     return SiStripDetId::TID;
00109   } else if ( det() == DetId::Tracker &&
00110               subdetId() == static_cast<int>(SiStripDetId::TOB) ) {
00111     return SiStripDetId::TOB;
00112   } else if ( det() == DetId::Tracker &&
00113               subdetId() == static_cast<int>(SiStripDetId::TEC) ) {
00114     return SiStripDetId::TEC;
00115   } else {
00116     return SiStripDetId::UNKNOWN;
00117   }
00118 }
00119 
00120 SiStripDetId::ModuleGeometry SiStripDetId::moduleGeometry() const {
00121   switch(subDetector()) {
00122   case TIB: return int((id_>>layerStartBit_) & layerMask_)<3? IB1 : IB2;
00123   case TOB: return int((id_>>layerStartBit_) & layerMask_)<5? OB2 : OB1;
00124   case TID: switch ((id_>>ringStartBitTID_) & ringMaskTID_) {
00125     case 1: return W1A;
00126     case 2: return W2A;
00127     case 3: return W3A;
00128     }
00129   case TEC: switch ((id_>>ringStartBitTEC_) & ringMaskTEC_) {
00130     case 1: return W1B;
00131     case 2: return W2B;
00132     case 3: return W3B;
00133     case 4: return W4;
00134     case 5: return W5;
00135     case 6: return W6;
00136     case 7: return W7;
00137     }
00138   case UNKNOWN: default: return UNKNOWNGEOMETRY;
00139   }
00140 }
00141 
00142 uint32_t SiStripDetId::glued() const {
00143   if ( ((id_>>sterStartBit_) & sterMask_ ) == 1 ) {
00144     return ( id_ - 1 );
00145   } else if ( ((id_>>sterStartBit_) & sterMask_ ) == 2 ) {
00146     return ( id_ - 2 );
00147   } else { return 0; }
00148 }
00149  
00150 uint32_t SiStripDetId::stereo() const {
00151   if ( ((id_>>sterStartBit_ ) & sterMask_ ) == 1 ) {
00152     return ( (id_>>sterStartBit_) & sterMask_ );
00153   } else { return 0; }
00154 }
00155  
00156 uint32_t SiStripDetId::partnerDetId() const {
00157   if ( ((id_>>sterStartBit_) & sterMask_ ) == 1 ) {
00158     return ( id_ + 1 );
00159   } else if ( ((id_>>sterStartBit_) & sterMask_ ) == 2 ) {
00160     return ( id_ - 1 );
00161   } else { return 0; }
00162 }
00163  
00164 double SiStripDetId::stripLength() const {
00165   return 0.;
00166 }
00167 
00168 //bool SiStripDetId::isDoubleSide() const {
00169 //  return false;
00170 //}
00171 
00172 uint16_t SiStripDetId::reserved() const { 
00173   return static_cast<uint16_t>( (id_>>reservedStartBit_) & reservedMask_ );
00174 }
00175 
00176 #endif // DataFormats_SiStripDetId_SiStripDetId_h
00177