CMS 3D CMS Logo

TotemRPDetId.h
Go to the documentation of this file.
1 /****************************************************************************
2  *
3  * This is a part of TOTEM offline software.
4  * Authors:
5  * Hubert Niewiadomski
6  * Jan Kašpar (jan.kaspar@gmail.com)
7  *
8  ****************************************************************************/
9 
10 #ifndef DataFormats_CTPPSDetId_TotemRPDetId
11 #define DataFormats_CTPPSDetId_TotemRPDetId
12 
14 
16 
17 #include <iosfwd>
18 #include <iostream>
19 #include <string>
20 
30 class TotemRPDetId : public CTPPSDetId
31 {
32  public:
35  explicit TotemRPDetId(uint32_t id);
36 
38  {
39  }
40 
42  TotemRPDetId(uint32_t Arm, uint32_t Station, uint32_t RomanPot=0, uint32_t Plane=0, uint32_t Chip=0);
43 
44  static const uint32_t startPlaneBit, maskPlane, maxPlane, lowMaskPlane;
45  static const uint32_t startChipBit, maskChip, maxChip, lowMaskChip;
46 
47  //-------------------- component getters and setters --------------------
48 
49  uint32_t plane() const
50  {
51  return ((id_>>startPlaneBit) & maskPlane);
52  }
53 
54  void setPlane(uint32_t det)
55  {
56  id_ &= ~(maskPlane << startPlaneBit);
57  id_ |= ((det & maskPlane) << startPlaneBit);
58  }
59 
60  uint32_t chip() const
61  {
62  return ((id_>>startChipBit) & maskChip);
63  }
64 
65  void setChip(uint32_t chip)
66  {
67  id_ &= ~(maskChip << startChipBit);
68  id_ |= ((chip & maskChip) << startChipBit);
69  }
70 
71  //-------------------- id getters for higher-level objects --------------------
72 
74  {
75  return TotemRPDetId( rawId() & (~lowMaskPlane) );
76  }
77 
78  //-------------------- strip orientation methods --------------------
79 
81  {
82  return plane() % 2;
83  }
84 
86  {
88  }
89 
90  //-------------------- conversions to the obsolete decimal representation --------------------
91  // NOTE: only for backward compatibility, do not use otherwise!
92 
93  inline uint32_t getRPDecimalId() const
94  {
95  return rp() + station()*10 + arm()*100;
96  }
97 
98  inline uint32_t getPlaneDecimalId() const
99  {
100  return plane() + getRPDecimalId()*10;
101  }
102 
103  //-------------------- name methods --------------------
104 
105  inline void planeName(std::string &name, NameFlag flag = nFull) const
106  {
107  switch (flag)
108  {
109  case nShort: name = ""; break;
110  case nFull: rpName(name, flag); name += "_"; break;
111  case nPath: rpName(name, flag); name += "/plane "; break;
112  }
113 
114  name += planeNames[plane()];
115  }
116 
117  inline void chipName(std::string &name, NameFlag flag = nFull) const
118  {
119  switch (flag)
120  {
121  case nShort: name = ""; break;
122  case nFull: planeName(name, flag); name += "_"; break;
123  case nPath: planeName(name, flag); name += "/chip "; break;
124  }
125 
126  name += chipNames[chip()];
127  }
128 
129  private:
130  static const std::string planeNames[];
131  static const std::string chipNames[];
132 };
133 
134 std::ostream& operator<<(std::ostream& os, const TotemRPDetId& id);
135 
136 #endif
Detector ID class for TOTEM Si strip detectors.
Definition: TotemRPDetId.h:30
uint32_t station() const
Definition: CTPPSDetId.h:63
static const uint32_t maskChip
Definition: TotemRPDetId.h:45
static const uint32_t startChipBit
Definition: TotemRPDetId.h:45
uint32_t chip() const
Definition: TotemRPDetId.h:60
NameFlag
type of name returned by *Name functions
Definition: CTPPSDetId.h:105
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:47
uint32_t getRPDecimalId() const
Definition: TotemRPDetId.h:93
uint32_t plane() const
Definition: TotemRPDetId.h:49
std::ostream & operator<<(std::ostream &os, const TotemRPDetId &id)
Definition: TotemRPDetId.cc:69
bool isStripsCoordinateUDirection() const
Definition: TotemRPDetId.h:80
TotemRPDetId(uint32_t id)
Definition: TotemRPDetId.cc:27
Definition: Plane.h:17
bool isStripsCoordinateVDirection() const
Definition: TotemRPDetId.h:85
static const uint32_t lowMaskChip
Definition: TotemRPDetId.h:45
TotemRPDetId(const CTPPSDetId &id)
Definition: TotemRPDetId.h:37
void rpName(std::string &name, NameFlag flag=nFull) const
Definition: CTPPSDetId.h:139
uint32_t arm() const
Definition: CTPPSDetId.h:52
uint32_t id_
Definition: DetId.h:59
void setPlane(uint32_t det)
Definition: TotemRPDetId.h:54
void chipName(std::string &name, NameFlag flag=nFull) const
Definition: TotemRPDetId.h:117
void setChip(uint32_t chip)
Definition: TotemRPDetId.h:65
static const std::string planeNames[]
Definition: TotemRPDetId.h:130
Base class for CTPPS detector IDs.
Definition: CTPPSDetId.h:32
static const uint32_t lowMaskPlane
Definition: TotemRPDetId.h:44
static const uint32_t startPlaneBit
Definition: TotemRPDetId.h:44
static const uint32_t maxChip
Definition: TotemRPDetId.h:45
static const uint32_t maskPlane
Definition: TotemRPDetId.h:44
uint32_t getPlaneDecimalId() const
Definition: TotemRPDetId.h:98
void planeName(std::string &name, NameFlag flag=nFull) const
Definition: TotemRPDetId.h:105
static const uint32_t maxPlane
Definition: TotemRPDetId.h:44
TotemRPDetId getPlaneId() const
Definition: TotemRPDetId.h:73
static const std::string chipNames[]
Definition: TotemRPDetId.h:131
uint32_t rp() const
Definition: CTPPSDetId.h:74
constexpr Detector det() const
get the detector field from this detid
Definition: DetId.h:39