File indexing completed on 2024-04-06 12:04:01
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include "DataFormats/CTPPSDetId/interface/TotemT2DetId.h"
0010 #include "FWCore/Utilities/interface/Exception.h"
0011
0012
0013
0014 TotemT2DetId::TotemT2DetId(uint32_t id) : CTPPSDetId(id) {
0015 if (!check(id))
0016 throw cms::Exception("InvalidDetId") << "TotemT2DetId ctor:"
0017 << " channel: " << channel() << " subdet: " << subdetId()
0018 << " is not a valid Totem nT2 id";
0019 }
0020
0021
0022
0023 TotemT2DetId::TotemT2DetId(uint32_t arm, uint32_t plane, uint32_t channel) : CTPPSDetId(sdTotemT2, arm, 0, 0) {
0024 if (arm > maxArm || plane > maxPlane || channel > maxChannel)
0025 throw cms::Exception("InvalidDetId") << "TotemT2DetId ctor:"
0026 << " Invalid parameters:"
0027 << " arm=" << arm << " plane=" << plane << " detector=" << channel;
0028
0029 uint32_t ok = 0xfe000000;
0030 id_ &= ok;
0031
0032 id_ |= ((arm & maskArm) << startArmBit);
0033 id_ |= ((plane & maskPlane) << startPlaneBit);
0034 id_ |= ((channel & maskChannel) << startChannelBit);
0035 }
0036
0037
0038
0039 void TotemT2DetId::planeName(std::string& name, NameFlag flag) const {
0040 switch (flag) {
0041 case nShort:
0042 name = "";
0043 break;
0044 case nFull:
0045 armName(name, flag);
0046 name += "_";
0047 break;
0048 case nPath:
0049 armName(name, flag);
0050 name += "/plane ";
0051 break;
0052 }
0053 name += std::to_string(plane());
0054 }
0055
0056
0057
0058 void TotemT2DetId::channelName(std::string& name, NameFlag flag) const {
0059 switch (flag) {
0060 case nShort:
0061 name = "";
0062 break;
0063 case nFull:
0064 planeName(name, flag);
0065 name += "_";
0066 break;
0067 case nPath:
0068 planeName(name, flag);
0069 name += "/channel ";
0070 break;
0071 }
0072 name += std::to_string(channel());
0073 }
0074
0075
0076
0077 std::ostream& operator<<(std::ostream& os, const TotemT2DetId& id) {
0078 return os << "arm=" << id.arm() << " plane=" << id.plane() << " channel=" << id.channel();
0079 }