Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:54:41

0001 #ifndef DataFormats_SiStripDetId_PXBDetId_H
0002 #define DataFormats_SiStripDetId_PXBDetId_H
0003 
0004 #include <ostream>
0005 #include "DataFormats/DetId/interface/DetId.h"
0006 #include "DataFormats/SiPixelDetId/interface/PixelSubdetector.h"
0007 
0008 /** 
0009  *  Det identifier class for the PixelBarrel
0010  */
0011 
0012 class PXBDetId;
0013 
0014 std::ostream& operator<<(std::ostream& os, const PXBDetId& id);
0015 
0016 class PXBDetId : public DetId {
0017 public:
0018   /** Constructor of a null id */
0019   PXBDetId();
0020   /** Constructor from a raw value */
0021   PXBDetId(uint32_t rawid);
0022   /**Construct from generic DetId */
0023   PXBDetId(const DetId& id);
0024 
0025   PXBDetId(uint32_t layer, uint32_t ladder, uint32_t module) : DetId(DetId::Tracker, PixelSubdetector::PixelBarrel) {
0026     id_ |= (layer & layerMask_) << layerStartBit_ | (ladder & ladderMask_) << ladderStartBit_ |
0027            (module & moduleMask_) << moduleStartBit_;
0028   }
0029 
0030   /// layer id
0031   unsigned int layer() const { return int((id_ >> layerStartBit_) & layerMask_); }
0032 
0033   /// ladder  id
0034   unsigned int ladder() const { return ((id_ >> ladderStartBit_) & ladderMask_); }
0035 
0036   /// det id
0037   unsigned int module() const { return ((id_ >> moduleStartBit_) & moduleMask_); }
0038 
0039 private:
0040   /// two bits would be enough, but  we could use the number "0" as a wildcard
0041   static const unsigned int layerStartBit_ = 16;
0042   static const unsigned int ladderStartBit_ = 8;
0043   static const unsigned int moduleStartBit_ = 2;
0044   /// two bits would be enough, but  we could use the number "0" as a wildcard
0045   static const unsigned int layerMask_ = 0xF;
0046   static const unsigned int ladderMask_ = 0xFF;
0047   static const unsigned int moduleMask_ = 0x3F;
0048 };
0049 
0050 #endif