CMS 3D CMS Logo

RPCGeomServ.cc
Go to the documentation of this file.
3 #include <sstream>
4 #include <iomanip>
5 
6 RPCGeomServ::RPCGeomServ::RPCGeomServ(const RPCDetId& id)
7  : _id(&id), _n(""), _sn(""), _cn(""), _t(-99), _z(true), _a(true) {}
8 
10 
12  if (_n.empty()) {
13  int station = _id->station();
14  int region = _id->region();
15  int roll = _id->roll();
16  int ring = _id->ring();
17  int layer = _id->layer();
18  int sector = _id->sector();
19  int subsector = _id->subsector();
20 
21  std::stringstream os;
22 
23  if (region == 0) {
24  os << "W";
25  os << std::setw(2) << std::setfill('+') << ring << std::setfill(' ') << "_";
26 
27  os << "RB" << station;
28  if (station <= 2) {
29  (layer == 1) ? os << "in" : os << "out";
30 
31  } else if (station > 2) {
32  if (sector == 4 && station == 4) {
33  if (subsector == 1) {
34  os << "--";
35  } else if (subsector == 2) {
36  os << "-";
37  } else if (subsector == 3) {
38  os << "+";
39  } else if (subsector == 4) {
40  os << "++";
41  }
42  }
43 
44  if (station == 3) {
45  if (subsector == 1)
46  os << "-";
47  else
48  os << "+";
49  } else if (station == 4 && sector != 9 && sector != 11 && sector != 4) {
50  if (subsector == 1)
51  os << "-";
52  else
53  os << "+";
54  }
55  }
56 
57  os << "_";
58  os << "S" << std::setw(2) << std::setfill('0') << sector << std::setfill(' ');
59  if (roll == 1)
60  os << "_Backward";
61  else if (roll == 3)
62  os << "_Forward";
63  else if (roll == 2)
64  os << "_Middle";
65  } else {
66  os << "RE";
67 
68  os << std::setw(2) << std::setfill('+') << station * region << std::setfill(' ') << "_";
69 
70  os << "R" << ring;
71  os << "_CH" << std::setw(2) << std::setfill('0') << this->segment();
72 
73  if (roll == 1)
74  os << "_A";
75  else if (roll == 2)
76  os << "_B";
77  else if (roll == 3)
78  os << "_C";
79  else if (roll == 4)
80  os << "_D";
81  else if (roll == 5)
82  os << "_E";
83  }
84  _n = os.str();
85  }
86  return _n;
87 }
88 
90  if (_cn.empty()) {
91  int station = _id->station();
92  int region = _id->region();
93  int ring = _id->ring();
94  int layer = _id->layer();
95  int sector = _id->sector();
96  int subsector = _id->subsector();
97 
98  std::stringstream os;
99 
100  if (region == 0) {
101  os << "W";
102 
103  os << std::setw(2) << std::setfill('+') << ring << std::setfill(' ') << "_";
104 
105  os << "RB" << station;
106  if (station <= 2) {
107  (layer == 1) ? os << "in" : os << "out";
108 
109  } else if (station > 2) {
110  if (sector == 4 && station == 4) {
111  if (subsector == 1) {
112  os << "--";
113  } else if (subsector == 2) {
114  os << "-";
115  } else if (subsector == 3) {
116  os << "+";
117  } else if (subsector == 4) {
118  os << "++";
119  }
120  }
121 
122  if (station == 3) {
123  if (subsector == 1)
124  os << "-";
125  else
126  os << "+";
127  } else if (station == 4 && sector != 9 && sector != 11 && sector != 4) {
128  if (subsector == 1)
129  os << "-";
130  else
131  os << "+";
132  }
133  }
134 
135  os << "_";
136  os << "S" << std::setw(2) << std::setfill('0') << sector << std::setfill(' ');
137  } else {
138  os << "RE";
139 
140  os << std::setw(2) << std::setfill('+') << station * region << std::setfill(' ') << "_";
141 
142  os << "R" << ring;
143  os << "_CH" << std::setw(2) << std::setfill('0') << this->segment();
144  }
145  _cn = os.str();
146  }
147  return _cn;
148 }
149 
151  if (_sn.empty()) {
152  int station = _id->station();
153  int region = _id->region();
154  int roll = _id->roll();
155  int ring = _id->ring();
156  int layer = _id->layer();
157  int sector = _id->sector();
158  int subsector = _id->subsector();
159 
160  std::stringstream os;
161 
162  if (region == 0) {
163  os << "RB" << station;
164  if (station <= 2) {
165  (layer == 1) ? os << "in" : os << "out";
166 
167  } else {
168  if (sector == 4 && station == 4) {
169  if (subsector == 1) {
170  os << "--";
171  } else if (subsector == 2) {
172  os << ",-";
173  } else if (subsector == 3) {
174  os << "+";
175  } else if (subsector == 4) {
176  os << "++";
177  }
178  } else {
179  if (subsector == 1)
180  os << ",-";
181  else
182  os << "+";
183  }
184  }
185  if (roll == 1)
186  os << " B";
187  else if (roll == 3)
188  os << " F";
189  else if (roll == 2)
190  os << " M";
191  } else {
192  os << "Ri" << ring << " Su" << subsector;
193  }
194  _sn = os.str();
195  }
196  return _sn;
197 }
198 
199 // returns a vector with number of channels for each chip in each FEB
200 std::vector<int> RPCGeomServ::channelInChip(void) {
201  std::vector<int> chipCh(4, 8); //Endcap
202 
203  if (_id->region() == 0) { //Barrel
204  chipCh.clear();
205 
206  int station = _id->station();
207 
208  if (station < 3 && _id->layer() == 1) { // i.e. RB1in ||RB2in
209  chipCh.emplace_back(7);
210  chipCh.emplace_back(8);
211  } else if (station == 1 || station == 3) { //i.e. RB1out || RB3
212  chipCh.emplace_back(7);
213  chipCh.emplace_back(7);
214  } else if (station == 2) { // i.e. RB2out
215  chipCh.emplace_back(6);
216  chipCh.emplace_back(8);
217  } else if (_id->sector() == 4 || _id->sector() == 10 || (_id->sector() == 8 && _id->subsector() != 1) ||
218  (_id->sector() == 12 && _id->subsector() == 1)) {
219  chipCh.emplace_back(6); //i.e. Sector 4 & 10 RB4 and Sector 8 &12 RB4+
220  chipCh.emplace_back(6);
221  } else {
222  chipCh.emplace_back(8);
223  chipCh.emplace_back(8);
224  }
225  }
226 
227  return chipCh;
228 }
229 
231  if (_t < -90) {
232  if (_id->region() == 0) {
233  if (this->inverted()) {
234  _t = 3 * (_id->ring()) + (3 - _id->roll()) - 1;
235  } else {
236  _t = 3 * (_id->ring()) + _id->roll() - 2;
237  }
238  } else {
239  _t = _id->region() * (3 * (3 - _id->ring()) + _id->roll() + 7);
240  }
241  }
242  return _t;
243 }
244 
246  // Station1
247  if (_id->station() == 1) {
248  // in
249  if (_id->layer() == 1) {
250  if (_id->roll() == 1)
251  _cnr = 1;
252  else
253  _cnr = 2;
254  }
255  //out
256  else {
257  if (_id->roll() == 1)
258  _cnr = 3;
259  else
260  _cnr = 4;
261  }
262  }
263 
264  //Station 2
265  if (_id->station() == 2) {
266  //in
267  if (_id->layer() == 1) {
268  if (_id->roll() == 1) //backward
269  _cnr = 5;
270  if (_id->roll() == 3) //forward
271  _cnr = 6;
272  if (_id->roll() == 2) //middle
273  _cnr = 7;
274  }
275  //out
276  else {
277  if (_id->roll() == 2)
278 
279  _cnr = 7;
280 
281  if (_id->roll() == 1)
282  _cnr = 8;
283  if (_id->roll() == 3)
284  _cnr = 9;
285  }
286  }
287 
288  //RB3- RB3+
289  if (_id->station() == 3) {
290  if (_id->subsector() == 1) {
291  if (_id->roll() == 1)
292  _cnr = 10;
293  else
294  _cnr = 11;
295  } else {
296  if (_id->roll() == 1)
297  _cnr = 12;
298  else
299  _cnr = 13;
300  }
301  }
302 
303  //RB4
304  if (_id->station() == 4) {
305  if (_id->sector() == 4) {
306  if (_id->subsector() == 2) { //RB4-
307 
308  if (_id->roll() == 1)
309  _cnr = 14;
310  else
311  _cnr = 15;
312  }
313 
314  if (_id->subsector() == 3) { //RB4+
315 
316  if (_id->roll() == 1)
317  _cnr = 16;
318  else
319  _cnr = 17;
320  }
321 
322  if (_id->subsector() == 1) { //RB4--
323 
324  if (_id->roll() == 1)
325  _cnr = 18;
326  else
327  _cnr = 19;
328  }
329 
330  if (_id->subsector() == 4) { //RB4++
331 
332  if (_id->roll() == 1)
333  _cnr = 20;
334  else
335  _cnr = 21;
336  }
337 
338  }
339 
340  else
341 
342  {
343  if (_id->subsector() == 1) {
344  if (_id->roll() == 1)
345  _cnr = 14;
346  else
347  _cnr = 15;
348  } else {
349  if (_id->roll() == 1)
350  _cnr = 16;
351  else
352  _cnr = 17;
353  }
354  }
355  }
356 
357  // _cnr=10;
358  return _cnr;
359 }
360 
362  int nsub = 6;
363  int station = _id->station();
364  int ring = _id->ring();
365  (ring == 1 && station > 1) ? nsub = 3 : nsub = 6;
366 
367  return (_id->subsector() + nsub * (_id->sector() - 1));
368 }
369 
371  // return !(this->zpositive() && this->aclockwise());
372  return !(this->zpositive());
373 }
374 
376  if (_id->region() == 0 && _t < -90) {
377  if (_id->ring() < 0) {
378  _z = false;
379  }
380  if (_id->ring() == 0) {
381  if (_id->sector() == 1 || _id->sector() == 4 || _id->sector() == 5 || _id->sector() == 8 || _id->sector() == 9 ||
382  _id->sector() == 12) {
383  _z = false;
384  }
385  }
386  }
387 
388  return _z;
389 }
390 
392  if (_id->region() == 0 && _t < -90) {
393  if (_id->ring() > 0) {
394  if (_id->layer() == 2) {
395  _a = false;
396  }
397  } else if (_id->ring() < 0) {
398  if (_id->layer() == 1) {
399  _a = false;
400  }
401  } else if (_id->ring() == 0) {
402  if ((_id->sector() == 1 || _id->sector() == 4 || _id->sector() == 5 || _id->sector() == 8 || _id->sector() == 9 ||
403  _id->sector() == 12) &&
404  _id->layer() == 1)
405  _a = false;
406  else if ((_id->sector() == 2 || _id->sector() == 3 || _id->sector() == 6 || _id->sector() == 7 ||
407  _id->sector() == 10 || _id->sector() == 11) &&
408  _id->layer() == 2)
409  _a = false;
410  }
411  }
412  return _a;
413 }
414 
415 RPCGeomServ::RPCGeomServ() : _id(nullptr), _n(""), _sn(""), _cn(""), _t(-99), _z(false), _a(false) {}
int sector() const
Sector id: the group of chambers at same phi (and increasing r)
Definition: RPCDetId.h:81
virtual int chambernr()
Definition: RPCGeomServ.cc:245
virtual std::string chambername()
Definition: RPCGeomServ.cc:89
std::string _sn
Definition: RPCGeomServ.h:29
virtual int eta_partition()
Definition: RPCGeomServ.cc:230
int ring() const
Definition: RPCDetId.h:59
std::vector< int > channelInChip()
Definition: RPCGeomServ.cc:200
const int nsub
std::string _n
Definition: RPCGeomServ.h:28
virtual std::string name()
Definition: RPCGeomServ.cc:11
virtual bool aclockwise()
Definition: RPCGeomServ.cc:391
virtual ~RPCGeomServ()
Definition: RPCGeomServ.cc:9
int roll() const
Definition: RPCDetId.h:92
virtual std::string shortname()
Definition: RPCGeomServ.cc:150
int subsector() const
SubSector id : some sectors are divided along the phi direction in subsectors (from 1 to 4 in Barrel...
Definition: RPCDetId.h:88
virtual int segment()
Definition: RPCGeomServ.cc:361
virtual bool zpositive()
Definition: RPCGeomServ.cc:375
int station() const
Definition: RPCDetId.h:78
int region() const
Region id: 0 for Barrel, +/-1 For +/- Endcap.
Definition: RPCDetId.h:53
std::string _cn
Definition: RPCGeomServ.h:30
virtual bool inverted()
Definition: RPCGeomServ.cc:370
int layer() const
Definition: RPCDetId.h:85
const RPCDetId * _id
Definition: RPCGeomServ.h:27