CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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_TotemRPDetId_TotemRPDetId
11 #define DataFormats_TotemRPDetId_TotemRPDetId
12 
14 
16 
17 #include <iosfwd>
18 #include <iostream>
19 #include <string>
20 
51 class TotemRPDetId : public DetId
52 {
53  public:
54  TotemRPDetId();
55 
58  explicit TotemRPDetId(uint32_t id);
59 
61  TotemRPDetId(unsigned int Arm, unsigned int Station, unsigned int RomanPot, unsigned int Detector);
62 
63  static const unsigned int totem_rp_subdet_id = 3;
64 
65  static const unsigned int startArmBit = 24, maskArm = 0x1, maxArm = 1;
66  static const unsigned int startStationBit = 22, maskStation = 0x3, maxStation = 2;
67  static const unsigned int startRPBit = 19, maskRP = 0x7, maxRP = 5;
68  static const unsigned int startDetBit = 15, maskDet = 0xF, maxDet = 9;
69 
70  inline int arm() const
71  {
72  return int ((id_>>startArmBit) & maskArm);
73  }
74 
75  inline int station() const
76  {
77  return int ((id_>>startStationBit) & maskStation);
78  }
79 
80  inline int romanPot() const
81  {
82  return int ((id_>>startRPBit) & maskRP);
83  }
84 
85  inline int detector() const
86  {
87  return int ((id_>>startDetBit) & maskDet);
88  }
89 
90  int rpCopyNumber() const
91  {
92  return romanPot() + 10*station() + 100*arm();
93  }
94 
96  {
97  return detector()%2;
98  }
99 
101  {
103  }
104 
105  inline unsigned int detectorDecId() const
106  {
107  return detector() + romanPot()*10 + station()*100 + arm()*1000;
108  }
109 
110  //-------------------------------- static members ---------------------------------------
111 
113  static bool check(unsigned int raw)
114  {
115  return ((raw >> DetId::kDetOffset) & 0xF) == DetId::VeryForward &&
116  ((raw >> DetId::kSubdetOffset) & 0x7) == totem_rp_subdet_id;
117  }
118 
120  static unsigned int rawToDecId(unsigned int raw)
121  {
122  return ((raw >> startArmBit) & maskArm) * 1000
123  + ((raw >> startStationBit) & maskStation) * 100
124  + ((raw >> startRPBit) & maskRP) * 10
125  + ((raw >> startDetBit) & maskDet);
126  }
127 
129  static unsigned int decToRawId(unsigned int dec)
130  {
132  i &= 0xFE000000;
133  i |= ((dec % 10) & maskDet) << startDetBit; dec /= 10;
134  i |= ((dec % 10) & maskRP) << startRPBit; dec /= 10;
135  i |= ((dec % 10) & maskStation) << startStationBit; dec /= 10;
136  i |= ((dec % 10) & maskArm) << startArmBit;
137  return i;
138  }
139 
141  static unsigned int rpOfDet(unsigned int i) { return i / 10; }
142 
144  static unsigned int stOfDet(unsigned int i) { return i / 100; }
145 
147  static unsigned int armOfDet(unsigned int i) { return i / 1000; }
148 
150  static unsigned int stOfRP(unsigned int i) { return i / 10; }
151 
153  static unsigned int armOfRP(unsigned int i) { return i / 100; }
154 
156  static unsigned int armOfSt(unsigned int i) { return i / 10; }
157 
158 
161  static bool isStripsCoordinateUDirection(int Detector)
162  {
163  return Detector%2;
164  }
165 
166 
169 
172 
174  static std::string systemName(NameFlag flag = nFull);
175 
177  static std::string armName(unsigned int id, NameFlag flag = nFull);
178 
180  static std::string stationName(unsigned int id, NameFlag flag = nFull);
181 
183  static std::string rpName(unsigned int id, NameFlag flag = nFull);
184 
186  static std::string planeName(unsigned int id, NameFlag flag = nFull);
187 
189  static std::string chipName(unsigned int id, NameFlag flag = nFull);
190 
192  static std::string stripName(unsigned int id, unsigned char strip, NameFlag flag = nFull);
193 
195  static std::string officialName(ElementLevel level, unsigned int id, NameFlag flag = nFull, unsigned char strip = 0);
196 
197  private:
198  inline void init(unsigned int Arm, unsigned int Station, unsigned int RomanPot, unsigned int Detector);
199 };
200 
201 std::ostream& operator<<(std::ostream& os, const TotemRPDetId& id);
202 
203 #endif
static const unsigned int startRPBit
Definition: TotemRPDetId.h:67
Roman Pot detector ID.
Definition: TotemRPDetId.h:51
int i
Definition: DBlmapReader.cc:9
void init(unsigned int Arm, unsigned int Station, unsigned int RomanPot, unsigned int Detector)
Definition: TotemRPDetId.cc:37
static std::string rpName(unsigned int id, NameFlag flag=nFull)
returns official name of a RP characterized by &#39;&#39;id&#39;&#39;; if &#39;&#39;full&#39;&#39; is true, name of station is prefix...
static unsigned int rpOfDet(unsigned int i)
returns ID of RP for given detector ID &#39;&#39;i&#39;&#39;
Definition: TotemRPDetId.h:141
static std::string officialName(ElementLevel level, unsigned int id, NameFlag flag=nFull, unsigned char strip=0)
shortcut to use any of the *Name methods, given the ElementLevel
static std::string planeName(unsigned int id, NameFlag flag=nFull)
returns official name of a plane characterized by &#39;&#39;id&#39;&#39;; if &#39;&#39;full&#39;&#39; is true, name of RP is prefixed...
int station() const
Definition: TotemRPDetId.h:75
static unsigned int rawToDecId(unsigned int raw)
fast conversion Raw to Decimal ID
Definition: TotemRPDetId.h:120
int detector() const
Definition: TotemRPDetId.h:85
static std::string chipName(unsigned int id, NameFlag flag=nFull)
returns official name of a chip characterized by &#39;&#39;id&#39;&#39;; if &#39;&#39;full&#39;&#39; is true, name of plane is prefix...
static bool isStripsCoordinateUDirection(int Detector)
Definition: TotemRPDetId.h:161
static const int kSubdetOffset
Definition: DetId.h:21
bool isStripsCoordinateUDirection() const
Definition: TotemRPDetId.h:95
std::ostream & operator<<(std::ostream &out, const ALILine &li)
Definition: ALILine.cc:187
static unsigned int armOfRP(unsigned int i)
returns ID of arm for given RP ID &#39;&#39;i&#39;&#39;
Definition: TotemRPDetId.h:153
NameFlag
type of name returned by *Name functions
Definition: TotemRPDetId.h:168
static std::string stationName(unsigned int id, NameFlag flag=nFull)
returns official name of a station characterized by &#39;&#39;id&#39;&#39;; if &#39;&#39;full&#39;&#39; is true, name of arm is prefi...
bool isStripsCoordinateVDirection() const
Definition: TotemRPDetId.h:100
static const unsigned int maskDet
Definition: TotemRPDetId.h:68
static const unsigned int startStationBit
Definition: TotemRPDetId.h:66
static const unsigned int maskRP
Definition: TotemRPDetId.h:67
int romanPot() const
Definition: TotemRPDetId.h:80
static std::string stripName(unsigned int id, unsigned char strip, NameFlag flag=nFull)
returns official name of a strip characterized by &#39;&#39;id&#39;&#39; (of chip) and strip number; if &#39;&#39;full&#39;&#39; is t...
static const unsigned int totem_rp_subdet_id
Definition: TotemRPDetId.h:63
static unsigned int stOfDet(unsigned int i)
returns ID of station for given detector ID &#39;&#39;i&#39;&#39;
Definition: TotemRPDetId.h:144
static const unsigned int maxRP
Definition: TotemRPDetId.h:67
static const unsigned int startDetBit
Definition: TotemRPDetId.h:68
int arm() const
Definition: TotemRPDetId.h:70
ElementLevel
level identifier in the RP hierarchy
Definition: TotemRPDetId.h:171
static unsigned int armOfSt(unsigned int i)
returns ID of arm for given station ID &#39;&#39;i&#39;&#39;
Definition: TotemRPDetId.h:156
Definition: DetId.h:18
static const unsigned int startArmBit
Definition: TotemRPDetId.h:65
static const unsigned int maxStation
Definition: TotemRPDetId.h:66
static unsigned int armOfDet(unsigned int i)
returns ID of arm for given detector ID &#39;&#39;i&#39;&#39;
Definition: TotemRPDetId.h:147
static const unsigned int maxDet
Definition: TotemRPDetId.h:68
unsigned int detectorDecId() const
Definition: TotemRPDetId.h:105
Detector
Definition: DetId.h:24
uint32_t id_
Definition: DetId.h:55
static unsigned int stOfRP(unsigned int i)
returns ID of station for given RP ID &#39;&#39;i&#39;&#39;
Definition: TotemRPDetId.h:150
int rpCopyNumber() const
Definition: TotemRPDetId.h:90
static const int kDetOffset
Definition: DetId.h:20
static std::string armName(unsigned int id, NameFlag flag=nFull)
returns official name of an arm characterized by &#39;&#39;id&#39;&#39;; if &#39;&#39;full&#39;&#39; is true, prefix rp_ added ...
Definition: TotemRPDetId.cc:92
static std::string systemName(NameFlag flag=nFull)
returns the name of the RP system
Definition: TotemRPDetId.cc:81
static bool check(unsigned int raw)
returs true it the raw ID is a TOTEM RP one
Definition: TotemRPDetId.h:113
tuple level
Definition: testEve_cfg.py:34
static const unsigned int maxArm
Definition: TotemRPDetId.h:65
static const unsigned int maskArm
Definition: TotemRPDetId.h:65
static unsigned int decToRawId(unsigned int dec)
fast conversion Decimal to Raw ID
Definition: TotemRPDetId.h:129
static const unsigned int maskStation
Definition: TotemRPDetId.h:66