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, uint32_t station, uint32_t romanPot = 0, uint32_t plane = 0, uint32_t channel = 0);
37 
38  static constexpr uint32_t startPlaneBit = 17, maskPlane = 0x3, maxPlane = 3, lowMaskPlane = 0x1FFFF;
39  static constexpr uint32_t startDetBit = 12, maskChannel = 0x1F, maxChannel = 31, lowMaskChannel = 0xFFF;
40 
42  static bool check(unsigned int raw) {
43  return (((raw >> DetId::kDetOffset) & 0xF) == DetId::VeryForward &&
44  ((raw >> DetId::kSubdetOffset) & 0x7) == sdTimingFastSilicon);
45  }
46  //-------------------- getting and setting methods --------------------
47 
48  uint32_t plane() const { return ((id_ >> startPlaneBit) & maskPlane); }
49 
50  void setPlane(uint32_t channel) {
51  id_ &= ~(maskPlane << startPlaneBit);
52  id_ |= ((channel & maskPlane) << startPlaneBit);
53  }
54 
55  uint32_t channel() const { return ((id_ >> startDetBit) & maskChannel); }
56 
57  void setChannel(uint32_t channel) {
58  id_ &= ~(maskChannel << startDetBit);
59  id_ |= ((channel & maskChannel) << startDetBit);
60  }
61 
62  //-------------------- id getters for higher-level objects --------------------
63 
65 
66  //-------------------- name methods --------------------
67 
68  inline void planeName(std::string& name, NameFlag flag = nFull) const {
69  switch (flag) {
70  case nShort:
71  name = "";
72  break;
73  case nFull:
74  rpName(name, flag);
75  name += "_";
76  break;
77  case nPath:
78  rpName(name, flag);
79  name += "/plane ";
80  break;
81  }
82  name += std::to_string(plane());
83  }
84 
85  inline void channelName(std::string& name, NameFlag flag = nFull) const {
86  switch (flag) {
87  case nShort:
88  name = "";
89  break;
90  case nFull:
91  planeName(name, flag);
92  name += "_";
93  break;
94  case nPath:
95  planeName(name, flag);
96  name += "/channel ";
97  break;
98  }
99  name += std::to_string(channel());
100  }
101 };
102 
103 std::ostream& operator<<(std::ostream& os, const TotemTimingDetId& id);
104 
105 #endif
uint32_t station() const
Definition: CTPPSDetId.h:58
void channelName(std::string &name, NameFlag flag=nFull) const
static uint32_t lowMaskPlane
void setChannel(uint32_t channel)
static uint32_t startPlaneBit
NameFlag
type of name returned by *Name functions
Definition: CTPPSDetId.h:83
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:50
uint32_t channel() const
static const int kSubdetOffset
Definition: DetId.h:23
static uint32_t maskPlane
TotemTimingDetId getPlaneId() const
void setPlane(uint32_t channel)
static uint32_t lowMaskChannel
TotemTimingDetId(const CTPPSDetId &id)
TotemTimingDetId(uint32_t id)
Construct from a raw id.
static uint32_t maxChannel
void rpName(std::string &name, NameFlag flag=nFull) const
Definition: CTPPSDetId.h:128
uint32_t arm() const
Definition: CTPPSDetId.h:51
static bool check(unsigned int raw)
returns true if the raw ID is a PPS-timing one
static uint32_t maxPlane
uint32_t plane() const
static uint32_t startDetBit
uint32_t id_
Definition: DetId.h:62
static uint32_t maskChannel
Base class for CTPPS detector IDs.
Definition: CTPPSDetId.h:32
std::ostream & operator<<(std::ostream &os, const TotemTimingDetId &id)
static const int kDetOffset
Definition: DetId.h:22
void planeName(std::string &name, NameFlag flag=nFull) const
#define constexpr
Detector ID class for CTPPS Totem Timing detectors. Bits [19:31] : Assigend in CTPPSDetId Calss Bits ...