CMS 3D CMS Logo

PixelBarrelNameUpgrade.cc
Go to the documentation of this file.
2 
3 #include <sstream>
4 #include <iostream>
5 
8 
9 using namespace std;
10 
12  // uint32_t rawId = id.rawId();
13  PXBDetId cmssw_numbering(id);
14 
15  theLayer = cmssw_numbering.layer();
16 
17  int oldModule = cmssw_numbering.module() - 4;
18  if (oldModule <= 0)
19  oldModule--; // -4, ..., -1, +1, ...,+4
20 
21  int oldLadder = cmssw_numbering.ladder();
22 
23  if (theLayer == 1) {
24  if (oldLadder <= 3)
25  oldLadder = 4 - oldLadder; // +1, ..., +3
26  else if (oldLadder >= 4 && oldLadder <= 9)
27  oldLadder = 3 - oldLadder; // -1, ..., -6
28  else if (oldLadder >= 10)
29  oldLadder = 16 - oldLadder; // +6, ..., +4
30  } else if (theLayer == 2) {
31  if (oldLadder <= 7)
32  oldLadder = 8 - oldLadder;
33  else if (oldLadder >= 8 && oldLadder <= 21)
34  oldLadder = 7 - oldLadder;
35  else if (oldLadder >= 22)
36  oldLadder = 36 - oldLadder;
37  } else if (theLayer == 3) {
38  if (oldLadder <= 11)
39  oldLadder = 12 - oldLadder;
40  else if (oldLadder >= 12 && oldLadder <= 33)
41  oldLadder = 11 - oldLadder;
42  else if (oldLadder >= 34)
43  oldLadder = 56 - oldLadder;
44  } else if (theLayer == 4) {
45  if (oldLadder <= 16)
46  oldLadder = 17 - oldLadder;
47  else if (oldLadder >= 17 && oldLadder <= 48)
48  oldLadder = 16 - oldLadder;
49  else if (oldLadder >= 49)
50  oldLadder = 81 - oldLadder;
51  }
52 
53  //
54  // part
55  //
56  if (oldModule < 0 && oldLadder < 0)
57  thePart = mO;
58  else if (oldModule > 0 && oldLadder < 0)
59  thePart = pO;
60  else if (oldModule < 0 && oldLadder > 0)
61  thePart = mI;
62  else if (oldModule > 0 && oldLadder > 0)
63  thePart = pI;
64  //std::cout << "(oldModule, oldLadder)============(" << oldModule << ", "<< oldLadder<<" )" << std::endl;
65 
66  //
67  // ladder
68  //
69  theLadder = abs(oldLadder);
70 
71  //
72  // module
73  //
74  theModule = abs(oldModule);
75 }
76 
77 // constructor from name string
79  : PixelModuleName(true), thePart(mO), theLayer(0), theModule(0), theLadder(0) {
80  std::cout << "NAME=" << name << std::endl;
81  // parse the name string
82  // first, check to make sure this is an BPix name, should start with "BPix_"
83  // also check to make sure the needed parts are present
84  if ((name.substr(0, 5) != "BPix_") || (name.find("_B") == string::npos) || (name.find("_LYR") == string::npos) ||
85  (name.find("_LDR") == string::npos) || (name.find("_MOD") == string::npos)) {
86  edm::LogError("BadNameString|SiPixel")
87  << "Bad name string in PixelBarrelNameUpgrade::PixelBarrelName(std::string): " << name;
88  return;
89  }
90 
91  // strip off ROC part if it's there
92  if (name.find("_ROC") != string::npos)
93  name = name.substr(0, name.find("_ROC"));
94 
95  // find shell
96  string shellString = name.substr(name.find("_B") + 2, name.find("_SEC") - name.find("_B") - 2);
97  if (shellString == "mO")
98  thePart = mO;
99  else if (shellString == "mI")
100  thePart = mI;
101  else if (shellString == "pO")
102  thePart = pO;
103  else if (shellString == "pI")
104  thePart = pI;
105  else {
106  edm::LogError("BadNameString|SiPixel")
107  << "Unable to determine shell in PixelBarrelNameUpgrade::PixelBarrelName(std::string): " << name;
108  }
109 
110  // find the layer
111  string layerString = name.substr(name.find("_LYR") + 4, name.find("_LDR") - name.find("_LYR") - 4);
112  if (layerString == "1")
113  theLayer = 1;
114  else if (layerString == "2")
115  theLayer = 2;
116  else if (layerString == "3")
117  theLayer = 3;
118  else if (layerString == "4")
119  theLayer = 4;
120  else {
121  edm::LogError("BadNameString|SiPixel")
122  << "Unable to determine layer in PixelBarrelNameUpgrade::PixelBarrelName(std::string): " << name;
123  }
124 
125  // find the ladder
126  string ladderString = name.substr(name.find("_LDR") + 4, name.find("_MOD") - name.find("_LDR") - 4);
127  if (ladderString.substr(ladderString.size() - 1, 1) == "F") {
128  int ladderNum = atoi(ladderString.substr(0, ladderString.size() - 1).c_str());
129  if (theLayer == 1 && ladderNum >= 1 && ladderNum <= 6)
130  theLadder = ladderNum;
131  else if (theLayer == 2 && ladderNum >= 1 && ladderNum <= 14)
132  theLadder = ladderNum;
133  else if (theLayer == 3 && ladderNum >= 1 && ladderNum <= 22)
134  theLadder = ladderNum;
135  else if (theLayer == 4 && ladderNum >= 1 && ladderNum <= 32)
136  theLadder = ladderNum;
137  else {
138  edm::LogError("BadNameString|SiPixel")
139  << "Unable to determine ladder in PixelBarrelNameUpgrade::PixelBarrelName(std::string): " << name;
140  }
141  } // full ladders
142  else {
143  edm::LogError("BadNameString|SiPixel")
144  << "Unable to determine ladder in PixelBarrelNameUpgrade::PixelBarrelName(std::string): " << name;
145  }
146 
147  // find the module
148  string moduleString = name.substr(name.find("_MOD") + 4, name.size() - name.find("_MOD") - 4);
149  if (moduleString == "1")
150  theModule = 1;
151  else if (moduleString == "2")
152  theModule = 2;
153  else if (moduleString == "3")
154  theModule = 3;
155  else if (moduleString == "4")
156  theModule = 4;
157  else {
158  edm::LogError("BadNameString|SiPixel")
159  << "Unable to determine module in PixelBarrelNameUpgrade::PixelBarrelName(std::string): " << name;
160  }
161 
162 } // PixelBarrelNameUpgrade::PixelBarrelName(std::string name)
163 
165  int sector = 0;
166  if (theLayer == 1) {
167  switch (theLadder) {
168  case 1: {
169  sector = 1;
170  break;
171  }
172  case 2: {
173  sector = 2;
174  break;
175  }
176  case 3: {
177  sector = 3;
178  break;
179  }
180  case 4: {
181  sector = 6;
182  break;
183  }
184  case 5: {
185  sector = 7;
186  break;
187  }
188  case 6: {
189  sector = 8;
190  break;
191  }
192  default:;
193  };
194  } else if (theLayer == 2) {
195  switch (theLadder) {
196  case 1:
197  case 2: {
198  sector = 1;
199  break;
200  }
201  case 3:
202  case 4: {
203  sector = 2;
204  break;
205  }
206  case 5:
207  case 6: {
208  sector = 3;
209  break;
210  }
211  case 7: {
212  sector = 4;
213  break;
214  }
215  case 8: {
216  sector = 5;
217  break;
218  }
219  case 9:
220  case 10: {
221  sector = 6;
222  break;
223  }
224  case 11:
225  case 12: {
226  sector = 7;
227  break;
228  }
229  case 13:
230  case 14: {
231  sector = 8;
232  break;
233  }
234  default:;
235  };
236  } else if (theLayer == 3) {
237  switch (theLadder) {
238  case 1:
239  case 2:
240  case 3: {
241  sector = 1;
242  break;
243  }
244  case 4:
245  case 5:
246  case 6: {
247  sector = 2;
248  break;
249  }
250  case 7:
251  case 8:
252  case 9: {
253  sector = 3;
254  break;
255  }
256  case 10:
257  case 11: {
258  sector = 4;
259  break;
260  }
261  case 12:
262  case 13: {
263  sector = 5;
264  break;
265  }
266  case 14:
267  case 15:
268  case 16: {
269  sector = 6;
270  break;
271  }
272  case 17:
273  case 18:
274  case 19: {
275  sector = 7;
276  break;
277  }
278  case 20:
279  case 21:
280  case 22: {
281  sector = 8;
282  break;
283  }
284  default:;
285  };
286  } else if (theLayer == 4) {
287  switch (theLadder) {
288  case 1:
289  case 2:
290  case 3:
291  case 4: {
292  sector = 1;
293  break;
294  }
295  case 5:
296  case 6:
297  case 7:
298  case 8: {
299  sector = 2;
300  break;
301  }
302  case 9:
303  case 10:
304  case 11:
305  case 12: {
306  sector = 3;
307  break;
308  }
309  case 13:
310  case 14:
311  case 15:
312  case 16: {
313  sector = 4;
314  break;
315  }
316  case 17:
317  case 18:
318  case 19:
319  case 20: {
320  sector = 5;
321  break;
322  }
323  case 21:
324  case 22:
325  case 23:
326  case 24: {
327  sector = 6;
328  break;
329  }
330  case 25:
331  case 26:
332  case 27:
333  case 28: {
334  sector = 7;
335  break;
336  }
337  case 29:
338  case 30:
339  case 31:
340  case 32: {
341  sector = 8;
342  break;
343  }
344  default:;
345  };
346  }
347 
348  return sector;
349 }
350 
351 //---- this needs to be removed --------------------------------
352 //---- there is no half module in the upgraded geometry!!! -----
354  bool halfModule = false;
355  // if (theLadder == 1) halfModule = true;
356  // if (theLayer == 1 && theLadder == 10) halfModule = true;
357  // if (theLayer == 2 && theLadder == 16) halfModule = true;
358  // if (theLayer == 3 && theLadder == 22) halfModule = true;
359  return halfModule;
360 }
361 
364 }
365 
367  return other.isBarrel() ? (dynamic_cast<const PixelBarrelNameUpgrade&>(other) == *this) : false;
368 }
369 
371  std::ostringstream stm;
372 
373  stm << "BPix_B" << thePart << "_SEC" << sectorName() << "_LYR" << theLayer << "_LDR" << theLadder;
374  stm << "F";
375  stm << "_MOD" << theModule;
376 
377  return stm.str();
378 }
379 /*
380 string PixelBarrelNameUpgrade::name() const
381 {
382  std::ostringstream stm;
383 
384  stm<<"BPix_B"<<thePart<<"_SEC"<<sectorName()<<"_LYR"<<theLayer<<"_LDR"<<theLadder;
385  if ( isHalfModule() ) stm <<"H"; else stm <<"F";
386  stm << "_MOD" << theModule;
387 
388  return stm.str();
389 }
390 */
391 
392 // return the DetId
394  uint32_t layer = 0;
395  uint32_t ladder = 0;
396  uint32_t module = 0;
397 
398  layer = layerName();
399  uint32_t tmpLadder = ladderName();
400  uint32_t tmpModule = moduleName();
401 
402  // translate the ladder number from the naming convention to the cmssw convention
403  bool outer = false;
404  Shell shell = thePart;
405  outer = (shell == mO) || (shell == pO);
406  if (outer) {
407  if (layer == 1)
408  ladder = tmpLadder + 3;
409  else if (layer == 2)
410  ladder = tmpLadder + 7;
411  else if (layer == 3)
412  ladder = tmpLadder + 11;
413  else if (layer == 4)
414  ladder = tmpLadder + 16;
415  } // outer
416  else { // inner
417  if (layer == 1) {
418  if (tmpLadder <= 3)
419  ladder = 4 - tmpLadder;
420  else if (tmpLadder <= 6)
421  ladder = 16 - tmpLadder;
422  } // layer 1
423  else if (layer == 2) {
424  if (tmpLadder <= 7)
425  ladder = 8 - tmpLadder;
426  else if (tmpLadder <= 14)
427  ladder = 36 - tmpLadder;
428  } // layer 2
429  else if (layer == 3) {
430  if (tmpLadder <= 11)
431  ladder = 12 - tmpLadder;
432  else if (tmpLadder <= 22)
433  ladder = 56 - tmpLadder;
434  } // layer 3
435  else if (layer == 4) {
436  if (tmpLadder <= 16)
437  ladder = 17 - tmpLadder;
438  else if (tmpLadder <= 32)
439  ladder = 81 - tmpLadder;
440  } // layer 4
441  } // inner
442 
443  // translate the module number from naming convention to cmssw convention
444  // numbering starts at positive z
445  if (shell == pO || shell == pI)
446  module = tmpModule + 4;
447  else // negative z side
448  module = 5 - tmpModule;
449 
450  return PXBDetId(layer, ladder, module);
451 
452 } // PXBDetId PixelBarrelNameUpgrade::getDetId()
453 
454 std::ostream& operator<<(std::ostream& out, const PixelBarrelNameUpgrade::Shell& t) {
455  switch (t) {
457  out << "pI";
458  break;
459  }
461  out << "pO";
462  break;
463  }
465  out << "mI";
466  break;
467  }
469  out << "mO";
470  break;
471  }
472  default:
473  out << "unknown";
474  };
475  return out;
476 }
PixelBarrelNameUpgrade(const DetId &)
ctor from DetId
std::ostream & operator<<(std::ostream &out, const PixelBarrelNameUpgrade::Shell &t)
int layerName() const
layer id
unsigned int module() const
det id
Definition: PXBDetId.h:37
bool isHalfModule() const
full or half module
unsigned int layer() const
layer id
Definition: PXBDetId.h:31
Log< level::Error, false > LogError
std::string name() const override
from base class
PXBDetId getDetId()
return the DetId
int moduleName() const
module id (index in z)
int ladderName() const
ladder id (index in phi)
PixelModuleName::ModuleType moduleType() const override
module Type
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
Definition: DetId.h:17
int sectorName() const
sector id
bool operator==(const PixelModuleName &) const override
check equality of modules from datamemebers
Definition: shell.py:1
unsigned int ladder() const
ladder id
Definition: PXBDetId.h:34