CMS 3D CMS Logo

PixelEndcapName.cc
Go to the documentation of this file.
2 
3 #include <sstream>
6 
7 using namespace std;
8 
9 namespace {
10  //const bool phase1 = false;
11  const bool pilot_blade = false;
12 } // namespace
13 
14 // Decodes the pixel name from the cmssw DetID, uses tracker topology
16  : PixelModuleName(false), thePart(mO), theDisk(0), theBlade(0), thePannel(0), thePlaquette(0), phase1(phase) {
17  //PXFDetId cmssw_numbering(id);
18  int side = tt->pxfSide(id);
19  int tmpBlade = tt->pxfBlade(id);
20  theDisk = tt->pxfDisk(id);
21  thePannel = tt->pxfPanel(id);
22  bool outer = false; // outer means with respect to the LHC ring (x - axis) Bm(p)I/O
23 
24  if (phase1) { // phase 1
25 
26  int ring = 0; // ring number , according to radius, 1-lower, 2- higher
27 
28  if (tmpBlade >= 7 && tmpBlade <= 17) { // ring 1, O
29  outer = true;
30  theBlade = tmpBlade - 6; //7...17-->1...11
31  ring = 1; // lower radius
32 
33  } else if (tmpBlade <= 6) { // ring 1, I
34  theBlade = 7 - tmpBlade; //1...6-->6...1
35  ring = 1;
36 
37  } else if (tmpBlade >= 18 && tmpBlade <= 22) { // ring 1, I
38  theBlade = 29 - tmpBlade; //18...22-->11...7
39  ring = 1;
40 
41  } else if (tmpBlade >= 32 && tmpBlade <= 48) { // ring 2, O
42  outer = true;
43  theBlade = tmpBlade - 31; //32...48-->28...12
44  ring = 2; // higher radius
45 
46  } else if (tmpBlade >= 23 && tmpBlade <= 31) { // ring 2, I
47  theBlade = 32 - tmpBlade; //23...31-->9...1
48  ring = 2;
49 
50  } else if (tmpBlade >= 49 && tmpBlade <= 56) { // ring 2, I
51  theBlade = 66 - tmpBlade; //49...56-->28...21
52  ring = 2;
53 
54  } // end
55 
57 
58  } else { // phase0
59 
60  // hack for the pilot blade
61  if (pilot_blade && theDisk == 3) { // do only for disk 3
62  //cout<<tmpBlade<<" "<<theDisk<<endl;
63  if (tmpBlade >= 1 && tmpBlade <= 4) {
64  // convert the sequential counting of pilot blades to std. cmssw convention
65  if (tmpBlade < 3)
66  tmpBlade += 3;
67  else
68  tmpBlade += 13;
69  } else {
70  edm::LogError("Bad PilotBlade blade number ") << tmpBlade;
71  }
72  }
73 
74  if (tmpBlade >= 7 && tmpBlade <= 18) {
75  outer = true;
76  theBlade = tmpBlade - 6;
77  } else if (tmpBlade <= 6) {
78  theBlade = 7 - tmpBlade;
79  } else if (tmpBlade >= 19) {
80  theBlade = 31 - tmpBlade;
81  }
82 
83  thePlaquette = tt->pxfModule(id); // ring number is coded as plaqutte (plaqs are unused)
84 
85  } // end phase1
86 
87  if (side == 1 && outer)
88  thePart = mO;
89  else if (side == 1 && !outer)
90  thePart = mI;
91  else if (side == 2 && outer)
92  thePart = pO;
93  else if (side == 2 && !outer)
94  thePart = pI;
95 }
96 
97 // Decodes the pixel name from the cmssw DetID, uses old pixel name classes
99  : PixelModuleName(false), thePart(mO), theDisk(0), theBlade(0), thePannel(0), thePlaquette(0), phase1(phase) {
100  PXFDetId cmssw_numbering(id);
101  int side = cmssw_numbering.side();
102  int tmpBlade = cmssw_numbering.blade();
103  theDisk = cmssw_numbering.disk();
104  thePannel = cmssw_numbering.panel();
105  bool outer = false; // outer means with respect to the LHC ring (x - axis)
106 
107  if (phase1) { // phase1
108 
109  int ring = 0; // ring number , according to radius, 1-lower, 2- higher
110 
111  if (tmpBlade >= 7 && tmpBlade <= 17) { // ring 1, O
112  outer = true;
113  theBlade = tmpBlade - 6; //7...17-->1...11
114  ring = 1; // lower radius
115 
116  } else if (tmpBlade <= 6) { // ring 1, I
117  theBlade = 7 - tmpBlade; //1...6-->6...1
118  ring = 1;
119 
120  } else if (tmpBlade >= 18 && tmpBlade <= 22) { // ring 1, I
121  theBlade = 29 - tmpBlade; //18...22-->11...7
122  ring = 1;
123 
124  } else if (tmpBlade >= 32 && tmpBlade <= 48) { // ring 2, O
125  outer = true;
126  theBlade = tmpBlade - 31; //32...48-->28...12
127  ring = 2; // higher radius
128 
129  } else if (tmpBlade >= 23 && tmpBlade <= 31) { // ring 2, I
130  theBlade = 32 - tmpBlade; //23...31-->9...1
131  ring = 2;
132 
133  } else if (tmpBlade >= 49 && tmpBlade <= 56) { // ring 2, I
134  theBlade = 66 - tmpBlade; //49...56-->28...21
135  ring = 2;
136 
137  } // end
138 
139  thePlaquette = ring;
140 
141  } else { // phase 0
142 
143  // hack for the pilot blade
144  if (pilot_blade && theDisk == 3) { // do only for disk 3
145  if (tmpBlade >= 1 && tmpBlade <= 4) {
146  // convert the sequential counting of pilot blades to std. cmssw convention
147  if (tmpBlade < 3)
148  tmpBlade += 3;
149  else
150  tmpBlade += 13;
151  } else {
152  edm::LogError("Bad PilotBlade blade number ") << tmpBlade;
153  }
154  }
155 
156  if (tmpBlade >= 7 && tmpBlade <= 18) {
157  outer = true; // outer means with respect to the LHC ring (x - axis)
158  theBlade = tmpBlade - 6;
159  } else if (tmpBlade <= 6) {
160  theBlade = 7 - tmpBlade;
161  } else if (tmpBlade >= 19) {
162  theBlade = 31 - tmpBlade;
163  }
164 
165  thePlaquette = cmssw_numbering.module();
166 
167  } // end phase1
168 
169  if (side == 1 && outer)
170  thePart = mO;
171  else if (side == 1 && !outer)
172  thePart = mI;
173  else if (side == 2 && outer)
174  thePart = pO;
175  else if (side == 2 && !outer)
176  thePart = pI;
177 }
178 
179 // constructor from name string
181  : PixelModuleName(false), thePart(mO), theDisk(0), theBlade(0), thePannel(0), thePlaquette(0), phase1(phase) {
182  // parse the name string
183  // first, check to make sure this is an FPix name, should start with "FPix_"
184  // also check to make sure the needed parts are present
185  if ((name.substr(0, 5) != "FPix_") || (name.find("_B") == string::npos) || (name.find("_D") == string::npos) ||
186  (name.find("_BLD") == string::npos) || (name.find("_PNL") == string::npos) ||
187  ((phase1 && name.find("_RNG") == string::npos)) || ((!phase1 && name.find("_PLQ") == string::npos))) {
188  edm::LogError("BadNameString|SiPixel")
189  << "Bad name string in PixelEndcapName::PixelEndcapName(std::string): " << name;
190  return;
191  }
192 
193  // strip off ROC part if it's there
194  if (name.find("_ROC") != string::npos)
195  name = name.substr(0, name.find("_ROC"));
196 
197  // get the half cylinder
198  string hcString = name.substr(name.find("_B") + 2, name.find("_D") - name.find("_B") - 2);
199  if (hcString == "mO")
200  thePart = mO;
201  else if (hcString == "mI")
202  thePart = mI;
203  else if (hcString == "pO")
204  thePart = pO;
205  else if (hcString == "pI")
206  thePart = pI;
207  else {
208  edm::LogError("BadNameString|SiPixel")
209  << "Unable to determine half cylinder in PixelEndcapName::PixelEndcapName(std::string): " << name;
210  }
211 
212  // get the disk
213  string diskString = name.substr(name.find("_D") + 2, name.find("_BLD") - name.find("_D") - 2);
214  if (diskString == "1")
215  theDisk = 1;
216  else if (diskString == "2")
217  theDisk = 2;
218  else if (diskString == "3")
219  theDisk = 3;
220  else {
221  edm::LogError("BadNameString|SiPixel")
222  << "Unable to determine disk number in PixelEndcapName::PixelEndcapName(std::string): " << name;
223  }
224 
225  // get the blade
226  string bladeString = name.substr(name.find("_BLD") + 4, name.find("_PNL") - name.find("_BLD") - 4);
227  // since atoi() doesn't report errors, do it the long way
228  if (bladeString == "1")
229  theBlade = 1;
230  else if (bladeString == "2")
231  theBlade = 2;
232  else if (bladeString == "3")
233  theBlade = 3;
234  else if (bladeString == "4")
235  theBlade = 4;
236  else if (bladeString == "5")
237  theBlade = 5;
238  else if (bladeString == "6")
239  theBlade = 6;
240  else if (bladeString == "7")
241  theBlade = 7;
242  else if (bladeString == "8")
243  theBlade = 8;
244  else if (bladeString == "9")
245  theBlade = 9;
246  else if (bladeString == "10")
247  theBlade = 10;
248  else if (bladeString == "11")
249  theBlade = 11;
250  else if (bladeString == "12")
251  theBlade = 12;
252  else if (bladeString == "13")
253  theBlade = 13;
254  else if (bladeString == "14")
255  theBlade = 14;
256  else if (bladeString == "15")
257  theBlade = 15;
258  else if (bladeString == "16")
259  theBlade = 16;
260  else if (bladeString == "17")
261  theBlade = 17;
262  else {
263  edm::LogError("BadNameString|SiPixel")
264  << "Unable to determine blade number in PixelEndcapName::PixelEndcapName(std::string): " << name;
265  }
266 
267  // find the panel
268  string panelString;
269  if (phase1)
270  panelString = name.substr(name.find("_PNL") + 4, name.find("_RNG") - name.find("_PNL") - 4);
271  else
272  panelString = name.substr(name.find("_PNL") + 4, name.find("_PLQ") - name.find("_PNL") - 4);
273 
274  if (panelString == "1")
275  thePannel = 1;
276  else if (panelString == "2")
277  thePannel = 2;
278  else {
279  edm::LogError("BadNameString|SiPixel")
280  << "Unable to determine panel number in PixelEndcapName::PixelEndcapName(std::string): " << name;
281  }
282 
283  // find the plaquette, for phase 1 this is the rung number
284  if (phase1) { // phase1
285 
286  string ringString = name.substr(name.find("_RNG") + 4, name.size() - name.find("_RNG") - 4);
287  if (ringString == "1")
288  thePlaquette = 1; // code ring in the plaquette
289  else if (ringString == "2")
290  thePlaquette = 2;
291  else {
292  edm::LogError("BadNameString|SiPixel")
293  << "Unable to determine ring number in PixelEndcapName::PixelEndcapName(std::string): " << name;
294  }
295 
296  } else { // phase 0
297 
298  // find the plaquette
299  string plaquetteString = name.substr(name.find("_PLQ") + 4, name.size() - name.find("_PLQ") - 4);
300  if (plaquetteString == "1")
301  thePlaquette = 1;
302  else if (plaquetteString == "2")
303  thePlaquette = 2;
304  else if (plaquetteString == "3")
305  thePlaquette = 3;
306  else if (plaquetteString == "4")
307  thePlaquette = 4;
308  else {
309  edm::LogError("BadNameString|SiPixel")
310  << "Unable to determine plaquette number in PixelEndcapName::PixelEndcapName(std::string): " << name;
311  }
312 
313  } // end phase1
314 
315 } // PixelEndcapName::PixelEndcapName(std::string name)
316 
318  ModuleType type = v1x2;
319 
320  if (phase1) { // phase1
321 
322  type = v2x8;
323 
324  } else { // phase 0
325 
326  if (pannelName() == 1) {
327  if (plaquetteName() == 1) {
328  type = v1x2;
329  } else if (plaquetteName() == 2) {
330  type = v2x3;
331  } else if (plaquetteName() == 3) {
332  type = v2x4;
333  } else if (plaquetteName() == 4) {
334  type = v1x5;
335  }
336  } else {
337  if (plaquetteName() == 1) {
338  type = v2x3;
339  } else if (plaquetteName() == 2) {
340  type = v2x4;
341  } else if (plaquetteName() == 3) {
342  type = v2x5;
343  }
344  }
345 
346  // hack for the pilot blade
347  if (pilot_blade && theDisk == 3) {
348  type = v2x8;
349  } // do only for disk 3
350 
351  } // end phase1
352 
353  return type;
354 }
355 
357  if (!o.isBarrel()) {
358  const PixelEndcapName* other = dynamic_cast<const PixelEndcapName*>(&o);
359  return (other && thePart == other->thePart && theDisk == other->theDisk && theBlade == other->theBlade &&
360  thePannel == other->thePannel && thePlaquette == other->thePlaquette);
361  } else
362  return false;
363 }
364 
365 string PixelEndcapName::name() const {
366  std::ostringstream stm;
367 
368  if (phase1)
369  stm << "FPix_B" << thePart << "_D" << theDisk << "_BLD" << theBlade << "_PNL" << thePannel << "_RNG"
370  << thePlaquette;
371  else
372  stm << "FPix_B" << thePart << "_D" << theDisk << "_BLD" << theBlade << "_PNL" << thePannel << "_PLQ"
373  << thePlaquette;
374 
375  return stm.str();
376 }
377 
378 std::ostream& operator<<(std::ostream& out, const PixelEndcapName::HalfCylinder& t) {
379  switch (t) {
380  case (PixelEndcapName::pI): {
381  out << "pI";
382  break;
383  }
384  case (PixelEndcapName::pO): {
385  out << "pO";
386  break;
387  }
388  case (PixelEndcapName::mI): {
389  out << "mI";
390  break;
391  }
392  case (PixelEndcapName::mO): {
393  out << "mO";
394  break;
395  }
396  default:
397  out << "unknown";
398  };
399  return out;
400 }
401 
402 // return the DetId
404  uint32_t side = 0;
405  uint32_t disk = 0;
406  uint32_t blade = 0;
407  uint32_t panel = 0;
408  uint32_t module = 0;
409 
410  // figure out the side
411  HalfCylinder hc = halfCylinder();
412  if (hc == mO || hc == mI)
413  side = 1;
414  else if (hc == pO || hc == pI)
415  side = 2;
416 
417  // get disk/blade/panel/module numbers from PixelEndcapName object
418  disk = static_cast<uint32_t>(diskName());
419  uint32_t tmpBlade = static_cast<uint32_t>(bladeName());
420  panel = static_cast<uint32_t>(pannelName());
421 
422  // convert blade numbering to cmssw convention
423  bool outer = false;
424  outer = (hc == mO) || (hc == pO);
425 
426  if (phase1) { // phase1
427 
428  module = 1;
429  int ring = static_cast<uint32_t>(ringName()); // this is ring for phase1
430  if (ring == 1) { // ring 1, lower radius
431  if (outer) {
432  if (tmpBlade >= 1 && tmpBlade <= 11)
433  blade = tmpBlade + 6;
434  } else { //inner
435  if (tmpBlade <= 6)
436  blade = 7 - tmpBlade;
437  else
438  blade = 29 - tmpBlade;
439  }
440 
441  } else if (ring == 2) { //ring 2, upper radius
442  if (outer) {
443  if (tmpBlade >= 1 && tmpBlade <= 17)
444  blade = tmpBlade + 31;
445  } else { //inner
446  if (tmpBlade <= 9)
447  blade = 32 - tmpBlade;
448  else
449  blade = 66 - tmpBlade;
450  }
451  }
452 
453  } else { // phase 0
454 
455  if (outer) {
456  blade = tmpBlade + 6;
457  } else { // inner
458  if (tmpBlade <= 6)
459  blade = 7 - tmpBlade;
460  else if (tmpBlade <= 12)
461  blade = 31 - tmpBlade;
462  }
463 
464  // hack for the pilot blade
465  if (pilot_blade && theDisk == 3) { // do only for disk 3
466  //cout<<tmpBlade<<" "<<blade<<endl;
467  if (blade <= 5)
468  blade -= 3;
469  else
470  blade -= 13;
471  //cout<<tmpBlade<<" "<<blade<<endl;
472  }
473 
474  module = static_cast<uint32_t>(plaquetteName());
475  } // end phase1
476 
477  // create and return the DetId
478  DetId id = tt->pxfDetId(side, disk, blade, panel, module);
479 
480  return id;
481 
482 } // PXFDetId PixelEndcapName::getDetId()
483 
484 // return the DetId
486  uint32_t side = 0;
487  uint32_t disk = 0;
488  uint32_t blade = 0;
489  uint32_t panel = 0;
490  uint32_t module = 0;
491 
492  // figure out the side
493  HalfCylinder hc = halfCylinder();
494  if (hc == mO || hc == mI)
495  side = 1;
496  else if (hc == pO || hc == pI)
497  side = 2;
498 
499  // get disk/blade/panel/module numbers from PixelEndcapName object
500  disk = static_cast<uint32_t>(diskName());
501  uint32_t tmpBlade = static_cast<uint32_t>(bladeName());
502  panel = static_cast<uint32_t>(pannelName());
503 
504  // convert blade numbering to cmssw convention
505  bool outer = false;
506  outer = (hc == mO) || (hc == pO);
507 
508  if (phase1) { // phase1
509 
510  module = 1; // for phase 1 always 1,
511  int ring = static_cast<uint32_t>(ringName()); // this is ring for phase1
512  if (ring == 1) { // ring 1, lower radius
513  if (outer) {
514  if (tmpBlade >= 1 && tmpBlade <= 11)
515  blade = tmpBlade + 6;
516  } else { //inner
517  if (tmpBlade <= 6)
518  blade = 7 - tmpBlade;
519  else
520  blade = 29 - tmpBlade;
521  }
522 
523  } else if (ring == 2) { //ring 2, upper radius
524  if (outer) {
525  if (tmpBlade >= 1 && tmpBlade <= 17)
526  blade = tmpBlade + 31;
527  } else { //inner
528  if (tmpBlade <= 9)
529  blade = 32 - tmpBlade;
530  else
531  blade = 66 - tmpBlade;
532  }
533  }
534 
535  } else { // phase 0
536 
537  if (outer) {
538  blade = tmpBlade + 6;
539  } else { // inner
540  if (tmpBlade <= 6)
541  blade = 7 - tmpBlade;
542  else if (tmpBlade <= 12)
543  blade = 31 - tmpBlade;
544  }
545 
546  // hack for the pilot blade
547  if (pilot_blade && theDisk == 3) { // do only for disk 3
548  //cout<<tmpBlade<<" "<<blade<<endl;
549  if (blade <= 5)
550  blade -= 3;
551  else
552  blade -= 13;
553  //cout<<tmpBlade<<" "<<blade<<endl;
554  }
555 
556  module = static_cast<uint32_t>(plaquetteName());
557  } // end phase1
558 
559  // create and return the DetId
560  return PXFDetId(side, disk, blade, panel, module);
561 
562 } // PXFDetId PixelEndcapName::getDetId()
PixelModuleName::ModuleType moduleType() const override
module Type
unsigned int disk() const
disk id
Definition: PXFDetId.h:35
int ringName() const
ring Id
int bladeName() const
blade id
unsigned int side() const
positive or negative id
Definition: PXFDetId.h:32
Log< level::Error, false > LogError
HalfCylinder thePart
Definition: TTTypes.h:54
int diskName() const
disk id
std::string name() const override
from base class
HalfCylinder halfCylinder() const
unsigned int module() const
det id
Definition: PXFDetId.h:44
PXFDetId getDetId()
return DetId
unsigned int blade() const
blade id
Definition: PXFDetId.h:38
Definition: DetId.h:17
PixelEndcapName(const DetId &, bool phase=false)
ctor from DetId
bool operator==(const PixelModuleName &) const override
check equality of modules from datamemebers
unsigned int panel() const
panel id
Definition: PXFDetId.h:41
std::ostream & operator<<(std::ostream &out, const PixelEndcapName::HalfCylinder &t)
int pannelName() const
pannel id
int plaquetteName() const
plaquetteId (in pannel)