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);
33  TotemTimingDetId(const CTPPSDetId& id) : CTPPSDetId(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) {
52  id_ |= ((channel & maskPlane) << startPlaneBit);
53  }
54 
55  uint32_t channel() const { return ((id_ >> startDetBit) & maskChannel); }
56 
57  void setChannel(uint32_t channel) {
59  id_ |= ((channel & maskChannel) << startDetBit);
60  }
61 
62  //-------------------- id getters for higher-level objects --------------------
63 
64  TotemTimingDetId planeId() const { return TotemTimingDetId(rawId() & (~lowMaskPlane)); }
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:
92  name += "_";
93  break;
94  case nPath:
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
TotemTimingDetId::channel
uint32_t channel() const
Definition: TotemTimingDetId.h:56
operator<<
std::ostream & operator<<(std::ostream &os, const TotemTimingDetId &id)
Definition: TotemTimingDetId.cc:41
TotemTimingDetId::ID_NOT_SET
Definition: TotemTimingDetId.h:32
TotemTimingDetId::startDetBit
static constexpr uint32_t startDetBit
Definition: TotemTimingDetId.h:40
TotemTimingDetId::maxChannel
static constexpr uint32_t maxChannel
Definition: TotemTimingDetId.h:40
TotemTimingDetId::TotemTimingDetId
TotemTimingDetId(uint32_t id)
Construct from a raw id.
Definition: TotemTimingDetId.cc:10
CTPPSDetId::sdTimingFastSilicon
Definition: CTPPSDetId.h:44
CTPPSDetId::nShort
Definition: CTPPSDetId.h:87
TotemTimingDetId::check
static bool check(unsigned int raw)
returns true if the raw ID is a PPS-timing one
Definition: TotemTimingDetId.h:43
TotemTimingDetId::plane
uint32_t plane() const
Definition: TotemTimingDetId.h:49
DetId::VeryForward
Definition: DetId.h:31
CTPPSDetId::nPath
Definition: CTPPSDetId.h:87
DetId::kSubdetOffset
static const int kSubdetOffset
Definition: DetId.h:22
CTPPSDetId::station
uint32_t station() const
Definition: CTPPSDetId.h:62
TotemTimingDetId::planeId
TotemTimingDetId planeId() const
Definition: TotemTimingDetId.h:65
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
CTPPSDetId::arm
uint32_t arm() const
Definition: CTPPSDetId.h:55
CTPPSDetId::NameFlag
NameFlag
type of name returned by *Name functions
Definition: CTPPSDetId.h:87
TotemTimingDetId
Detector ID class for CTPPS Totem Timing detectors. Bits [19:31] : Assigend in CTPPSDetId Calss Bits ...
Definition: TotemTimingDetId.h:26
TotemTimingDetId::setChannel
void setChannel(uint32_t channel)
Definition: TotemTimingDetId.h:58
TotemTimingDetId::lowMaskChannel
static constexpr uint32_t lowMaskChannel
Definition: TotemTimingDetId.h:40
DetId::id_
uint32_t id_
Definition: DetId.h:69
CTPPSDetId::nFull
Definition: CTPPSDetId.h:87
CTPPSDetId
Base class for CTPPS detector IDs.
Definition: CTPPSDetId.h:31
TotemTimingDetId::maskPlane
static constexpr uint32_t maskPlane
Definition: TotemTimingDetId.h:39
DetId::kDetOffset
static const int kDetOffset
Definition: DetId.h:21
DetId::rawId
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:31
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
CTPPSDetId.h
Exception.h
TotemTimingDetId::maxPlane
static constexpr uint32_t maxPlane
Definition: TotemTimingDetId.h:39
TotemTimingDetId::planeName
void planeName(std::string &name, NameFlag flag=nFull) const
Definition: TotemTimingDetId.h:69
TotemTimingDetId::lowMaskPlane
static constexpr uint32_t lowMaskPlane
Definition: TotemTimingDetId.h:39
TotemTimingDetId::channelName
void channelName(std::string &name, NameFlag flag=nFull) const
Definition: TotemTimingDetId.h:86
TotemTimingDetId::startPlaneBit
static constexpr uint32_t startPlaneBit
Definition: TotemTimingDetId.h:39
TotemTimingDetId::maskChannel
static constexpr uint32_t maskChannel
Definition: TotemTimingDetId.h:40
RemoveAddSevLevel.flag
flag
Definition: RemoveAddSevLevel.py:116
TotemTimingDetId::setPlane
void setPlane(uint32_t channel)
Definition: TotemTimingDetId.h:51
CTPPSDetId::rpName
void rpName(std::string &name, NameFlag flag=nFull) const
Definition: CTPPSDetId.h:132