CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 = true;
11 }
12 
14  : PixelModuleName(false), phase1(phase)
15 {
16 
17  //PXFDetId cmssw_numbering(id);
18  int side = tt->pxfSide(id);
19  int tmpBlade = tt->pxfBlade(id);
20  theDisk = tt->pxfDisk(id);
21  thePlaquette = tt->pxfModule(id);
22  bool outer = false; // outer means with respect to the LHC ring (x - axis)
23 
24 
25  if(phase1) { // phase 1
26 
27  // this still has to be modified so blades start from 1 on the top
28  if (tmpBlade>=7 && tmpBlade<=17) {
29  outer = true;
30  theBlade = tmpBlade-6; //7...17-->1...11
31  } else if (tmpBlade>=32 && tmpBlade<=48) {
32  outer = true;
33  theBlade = 60-tmpBlade; //32...48-->28...12
34  } else if( tmpBlade<=6 ) {
35  theBlade = 7-tmpBlade; //1...6-->6...1
36  } else if( tmpBlade>=18 && tmpBlade<=31 ) {
37  theBlade = 38-tmpBlade; //18...31-->20...7
38  } else if( tmpBlade>=49 && tmpBlade<=56 ) {
39  theBlade = 77-tmpBlade; //49...56-->28...21
40  } // iasonas2-end
41 
42  thePannel = tt->pxfPanel(id); // this is the ring
43  //thePannel = tt->pxfRing(id); // this is the ring
44 
45  } else { // phase0
46 
47  // hack for the pilot blade
48  if(pilot_blade && theDisk==3 ) { // do only for disk 3
49  //cout<<tmpBlade<<" "<<theDisk<<endl;
50  if(tmpBlade>=1 && tmpBlade<=4) {
51  // convert the sequential counting of pilot blades to std. cmssw convention
52  if(tmpBlade<3) tmpBlade +=3;
53  else tmpBlade +=13;
54  } else {
55  edm::LogError ("Bad PilotBlade blade number ")
56  << tmpBlade;
57  }
58  }
59 
60  if (tmpBlade >= 7 && tmpBlade <= 18) {
61  outer = true;
62  theBlade = tmpBlade-6;
63  } else if( tmpBlade <=6 ) {
64  theBlade = 7-tmpBlade;
65  } else if( tmpBlade >= 19) {
66  theBlade = 31-tmpBlade;
67  }
68 
69  thePannel = tt->pxfPanel(id);
70 
71  } // end phase1
72 
73  if( side == 1 && outer ) thePart = mO;
74  else if( side == 1 && !outer ) thePart = mI;
75  else if( side == 2 && outer ) thePart = pO;
76  else if( side == 2 && !outer ) thePart = pI;
77 
78 }
79 
80 PixelEndcapName::PixelEndcapName(const DetId & id, bool phase)
81  : PixelModuleName(false), phase1(phase)
82 {
83  PXFDetId cmssw_numbering(id);
84  int side = cmssw_numbering.side();
85  int tmpBlade = cmssw_numbering.blade();
86  thePlaquette = cmssw_numbering.module();
87  theDisk = cmssw_numbering.disk();
88  bool outer = false; // outer means with respect to the LHC ring (x - axis)
89 
90  if(phase1) { // phase1
91  // this still has to be modified so blades start from 1 on the top
92  if (tmpBlade>=7 && tmpBlade<=17) {
93  outer = true; // outer means with respect to the LHC ring (x - axis)
94  theBlade = tmpBlade-6; //7...17-->1...11
95  } else if (tmpBlade>=32 && tmpBlade<=48) {
96  outer = true;
97  theBlade = 60-tmpBlade; //32...48-->28...12
98  } else if( tmpBlade<=6 ) {
99  theBlade = 7-tmpBlade; //1...6-->6...1
100  } else if( tmpBlade>=18 && tmpBlade<=31 ) {
101  theBlade = 38-tmpBlade; //18...31-->20...7
102  } else if( tmpBlade>=49 && tmpBlade<=56 ) {
103  theBlade = 77-tmpBlade; //49...56-->28...21
104  } // iasonas2-end
105 
106  thePannel = cmssw_numbering.panel(); // this is really the ring
107 
108  } else { // phase 0
109 
110  // hack for the pilot blade
111  if(pilot_blade && theDisk==3 ) { // do only for disk 3
112  if(tmpBlade>=1 && tmpBlade<=4) {
113  // convert the sequential counting of pilot blades to std. cmssw convention
114  if(tmpBlade<3) tmpBlade +=3;
115  else tmpBlade +=13;
116  } else {
117  edm::LogError ("Bad PilotBlade blade number ")
118  << tmpBlade;
119  }
120  }
121 
122  if (tmpBlade >= 7 && tmpBlade <= 18) {
123  outer = true; // outer means with respect to the LHC ring (x - axis)
124  theBlade = tmpBlade-6;
125  } else if( tmpBlade <=6 ) {
126  theBlade = 7-tmpBlade;
127  } else if( tmpBlade >= 19) {
128  theBlade = 31-tmpBlade;
129  }
130 
131  thePannel = cmssw_numbering.panel();
132 
133  } // end phase1
134 
135  if( side == 1 && outer ) thePart = mO;
136  else if( side == 1 && !outer ) thePart = mI;
137  else if( side == 2 && outer ) thePart = pO;
138  else if( side == 2 && !outer ) thePart = pI;
139 
140 }
141 
142 // constructor from name string
144  : PixelModuleName(false), thePart(mO), theDisk(0),
145  theBlade(0), thePannel(0), thePlaquette(0) {
146 
147  // parse the name string
148  // first, check to make sure this is an FPix name, should start with "FPix_"
149  // also check to make sure the needed parts are present
150  if ( (name.substr(0, 5) != "FPix_") ||
151  (name.find("_B") == string::npos) ||
152  (name.find("_D") == string::npos) ||
153  (name.find("_BLD") == string::npos) ||
154  (name.find("_PNL") == string::npos) ||
155  ( (phase1 && name.find("_RNG") == string::npos) ) ||
156  ( (!phase1 && name.find("_PLQ") == string::npos) ) ) {
157  edm::LogError ("BadNameString|SiPixel")
158  << "Bad name string in PixelEndcapName::PixelEndcapName(std::string): "
159  << name;
160  return;
161  }
162 
163  // strip off ROC part if it's there
164  if (name.find("_ROC") != string::npos)
165  name = name.substr(0, name.find("_ROC"));
166 
167  // get the half cylinder
168  string hcString = name.substr(name.find("_B")+2, name.find("_D")-name.find("_B")-2);
169  if (hcString == "mO") thePart = mO;
170  else if (hcString == "mI") thePart = mI;
171  else if (hcString == "pO") thePart = pO;
172  else if (hcString == "pI") thePart = pI;
173  else {
174  edm::LogError ("BadNameString|SiPixel")
175  << "Unable to determine half cylinder in PixelEndcapName::PixelEndcapName(std::string): "
176  << name;
177  }
178 
179  // get the disk
180  string diskString = name.substr(name.find("_D")+2, name.find("_BLD")-name.find("_D")-2);
181  if (diskString == "1") theDisk = 1;
182  else if (diskString == "2") theDisk = 2;
183  else if (diskString == "3") theDisk = 3;
184  else {
185  edm::LogError ("BadNameString|SiPixel")
186  << "Unable to determine disk number in PixelEndcapName::PixelEndcapName(std::string): "
187  << name;
188  }
189 
190  // get the blade
191  string bladeString = name.substr(name.find("_BLD")+4, name.find("_PNL")-name.find("_BLD")-4);
192  // since atoi() doesn't report errors, do it the long way
193  if (bladeString == "1") theBlade = 1;
194  else if (bladeString == "2") theBlade = 2;
195  else if (bladeString == "3") theBlade = 3;
196  else if (bladeString == "4") theBlade = 4;
197  else if (bladeString == "5") theBlade = 5;
198  else if (bladeString == "6") theBlade = 6;
199  else if (bladeString == "7") theBlade = 7;
200  else if (bladeString == "8") theBlade = 8;
201  else if (bladeString == "9") theBlade = 9;
202  else if (bladeString == "10") theBlade = 10;
203  else if (bladeString == "11") theBlade = 11;
204  else if (bladeString == "12") theBlade = 12;
205  else if (bladeString == "13") theBlade = 13;
206  else if (bladeString == "14") theBlade = 14;
207  else if (bladeString == "15") theBlade = 15;
208  else if (bladeString == "16") theBlade = 16;
209  else if (bladeString == "17") theBlade = 17;
210  else {
211  edm::LogError ("BadNameString|SiPixel")
212  << "Unable to determine blade number in PixelEndcapName::PixelEndcapName(std::string): "
213  << name;
214  }
215 
216 
217  if(phase1) { // phase1
218  string ringString = name.substr(name.find("_RNG")+4, name.size()-name.find("_RNG")-4);
219  if (ringString == "1") thePannel = 1; // code ring in the pannel
220  else if (ringString == "2") thePannel = 2;
221  else {
222  edm::LogError ("BadNameString|SiPixel")
223  << "Unable to determine ring number in PixelEndcapName::PixelEndcapName(std::string): "
224  << name;
225  }
226 
227  } else { // phase 0
228 
229  // find the panel
230  string panelString = name.substr(name.find("_PNL")+4, name.find("_PLQ")-name.find("_PNL")-4);
231  if (panelString == "1") thePannel = 1;
232  else if (panelString == "2") thePannel = 2;
233  else {
234  edm::LogError ("BadNameString|SiPixel")
235  << "Unable to determine panel number in PixelEndcapName::PixelEndcapName(std::string): "
236  << name;
237  }
238  } // end phase1
239 
240  // find the plaquette
241  string plaquetteString = name.substr(name.find("_PLQ")+4, name.size()-name.find("_PLQ")-4);
242  if (plaquetteString == "1") thePlaquette = 1;
243  else if (plaquetteString == "2") thePlaquette = 2;
244  else if (plaquetteString == "3") thePlaquette = 3;
245  else if (plaquetteString == "4") thePlaquette = 4;
246  else {
247  edm::LogError ("BadNameString|SiPixel")
248  << "Unable to determine plaquette number in PixelEndcapName::PixelEndcapName(std::string): "
249  << name;
250  }
251 
252 
253 } // PixelEndcapName::PixelEndcapName(std::string name)
254 
256 {
257  ModuleType type = v1x2;
258 
259  if(phase1) { // phase1
260 
261  type = v2x8;
262 
263  } else { // phase 0
264 
265  if (pannelName() == 1) {
266  if (plaquetteName() == 1) { type = v1x2; }
267  else if (plaquetteName() == 2) { type = v2x3; }
268  else if (plaquetteName() == 3) { type = v2x4; }
269  else if (plaquetteName() == 4) { type = v1x5; }
270  } else {
271  if (plaquetteName() == 1) { type = v2x3; }
272  else if (plaquetteName() == 2) { type = v2x4; }
273  else if (plaquetteName() == 3) { type = v2x5; }
274  }
275 
276  // hack for the pilot blade
277  if(pilot_blade && theDisk==3 ) {type=v2x8;} // do only for disk 3
278 
279  } // end phase1
280 
281  return type;
282 }
283 
285 {
286  if (!o.isBarrel()) {
287  const PixelEndcapName * other = dynamic_cast<const PixelEndcapName *>(&o);
288  return ( other
289  && thePart == other->thePart
290  && theDisk == other->theDisk
291  && theBlade == other->theBlade
292  && thePannel == other->thePannel
293  && thePlaquette == other->thePlaquette );
294  } else return false;
295 }
296 
297 
298 string PixelEndcapName::name() const
299 {
300  std::ostringstream stm;
301 
302  stm <<"FPix_B"<<thePart<<"_D"<<theDisk<<"_BLD"<<theBlade<<"_PNL"<<thePannel<<"_PLQ"<<thePlaquette;
303  return stm.str();
304 }
305 
306 std::ostream & operator<<( std::ostream& out, const PixelEndcapName::HalfCylinder& t)
307 {
308  switch (t) {
309  case(PixelEndcapName::pI) : {out << "pI"; break;}
310  case(PixelEndcapName::pO) : {out << "pO"; break;}
311  case(PixelEndcapName::mI) : {out << "mI"; break;}
312  case(PixelEndcapName::mO) : {out << "mO"; break;}
313  default: out << "unknown";
314  };
315  return out;
316 }
317 
318 // return the DetId
320 
321  uint32_t side = 0;
322  uint32_t disk = 0;
323  uint32_t blade = 0;
324  uint32_t panel = 0;
325  uint32_t module = 0;
326 
327  // figure out the side
329  if (hc == mO || hc == mI) side = 1;
330  else if (hc == pO || hc == pI) side = 2;
331 
332  // get disk/blade/panel/module numbers from PixelEndcapName object
333  disk = static_cast<uint32_t>(diskName());
334  uint32_t tmpBlade = static_cast<uint32_t>(bladeName());
335  panel = static_cast<uint32_t>(pannelName());
336 
337  // convert blade numbering to cmssw convention
338  bool outer = false;
339  outer = (hc == mO) || (hc == pO);
340 
341  if(phase1) { // phase1
342 
343  // this still has to be modified so blades start from 1 on the top
344  if (outer) {
345  if (tmpBlade>=7 && tmpBlade<=17) theBlade = tmpBlade+6;
346  else if (tmpBlade>=32 && tmpBlade<=48) theBlade = 60-tmpBlade;
347  } else { //inner
348  if (tmpBlade<=6 ) theBlade = 7-tmpBlade;
349  else if (tmpBlade>=18 && tmpBlade<=31) theBlade = 38-tmpBlade;
350  else if (tmpBlade>=49 && tmpBlade<=56) theBlade = 77-tmpBlade;
351  }
352 
353  module = static_cast<uint32_t>(ringName());
354 
355  } else { // phase 0
356 
357  if (outer) {
358  blade = tmpBlade + 6;
359  } else { // inner
360  if (tmpBlade <= 6) blade = 7 - tmpBlade;
361  else if (tmpBlade <= 12) blade = 31 - tmpBlade;
362  }
363 
364  // hack for the pilot blade
365  if(pilot_blade && theDisk==3 ) { // do only for disk 3
366  //cout<<tmpBlade<<" "<<blade<<endl;
367  if(blade<=5) blade -=3;
368  else blade -=13;
369  //cout<<tmpBlade<<" "<<blade<<endl;
370  }
371 
372  module = static_cast<uint32_t>(plaquetteName());
373  } // end phase1
374 
375 
376  // create and return the DetId
377  DetId id = tt->pxfDetId(side, disk, blade, panel, module);
378 
379  return id;
380 
381 } // PXFDetId PixelEndcapName::getDetId()
382 
383 
384 // return the DetId
386 
387  uint32_t side = 0;
388  uint32_t disk = 0;
389  uint32_t blade = 0;
390  uint32_t panel = 0;
391  uint32_t module = 0;
392 
393  // figure out the side
395  if (hc == mO || hc == mI) side = 1;
396  else if (hc == pO || hc == pI) side = 2;
397 
398  // get disk/blade/panel/module numbers from PixelEndcapName object
399  disk = static_cast<uint32_t>(diskName());
400  uint32_t tmpBlade = static_cast<uint32_t>(bladeName());
401  panel = static_cast<uint32_t>(pannelName());
402 
403  // convert blade numbering to cmssw convention
404  bool outer = false;
405  outer = (hc == mO) || (hc == pO);
406 
407  if(phase1) { // phase1
408 
409  // this still has to be modified so blades start from 1 on the top
410  if (outer) {
411  if (tmpBlade>=7 && tmpBlade<=17) theBlade = tmpBlade+6;
412  else if (tmpBlade>=32 && tmpBlade<=48) theBlade = 60-tmpBlade;
413  } else { //inner
414  if (tmpBlade<=6 ) theBlade = 7-tmpBlade;
415  else if (tmpBlade>=18 && tmpBlade<=31) theBlade = 38-tmpBlade;
416  else if (tmpBlade>=49 && tmpBlade<=56) theBlade = 77-tmpBlade;
417  }
418 
419  module = static_cast<uint32_t>(ringName());
420 
421  } else { // phase 0
422  if (outer) {
423  blade = tmpBlade + 6;
424  } else { // inner
425  if (tmpBlade <= 6) blade = 7 - tmpBlade;
426  else if (tmpBlade <= 12) blade = 31 - tmpBlade;
427  }
428 
429  // hack for the pilot blade
430  if(pilot_blade && theDisk==3 ) { // do only for disk 3
431  //cout<<tmpBlade<<" "<<blade<<endl;
432  if(blade<=5) blade -=3;
433  else blade -=13;
434  //cout<<tmpBlade<<" "<<blade<<endl;
435  }
436 
437  module = static_cast<uint32_t>(plaquetteName());
438  } // end phase1
439 
440  // create and return the DetId
441  return PXFDetId(side, disk, blade, panel, module);
442 
443 } // 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
std::ostream & operator<<(std::ostream &out, const ALILine &li)
Definition: ALILine.cc:187
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
tuple out
Definition: dbtoconf.py:99
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
volatile std::atomic< bool > shutdown_flag false
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