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