CMS 3D CMS Logo

TotemTimingDetId.h
Go to the documentation of this file.
1 /****************************************************************************
2  * Author: Nicola Minafra
3  * March 2018
4  ****************************************************************************/
5 
6 #ifndef DataFormats_CTPPSDetId_TotemTimingDetId
7 #define DataFormats_CTPPSDetId_TotemTimingDetId
8 
10 
12 
13 #include <iosfwd>
14 #include <iostream>
15 #include <string>
16 
27 class TotemTimingDetId : public CTPPSDetId {
28 public:
29  enum { ID_NOT_SET = 28 };
30 
32  explicit TotemTimingDetId(uint32_t id);
34 
36  TotemTimingDetId(uint32_t arm,
37  uint32_t station,
38  uint32_t romanPot = 0,
39  uint32_t plane = 0,
40  uint32_t channel = 0,
41  uint32_t subdet = sdTimingFastSilicon);
42 
43  static constexpr uint32_t startPlaneBit = 17, maskPlane = 0x3, maxPlane = 3, lowMaskPlane = 0x1FFFF;
44  static constexpr uint32_t startDetBit = 12, maskChannel = 0x1F, maxChannel = 31, lowMaskChannel = 0xFFF;
45 
47  static bool check(unsigned int raw) {
48  return (((raw >> DetId::kDetOffset) & 0xF) == DetId::VeryForward &&
49  (((raw >> DetId::kSubdetOffset) & 0x7) == sdTimingFastSilicon ||
50  ((raw >> DetId::kSubdetOffset) & 0x7) == sdTimingDiamond));
51  }
52  //-------------------- getting and setting methods --------------------
53 
54  uint32_t plane() const { return ((id_ >> startPlaneBit) & maskPlane); }
55 
56  void setPlane(uint32_t channel) {
57  id_ &= ~(maskPlane << startPlaneBit);
58  id_ |= ((channel & maskPlane) << startPlaneBit);
59  }
60 
61  uint32_t channel() const { return ((id_ >> startDetBit) & maskChannel); }
62 
63  void setChannel(uint32_t channel) {
64  id_ &= ~(maskChannel << startDetBit);
65  id_ |= ((channel & maskChannel) << startDetBit);
66  }
67 
68  //-------------------- id getters for higher-level objects --------------------
69 
71 
72  //-------------------- name methods --------------------
73 
74  inline void planeName(std::string& name, NameFlag flag = nFull) const {
75  switch (flag) {
76  case nShort:
77  name = "";
78  break;
79  case nFull:
80  rpName(name, flag);
81  name += "_";
82  break;
83  case nPath:
84  rpName(name, flag);
85  name += "/plane ";
86  break;
87  }
89  }
90 
91  inline void channelName(std::string& name, NameFlag flag = nFull) const {
92  switch (flag) {
93  case nShort:
94  name = "";
95  break;
96  case nFull:
98  name += "_";
99  break;
100  case nPath:
101  planeName(name, flag);
102  name += "/channel ";
103  break;
104  }
106  }
107 };
108 
109 std::ostream& operator<<(std::ostream& os, const TotemTimingDetId& id);
110 
111 #endif
static constexpr uint32_t lowMaskChannel
void setChannel(uint32_t channel)
uint32_t arm() const
Definition: CTPPSDetId.h:51
static constexpr uint32_t maskPlane
NameFlag
type of name returned by *Name functions
Definition: CTPPSDetId.h:83
std::string to_string(const V &value)
Definition: OMSAccess.h:71
static const int kSubdetOffset
Definition: DetId.h:22
static constexpr uint32_t lowMaskPlane
void channelName(std::string &name, NameFlag flag=nFull) const
static constexpr uint32_t maskChannel
void planeName(std::string &name, NameFlag flag=nFull) const
void setPlane(uint32_t channel)
void rpName(std::string &name, NameFlag flag=nFull) const
Definition: CTPPSDetId.h:128
static constexpr uint32_t startDetBit
uint32_t channel() const
static constexpr uint32_t maxPlane
TotemTimingDetId(const CTPPSDetId &id)
TotemTimingDetId(uint32_t id)
Construct from a raw id.
static constexpr uint32_t maxChannel
static bool check(unsigned int raw)
returns true if the raw ID is a PPS-timing one
static constexpr uint32_t startPlaneBit
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
uint32_t id_
Definition: DetId.h:69
uint32_t station() const
Definition: CTPPSDetId.h:58
Base class for CTPPS detector IDs.
Definition: CTPPSDetId.h:32
uint32_t plane() const
TotemTimingDetId planeId() const
std::ostream & operator<<(std::ostream &os, const TotemTimingDetId &id)
static const int kDetOffset
Definition: DetId.h:21
Detector ID class for CTPPS Totem Timing detectors. Bits [19:31] : Assigend in CTPPSDetId Calss Bits ...