Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:54:49

0001 #include "DataFormats/TrackerCommon/interface/PixelBarrelName.h"
0002 
0003 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0004 
0005 //#include "DataFormats/SiPixelDetId/interface/PXBDetId.h"
0006 #include "DataFormats/TrackerCommon/interface/TrackerTopology.h"
0007 
0008 #include <sstream>
0009 #include <iostream>
0010 
0011 using namespace std;
0012 
0013 namespace {
0014   // ladder limits
0015   // for phase 0
0016   const int lL[2][12] = {{5, 15, 26, 8, 24, 41, 11, 33, 56, 0, 0, 0}, {3, 9, 16, 7, 21, 36, 11, 33, 56, 16, 48, 81}};
0017   // for phase 1
0018   //const int lL[12] ={ 3, 9,16, 7,21,36,11,33,56,16,48,81};
0019   //const bool phase1 = false; // this has to come from the trackerTopology class
0020 }  // namespace
0021 
0022 PixelBarrelName::PixelBarrelName(const DetId& id, const TrackerTopology* tt, bool phase)
0023     : PixelModuleName(true), thePart(mO), theLayer(0), theModule(0), theLadder(0), phase1(phase) {
0024   theLayer = tt->pxbLayer(id);
0025   int oldModule = tt->pxbModule(id);  // CMSSW convention
0026   int oldLadder = tt->pxbLadder(id);  // CMSSW convention
0027 
0028   int ladder = convertLadderNumber(oldLadder);  // convert to online convention
0029   int module = oldModule - 4;                   // convert
0030   if (module <= 0)
0031     module--;
0032 
0033   //
0034   // part
0035   //
0036   if (module < 0 && ladder < 0)
0037     thePart = mO;
0038   else if (module > 0 && ladder < 0)
0039     thePart = pO;
0040   else if (module < 0 && ladder > 0)
0041     thePart = mI;
0042   else if (module > 0 && ladder > 0)
0043     thePart = pI;
0044 
0045   //
0046   // ladder
0047   //
0048   theLadder = abs(ladder);
0049 
0050   //
0051   // module
0052   //
0053   theModule = abs(module);
0054 }
0055 
0056 // Old constructor, works with the old pixel classes  DO NOT USE
0057 PixelBarrelName::PixelBarrelName(const DetId& id, bool phase)
0058     : PixelModuleName(true), thePart(mO), theLayer(0), theModule(0), theLadder(0), phase1(phase) {
0059   //  uint32_t rawId = id.rawId();
0060   PXBDetId cmssw_numbering(id);
0061 
0062   theLayer = cmssw_numbering.layer();
0063 
0064   int oldModule = cmssw_numbering.module() - 4;
0065   if (oldModule <= 0)
0066     oldModule--;
0067   int oldLadder = cmssw_numbering.ladder();
0068 
0069   if (phase1) {  // phase 1
0070 
0071     if (theLayer == 1) {
0072       if (oldLadder <= 3)
0073         oldLadder = 4 - oldLadder;  // +1, ..., +3
0074       else if (oldLadder >= 4 && oldLadder <= 9)
0075         oldLadder = 3 - oldLadder;  // -1, ..., -6
0076       else if (oldLadder >= 10)
0077         oldLadder = 16 - oldLadder;  // +6, ..., +4
0078     } else if (theLayer == 2) {
0079       if (oldLadder <= 7)
0080         oldLadder = 8 - oldLadder;
0081       else if (oldLadder >= 8 && oldLadder <= 21)
0082         oldLadder = 7 - oldLadder;
0083       else if (oldLadder >= 22)
0084         oldLadder = 36 - oldLadder;
0085     } else if (theLayer == 3) {
0086       if (oldLadder <= 11)
0087         oldLadder = 12 - oldLadder;
0088       else if (oldLadder >= 12 && oldLadder <= 33)
0089         oldLadder = 11 - oldLadder;
0090       else if (oldLadder >= 34)
0091         oldLadder = 56 - oldLadder;
0092     } else if (theLayer == 4) {
0093       if (oldLadder <= 16)
0094         oldLadder = 17 - oldLadder;
0095       else if (oldLadder >= 17 && oldLadder <= 48)
0096         oldLadder = 16 - oldLadder;
0097       else if (oldLadder >= 49)
0098         oldLadder = 81 - oldLadder;
0099     }
0100 
0101   } else {  // phase 0
0102 
0103     if (theLayer == 1) {
0104       if (oldLadder <= 5)
0105         oldLadder = 6 - oldLadder;
0106       else if (oldLadder >= 6 && oldLadder <= 15)
0107         oldLadder = 5 - oldLadder;
0108       else if (oldLadder >= 16)
0109         oldLadder = 26 - oldLadder;
0110     } else if (theLayer == 2) {
0111       if (oldLadder <= 8)
0112         oldLadder = 9 - oldLadder;
0113       else if (oldLadder >= 9 && oldLadder <= 24)
0114         oldLadder = 8 - oldLadder;
0115       else if (oldLadder >= 25)
0116         oldLadder = 41 - oldLadder;
0117     } else if (theLayer == 3) {
0118       if (oldLadder <= 11)
0119         oldLadder = 12 - oldLadder;
0120       else if (oldLadder >= 12 && oldLadder <= 33)
0121         oldLadder = 11 - oldLadder;
0122       else if (oldLadder >= 34)
0123         oldLadder = 56 - oldLadder;
0124     }
0125   }  // end phase 0/1
0126 
0127   //
0128   // part
0129   //
0130   if (oldModule < 0 && oldLadder < 0)
0131     thePart = mO;
0132   else if (oldModule > 0 && oldLadder < 0)
0133     thePart = pO;
0134   else if (oldModule < 0 && oldLadder > 0)
0135     thePart = mI;
0136   else if (oldModule > 0 && oldLadder > 0)
0137     thePart = pI;
0138 
0139   //
0140   // ladder
0141   //
0142   theLadder = abs(oldLadder);
0143 
0144   //
0145   // module
0146   //
0147   theModule = abs(oldModule);
0148 }
0149 
0150 // convert ladder number
0151 int PixelBarrelName::convertLadderNumber(int oldLadder) {
0152   int ladder = -1;
0153   int ind = 0;
0154   if (phase1)
0155     ind = 1;
0156 
0157   if (theLayer == 1) {
0158     if (oldLadder <= lL[ind][0])
0159       ladder = (lL[ind][0] + 1) - oldLadder;
0160     else if (oldLadder >= (lL[ind][0] + 1) && oldLadder <= lL[ind][1])
0161       ladder = lL[ind][0] - oldLadder;
0162     else if (oldLadder >= (lL[ind][1] + 1))
0163       ladder = lL[ind][2] - oldLadder;
0164 
0165   } else if (theLayer == 2) {
0166     if (oldLadder <= lL[ind][3])
0167       ladder = (lL[ind][3] + 1) - oldLadder;
0168     else if (oldLadder >= (lL[ind][3] + 1) && oldLadder <= lL[ind][4])
0169       ladder = lL[ind][3] - oldLadder;
0170     else if (oldLadder >= (lL[ind][4] + 1))
0171       ladder = lL[ind][5] - oldLadder;
0172 
0173   } else if (theLayer == 3) {
0174     if (oldLadder <= lL[ind][6])
0175       ladder = (lL[ind][6] + 1) - oldLadder;
0176     else if (oldLadder >= (lL[ind][6] + 1) && oldLadder <= lL[ind][7])
0177       ladder = lL[ind][6] - oldLadder;
0178     else if (oldLadder >= (lL[ind][7] + 1))
0179       ladder = lL[ind][8] - oldLadder;
0180 
0181   } else if (theLayer == 4) {
0182     if (oldLadder <= lL[ind][9])
0183       ladder = (lL[ind][9] + 1) - oldLadder;
0184     else if (oldLadder >= (lL[ind][9] + 1) && oldLadder <= lL[ind][10])
0185       ladder = lL[ind][9] - oldLadder;
0186     else if (oldLadder >= (lL[ind][10] + 1))
0187       ladder = lL[ind][11] - oldLadder;
0188   }
0189 
0190   return ladder;
0191 }
0192 
0193 // constructor from name string
0194 PixelBarrelName::PixelBarrelName(std::string name, bool phase)
0195     : PixelModuleName(true), thePart(mO), theLayer(0), theModule(0), theLadder(0), phase1(phase) {
0196   // parse the name string
0197   // first, check to make sure this is an BPix name, should start with "BPix_"
0198   // also check to make sure the needed parts are present
0199   if ((name.substr(0, 5) != "BPix_") || (name.find("_B") == string::npos) || (name.find("_LYR") == string::npos) ||
0200       (name.find("_LDR") == string::npos) || (name.find("_MOD") == string::npos)) {
0201     edm::LogError("BadNameString|SiPixel")
0202         << "Bad name string in PixelBarrelName::PixelBarrelName(std::string): " << name;
0203     return;
0204   }
0205 
0206   // strip off ROC part if it's there
0207   if (name.find("_ROC") != string::npos)
0208     name = name.substr(0, name.find("_ROC"));
0209 
0210   // find shell
0211   string shellString = name.substr(name.find("_B") + 2, name.find("_SEC") - name.find("_B") - 2);
0212   if (shellString == "mO")
0213     thePart = mO;
0214   else if (shellString == "mI")
0215     thePart = mI;
0216   else if (shellString == "pO")
0217     thePart = pO;
0218   else if (shellString == "pI")
0219     thePart = pI;
0220   else {
0221     edm::LogError("BadNameString|SiPixel")
0222         << "Unable to determine shell in PixelBarrelName::PixelBarrelName(std::string): " << name;
0223   }
0224 
0225   // find the layer
0226   string layerString = name.substr(name.find("_LYR") + 4, name.find("_LDR") - name.find("_LYR") - 4);
0227   if (layerString == "1")
0228     theLayer = 1;
0229   else if (layerString == "2")
0230     theLayer = 2;
0231   else if (layerString == "3")
0232     theLayer = 3;
0233   else if (phase1 && layerString == "4")
0234     theLayer = 4;
0235   else {
0236     edm::LogError("BadNameString|SiPixel")
0237         << "Unable to determine layer in PixelBarrelName::PixelBarrelName(std::string): " << name;
0238   }
0239 
0240   // find the ladder
0241   string ladderString = name.substr(name.find("_LDR") + 4, name.find("_MOD") - name.find("_LDR") - 4);
0242 
0243   if (phase1) {  // phase 1 ladders
0244     // do we want to kee the "F" for phase1?
0245     if (ladderString.substr(ladderString.size() - 1, 1) == "F") {
0246       int ladderNum = atoi(ladderString.substr(0, ladderString.size() - 1).c_str());
0247       if (theLayer == 1 && ladderNum >= 1 && ladderNum <= 6)
0248         theLadder = ladderNum;
0249       else if (theLayer == 2 && ladderNum >= 1 && ladderNum <= 14)
0250         theLadder = ladderNum;
0251       else if (theLayer == 3 && ladderNum >= 1 && ladderNum <= 22)
0252         theLadder = ladderNum;
0253       else if (theLayer == 4 && ladderNum >= 1 && ladderNum <= 32)
0254         theLadder = ladderNum;
0255       else {
0256         edm::LogError("BadNameString|SiPixel")
0257             << "Unable to determine ladder in PixelBarrelNameUpgrade::PixelBarrelName(std::string): " << name;
0258       }
0259     }  // full ladders
0260     else {
0261       edm::LogError("BadNameString|SiPixel")
0262           << "Unable to determine ladder in PixelBarrelNameUpgrade::PixelBarrelName(std::string): " << name;
0263     }
0264 
0265   } else {  // phase 0 ladders
0266 
0267     if (ladderString == "1H")
0268       theLadder = 1;
0269     else if (ladderString == "10H" && theLayer == 1)
0270       theLadder = 10;
0271     else if (ladderString == "16H" && theLayer == 2)
0272       theLadder = 16;
0273     else if (ladderString == "22H" && theLayer == 3)
0274       theLadder = 22;
0275     else if (ladderString.substr(ladderString.size() - 1, 1) == "F") {
0276       int ladderNum = atoi(ladderString.substr(0, ladderString.size() - 1).c_str());
0277       if (theLayer == 1 && ladderNum > 1 && ladderNum < 10)
0278         theLadder = ladderNum;
0279       else if (theLayer == 2 && ladderNum > 1 && ladderNum < 16)
0280         theLadder = ladderNum;
0281       else if (theLayer == 3 && ladderNum > 1 && ladderNum < 22)
0282         theLadder = ladderNum;
0283       else {
0284         edm::LogError("BadNameString|SiPixel")
0285             << "Unable to determine ladder in PixelBarrelName::PixelBarrelName(std::string): " << name;
0286       }
0287     }  // full ladders
0288     else {
0289       edm::LogError("BadNameString|SiPixel")
0290           << "Unable to determine ladder in PixelBarrelName::PixelBarrelName(std::string): " << name;
0291     }
0292   }  // phase0/1
0293 
0294   // find the module
0295   string moduleString = name.substr(name.find("_MOD") + 4, name.size() - name.find("_MOD") - 4);
0296   if (moduleString == "1")
0297     theModule = 1;
0298   else if (moduleString == "2")
0299     theModule = 2;
0300   else if (moduleString == "3")
0301     theModule = 3;
0302   else if (moduleString == "4")
0303     theModule = 4;
0304   else {
0305     edm::LogError("BadNameString|SiPixel")
0306         << "Unable to determine module in PixelBarrelName::PixelBarrelName(std::string): " << name;
0307   }
0308 
0309 }  // PixelBarrelName::PixelBarrelName(std::string name)
0310 
0311 int PixelBarrelName::sectorName() const {
0312   int sector = 0;
0313 
0314   if (theLayer == 1) {
0315     if (phase1) {  // phase 1
0316       // Layer 1 for phase1 is special, modules on a ladder are shared in different sectors
0317       // Ladder   Module    Sector
0318       //   1      2,3,4       1
0319       //   1        1         2
0320       //   2       3,4        2
0321       //   2       1,2        3
0322       //   3        4         3
0323       //   3      1,2,3       4
0324       //   4      2,3,4       5
0325       //   4        1         6
0326       //   5       3,4        6
0327       //   5       1,2        7
0328       //   6        4         7
0329       //   6      1,2,3       8
0330 
0331       switch (theLadder) {
0332         case 1: {  // ladder 1
0333           if (theModule >= 2) {
0334             sector = 1;
0335             break;
0336           }  // mods 2,3,4
0337           else {
0338             sector = 2;
0339             break;
0340           }  // mods 1
0341         }
0342         case 2: {  // ladder 2
0343           if (theModule >= 3) {
0344             sector = 2;
0345             break;
0346           }  // mods 3,4
0347           else {
0348             sector = 3;
0349             break;
0350           }  // mods 1,2
0351         }
0352         case 3: {  // ladder 3
0353           if (theModule >= 4) {
0354             sector = 3;
0355             break;
0356           } else {
0357             sector = 4;
0358             break;
0359           }
0360           sector = 3;
0361           break;
0362         }
0363         case 4: {  // ladder 4
0364           if (theModule >= 2) {
0365             sector = 5;
0366             break;
0367           } else {
0368             sector = 6;
0369             break;
0370           }
0371           sector = 6;
0372           break;
0373         }
0374         case 5: {  // ladder 5
0375           if (theModule >= 3) {
0376             sector = 6;
0377             break;
0378           } else {
0379             sector = 7;
0380             break;
0381           }
0382           sector = 7;
0383           break;
0384         }
0385         case 6: {  // ladder 6
0386           if (theModule >= 4) {
0387             sector = 7;
0388             break;
0389           }  // mods 4
0390           else {
0391             sector = 8;
0392             break;
0393           }  // mods 1,2,3
0394           sector = 8;
0395           break;
0396         }
0397         default:;
0398       };
0399 
0400     } else {  // phase 0
0401       switch (theLadder) {
0402         case 1:
0403         case 2: {
0404           sector = 1;
0405           break;
0406         }
0407         case 3: {
0408           sector = 2;
0409           break;
0410         }
0411         case 4: {
0412           sector = 3;
0413           break;
0414         }
0415         case 5: {
0416           sector = 4;
0417           break;
0418         }
0419         case 6: {
0420           sector = 5;
0421           break;
0422         }
0423         case 7: {
0424           sector = 6;
0425           break;
0426         }
0427         case 8: {
0428           sector = 7;
0429           break;
0430         }
0431         case 9:
0432         case 10: {
0433           sector = 8;
0434           break;
0435         }
0436         default:;
0437       };
0438     }  // phase0/1
0439 
0440   } else if (theLayer == 2) {
0441     if (phase1) {  // phase 1
0442       switch (theLadder) {
0443         case 1:
0444         case 2: {
0445           sector = 1;
0446           break;
0447         }
0448         case 3:
0449         case 4: {
0450           sector = 2;
0451           break;
0452         }
0453         case 5: {
0454           sector = 3;
0455           break;
0456         }
0457         case 6:
0458         case 7: {
0459           sector = 4;
0460           break;
0461         }
0462         case 8:
0463         case 9: {
0464           sector = 5;
0465           break;
0466         }
0467         case 10: {
0468           sector = 6;
0469           break;
0470         }
0471         case 11:
0472         case 12: {
0473           sector = 7;
0474           break;
0475         }
0476         case 13:
0477         case 14: {
0478           sector = 8;
0479           break;
0480         }
0481         default:;
0482       };
0483 
0484     } else {  // phase 0
0485       switch (theLadder) {
0486         case 1:
0487         case 2: {
0488           sector = 1;
0489           break;
0490         }
0491         case 3:
0492         case 4: {
0493           sector = 2;
0494           break;
0495         }
0496         case 5:
0497         case 6: {
0498           sector = 3;
0499           break;
0500         }
0501         case 7:
0502         case 8: {
0503           sector = 4;
0504           break;
0505         }
0506         case 9:
0507         case 10: {
0508           sector = 5;
0509           break;
0510         }
0511         case 11:
0512         case 12: {
0513           sector = 6;
0514           break;
0515         }
0516         case 13:
0517         case 14: {
0518           sector = 7;
0519           break;
0520         }
0521         case 15:
0522         case 16: {
0523           sector = 8;
0524           break;
0525         }
0526         default:;
0527       };
0528     }  // enad phase0/1
0529 
0530   } else if (theLayer == 3) {
0531     if (phase1) {  // phase 1
0532       switch (theLadder) {
0533         case 1:
0534         case 2: {
0535           sector = 1;
0536           break;
0537         }
0538         case 3:
0539         case 4:
0540         case 5: {
0541           sector = 2;
0542           break;
0543         }
0544         case 6:
0545         case 7:
0546         case 8: {
0547           sector = 3;
0548           break;
0549         }
0550         case 9:
0551         case 10:
0552         case 11: {
0553           sector = 4;
0554           break;
0555         }
0556         case 12:
0557         case 13:
0558         case 14: {
0559           sector = 5;
0560           break;
0561         }
0562         case 15:
0563         case 16:
0564         case 17: {
0565           sector = 6;
0566           break;
0567         }
0568         case 18:
0569         case 19:
0570         case 20: {
0571           sector = 7;
0572           break;
0573         }
0574         case 21:
0575         case 22: {
0576           sector = 8;
0577           break;
0578         }
0579         default:;
0580       };
0581 
0582     } else {  // phase 0
0583       switch (theLadder) {
0584         case 1:
0585         case 2:
0586         case 3: {
0587           sector = 1;
0588           break;
0589         }
0590         case 4:
0591         case 5:
0592         case 6: {
0593           sector = 2;
0594           break;
0595         }
0596         case 7:
0597         case 8:
0598         case 9: {
0599           sector = 3;
0600           break;
0601         }
0602         case 10:
0603         case 11: {
0604           sector = 4;
0605           break;
0606         }
0607         case 12:
0608         case 13: {
0609           sector = 5;
0610           break;
0611         }
0612         case 14:
0613         case 15:
0614         case 16: {
0615           sector = 6;
0616           break;
0617         }
0618         case 17:
0619         case 18:
0620         case 19: {
0621           sector = 7;
0622           break;
0623         }
0624         case 20:
0625         case 21:
0626         case 22: {
0627           sector = 8;
0628           break;
0629         }
0630         default:;
0631       };
0632     }  // end phase 0/1
0633 
0634   } else if (theLayer == 4) {
0635     if (phase1) {  // phase 1
0636       switch (theLadder) {
0637         case 1:
0638         case 2:
0639         case 3:
0640         case 4: {
0641           sector = 1;
0642           break;
0643         }
0644         case 5:
0645         case 6:
0646         case 7:
0647         case 8: {
0648           sector = 2;
0649           break;
0650         }
0651         case 9:
0652         case 10:
0653         case 11:
0654         case 12: {
0655           sector = 3;
0656           break;
0657         }
0658         case 13:
0659         case 14:
0660         case 15:
0661         case 16: {
0662           sector = 4;
0663           break;
0664         }
0665         case 17:
0666         case 18:
0667         case 19:
0668         case 20: {
0669           sector = 5;
0670           break;
0671         }
0672         case 21:
0673         case 22:
0674         case 23:
0675         case 24: {
0676           sector = 6;
0677           break;
0678         }
0679         case 25:
0680         case 26:
0681         case 27:
0682         case 28: {
0683           sector = 7;
0684           break;
0685         }
0686         case 29:
0687         case 30:
0688         case 31:
0689         case 32: {
0690           sector = 8;
0691           break;
0692         }
0693         default:;
0694       };
0695     }  // end phase1
0696 
0697   }  // layer
0698 
0699   return sector;
0700 }
0701 
0702 bool PixelBarrelName::isHalfModule() const {
0703   bool halfModule = false;
0704 
0705   if (!phase1) {
0706     if (theLadder == 1)
0707       halfModule = true;
0708     if (theLayer == 1 && theLadder == 10)
0709       halfModule = true;
0710     if (theLayer == 2 && theLadder == 16)
0711       halfModule = true;
0712     if (theLayer == 3 && theLadder == 22)
0713       halfModule = true;
0714   }
0715   return halfModule;
0716 }
0717 
0718 PixelModuleName::ModuleType PixelBarrelName::moduleType() const {
0719   return isHalfModule() ? PixelBarrelName::v1x8 : PixelBarrelName::v2x8;
0720 }
0721 
0722 bool PixelBarrelName::operator==(const PixelModuleName& o) const {
0723   if (o.isBarrel()) {
0724     const PixelBarrelName* other = dynamic_cast<const PixelBarrelName*>(&o);
0725     return (other && thePart == other->thePart && theLayer == other->theLayer && theModule == other->theModule &&
0726             theLadder == other->theLadder);
0727   } else
0728     return false;
0729 }
0730 
0731 string PixelBarrelName::name() const {
0732   std::ostringstream stm;
0733 
0734   stm << "BPix_B" << thePart << "_SEC" << sectorName() << "_LYR" << theLayer << "_LDR" << theLadder;
0735   if (isHalfModule())
0736     stm << "H";
0737   else
0738     stm << "F";
0739   stm << "_MOD" << theModule;
0740 
0741   return stm.str();
0742 }
0743 
0744 // return the DetId, uses the new topology class
0745 DetId PixelBarrelName::getDetId(const TrackerTopology* tt) {
0746   uint32_t layer = 0;
0747   uint32_t ladder = 0;
0748   uint32_t module = 0;
0749 
0750   layer = layerName();
0751   int tmpLadder = ladderName();
0752   uint32_t tmpModule = moduleName();
0753 
0754   // translate the ladder number from the naming convention to the cmssw convention
0755   bool outer = false;
0756   Shell shell = thePart;
0757   int ind = 0;
0758   if (phase1)
0759     ind = 1;
0760   outer = (shell == mO) || (shell == pO);
0761   if (outer) {
0762     if (layer == 1)
0763       ladder = tmpLadder + lL[ind][0];
0764     else if (layer == 2)
0765       ladder = tmpLadder + lL[ind][3];
0766     else if (layer == 3)
0767       ladder = tmpLadder + lL[ind][6];
0768     else if (layer == 4)
0769       ladder = tmpLadder + lL[ind][9];
0770   }       // outer
0771   else {  // inner
0772     if (layer == 1) {
0773       if (tmpLadder <= lL[ind][0])
0774         ladder = (lL[ind][0] + 1) - tmpLadder;
0775       else
0776         ladder = lL[ind][2] - tmpLadder;
0777     } else if (layer == 2) {
0778       if (tmpLadder <= lL[ind][3])
0779         ladder = (lL[ind][3] + 1) - tmpLadder;
0780       else
0781         ladder = lL[ind][5] - tmpLadder;
0782     } else if (layer == 3) {
0783       if (tmpLadder <= lL[ind][6])
0784         ladder = (lL[ind][6] + 1) - tmpLadder;
0785       else
0786         ladder = lL[ind][8] - tmpLadder;
0787     } else if (layer == 4) {
0788       if (tmpLadder <= lL[ind][9])
0789         ladder = (lL[ind][9] + 1) - tmpLadder;
0790       else
0791         ladder = lL[ind][11] - tmpLadder;
0792     }  // layer
0793   }    // inner
0794 
0795   // translate the module number from naming convention to cmssw convention
0796   // numbering starts at positive z
0797   if (shell == pO || shell == pI)
0798     module = tmpModule + 4;
0799   else  // negative z side
0800     module = 5 - tmpModule;
0801 
0802   DetId id = tt->pxbDetId(layer, ladder, module);
0803   return id;
0804 }
0805 
0806 // return the pixel DetId, obsolete, uses the old index class
0807 PXBDetId PixelBarrelName::getDetId() {
0808   uint32_t layer = 0;
0809   uint32_t ladder = 0;
0810   uint32_t module = 0;
0811 
0812   layer = layerName();
0813   uint32_t tmpLadder = ladderName();
0814   uint32_t tmpModule = moduleName();
0815 
0816   // translate the ladder number from the naming convention to the cmssw convention
0817   bool outer = false;
0818   Shell shell = thePart;
0819   outer = (shell == mO) || (shell == pO);
0820 
0821   if (phase1) {  // phase 1
0822 
0823     if (outer) {  // outer
0824       if (layer == 1)
0825         ladder = tmpLadder + 3;
0826       else if (layer == 2)
0827         ladder = tmpLadder + 7;
0828       else if (layer == 3)
0829         ladder = tmpLadder + 11;
0830       else if (layer == 4)
0831         ladder = tmpLadder + 16;
0832     } else {  // inner
0833       if (layer == 1) {
0834         if (tmpLadder <= 3)
0835           ladder = 4 - tmpLadder;
0836         else if (tmpLadder <= 6)
0837           ladder = 16 - tmpLadder;
0838       } else if (layer == 2) {
0839         if (tmpLadder <= 7)
0840           ladder = 8 - tmpLadder;
0841         else if (tmpLadder <= 14)
0842           ladder = 36 - tmpLadder;
0843       } else if (layer == 3) {
0844         if (tmpLadder <= 11)
0845           ladder = 12 - tmpLadder;
0846         else if (tmpLadder <= 22)
0847           ladder = 56 - tmpLadder;
0848       } else if (layer == 4) {
0849         if (tmpLadder <= 16)
0850           ladder = 17 - tmpLadder;
0851         else if (tmpLadder <= 32)
0852           ladder = 81 - tmpLadder;
0853       }  // layer
0854     }    // inner
0855 
0856   } else {        // phase 0
0857     if (outer) {  // outer
0858       if (layer == 1)
0859         ladder = tmpLadder + 5;
0860       else if (layer == 2)
0861         ladder = tmpLadder + 8;
0862       else if (layer == 3)
0863         ladder = tmpLadder + 11;
0864     } else {             // inner
0865       if (layer == 1) {  // layer 1
0866         if (tmpLadder <= 5)
0867           ladder = 6 - tmpLadder;
0868         else if (tmpLadder <= 10)
0869           ladder = 26 - tmpLadder;
0870       } else if (layer == 2) {  // layer 2
0871         if (tmpLadder <= 8)
0872           ladder = 9 - tmpLadder;
0873         else if (tmpLadder <= 16)
0874           ladder = 41 - tmpLadder;
0875       } else if (layer == 3) {  // layer 3
0876         if (tmpLadder <= 11)
0877           ladder = 12 - tmpLadder;
0878         else if (tmpLadder <= 22)
0879           ladder = 56 - tmpLadder;
0880       }  // end layer
0881     }    // inner
0882 
0883   }  // phase
0884 
0885   // translate the module number from naming convention to cmssw convention
0886   // numbering starts at positive z
0887   if (shell == pO || shell == pI)
0888     module = tmpModule + 4;
0889   else  // negative z side
0890     module = 5 - tmpModule;
0891 
0892   return PXBDetId(layer, ladder, module);
0893 }
0894 
0895 std::ostream& operator<<(std::ostream& out, const PixelBarrelName::Shell& t) {
0896   switch (t) {
0897     case (PixelBarrelName::pI): {
0898       out << "pI";
0899       break;
0900     }
0901     case (PixelBarrelName::pO): {
0902       out << "pO";
0903       break;
0904     }
0905     case (PixelBarrelName::mI): {
0906       out << "mI";
0907       break;
0908     }
0909     case (PixelBarrelName::mO): {
0910       out << "mO";
0911       break;
0912     }
0913     default:
0914       out << "unknown";
0915   };
0916   return out;
0917 }