File indexing completed on 2024-04-06 12:04:00
0001
0002
0003
0004
0005
0006 #ifndef DataFormats_CTPPSDetId_TotemTimingDetId
0007 #define DataFormats_CTPPSDetId_TotemTimingDetId
0008
0009 #include "DataFormats/CTPPSDetId/interface/CTPPSDetId.h"
0010
0011 #include "FWCore/Utilities/interface/Exception.h"
0012
0013 #include <iosfwd>
0014 #include <iostream>
0015 #include <string>
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027 class TotemTimingDetId : public CTPPSDetId {
0028 public:
0029 enum { ID_NOT_SET = 28 };
0030
0031
0032 explicit TotemTimingDetId(uint32_t id);
0033 TotemTimingDetId(const CTPPSDetId& id) : CTPPSDetId(id) {}
0034
0035
0036 TotemTimingDetId(uint32_t arm,
0037 uint32_t station,
0038 uint32_t romanPot = 0,
0039 uint32_t plane = 0,
0040 uint32_t channel = 0,
0041 uint32_t subdet = sdTimingFastSilicon);
0042
0043 static constexpr uint32_t startPlaneBit = 17, maskPlane = 0x3, maxPlane = 3, lowMaskPlane = 0x1FFFF;
0044 static constexpr uint32_t startDetBit = 12, maskChannel = 0x1F, maxChannel = 31, lowMaskChannel = 0xFFF;
0045
0046
0047 static bool check(unsigned int raw) {
0048 return (((raw >> DetId::kDetOffset) & 0xF) == DetId::VeryForward &&
0049 (((raw >> DetId::kSubdetOffset) & 0x7) == sdTimingFastSilicon ||
0050 ((raw >> DetId::kSubdetOffset) & 0x7) == sdTimingDiamond));
0051 }
0052
0053
0054 uint32_t plane() const { return ((id_ >> startPlaneBit) & maskPlane); }
0055
0056 void setPlane(uint32_t channel) {
0057 id_ &= ~(maskPlane << startPlaneBit);
0058 id_ |= ((channel & maskPlane) << startPlaneBit);
0059 }
0060
0061 uint32_t channel() const { return ((id_ >> startDetBit) & maskChannel); }
0062
0063 void setChannel(uint32_t channel) {
0064 id_ &= ~(maskChannel << startDetBit);
0065 id_ |= ((channel & maskChannel) << startDetBit);
0066 }
0067
0068
0069
0070 TotemTimingDetId planeId() const { return TotemTimingDetId(rawId() & (~lowMaskPlane)); }
0071
0072
0073
0074 inline void planeName(std::string& name, NameFlag flag = nFull) const {
0075 switch (flag) {
0076 case nShort:
0077 name = "";
0078 break;
0079 case nFull:
0080 rpName(name, flag);
0081 name += "_";
0082 break;
0083 case nPath:
0084 rpName(name, flag);
0085 name += "/plane ";
0086 break;
0087 }
0088 name += std::to_string(plane());
0089 }
0090
0091 inline void channelName(std::string& name, NameFlag flag = nFull) const {
0092 switch (flag) {
0093 case nShort:
0094 name = "";
0095 break;
0096 case nFull:
0097 planeName(name, flag);
0098 name += "_";
0099 break;
0100 case nPath:
0101 planeName(name, flag);
0102 name += "/channel ";
0103 break;
0104 }
0105 name += std::to_string(channel());
0106 }
0107 };
0108
0109 std::ostream& operator<<(std::ostream& os, const TotemTimingDetId& id);
0110
0111 #endif