File indexing completed on 2024-04-06 12:04:00
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #include "DataFormats/CTPPSDetId/interface/TotemRPDetId.h"
0011
0012 #include "FWCore/Utilities/interface/Exception.h"
0013
0014 using namespace std;
0015
0016
0017
0018 const uint32_t TotemRPDetId::startPlaneBit = 15, TotemRPDetId::maskPlane = 0xF, TotemRPDetId::maxPlane = 9,
0019 TotemRPDetId::lowMaskPlane = 0x7FFF;
0020 const uint32_t TotemRPDetId::startChipBit = 13, TotemRPDetId::maskChip = 0x3, TotemRPDetId::maxChip = 3,
0021 TotemRPDetId::lowMaskChip = 0x1FFF;
0022
0023 const string TotemRPDetId::planeNames[] = {"01", "02", "03", "04", "05", "06", "07", "08", "09", "10"};
0024 const string TotemRPDetId::chipNames[] = {"1", "2", "3", "4"};
0025
0026
0027
0028 TotemRPDetId::TotemRPDetId(uint32_t id) : CTPPSDetId(id) {
0029 bool inputOK = (det() == DetId::VeryForward && subdetId() == sdTrackingStrip);
0030
0031 if (!inputOK) {
0032 throw cms::Exception("InvalidDetId") << "TotemRPDetId ctor:"
0033 << " det: " << det() << " subdet: " << subdetId()
0034 << " is not a valid TotemRP id.";
0035 }
0036 }
0037
0038
0039
0040 TotemRPDetId::TotemRPDetId(uint32_t Arm, uint32_t Station, uint32_t RomanPot, uint32_t Plane, uint32_t Chip)
0041 : CTPPSDetId(sdTrackingStrip, Arm, Station, RomanPot) {
0042 if (Arm > maxArm || Station > maxStation || RomanPot > maxRP || Plane > maxPlane || Chip > maxChip) {
0043 throw cms::Exception("InvalidDetId") << "TotemRPDetId ctor:"
0044 << " Invalid parameters:"
0045 << " arm=" << Arm << " station=" << Station << " rp=" << RomanPot
0046 << " plane=" << Plane << " chip=" << Chip << std::endl;
0047 }
0048
0049 uint32_t ok = 0xfe000000;
0050 id_ &= ok;
0051
0052 id_ |= ((Arm & maskArm) << startArmBit);
0053 id_ |= ((Station & maskStation) << startStationBit);
0054 id_ |= ((RomanPot & maskRP) << startRPBit);
0055 id_ |= ((Plane & maskPlane) << startPlaneBit);
0056 id_ |= ((Chip & maskChip) << startChipBit);
0057 }
0058
0059
0060
0061 std::ostream& operator<<(std::ostream& os, const TotemRPDetId& id) {
0062 os << "arm=" << id.arm() << " station=" << id.station() << " rp=" << id.rp() << " plane=" << id.plane()
0063 << " chip=" << id.chip();
0064
0065 return os;
0066 }