PXBDetId.hpp 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #ifndef DataFormats_SiStripDetId_PXBDetId_H
  2. #define DataFormats_SiStripDetId_PXBDetId_H
  3. #include <ostream>
  4. #include "util/DetId.hpp"
  5. #include "util/PixelSubdetector.hpp"
  6. /**
  7. * Det identifier class for the PixelBarrel
  8. */
  9. class PXBDetId;
  10. std::ostream& operator<<(std::ostream& os,const PXBDetId& id);
  11. class PXBDetId : public DetId {
  12. public:
  13. /** Constructor of a null id */
  14. PXBDetId();
  15. /** Constructor from a raw value */
  16. PXBDetId(uint32_t rawid);
  17. /**Construct from generic DetId */
  18. PXBDetId(const DetId& id);
  19. PXBDetId(uint32_t layer, uint32_t ladder, uint32_t module)
  20. :DetId(DetId::Tracker,PixelSubdetector::PixelBarrel){
  21. id_ |= (layer& layerMask_) << layerStartBit_ |
  22. (ladder& ladderMask_) << ladderStartBit_ |
  23. (module& moduleMask_) << moduleStartBit_;
  24. }
  25. /// layer id
  26. unsigned int layer() const{
  27. return int((id_>>layerStartBit_) & layerMask_);}
  28. /// ladder id
  29. unsigned int ladder() const
  30. { return ((id_>>ladderStartBit_) & ladderMask_) ;}
  31. /// det id
  32. unsigned int module() const
  33. { return ((id_>>moduleStartBit_)& moduleMask_) ;}
  34. private:
  35. /// two bits would be enough, but we could use the number "0" as a wildcard
  36. static const unsigned int layerStartBit_= 16;
  37. static const unsigned int ladderStartBit_= 8;
  38. static const unsigned int moduleStartBit_= 2;
  39. /// two bits would be enough, but we could use the number "0" as a wildcard
  40. static const unsigned int layerMask_= 0xF;
  41. static const unsigned int ladderMask_= 0xFF;
  42. static const unsigned int moduleMask_= 0x3F;
  43. };
  44. #endif