test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
TotemRPDetId.cc
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 
13 
14 using namespace std;
15 
16 //----------------------------------------------------------------------------------------------------
17 
18 TotemRPDetId::TotemRPDetId() : DetId(DetId::VeryForward, totem_rp_subdet_id)
19 {
20 }
21 
22 //----------------------------------------------------------------------------------------------------
23 
25 {
26  if (! check(id))
27  {
28  throw cms::Exception("InvalidDetId") << "TotemRPDetId ctor:"
29  << " det: " << det()
30  << " subdet: " << subdetId()
31  << " is not a valid Totem RP id";
32  }
33 }
34 
35 //----------------------------------------------------------------------------------------------------
36 
37 void TotemRPDetId::init(unsigned int Arm, unsigned int Station, unsigned int RomanPot, unsigned int Detector)
38 {
39  if (Arm > maxArm || Station > maxStation || RomanPot > maxRP || Detector > maxDet)
40  {
41  throw cms::Exception("InvalidDetId") << "TotemRPDetId ctor:"
42  << " Invalid parameters: "
43  << " Arm "<<Arm
44  << " Station "<<Station
45  << " RomanPot "<<RomanPot
46  << " Detector "<<Detector
47  << std::endl;
48  }
49 
50  uint32_t ok=0xfe000000;
51  id_ &= ok;
52 
53  id_ |= ((Arm & maskArm) << startArmBit);
54  id_ |= ((Station & maskStation) << startStationBit);
55  id_ |= ((RomanPot & maskRP) << startRPBit);
56  id_ |= ((Detector & maskDet) << startDetBit);
57 }
58 
59 //----------------------------------------------------------------------------------------------------
60 
61 TotemRPDetId::TotemRPDetId(unsigned int Arm, unsigned int Station, unsigned int RomanPot, unsigned int Detector):
62  DetId(DetId::VeryForward, totem_rp_subdet_id)
63 {
64  this->init(Arm, Station, RomanPot, Detector);
65 }
66 
67 //----------------------------------------------------------------------------------------------------
68 
69 std::ostream& operator<<( std::ostream& os, const TotemRPDetId& id )
70 {
71  os << " Arm "<<id.arm()
72  << " Station "<<id.station()
73  << " RomanPot "<<id.romanPot()
74  << " Detector "<<id.detector();
75 
76  return os;
77 }
78 
79 //----------------------------------------------------------------------------------------------------
80 
82 {
83  string name;
84  if (flag == nFull) name = "rp";
85  if (flag == nPath) name = "RP";
86 
87  return name;
88 }
89 
90 //----------------------------------------------------------------------------------------------------
91 
92 string TotemRPDetId::armName(unsigned int id, NameFlag flag)
93 {
94  string name;
95  if (flag == nFull) name = systemName(flag) + "_";
96  if (flag == nPath) name = systemName(flag) + "/sector ";
97 
98  if (id == 0) name += "45";
99  if (id == 1) name += "56";
100 
101  return name;
102 }
103 
104 //----------------------------------------------------------------------------------------------------
105 
106 string TotemRPDetId::stationName(unsigned int id, NameFlag flag)
107 {
108  string name;
109  if (flag == nFull) name = armName(id / 10, flag) + "_";
110  if (flag == nPath) name = armName(id / 10, flag) + "/station ";
111 
112  if ((id % 10) == 0) name += "210";
113  if ((id % 10) == 2) name += "220";
114 
115  return name;
116 }
117 
118 //----------------------------------------------------------------------------------------------------
119 
120 string TotemRPDetId::rpName(unsigned int id, NameFlag flag)
121 {
122  string name;
123  if (flag == nFull) name = stationName(id / 10, flag) + "_";
124  if (flag == nPath) name = stationName(id / 10, flag) + "/";
125 
126  if ((id % 10) == 0) name += "nr_tp";
127  if ((id % 10) == 1) name += "nr_bt";
128  if ((id % 10) == 2) name += "nr_hr";
129  if ((id % 10) == 3) name += "fr_hr";
130  if ((id % 10) == 4) name += "fr_tp";
131  if ((id % 10) == 5) name += "fr_bt";
132  return name;
133 }
134 
135 //----------------------------------------------------------------------------------------------------
136 
137 string TotemRPDetId::planeName(unsigned int id, NameFlag flag)
138 {
139  string name;
140  if (flag == nFull) name = rpName(id / 10, flag) + "_";
141  if (flag == nPath) name = rpName(id / 10, flag) + "/plane ";
142 
143  char buf[10];
144  sprintf(buf, "%02u", (id % 10) + 1);
145 
146  return name + buf;
147 }
148 
149 //----------------------------------------------------------------------------------------------------
150 
151 string TotemRPDetId::chipName(unsigned int id, NameFlag flag)
152 {
153  string name;
154  if (flag == nFull) name = planeName(id / 10, flag) + "_";
155  if (flag == nPath) name = planeName(id / 10, flag) + "/chip ";
156 
157  char buf[10];
158  sprintf(buf, "%u", (id % 10) + 1);
159 
160  return name + buf;
161 }
162 
163 //----------------------------------------------------------------------------------------------------
164 
165 string TotemRPDetId::stripName(unsigned int id, unsigned char strip, NameFlag flag)
166 {
167  string name;
168  if (flag == nFull) name = chipName(id, flag) + "_";
169  if (flag == nPath) name = chipName(id, flag) + "/strip";
170 
171  char buf[10];
172  sprintf(buf, "%u", strip);
173 
174  return name + buf;
175 }
176 
177 //----------------------------------------------------------------------------------------------------
178 
179 string TotemRPDetId::officialName(ElementLevel level, unsigned int id, NameFlag flag, unsigned char strip)
180 {
181  switch (level)
182  {
183  case lSystem: return systemName(flag);
184  case lArm: return armName(id, flag);
185  case lStation: return stationName(id, flag);
186  case lRP: return rpName(id, flag);
187  case lPlane: return planeName(id, flag);
188  case lChip: return chipName(id, flag);
189  case lStrip: return stripName(id, flag);
190  default: return "";
191  }
192 }
static const unsigned int startRPBit
Definition: TotemRPDetId.h:67
Roman Pot detector ID.
Definition: TotemRPDetId.h:51
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 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...
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...
std::ostream & operator<<(std::ostream &out, const ALILine &li)
Definition: ALILine.cc:188
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...
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
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 maxRP
Definition: TotemRPDetId.h:67
static const unsigned int startDetBit
Definition: TotemRPDetId.h:68
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:37
ElementLevel
level identifier in the RP hierarchy
Definition: TotemRPDetId.h:171
Definition: DetId.h:18
static const unsigned int startArmBit
Definition: TotemRPDetId.h:65
static const unsigned int maxStation
Definition: TotemRPDetId.h:66
static const unsigned int maxDet
Definition: TotemRPDetId.h:68
Detector
Definition: DetId.h:24
uint32_t id_
Definition: DetId.h:55
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
Detector det() const
get the detector field from this detid
Definition: DetId.h:35
static const unsigned int maxArm
Definition: TotemRPDetId.h:65
static const unsigned int maskArm
Definition: TotemRPDetId.h:65
static const unsigned int maskStation
Definition: TotemRPDetId.h:66