CMS 3D CMS Logo

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   
00038   // ---------- Common methods ----------
00039 
00041   inline SubDetector subDetector() const;
00042   
00044   inline virtual uint32_t glued() const;
00045   
00047   inline virtual uint32_t stereo() const;
00048 
00050   inline virtual uint32_t partnerDetId() const;
00051  
00053   inline virtual double stripLength() const;
00054   
00056   //  inline virtual bool isDoubleSide() const;
00057   
00058   // ---------- Constructors that set "reserved" field ----------
00059   
00061   SiStripDetId( const uint32_t& raw_id, 
00062                 const uint16_t& reserved );
00063   
00065   SiStripDetId( const DetId& det_id, 
00066                 const uint16_t& reserved );
00067   
00069   inline uint16_t reserved() const;
00070   
00071  private:
00072   
00074   static const uint16_t reservedStartBit_ = 20;
00075 
00077   static const uint32_t sterStartBit_ = 0;
00078 
00080   static const uint16_t reservedMask_ = 0x7;
00081 
00083   static const uint32_t sterMask_ = 0x3;
00084   
00085 };
00086 
00087 // ---------- inline methods ----------
00088 
00089 SiStripDetId::SubDetector SiStripDetId::subDetector() const {
00090   if( det() == DetId::Tracker &&
00091       subdetId() == static_cast<int>(SiStripDetId::TIB) ) {
00092     return SiStripDetId::TIB;
00093   } else if ( det() == DetId::Tracker &&
00094               subdetId() == static_cast<int>(SiStripDetId::TID) ) {
00095     return SiStripDetId::TID;
00096   } else if ( det() == DetId::Tracker &&
00097               subdetId() == static_cast<int>(SiStripDetId::TOB) ) {
00098     return SiStripDetId::TOB;
00099   } else if ( det() == DetId::Tracker &&
00100               subdetId() == static_cast<int>(SiStripDetId::TEC) ) {
00101     return SiStripDetId::TEC;
00102   } else {
00103     return SiStripDetId::UNKNOWN;
00104   }
00105 }
00106 
00107 uint32_t SiStripDetId::glued() const {
00108   if ( ((id_>>sterStartBit_) & sterMask_ ) == 1 ) {
00109     return ( id_ - 1 );
00110   } else if ( ((id_>>sterStartBit_) & sterMask_ ) == 2 ) {
00111     return ( id_ - 2 );
00112   } else { return 0; }
00113 }
00114  
00115 uint32_t SiStripDetId::stereo() const {
00116   if ( ((id_>>sterStartBit_ ) & sterMask_ ) == 1 ) {
00117     return ( (id_>>sterStartBit_) & sterMask_ );
00118   } else { return 0; }
00119 }
00120  
00121 uint32_t SiStripDetId::partnerDetId() const {
00122   if ( ((id_>>sterStartBit_) & sterMask_ ) == 1 ) {
00123     return ( id_ + 1 );
00124   } else if ( ((id_>>sterStartBit_) & sterMask_ ) == 2 ) {
00125     return ( id_ - 1 );
00126   } else { return 0; }
00127 }
00128  
00129 double SiStripDetId::stripLength() const {
00130   return 0.;
00131 }
00132 
00133 //bool SiStripDetId::isDoubleSide() const {
00134 //  return false;
00135 //}
00136 
00137 uint16_t SiStripDetId::reserved() const { 
00138   return static_cast<uint16_t>( (id_>>reservedStartBit_) & reservedMask_ );
00139 }
00140 
00141 #endif // DataFormats_SiStripDetId_SiStripDetId_h
00142 

Generated on Tue Jun 9 17:31:45 2009 for CMSSW by  doxygen 1.5.4