File indexing completed on 2024-07-22 23:30:59
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& other) const {
0357 return other.isBarrel() ? false : (dynamic_cast<const PixelEndcapName&>(other) == *this);
0358 }
0359
0360 string PixelEndcapName::name() const {
0361 std::ostringstream stm;
0362
0363 if (phase1)
0364 stm << "FPix_B" << thePart << "_D" << theDisk << "_BLD" << theBlade << "_PNL" << thePannel << "_RNG"
0365 << thePlaquette;
0366 else
0367 stm << "FPix_B" << thePart << "_D" << theDisk << "_BLD" << theBlade << "_PNL" << thePannel << "_PLQ"
0368 << thePlaquette;
0369
0370 return stm.str();
0371 }
0372
0373 std::ostream& operator<<(std::ostream& out, const PixelEndcapName::HalfCylinder& t) {
0374 switch (t) {
0375 case (PixelEndcapName::pI): {
0376 out << "pI";
0377 break;
0378 }
0379 case (PixelEndcapName::pO): {
0380 out << "pO";
0381 break;
0382 }
0383 case (PixelEndcapName::mI): {
0384 out << "mI";
0385 break;
0386 }
0387 case (PixelEndcapName::mO): {
0388 out << "mO";
0389 break;
0390 }
0391 default:
0392 out << "unknown";
0393 };
0394 return out;
0395 }
0396
0397
0398 DetId PixelEndcapName::getDetId(const TrackerTopology* tt) {
0399 uint32_t side = 0;
0400 uint32_t disk = 0;
0401 uint32_t blade = 0;
0402 uint32_t panel = 0;
0403 uint32_t module = 0;
0404
0405
0406 HalfCylinder hc = halfCylinder();
0407 if (hc == mO || hc == mI)
0408 side = 1;
0409 else if (hc == pO || hc == pI)
0410 side = 2;
0411
0412
0413 disk = static_cast<uint32_t>(diskName());
0414 uint32_t tmpBlade = static_cast<uint32_t>(bladeName());
0415 panel = static_cast<uint32_t>(pannelName());
0416
0417
0418 bool outer = false;
0419 outer = (hc == mO) || (hc == pO);
0420
0421 if (phase1) {
0422
0423 module = 1;
0424 int ring = static_cast<uint32_t>(ringName());
0425 if (ring == 1) {
0426 if (outer) {
0427 if (tmpBlade >= 1 && tmpBlade <= 11)
0428 blade = tmpBlade + 6;
0429 } else {
0430 if (tmpBlade <= 6)
0431 blade = 7 - tmpBlade;
0432 else
0433 blade = 29 - tmpBlade;
0434 }
0435
0436 } else if (ring == 2) {
0437 if (outer) {
0438 if (tmpBlade >= 1 && tmpBlade <= 17)
0439 blade = tmpBlade + 31;
0440 } else {
0441 if (tmpBlade <= 9)
0442 blade = 32 - tmpBlade;
0443 else
0444 blade = 66 - tmpBlade;
0445 }
0446 }
0447
0448 } else {
0449
0450 if (outer) {
0451 blade = tmpBlade + 6;
0452 } else {
0453 if (tmpBlade <= 6)
0454 blade = 7 - tmpBlade;
0455 else if (tmpBlade <= 12)
0456 blade = 31 - tmpBlade;
0457 }
0458
0459
0460 if (pilot_blade && theDisk == 3) {
0461
0462 if (blade <= 5)
0463 blade -= 3;
0464 else
0465 blade -= 13;
0466
0467 }
0468
0469 module = static_cast<uint32_t>(plaquetteName());
0470 }
0471
0472
0473 DetId id = tt->pxfDetId(side, disk, blade, panel, module);
0474
0475 return id;
0476
0477 }
0478
0479
0480 PXFDetId PixelEndcapName::getDetId() {
0481 uint32_t side = 0;
0482 uint32_t disk = 0;
0483 uint32_t blade = 0;
0484 uint32_t panel = 0;
0485 uint32_t module = 0;
0486
0487
0488 HalfCylinder hc = halfCylinder();
0489 if (hc == mO || hc == mI)
0490 side = 1;
0491 else if (hc == pO || hc == pI)
0492 side = 2;
0493
0494
0495 disk = static_cast<uint32_t>(diskName());
0496 uint32_t tmpBlade = static_cast<uint32_t>(bladeName());
0497 panel = static_cast<uint32_t>(pannelName());
0498
0499
0500 bool outer = false;
0501 outer = (hc == mO) || (hc == pO);
0502
0503 if (phase1) {
0504
0505 module = 1;
0506 int ring = static_cast<uint32_t>(ringName());
0507 if (ring == 1) {
0508 if (outer) {
0509 if (tmpBlade >= 1 && tmpBlade <= 11)
0510 blade = tmpBlade + 6;
0511 } else {
0512 if (tmpBlade <= 6)
0513 blade = 7 - tmpBlade;
0514 else
0515 blade = 29 - tmpBlade;
0516 }
0517
0518 } else if (ring == 2) {
0519 if (outer) {
0520 if (tmpBlade >= 1 && tmpBlade <= 17)
0521 blade = tmpBlade + 31;
0522 } else {
0523 if (tmpBlade <= 9)
0524 blade = 32 - tmpBlade;
0525 else
0526 blade = 66 - tmpBlade;
0527 }
0528 }
0529
0530 } else {
0531
0532 if (outer) {
0533 blade = tmpBlade + 6;
0534 } else {
0535 if (tmpBlade <= 6)
0536 blade = 7 - tmpBlade;
0537 else if (tmpBlade <= 12)
0538 blade = 31 - tmpBlade;
0539 }
0540
0541
0542 if (pilot_blade && theDisk == 3) {
0543
0544 if (blade <= 5)
0545 blade -= 3;
0546 else
0547 blade -= 13;
0548
0549 }
0550
0551 module = static_cast<uint32_t>(plaquetteName());
0552 }
0553
0554
0555 return PXFDetId(side, disk, blade, panel, module);
0556
0557 }