CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
CTPPSDiamondDetId.h
Go to the documentation of this file.
1 /****************************************************************************
2  * Author: Seyed Mohsen Etesami
3  * September 2016
4  ****************************************************************************/
5 
6 #ifndef DataFormats_CTPPSDetId_CTPPSDiamondDetId
7 #define DataFormats_CTPPSDetId_CTPPSDiamondDetId
8 
10 
12 
13 #include <iosfwd>
14 #include <iostream>
15 #include <string>
16 
25 class CTPPSDiamondDetId : public CTPPSDetId {
26 public:
28  explicit CTPPSDiamondDetId(uint32_t id);
29 
31 
33  CTPPSDiamondDetId(uint32_t Arm, uint32_t Station, uint32_t RomanPot = 0, uint32_t Plane = 0, uint32_t Channel = 0);
34 
35  static const uint32_t startPlaneBit, maskPlane, maxPlane, lowMaskPlane;
37 
39  static bool check(unsigned int raw) {
40  return (((raw >> DetId::kDetOffset) & 0xF) == DetId::VeryForward &&
41  ((raw >> DetId::kSubdetOffset) & 0x7) == sdTimingDiamond);
42  }
43  //-------------------- getting and setting methods --------------------
44 
45  uint32_t plane() const { return ((id_ >> startPlaneBit) & maskPlane); }
46 
47  void setPlane(uint32_t channel) {
48  id_ &= ~(maskPlane << startPlaneBit);
49  id_ |= ((channel & maskPlane) << startPlaneBit);
50  }
51 
52  uint32_t channel() const { return ((id_ >> startDetBit) & maskChannel); }
53 
54  void setChannel(uint32_t channel) {
55  id_ &= ~(maskChannel << startDetBit);
56  id_ |= ((channel & maskChannel) << startDetBit);
57  }
58 
59  //-------------------- id getters for higher-level objects --------------------
60 
62 
63  //-------------------- name methods --------------------
64 
65  inline void planeName(std::string& name, NameFlag flag = nFull) const {
66  switch (flag) {
67  case nShort:
68  name = "";
69  break;
70  case nFull:
71  rpName(name, flag);
72  name += "_";
73  break;
74  case nPath:
75  rpName(name, flag);
76  name += "/plane ";
77  break;
78  }
79 
80  name += std::to_string(plane());
81  }
82 
83  inline void channelName(std::string& name, NameFlag flag = nFull) const {
84  switch (flag) {
85  case nShort:
86  name = "";
87  break;
88  case nFull:
89  planeName(name, flag);
90  name += "_";
91  break;
92  case nPath:
93  planeName(name, flag);
94  name += "/channel ";
95  break;
96  }
97 
98  name += std::to_string(channel());
99  }
100 };
101 
102 std::ostream& operator<<(std::ostream& os, const CTPPSDiamondDetId& id);
103 
104 #endif
static const uint32_t lowMaskChannel
void setPlane(uint32_t channel)
CTPPSDiamondDetId(uint32_t id)
Construct from a raw id.
NameFlag
type of name returned by *Name functions
Definition: CTPPSDetId.h:83
void setChannel(uint32_t channel)
void channelName(std::string &name, NameFlag flag=nFull) const
CTPPSDiamondDetId planeId() const
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
static const uint32_t maxChannel
static const int kSubdetOffset
Definition: DetId.h:22
std::ostream & operator<<(std::ostream &out, const ALILine &li)
Definition: ALILine.cc:167
static const uint32_t maskChannel
Definition: Plane.h:16
void rpName(std::string &name, NameFlag flag=nFull) const
Definition: CTPPSDetId.h:128
uint32_t plane() const
static bool check(unsigned int raw)
returns true if the raw ID is a PPS-timing one
static const uint32_t maxPlane
static const uint32_t startPlaneBit
uint32_t channel() const
uint32_t id_
Definition: DetId.h:69
void planeName(std::string &name, NameFlag flag=nFull) const
Base class for CTPPS detector IDs.
Definition: CTPPSDetId.h:32
static const uint32_t lowMaskPlane
CTPPSDiamondDetId(const CTPPSDetId &id)
static const int kDetOffset
Definition: DetId.h:21
Detector ID class for CTPPS Timing Diamond detectors. Bits [19:31] : Assigend in CTPPSDetId Calss Bit...
static const uint32_t startDetBit
static const uint32_t maskPlane
DQMChannel Channel