File indexing completed on 2023-03-17 10:51:30
0001 #include "DataFormats/TrackerCommon/interface/PixelEndcapName.h"
0002
0003 #include <sstream>
0004 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0005 #include "DataFormats/TrackerCommon/interface/TrackerTopology.h"
0006
0007 using namespace std;
0008
0009 namespace {
0010
0011 const bool pilot_blade = false;
0012 }
0013
0014
0015 PixelEndcapName::PixelEndcapName(const DetId& id, const TrackerTopology* tt, bool phase)
0016 : PixelModuleName(false), thePart(mO), theDisk(0), theBlade(0), thePannel(0), thePlaquette(0), phase1(phase) {
0017
0018 int side = tt->pxfSide(id);
0019 int tmpBlade = tt->pxfBlade(id);
0020 theDisk = tt->pxfDisk(id);
0021 thePannel = tt->pxfPanel(id);
0022 bool outer = false;
0023
0024 if (phase1) {
0025
0026 int ring = 0;
0027
0028 if (tmpBlade >= 7 && tmpBlade <= 17) {
0029 outer = true;
0030 theBlade = tmpBlade - 6;
0031 ring = 1;
0032
0033 } else if (tmpBlade <= 6) {
0034 theBlade = 7 - tmpBlade;
0035 ring = 1;
0036
0037 } else if (tmpBlade >= 18 && tmpBlade <= 22) {
0038 theBlade = 29 - tmpBlade;
0039 ring = 1;
0040
0041 } else if (tmpBlade >= 32 && tmpBlade <= 48) {
0042 outer = true;
0043 theBlade = tmpBlade - 31;
0044 ring = 2;
0045
0046 } else if (tmpBlade >= 23 && tmpBlade <= 31) {
0047 theBlade = 32 - tmpBlade;
0048 ring = 2;
0049
0050 } else if (tmpBlade >= 49 && tmpBlade <= 56) {
0051 theBlade = 66 - tmpBlade;
0052 ring = 2;
0053
0054 }
0055
0056 thePlaquette = ring;
0057
0058 } else {
0059
0060
0061 if (pilot_blade && theDisk == 3) {
0062
0063 if (tmpBlade >= 1 && tmpBlade <= 4) {
0064
0065 if (tmpBlade < 3)
0066 tmpBlade += 3;
0067 else
0068 tmpBlade += 13;
0069 } else {
0070 edm::LogError("Bad PilotBlade blade number ") << tmpBlade;
0071 }
0072 }
0073
0074 if (tmpBlade >= 7 && tmpBlade <= 18) {
0075 outer = true;
0076 theBlade = tmpBlade - 6;
0077 } else if (tmpBlade <= 6) {
0078 theBlade = 7 - tmpBlade;
0079 } else if (tmpBlade >= 19) {
0080 theBlade = 31 - tmpBlade;
0081 }
0082
0083 thePlaquette = tt->pxfModule(id);
0084
0085 }
0086
0087 if (side == 1 && outer)
0088 thePart = mO;
0089 else if (side == 1 && !outer)
0090 thePart = mI;
0091 else if (side == 2 && outer)
0092 thePart = pO;
0093 else if (side == 2 && !outer)
0094 thePart = pI;
0095 }
0096
0097
0098 PixelEndcapName::PixelEndcapName(const DetId& id, bool phase)
0099 : PixelModuleName(false), thePart(mO), theDisk(0), theBlade(0), thePannel(0), thePlaquette(0), phase1(phase) {
0100 PXFDetId cmssw_numbering(id);
0101 int side = cmssw_numbering.side();
0102 int tmpBlade = cmssw_numbering.blade();
0103 theDisk = cmssw_numbering.disk();
0104 thePannel = cmssw_numbering.panel();
0105 bool outer = false;
0106
0107 if (phase1) {
0108
0109 int ring = 0;
0110
0111 if (tmpBlade >= 7 && tmpBlade <= 17) {
0112 outer = true;
0113 theBlade = tmpBlade - 6;
0114 ring = 1;
0115
0116 } else if (tmpBlade <= 6) {
0117 theBlade = 7 - tmpBlade;
0118 ring = 1;
0119
0120 } else if (tmpBlade >= 18 && tmpBlade <= 22) {
0121 theBlade = 29 - tmpBlade;
0122 ring = 1;
0123
0124 } else if (tmpBlade >= 32 && tmpBlade <= 48) {
0125 outer = true;
0126 theBlade = tmpBlade - 31;
0127 ring = 2;
0128
0129 } else if (tmpBlade >= 23 && tmpBlade <= 31) {
0130 theBlade = 32 - tmpBlade;
0131 ring = 2;
0132
0133 } else if (tmpBlade >= 49 && tmpBlade <= 56) {
0134 theBlade = 66 - tmpBlade;
0135 ring = 2;
0136
0137 }
0138
0139 thePlaquette = ring;
0140
0141 } else {
0142
0143
0144 if (pilot_blade && theDisk == 3) {
0145 if (tmpBlade >= 1 && tmpBlade <= 4) {
0146
0147 if (tmpBlade < 3)
0148 tmpBlade += 3;
0149 else
0150 tmpBlade += 13;
0151 } else {
0152 edm::LogError("Bad PilotBlade blade number ") << tmpBlade;
0153 }
0154 }
0155
0156 if (tmpBlade >= 7 && tmpBlade <= 18) {
0157 outer = true;
0158 theBlade = tmpBlade - 6;
0159 } else if (tmpBlade <= 6) {
0160 theBlade = 7 - tmpBlade;
0161 } else if (tmpBlade >= 19) {
0162 theBlade = 31 - tmpBlade;
0163 }
0164
0165 thePlaquette = cmssw_numbering.module();
0166
0167 }
0168
0169 if (side == 1 && outer)
0170 thePart = mO;
0171 else if (side == 1 && !outer)
0172 thePart = mI;
0173 else if (side == 2 && outer)
0174 thePart = pO;
0175 else if (side == 2 && !outer)
0176 thePart = pI;
0177 }
0178
0179
0180 PixelEndcapName::PixelEndcapName(std::string name, bool phase)
0181 : PixelModuleName(false), thePart(mO), theDisk(0), theBlade(0), thePannel(0), thePlaquette(0), phase1(phase) {
0182
0183
0184
0185 if ((name.substr(0, 5) != "FPix_") || (name.find("_B") == string::npos) || (name.find("_D") == string::npos) ||
0186 (name.find("_BLD") == string::npos) || (name.find("_PNL") == string::npos) ||
0187 ((phase1 && name.find("_RNG") == string::npos)) || ((!phase1 && name.find("_PLQ") == string::npos))) {
0188 edm::LogError("BadNameString|SiPixel")
0189 << "Bad name string in PixelEndcapName::PixelEndcapName(std::string): " << name;
0190 return;
0191 }
0192
0193
0194 if (name.find("_ROC") != string::npos)
0195 name = name.substr(0, name.find("_ROC"));
0196
0197
0198 string hcString = name.substr(name.find("_B") + 2, name.find("_D") - name.find("_B") - 2);
0199 if (hcString == "mO")
0200 thePart = mO;
0201 else if (hcString == "mI")
0202 thePart = mI;
0203 else if (hcString == "pO")
0204 thePart = pO;
0205 else if (hcString == "pI")
0206 thePart = pI;
0207 else {
0208 edm::LogError("BadNameString|SiPixel")
0209 << "Unable to determine half cylinder in PixelEndcapName::PixelEndcapName(std::string): " << name;
0210 }
0211
0212
0213 string diskString = name.substr(name.find("_D") + 2, name.find("_BLD") - name.find("_D") - 2);
0214 if (diskString == "1")
0215 theDisk = 1;
0216 else if (diskString == "2")
0217 theDisk = 2;
0218 else if (diskString == "3")
0219 theDisk = 3;
0220 else {
0221 edm::LogError("BadNameString|SiPixel")
0222 << "Unable to determine disk number in PixelEndcapName::PixelEndcapName(std::string): " << name;
0223 }
0224
0225
0226 string bladeString = name.substr(name.find("_BLD") + 4, name.find("_PNL") - name.find("_BLD") - 4);
0227
0228 if (bladeString == "1")
0229 theBlade = 1;
0230 else if (bladeString == "2")
0231 theBlade = 2;
0232 else if (bladeString == "3")
0233 theBlade = 3;
0234 else if (bladeString == "4")
0235 theBlade = 4;
0236 else if (bladeString == "5")
0237 theBlade = 5;
0238 else if (bladeString == "6")
0239 theBlade = 6;
0240 else if (bladeString == "7")
0241 theBlade = 7;
0242 else if (bladeString == "8")
0243 theBlade = 8;
0244 else if (bladeString == "9")
0245 theBlade = 9;
0246 else if (bladeString == "10")
0247 theBlade = 10;
0248 else if (bladeString == "11")
0249 theBlade = 11;
0250 else if (bladeString == "12")
0251 theBlade = 12;
0252 else if (bladeString == "13")
0253 theBlade = 13;
0254 else if (bladeString == "14")
0255 theBlade = 14;
0256 else if (bladeString == "15")
0257 theBlade = 15;
0258 else if (bladeString == "16")
0259 theBlade = 16;
0260 else if (bladeString == "17")
0261 theBlade = 17;
0262 else {
0263 edm::LogError("BadNameString|SiPixel")
0264 << "Unable to determine blade number in PixelEndcapName::PixelEndcapName(std::string): " << name;
0265 }
0266
0267
0268 string panelString;
0269 if (phase1)
0270 panelString = name.substr(name.find("_PNL") + 4, name.find("_RNG") - name.find("_PNL") - 4);
0271 else
0272 panelString = name.substr(name.find("_PNL") + 4, name.find("_PLQ") - name.find("_PNL") - 4);
0273
0274 if (panelString == "1")
0275 thePannel = 1;
0276 else if (panelString == "2")
0277 thePannel = 2;
0278 else {
0279 edm::LogError("BadNameString|SiPixel")
0280 << "Unable to determine panel number in PixelEndcapName::PixelEndcapName(std::string): " << name;
0281 }
0282
0283
0284 if (phase1) {
0285
0286 string ringString = name.substr(name.find("_RNG") + 4, name.size() - name.find("_RNG") - 4);
0287 if (ringString == "1")
0288 thePlaquette = 1;
0289 else if (ringString == "2")
0290 thePlaquette = 2;
0291 else {
0292 edm::LogError("BadNameString|SiPixel")
0293 << "Unable to determine ring number in PixelEndcapName::PixelEndcapName(std::string): " << name;
0294 }
0295
0296 } else {
0297
0298
0299 string plaquetteString = name.substr(name.find("_PLQ") + 4, name.size() - name.find("_PLQ") - 4);
0300 if (plaquetteString == "1")
0301 thePlaquette = 1;
0302 else if (plaquetteString == "2")
0303 thePlaquette = 2;
0304 else if (plaquetteString == "3")
0305 thePlaquette = 3;
0306 else if (plaquetteString == "4")
0307 thePlaquette = 4;
0308 else {
0309 edm::LogError("BadNameString|SiPixel")
0310 << "Unable to determine plaquette number in PixelEndcapName::PixelEndcapName(std::string): " << name;
0311 }
0312
0313 }
0314
0315 }
0316
0317 PixelModuleName::ModuleType PixelEndcapName::moduleType() const {
0318 ModuleType type = v1x2;
0319
0320 if (phase1) {
0321
0322 type = v2x8;
0323
0324 } else {
0325
0326 if (pannelName() == 1) {
0327 if (plaquetteName() == 1) {
0328 type = v1x2;
0329 } else if (plaquetteName() == 2) {
0330 type = v2x3;
0331 } else if (plaquetteName() == 3) {
0332 type = v2x4;
0333 } else if (plaquetteName() == 4) {
0334 type = v1x5;
0335 }
0336 } else {
0337 if (plaquetteName() == 1) {
0338 type = v2x3;
0339 } else if (plaquetteName() == 2) {
0340 type = v2x4;
0341 } else if (plaquetteName() == 3) {
0342 type = v2x5;
0343 }
0344 }
0345
0346
0347 if (pilot_blade && theDisk == 3) {
0348 type = v2x8;
0349 }
0350
0351 }
0352
0353 return type;
0354 }
0355
0356 bool PixelEndcapName::operator==(const PixelModuleName& o) const {
0357 if (!o.isBarrel()) {
0358 const PixelEndcapName* other = dynamic_cast<const PixelEndcapName*>(&o);
0359 return (other && thePart == other->thePart && theDisk == other->theDisk && theBlade == other->theBlade &&
0360 thePannel == other->thePannel && thePlaquette == other->thePlaquette);
0361 } else
0362 return false;
0363 }
0364
0365 string PixelEndcapName::name() const {
0366 std::ostringstream stm;
0367
0368 if (phase1)
0369 stm << "FPix_B" << thePart << "_D" << theDisk << "_BLD" << theBlade << "_PNL" << thePannel << "_RNG"
0370 << thePlaquette;
0371 else
0372 stm << "FPix_B" << thePart << "_D" << theDisk << "_BLD" << theBlade << "_PNL" << thePannel << "_PLQ"
0373 << thePlaquette;
0374
0375 return stm.str();
0376 }
0377
0378 std::ostream& operator<<(std::ostream& out, const PixelEndcapName::HalfCylinder& t) {
0379 switch (t) {
0380 case (PixelEndcapName::pI): {
0381 out << "pI";
0382 break;
0383 }
0384 case (PixelEndcapName::pO): {
0385 out << "pO";
0386 break;
0387 }
0388 case (PixelEndcapName::mI): {
0389 out << "mI";
0390 break;
0391 }
0392 case (PixelEndcapName::mO): {
0393 out << "mO";
0394 break;
0395 }
0396 default:
0397 out << "unknown";
0398 };
0399 return out;
0400 }
0401
0402
0403 DetId PixelEndcapName::getDetId(const TrackerTopology* tt) {
0404 uint32_t side = 0;
0405 uint32_t disk = 0;
0406 uint32_t blade = 0;
0407 uint32_t panel = 0;
0408 uint32_t module = 0;
0409
0410
0411 HalfCylinder hc = halfCylinder();
0412 if (hc == mO || hc == mI)
0413 side = 1;
0414 else if (hc == pO || hc == pI)
0415 side = 2;
0416
0417
0418 disk = static_cast<uint32_t>(diskName());
0419 uint32_t tmpBlade = static_cast<uint32_t>(bladeName());
0420 panel = static_cast<uint32_t>(pannelName());
0421
0422
0423 bool outer = false;
0424 outer = (hc == mO) || (hc == pO);
0425
0426 if (phase1) {
0427
0428 module = 1;
0429 int ring = static_cast<uint32_t>(ringName());
0430 if (ring == 1) {
0431 if (outer) {
0432 if (tmpBlade >= 1 && tmpBlade <= 11)
0433 blade = tmpBlade + 6;
0434 } else {
0435 if (tmpBlade <= 6)
0436 blade = 7 - tmpBlade;
0437 else
0438 blade = 29 - tmpBlade;
0439 }
0440
0441 } else if (ring == 2) {
0442 if (outer) {
0443 if (tmpBlade >= 1 && tmpBlade <= 17)
0444 blade = tmpBlade + 31;
0445 } else {
0446 if (tmpBlade <= 9)
0447 blade = 32 - tmpBlade;
0448 else
0449 blade = 66 - tmpBlade;
0450 }
0451 }
0452
0453 } else {
0454
0455 if (outer) {
0456 blade = tmpBlade + 6;
0457 } else {
0458 if (tmpBlade <= 6)
0459 blade = 7 - tmpBlade;
0460 else if (tmpBlade <= 12)
0461 blade = 31 - tmpBlade;
0462 }
0463
0464
0465 if (pilot_blade && theDisk == 3) {
0466
0467 if (blade <= 5)
0468 blade -= 3;
0469 else
0470 blade -= 13;
0471
0472 }
0473
0474 module = static_cast<uint32_t>(plaquetteName());
0475 }
0476
0477
0478 DetId id = tt->pxfDetId(side, disk, blade, panel, module);
0479
0480 return id;
0481
0482 }
0483
0484
0485 PXFDetId PixelEndcapName::getDetId() {
0486 uint32_t side = 0;
0487 uint32_t disk = 0;
0488 uint32_t blade = 0;
0489 uint32_t panel = 0;
0490 uint32_t module = 0;
0491
0492
0493 HalfCylinder hc = halfCylinder();
0494 if (hc == mO || hc == mI)
0495 side = 1;
0496 else if (hc == pO || hc == pI)
0497 side = 2;
0498
0499
0500 disk = static_cast<uint32_t>(diskName());
0501 uint32_t tmpBlade = static_cast<uint32_t>(bladeName());
0502 panel = static_cast<uint32_t>(pannelName());
0503
0504
0505 bool outer = false;
0506 outer = (hc == mO) || (hc == pO);
0507
0508 if (phase1) {
0509
0510 module = 1;
0511 int ring = static_cast<uint32_t>(ringName());
0512 if (ring == 1) {
0513 if (outer) {
0514 if (tmpBlade >= 1 && tmpBlade <= 11)
0515 blade = tmpBlade + 6;
0516 } else {
0517 if (tmpBlade <= 6)
0518 blade = 7 - tmpBlade;
0519 else
0520 blade = 29 - tmpBlade;
0521 }
0522
0523 } else if (ring == 2) {
0524 if (outer) {
0525 if (tmpBlade >= 1 && tmpBlade <= 17)
0526 blade = tmpBlade + 31;
0527 } else {
0528 if (tmpBlade <= 9)
0529 blade = 32 - tmpBlade;
0530 else
0531 blade = 66 - tmpBlade;
0532 }
0533 }
0534
0535 } else {
0536
0537 if (outer) {
0538 blade = tmpBlade + 6;
0539 } else {
0540 if (tmpBlade <= 6)
0541 blade = 7 - tmpBlade;
0542 else if (tmpBlade <= 12)
0543 blade = 31 - tmpBlade;
0544 }
0545
0546
0547 if (pilot_blade && theDisk == 3) {
0548
0549 if (blade <= 5)
0550 blade -= 3;
0551 else
0552 blade -= 13;
0553
0554 }
0555
0556 module = static_cast<uint32_t>(plaquetteName());
0557 }
0558
0559
0560 return PXFDetId(side, disk, blade, panel, module);
0561
0562 }