CMS 3D CMS Logo

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