CMS 3D CMS Logo

CTPPSDetId.h
Go to the documentation of this file.
1 /****************************************************************************
2  *
3  * This is a part of TOTEM offline software.
4  * Authors:
5  * Jan Kašpar (jan.kaspar@gmail.com)
6  *
7  ****************************************************************************/
8 
9 #ifndef DataFormats_CTPPSDetId_CTPPSDetId
10 #define DataFormats_CTPPSDetId_CTPPSDetId
11 
13 
15 
16 #include <iosfwd>
17 #include <iostream>
18 #include <string>
19 
32 class CTPPSDetId : public DetId
33 {
34  public:
37 
39  explicit CTPPSDetId(uint32_t id);
40 
42  CTPPSDetId(uint32_t SubDet, uint32_t Arm, uint32_t Station, uint32_t RomanPot=0);
43 
44  //-------------------- bit assignment --------------------
45 
46  static const uint32_t startArmBit, maskArm, maxArm, lowMaskArm;
48  static const uint32_t startRPBit, maskRP, maxRP, lowMaskRP;
49 
50  //-------------------- component getters and setters --------------------
51 
52  uint32_t arm() const
53  {
54  return ((id_>>startArmBit) & maskArm);
55  }
56 
57  void setArm(uint32_t arm)
58  {
59  id_ &= ~(maskArm << startArmBit);
60  id_ |= ((arm & maskArm) << startArmBit);
61  }
62 
63  uint32_t station() const
64  {
65  return ((id_>>startStationBit) & maskStation);
66  }
67 
68  void setStation(uint32_t station)
69  {
70  id_ &= ~(maskStation << startStationBit);
71  id_ |= ((station & maskStation) << startStationBit);
72  }
73 
74  uint32_t rp() const
75  {
76  return ((id_>>startRPBit) & maskRP);
77  }
78 
79  void setRP(uint32_t rp)
80  {
81  id_ &= ~(maskRP << startRPBit);
82  id_ |= ((rp & maskRP) << startRPBit);
83  }
84 
85  //-------------------- id getters for higher-level objects --------------------
86 
88  {
89  return CTPPSDetId( rawId() & (~lowMaskArm) );
90  }
91 
93  {
94  return CTPPSDetId( rawId() & (~lowMaskStation) );
95  }
96 
98  {
99  return CTPPSDetId( rawId() & (~lowMaskRP) );
100  }
101 
102  //-------------------- name methods --------------------
103 
106 
108  {
109  if (flag == nPath)
110  name = subDetectorPaths[subdetId()];
111  else
112  name = subDetectorNames[subdetId()];
113  }
114 
115  inline void armName(std::string &name, NameFlag flag = nFull) const
116  {
117  switch (flag)
118  {
119  case nShort: name = ""; break;
120  case nFull: subDetectorName(name, flag); name += "_"; break;
121  case nPath: subDetectorName(name, flag); name += "/sector "; break;
122  }
123 
124  name += armNames[arm()];
125  }
126 
128  {
129  switch (flag)
130  {
131  case nShort: name = ""; break;
132  case nFull: armName(name, flag); name += "_"; break;
133  case nPath: armName(name, flag); name += "/station "; break;
134  }
135 
136  name += stationNames[station()];
137  }
138 
139  inline void rpName(std::string &name, NameFlag flag = nFull) const
140  {
141  switch (flag)
142  {
143  case nShort: name = ""; break;
144  case nFull: stationName(name, flag); name += "_"; break;
145  case nPath: stationName(name, flag); name += "/"; break;
146  }
147 
148  name += rpNames[rp()];
149  }
150 
151  private:
154  static const std::string armNames[];
155  static const std::string stationNames[];
156  static const std::string rpNames[];
157 };
158 
159 std::ostream& operator<<(std::ostream& os, const CTPPSDetId& id);
160 
161 #endif
uint32_t station() const
Definition: CTPPSDetId.h:63
SubDetector
CTPPS sub-detectors.
Definition: CTPPSDetId.h:36
static const uint32_t maxStation
Definition: CTPPSDetId.h:47
NameFlag
type of name returned by *Name functions
Definition: CTPPSDetId.h:105
void setArm(uint32_t arm)
Definition: CTPPSDetId.h:57
void setRP(uint32_t rp)
Definition: CTPPSDetId.h:79
CTPPSDetId getStationId() const
Definition: CTPPSDetId.h:92
static const uint32_t startRPBit
Definition: CTPPSDetId.h:48
static const uint32_t maskStation
Definition: CTPPSDetId.h:47
static const uint32_t maskRP
Definition: CTPPSDetId.h:48
uint32_t rawId() const
get the raw id
Definition: DetId.h:44
static const std::string armNames[]
Definition: CTPPSDetId.h:154
static const uint32_t lowMaskStation
Definition: CTPPSDetId.h:47
static const uint32_t maskArm
Definition: CTPPSDetId.h:46
static const uint32_t maxArm
Definition: CTPPSDetId.h:46
void rpName(std::string &name, NameFlag flag=nFull) const
Definition: CTPPSDetId.h:139
CTPPSDetId getRPId() const
Definition: CTPPSDetId.h:97
uint32_t arm() const
Definition: CTPPSDetId.h:52
static const std::string subDetectorPaths[]
Definition: CTPPSDetId.h:153
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:38
void armName(std::string &name, NameFlag flag=nFull) const
Definition: CTPPSDetId.h:115
static const uint32_t maxRP
Definition: CTPPSDetId.h:48
static const std::string rpNames[]
Definition: CTPPSDetId.h:156
void setStation(uint32_t station)
Definition: CTPPSDetId.h:68
static const std::string subDetectorNames[]
Definition: CTPPSDetId.h:152
Definition: DetId.h:18
std::ostream & operator<<(std::ostream &os, const CTPPSDetId &id)
Definition: CTPPSDetId.cc:74
CTPPSDetId getArmId() const
Definition: CTPPSDetId.h:87
uint32_t id_
Definition: DetId.h:56
static const uint32_t startStationBit
Definition: CTPPSDetId.h:47
Base class for CTPPS detector IDs.
Definition: CTPPSDetId.h:32
CTPPSDetId(uint32_t id)
Construct from a raw id.
Definition: CTPPSDetId.cc:31
static const uint32_t startArmBit
Definition: CTPPSDetId.h:46
void stationName(std::string &name, NameFlag flag=nFull) const
Definition: CTPPSDetId.h:127
static const std::string stationNames[]
Definition: CTPPSDetId.h:155
static const uint32_t lowMaskArm
Definition: CTPPSDetId.h:46
static const uint32_t lowMaskRP
Definition: CTPPSDetId.h:48
void subDetectorName(std::string &name, NameFlag flag=nFull) const
Definition: CTPPSDetId.h:107
uint32_t rp() const
Definition: CTPPSDetId.h:74