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  return other.isBarrel() ? false : (dynamic_cast<const PixelEndcapName&>(other) == *this);
358 }
359 
360 string PixelEndcapName::name() const {
361  std::ostringstream stm;
362 
363  if (phase1)
364  stm << "FPix_B" << thePart << "_D" << theDisk << "_BLD" << theBlade << "_PNL" << thePannel << "_RNG"
365  << thePlaquette;
366  else
367  stm << "FPix_B" << thePart << "_D" << theDisk << "_BLD" << theBlade << "_PNL" << thePannel << "_PLQ"
368  << thePlaquette;
369 
370  return stm.str();
371 }
372 
373 std::ostream& operator<<(std::ostream& out, const PixelEndcapName::HalfCylinder& t) {
374  switch (t) {
375  case (PixelEndcapName::pI): {
376  out << "pI";
377  break;
378  }
379  case (PixelEndcapName::pO): {
380  out << "pO";
381  break;
382  }
383  case (PixelEndcapName::mI): {
384  out << "mI";
385  break;
386  }
387  case (PixelEndcapName::mO): {
388  out << "mO";
389  break;
390  }
391  default:
392  out << "unknown";
393  };
394  return out;
395 }
396 
397 // return the DetId
399  uint32_t side = 0;
400  uint32_t disk = 0;
401  uint32_t blade = 0;
402  uint32_t panel = 0;
403  uint32_t module = 0;
404 
405  // figure out the side
406  HalfCylinder hc = halfCylinder();
407  if (hc == mO || hc == mI)
408  side = 1;
409  else if (hc == pO || hc == pI)
410  side = 2;
411 
412  // get disk/blade/panel/module numbers from PixelEndcapName object
413  disk = static_cast<uint32_t>(diskName());
414  uint32_t tmpBlade = static_cast<uint32_t>(bladeName());
415  panel = static_cast<uint32_t>(pannelName());
416 
417  // convert blade numbering to cmssw convention
418  bool outer = false;
419  outer = (hc == mO) || (hc == pO);
420 
421  if (phase1) { // phase1
422 
423  module = 1;
424  int ring = static_cast<uint32_t>(ringName()); // this is ring for phase1
425  if (ring == 1) { // ring 1, lower radius
426  if (outer) {
427  if (tmpBlade >= 1 && tmpBlade <= 11)
428  blade = tmpBlade + 6;
429  } else { //inner
430  if (tmpBlade <= 6)
431  blade = 7 - tmpBlade;
432  else
433  blade = 29 - tmpBlade;
434  }
435 
436  } else if (ring == 2) { //ring 2, upper radius
437  if (outer) {
438  if (tmpBlade >= 1 && tmpBlade <= 17)
439  blade = tmpBlade + 31;
440  } else { //inner
441  if (tmpBlade <= 9)
442  blade = 32 - tmpBlade;
443  else
444  blade = 66 - tmpBlade;
445  }
446  }
447 
448  } else { // phase 0
449 
450  if (outer) {
451  blade = tmpBlade + 6;
452  } else { // inner
453  if (tmpBlade <= 6)
454  blade = 7 - tmpBlade;
455  else if (tmpBlade <= 12)
456  blade = 31 - tmpBlade;
457  }
458 
459  // hack for the pilot blade
460  if (pilot_blade && theDisk == 3) { // do only for disk 3
461  //cout<<tmpBlade<<" "<<blade<<endl;
462  if (blade <= 5)
463  blade -= 3;
464  else
465  blade -= 13;
466  //cout<<tmpBlade<<" "<<blade<<endl;
467  }
468 
469  module = static_cast<uint32_t>(plaquetteName());
470  } // end phase1
471 
472  // create and return the DetId
473  DetId id = tt->pxfDetId(side, disk, blade, panel, module);
474 
475  return id;
476 
477 } // PXFDetId PixelEndcapName::getDetId()
478 
479 // return the DetId
481  uint32_t side = 0;
482  uint32_t disk = 0;
483  uint32_t blade = 0;
484  uint32_t panel = 0;
485  uint32_t module = 0;
486 
487  // figure out the side
488  HalfCylinder hc = halfCylinder();
489  if (hc == mO || hc == mI)
490  side = 1;
491  else if (hc == pO || hc == pI)
492  side = 2;
493 
494  // get disk/blade/panel/module numbers from PixelEndcapName object
495  disk = static_cast<uint32_t>(diskName());
496  uint32_t tmpBlade = static_cast<uint32_t>(bladeName());
497  panel = static_cast<uint32_t>(pannelName());
498 
499  // convert blade numbering to cmssw convention
500  bool outer = false;
501  outer = (hc == mO) || (hc == pO);
502 
503  if (phase1) { // phase1
504 
505  module = 1; // for phase 1 always 1,
506  int ring = static_cast<uint32_t>(ringName()); // this is ring for phase1
507  if (ring == 1) { // ring 1, lower radius
508  if (outer) {
509  if (tmpBlade >= 1 && tmpBlade <= 11)
510  blade = tmpBlade + 6;
511  } else { //inner
512  if (tmpBlade <= 6)
513  blade = 7 - tmpBlade;
514  else
515  blade = 29 - tmpBlade;
516  }
517 
518  } else if (ring == 2) { //ring 2, upper radius
519  if (outer) {
520  if (tmpBlade >= 1 && tmpBlade <= 17)
521  blade = tmpBlade + 31;
522  } else { //inner
523  if (tmpBlade <= 9)
524  blade = 32 - tmpBlade;
525  else
526  blade = 66 - tmpBlade;
527  }
528  }
529 
530  } else { // phase 0
531 
532  if (outer) {
533  blade = tmpBlade + 6;
534  } else { // inner
535  if (tmpBlade <= 6)
536  blade = 7 - tmpBlade;
537  else if (tmpBlade <= 12)
538  blade = 31 - tmpBlade;
539  }
540 
541  // hack for the pilot blade
542  if (pilot_blade && theDisk == 3) { // do only for disk 3
543  //cout<<tmpBlade<<" "<<blade<<endl;
544  if (blade <= 5)
545  blade -= 3;
546  else
547  blade -= 13;
548  //cout<<tmpBlade<<" "<<blade<<endl;
549  }
550 
551  module = static_cast<uint32_t>(plaquetteName());
552  } // end phase1
553 
554  // create and return the DetId
555  return PXFDetId(side, disk, blade, panel, module);
556 
557 } // 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)