File indexing completed on 2024-04-06 12:04:46
0001
0002
0003
0004
0005 #include <DataFormats/MuonDetId/interface/ME0DetId.h>
0006 #include <DataFormats/MuonDetId/interface/MuonSubdetId.h>
0007
0008 ME0DetId::ME0DetId() : DetId(DetId::Muon, MuonSubdetId::ME0) {}
0009
0010 ME0DetId::ME0DetId(uint32_t id) : DetId(id) {
0011 if (det() != DetId::Muon || subdetId() != MuonSubdetId::ME0) {
0012 throw cms::Exception("InvalidDetId") << "ME0DetId ctor:"
0013 << " det: " << det() << " subdet: " << subdetId() << " is not a valid ME0 id";
0014 }
0015 }
0016
0017 ME0DetId::ME0DetId(DetId id) : DetId(id) {
0018 if (det() != DetId::Muon || subdetId() != MuonSubdetId::ME0) {
0019 throw cms::Exception("InvalidDetId") << "ME0DetId ctor:"
0020 << " det: " << det() << " subdet: " << subdetId() << " is not a valid ME0 id";
0021 }
0022 }
0023
0024 ME0DetId::ME0DetId(int region, int layer, int chamber, int roll) : DetId(DetId::Muon, MuonSubdetId::ME0) {
0025 this->init(region, layer, chamber, roll);
0026 }
0027
0028 void ME0DetId::init(int region, int layer, int chamber, int roll) {
0029 if (region < minRegionId || region > maxRegionId || layer < minLayerId || layer > maxLayerId ||
0030 chamber < minChamberId || chamber > maxChamberId || roll < minRollId || roll > maxRollId) {
0031 throw cms::Exception("InvalidDetId") << "ME0DetId ctor:"
0032 << " Invalid parameters: "
0033 << " region " << region << " layer " << layer << " chamber " << chamber
0034 << " etaPartition " << roll << std::endl;
0035 }
0036 int regionInBits = region - minRegionId;
0037 int layerInBits = layer - minLayerId;
0038 int chamberInBits = chamber - minChamberId;
0039 int rollInBits = roll - minRollId;
0040
0041 id_ |= (regionInBits & RegionMask_) << RegionStartBit_ | (layerInBits & LayerMask_) << LayerStartBit_ |
0042 (chamberInBits & ChamberMask_) << ChamberStartBit_ | (rollInBits & RollMask_) << RollStartBit_;
0043 }
0044
0045 std::ostream& operator<<(std::ostream& os, const ME0DetId& id) {
0046 os << " Region " << id.region() << " Layer " << id.layer() << " Chamber " << id.chamber() << " EtaPartition "
0047 << id.roll() << " ";
0048
0049 return os;
0050 }