CMS 3D CMS Logo

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 
26 {
27  public:
29  explicit CTPPSDiamondDetId(uint32_t id);
30 
32  {
33  }
34 
36  CTPPSDiamondDetId(uint32_t Arm, uint32_t Station, uint32_t RomanPot=0, uint32_t Plane=0, uint32_t Channel=0);
37 
38  static const uint32_t startPlaneBit, maskPlane, maxPlane, lowMaskPlane;
40 
42  static bool check(unsigned int raw)
43  {
44  return (((raw >>DetId::kDetOffset) & 0xF) == DetId::VeryForward &&
45  ((raw >> DetId::kSubdetOffset) & 0x7) == sdTimingDiamond);
46  }
47  //-------------------- getting and setting methods --------------------
48 
49  uint32_t plane() const
50  {
51  return ((id_>>startPlaneBit) & maskPlane);
52  }
53 
54  void setPlane(uint32_t channel)
55  {
56  id_ &= ~(maskPlane << startPlaneBit);
57  id_ |= ((channel & maskPlane) << startPlaneBit);
58  }
59 
60  uint32_t channel() const
61  {
62  return ((id_>>startDetBit) & maskChannel);
63  }
64 
65  void setChannel(uint32_t channel)
66  {
67  id_ &= ~(maskChannel << startDetBit);
68  id_ |= ((channel & maskChannel) << startDetBit);
69  }
70 
71  //-------------------- id getters for higher-level objects --------------------
72 
74  {
75  return CTPPSDiamondDetId( rawId() & (~lowMaskPlane) );
76  }
77 
78  //-------------------- name methods --------------------
79 
80  inline void planeName(std::string &name, NameFlag flag = nFull) const
81  {
82  switch (flag)
83  {
84  case nShort: name = ""; break;
85  case nFull: rpName(name, flag); name += "_"; break;
86  case nPath: rpName(name, flag); name += "/plane "; break;
87  }
88 
89  name += std::to_string(plane());
90  }
91 
92  inline void channelName(std::string &name, NameFlag flag = nFull) const
93  {
94  switch (flag)
95  {
96  case nShort: name = ""; break;
97  case nFull: planeName(name, flag); name += "_"; break;
98  case nPath: planeName(name, flag); name += "/channel "; break;
99  }
100 
101  name += std::to_string(channel());
102  }
103 };
104 
105 std::ostream& operator<<(std::ostream& os, const CTPPSDiamondDetId& id);
106 
107 #endif
static const uint32_t lowMaskChannel
std::ostream & operator<<(std::ostream &os, const CTPPSDiamondDetId &id)
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:105
void setChannel(uint32_t channel)
void channelName(std::string &name, NameFlag flag=nFull) const
static const uint32_t maxChannel
static const int kSubdetOffset
Definition: DetId.h:21
static const uint32_t maskChannel
Definition: Plane.h:17
uint32_t rawId() const
get the raw id
Definition: DetId.h:44
void rpName(std::string &name, NameFlag flag=nFull) const
Definition: CTPPSDetId.h:139
uint32_t plane() const
CTPPSDiamondDetId getPlaneId() 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:56
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:20
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