CMS 3D CMS Logo

TotemT2DetId.h
Go to the documentation of this file.
1 /****************************************************************************
2  *
3  * This is a part of TOTEM offline software.
4  * Authors:
5  * Laurent Forthomme (laurent.forthomme@cern.ch)
6  *
7  ****************************************************************************/
8 
9 #ifndef DataFormats_CTPPSDetId_TotemT2DetId
10 #define DataFormats_CTPPSDetId_TotemT2DetId
11 
13 
14 #include <iosfwd>
15 #include <string>
16 
25 class TotemT2DetId : public CTPPSDetId {
26 public:
28  explicit TotemT2DetId(uint32_t id);
30 
32  TotemT2DetId(uint32_t arm, uint32_t plane, uint32_t channel = 0);
33 
34  static constexpr uint32_t startPlaneBit = 16, maskPlane = 0x7, maxPlane = 7, lowMaskPlane = 0xffff;
35  static constexpr uint32_t startChannelBit = 14, maskChannel = 0x3, maxChannel = 3, lowMaskChannel = 0x1fff;
36 
38  static bool check(unsigned int raw) {
39  return (((raw >> DetId::kDetOffset) & 0xF) == DetId::VeryForward &&
40  ((raw >> DetId::kSubdetOffset) & 0x7) == sdTotemT2);
41  }
42  //-------------------- getting and setting methods --------------------
43 
44  uint32_t plane() const { return ((id_ >> startPlaneBit) & maskPlane); }
45 
46  void setPlane(uint32_t channel) {
47  id_ &= ~(maskPlane << startPlaneBit);
48  id_ |= ((channel & maskPlane) << startPlaneBit);
49  }
50 
51  uint32_t channel() const { return ((id_ >> startChannelBit) & maskChannel); }
52 
53  void setChannel(uint32_t channel) {
56  }
57 
58  //-------------------- id getters for higher-level objects --------------------
59 
60  TotemT2DetId planeId() const { return TotemT2DetId(rawId() & (~lowMaskPlane)); }
61 
62  //-------------------- name methods --------------------
63 
64  void planeName(std::string& name, NameFlag flag = nFull) const;
66 };
67 
68 std::ostream& operator<<(std::ostream& os, const TotemT2DetId& id);
69 
70 namespace std {
71  template <>
72  struct hash<TotemT2DetId> {
74  typedef std::size_t result_type;
75  result_type operator()(const argument_type& id) const noexcept { return std::hash<uint64_t>()(id.rawId()); }
76  };
77 } // namespace std
78 
79 #endif
std::ostream & operator<<(std::ostream &os, const TotemT2DetId &id)
Definition: TotemT2DetId.cc:77
Detector ID class for Totem T2 detectors. Bits [19:31] : Base CTPPSDetId class attributes Bits [16:18...
Definition: TotemT2DetId.h:25
uint32_t arm() const
Definition: CTPPSDetId.h:57
NameFlag
type of name returned by *Name functions
Definition: CTPPSDetId.h:89
void setPlane(uint32_t channel)
Definition: TotemT2DetId.h:46
static constexpr uint32_t startChannelBit
Definition: TotemT2DetId.h:35
static constexpr uint32_t maxChannel
Definition: TotemT2DetId.h:35
TotemT2DetId planeId() const
Definition: TotemT2DetId.h:60
static constexpr uint32_t maskChannel
Definition: TotemT2DetId.h:35
static const int kSubdetOffset
Definition: DetId.h:22
static constexpr uint32_t maxPlane
Definition: TotemT2DetId.h:34
static constexpr uint32_t lowMaskPlane
Definition: TotemT2DetId.h:34
static constexpr uint32_t lowMaskChannel
Definition: TotemT2DetId.h:35
uint32_t plane() const
Definition: TotemT2DetId.h:44
TotemT2DetId(const CTPPSDetId &id)
Definition: TotemT2DetId.h:29
result_type operator()(const argument_type &id) const noexcept
Definition: TotemT2DetId.h:75
static constexpr uint32_t maskPlane
Definition: TotemT2DetId.h:34
void planeName(std::string &name, NameFlag flag=nFull) const
Definition: TotemT2DetId.cc:39
TotemT2DetId argument_type
Definition: TotemT2DetId.h:73
void setChannel(uint32_t channel)
Definition: TotemT2DetId.h:53
TotemT2DetId(uint32_t id)
Construct from a raw id.
Definition: TotemT2DetId.cc:14
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
uint32_t id_
Definition: DetId.h:69
Base class for CTPPS detector IDs.
Definition: CTPPSDetId.h:32
static const int kDetOffset
Definition: DetId.h:21
void channelName(std::string &name, NameFlag flag=nFull) const
Definition: TotemT2DetId.cc:58
static constexpr uint32_t startPlaneBit
Definition: TotemT2DetId.h:34
static bool check(unsigned int raw)
returns true if the raw ID is a PPS-timing one
Definition: TotemT2DetId.h:38
uint32_t channel() const
Definition: TotemT2DetId.h:51