CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 public:
34  explicit TotemRPDetId(uint32_t id);
35 
36  TotemRPDetId(const CTPPSDetId& id) : CTPPSDetId(id) {}
37 
39  TotemRPDetId(uint32_t Arm, uint32_t Station, uint32_t RomanPot = 0, uint32_t Plane = 0, uint32_t Chip = 0);
40 
41  static const uint32_t startPlaneBit, maskPlane, maxPlane, lowMaskPlane;
42  static const uint32_t startChipBit, maskChip, maxChip, lowMaskChip;
43 
44  //-------------------- component getters and setters --------------------
45 
46  uint32_t plane() const { return ((id_ >> startPlaneBit) & maskPlane); }
47 
48  void setPlane(uint32_t det) {
49  id_ &= ~(maskPlane << startPlaneBit);
50  id_ |= ((det & maskPlane) << startPlaneBit);
51  }
52 
53  uint32_t chip() const { return ((id_ >> startChipBit) & maskChip); }
54 
55  void setChip(uint32_t chip) {
56  id_ &= ~(maskChip << startChipBit);
57  id_ |= ((chip & maskChip) << startChipBit);
58  }
59 
60  //-------------------- id getters for higher-level objects --------------------
61 
62  TotemRPDetId planeId() const { return TotemRPDetId(rawId() & (~lowMaskPlane)); }
63 
64  //-------------------- strip orientation methods --------------------
65 
66  bool isStripsCoordinateUDirection() const { return plane() % 2; }
67 
69 
70  //-------------------- conversions to the obsolete decimal representation --------------------
71  // NOTE: only for backward compatibility, do not use otherwise!
72 
73  inline uint32_t rpDecimalId() const { return rp() + station() * 10 + arm() * 100; }
74 
75  inline uint32_t planeDecimalId() const { return plane() + rpDecimalId() * 10; }
76 
77  //-------------------- name methods --------------------
78 
79  inline void planeName(std::string& name, NameFlag flag = nFull) const {
80  switch (flag) {
81  case nShort:
82  name = "";
83  break;
84  case nFull:
85  rpName(name, flag);
86  name += "_";
87  break;
88  case nPath:
89  rpName(name, flag);
90  name += "/plane ";
91  break;
92  }
93 
94  name += planeNames[plane()];
95  }
96 
97  inline void chipName(std::string& name, NameFlag flag = nFull) const {
98  switch (flag) {
99  case nShort:
100  name = "";
101  break;
102  case nFull:
103  planeName(name, flag);
104  name += "_";
105  break;
106  case nPath:
107  planeName(name, flag);
108  name += "/chip ";
109  break;
110  }
111 
112  name += chipNames[chip()];
113  }
114 
115 private:
116  static const std::string planeNames[];
117  static const std::string chipNames[];
118 };
119 
120 std::ostream& operator<<(std::ostream& os, const TotemRPDetId& id);
121 
122 #endif
Detector ID class for TOTEM Si strip detectors.
Definition: TotemRPDetId.h:30
uint32_t station() const
Definition: CTPPSDetId.h:58
static const uint32_t maskChip
Definition: TotemRPDetId.h:42
static const uint32_t startChipBit
Definition: TotemRPDetId.h:42
uint32_t chip() const
Definition: TotemRPDetId.h:53
NameFlag
type of name returned by *Name functions
Definition: CTPPSDetId.h:83
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
uint32_t plane() const
Definition: TotemRPDetId.h:46
bool isStripsCoordinateUDirection() const
Definition: TotemRPDetId.h:66
std::ostream & operator<<(std::ostream &out, const ALILine &li)
Definition: ALILine.cc:167
TotemRPDetId(uint32_t id)
Definition: TotemRPDetId.cc:28
Definition: Plane.h:16
bool isStripsCoordinateVDirection() const
Definition: TotemRPDetId.h:68
static const uint32_t lowMaskChip
Definition: TotemRPDetId.h:42
TotemRPDetId(const CTPPSDetId &id)
Definition: TotemRPDetId.h:36
TotemRPDetId planeId() const
Definition: TotemRPDetId.h:62
void rpName(std::string &name, NameFlag flag=nFull) const
Definition: CTPPSDetId.h:128
uint32_t planeDecimalId() const
Definition: TotemRPDetId.h:75
uint32_t arm() const
Definition: CTPPSDetId.h:51
uint32_t id_
Definition: DetId.h:69
void setPlane(uint32_t det)
Definition: TotemRPDetId.h:48
void chipName(std::string &name, NameFlag flag=nFull) const
Definition: TotemRPDetId.h:97
void setChip(uint32_t chip)
Definition: TotemRPDetId.h:55
static const std::string planeNames[]
Definition: TotemRPDetId.h:116
Base class for CTPPS detector IDs.
Definition: CTPPSDetId.h:32
static const uint32_t lowMaskPlane
Definition: TotemRPDetId.h:41
static const uint32_t startPlaneBit
Definition: TotemRPDetId.h:41
static const uint32_t maxChip
Definition: TotemRPDetId.h:42
static const uint32_t maskPlane
Definition: TotemRPDetId.h:41
void planeName(std::string &name, NameFlag flag=nFull) const
Definition: TotemRPDetId.h:79
uint32_t rpDecimalId() const
Definition: TotemRPDetId.h:73
static const uint32_t maxPlane
Definition: TotemRPDetId.h:41
static const std::string chipNames[]
Definition: TotemRPDetId.h:117
uint32_t rp() const
Definition: CTPPSDetId.h:65
constexpr Detector det() const
get the detector field from this detid
Definition: DetId.h:46