File indexing completed on 2024-04-06 12:04:00
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef DataFormats_CTPPSDetId_TotemT2DetId
0010 #define DataFormats_CTPPSDetId_TotemT2DetId
0011
0012 #include "DataFormats/CTPPSDetId/interface/CTPPSDetId.h"
0013
0014 #include <iosfwd>
0015 #include <string>
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025 class TotemT2DetId : public CTPPSDetId {
0026 public:
0027
0028 explicit TotemT2DetId(uint32_t id);
0029 TotemT2DetId(const CTPPSDetId& id) : CTPPSDetId(id) {}
0030
0031
0032 TotemT2DetId(uint32_t arm, uint32_t plane, uint32_t channel = 0);
0033
0034 static constexpr uint32_t startPlaneBit = 16, maskPlane = 0x7, maxPlane = 7, lowMaskPlane = 0xffff;
0035 static constexpr uint32_t startChannelBit = 14, maskChannel = 0x3, maxChannel = 3, lowMaskChannel = 0x1fff;
0036
0037
0038 static bool check(unsigned int raw) {
0039 return (((raw >> DetId::kDetOffset) & 0xF) == DetId::VeryForward &&
0040 ((raw >> DetId::kSubdetOffset) & 0x7) == sdTotemT2);
0041 }
0042
0043
0044 uint32_t plane() const { return ((id_ >> startPlaneBit) & maskPlane); }
0045
0046 void setPlane(uint32_t channel) {
0047 id_ &= ~(maskPlane << startPlaneBit);
0048 id_ |= ((channel & maskPlane) << startPlaneBit);
0049 }
0050
0051 uint32_t channel() const { return ((id_ >> startChannelBit) & maskChannel); }
0052
0053 void setChannel(uint32_t channel) {
0054 id_ &= ~(maskChannel << startChannelBit);
0055 id_ |= ((channel & maskChannel) << startChannelBit);
0056 }
0057
0058
0059
0060 TotemT2DetId planeId() const { return TotemT2DetId(rawId() & (~lowMaskPlane)); }
0061
0062
0063
0064 void planeName(std::string& name, NameFlag flag = nFull) const;
0065 void channelName(std::string& name, NameFlag flag = nFull) const;
0066 };
0067
0068 std::ostream& operator<<(std::ostream& os, const TotemT2DetId& id);
0069
0070 namespace std {
0071 template <>
0072 struct hash<TotemT2DetId> {
0073 typedef TotemT2DetId argument_type;
0074 typedef std::size_t result_type;
0075 result_type operator()(const argument_type& id) const noexcept { return std::hash<uint64_t>()(id.rawId()); }
0076 };
0077 }
0078
0079 #endif