File indexing completed on 2023-03-17 10:50:42
0001 #ifndef DataFormats_MuonDetId_ME0DetId_h
0002 #define DataFormats_MuonDetId_ME0DetId_h
0003
0004
0005
0006
0007
0008
0009
0010 #include "DataFormats/DetId/interface/DetId.h"
0011 #include "FWCore/Utilities/interface/Exception.h"
0012
0013 #include <iosfwd>
0014 #include <iostream>
0015
0016 class ME0DetId : public DetId {
0017 public:
0018 ME0DetId();
0019
0020
0021
0022 ME0DetId(uint32_t id);
0023 ME0DetId(DetId id);
0024
0025
0026 ME0DetId(int region, int layer, int chamber, int roll);
0027
0028
0029 bool operator<(const ME0DetId& r) const {
0030 if (this->layer() == r.layer()) {
0031 return this->rawId() < r.rawId();
0032 } else {
0033 return (this->layer() > r.layer());
0034 }
0035 }
0036
0037
0038 int region() const { return int((id_ >> RegionStartBit_) & RegionMask_) + minRegionId; }
0039
0040
0041 int chamber() const { return int((id_ >> ChamberStartBit_) & ChamberMask_) + minChamberId; }
0042
0043
0044 int layer() const { return int((id_ >> LayerStartBit_) & LayerMask_) + minLayerId; }
0045
0046
0047
0048 int roll() const {
0049 return int((id_ >> RollStartBit_) & RollMask_) + minRollId;
0050 }
0051
0052
0053 ME0DetId chamberId() const { return ME0DetId(id_ & chamberIdMask_); }
0054
0055 ME0DetId layerId() const { return ME0DetId(id_ & layerIdMask_); }
0056
0057
0058 int station() const { return 1; }
0059
0060
0061 int nlayers() const { return int(maxLayerId); }
0062
0063 static constexpr int minRegionId = -1;
0064 static constexpr int maxRegionId = 1;
0065
0066 static constexpr int minChamberId = 0;
0067 static constexpr int maxChamberId = 18;
0068
0069 static constexpr int minLayerId = 0;
0070 static constexpr int maxLayerId = 6;
0071
0072 static constexpr int minRollId = 0;
0073 static constexpr int maxRollId = 10;
0074
0075 private:
0076 static constexpr int RegionNumBits_ = 2;
0077 static constexpr int RegionStartBit_ = 0;
0078 static constexpr int RegionMask_ = 0X3;
0079
0080 static constexpr int ChamberNumBits_ = 6;
0081 static constexpr int ChamberStartBit_ = RegionStartBit_ + RegionNumBits_;
0082 static constexpr unsigned int ChamberMask_ = 0X3F;
0083
0084 static constexpr int LayerNumBits_ = 5;
0085 static constexpr int LayerStartBit_ = ChamberStartBit_ + ChamberNumBits_;
0086 static constexpr unsigned int LayerMask_ = 0X1F;
0087
0088 static constexpr int RollNumBits_ = 5;
0089 static constexpr int RollStartBit_ = LayerStartBit_ + LayerNumBits_;
0090 static constexpr unsigned int RollMask_ = 0X1F;
0091
0092 public:
0093 static constexpr uint32_t chamberIdMask_ = ~((LayerMask_ << LayerStartBit_) | (RollMask_ << RollStartBit_));
0094 static constexpr uint32_t layerIdMask_ = ~(RollMask_ << RollStartBit_);
0095
0096 private:
0097 void init(int region, int layer, int chamber, int roll);
0098
0099 int trind;
0100 };
0101
0102 std::ostream& operator<<(std::ostream& os, const ME0DetId& id);
0103
0104 #endif