File indexing completed on 2024-04-06 12:04:46
0001
0002
0003
0004
0005
0006
0007 #include "DataFormats/MuonDetId/interface/DTChamberId.h"
0008 #include "DataFormats/MuonDetId/interface/MuonSubdetId.h"
0009 #include "FWCore/Utilities/interface/Exception.h"
0010 #include <ostream>
0011
0012 using namespace std;
0013
0014 DTChamberId::DTChamberId() : DetId(DetId::Muon, MuonSubdetId::DT) {}
0015
0016 DTChamberId::DTChamberId(uint32_t id) : DetId(id & chamberIdMask_) {
0017 checkMuonId();
0018 }
0019 DTChamberId::DTChamberId(DetId id) : DetId(id.rawId() & chamberIdMask_) {
0020 checkMuonId();
0021 }
0022
0023 DTChamberId::DTChamberId(int wheel, int station, int sector) : DetId(DetId::Muon, MuonSubdetId::DT) {
0024
0025 if (wheel < minWheelId || wheel > maxWheelId || station < minStationId || station > maxStationId ||
0026 sector < minSectorId || sector > maxSectorId) {
0027 throw cms::Exception("InvalidDetId") << "DTChamberId ctor:"
0028 << " Invalid parameters: "
0029 << " Wh:" << wheel << " St:" << station << " Se:" << sector << std::endl;
0030 }
0031
0032 int tmpwheelid = wheel - minWheelId + 1;
0033 id_ |= (tmpwheelid & wheelMask_) << wheelStartBit_ | (station & stationMask_) << stationStartBit_ |
0034 (sector & sectorMask_) << sectorStartBit_;
0035 }
0036
0037 DTChamberId::DTChamberId(const DTChamberId& chId)
0038
0039 : DetId(chId.rawId() & chamberIdMask_) {}
0040
0041 void DTChamberId::checkMuonId() {
0042 if (det() != DetId::Muon || subdetId() != MuonSubdetId::DT) {
0043 throw cms::Exception("InvalidDetId") << "DTChamberId ctor:"
0044 << " det: " << det() << " subdet: " << subdetId() << " is not a valid DT id";
0045 }
0046 }
0047
0048 std::ostream& operator<<(std::ostream& os, const DTChamberId& id) {
0049 os << " Wh:" << id.wheel() << " St:" << id.station() << " Se:" << id.sector() << " ";
0050
0051 return os;
0052 }