Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-07-22 23:30:59

0001 #include "DataFormats/SiPixelDetId/interface/PixelEndcapNameUpgrade.h"
0002 
0003 #include <sstream>
0004 
0005 #include "DataFormats/SiPixelDetId/interface/PXFDetId.h"
0006 
0007 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0008 
0009 using namespace std;
0010 
0011 PixelEndcapNameUpgrade::PixelEndcapNameUpgrade(const DetId& id) : PixelModuleName(false) {
0012   PXFDetId cmssw_numbering(id);
0013   int side = cmssw_numbering.side();
0014   int tmpBlade = cmssw_numbering.blade();
0015   bool outer = false;
0016 
0017   /*
0018   //    iasonas1-with this we determine inner-outer ring, NOT x-direction
0019   if (tmpBlade >= 23 && tmpBlade <= 56) {       //23-56-->outer ring
0020     outer = true;
0021     theBlade = 57-tmpBlade;
0022   } else if( tmpBlade <= 22 ) {                 //1-22-->inner ring
0023     theBlade = 23-tmpBlade; 
0024   } //  iasonas1-end
0025   
0026 */
0027   //    iasonas2-with this we determine inner-outer x-position (x>0-x<0), NOT ring
0028   //    m/pI:1-6,18-31,49-56. m/pO:7-17,32-48.
0029   if (tmpBlade >= 7 && tmpBlade <= 17) {
0030     outer = true;
0031     theBlade = tmpBlade - 6;  //7...17-->1...11
0032   } else if (tmpBlade >= 32 && tmpBlade <= 48) {
0033     outer = true;
0034     theBlade = 60 - tmpBlade;  //32...48-->28...12
0035   } else if (tmpBlade <= 6) {
0036     theBlade = 7 - tmpBlade;  //1...6-->6...1
0037   } else if (tmpBlade >= 18 && tmpBlade <= 31) {
0038     theBlade = 38 - tmpBlade;  //18...31-->20...7
0039   } else if (tmpBlade >= 49 && tmpBlade <= 56) {
0040     theBlade = 77 - tmpBlade;  //49...56-->28...21
0041   }                            //  iasonas2-end
0042 
0043   if (side == 1 && outer)
0044     thePart = mO;
0045   else if (side == 1 && !outer)
0046     thePart = mI;
0047   else if (side == 2 && outer)
0048     thePart = pO;
0049   else if (side == 2 && !outer)
0050     thePart = pI;
0051 
0052   theDisk = cmssw_numbering.disk();
0053   thePannel = cmssw_numbering.panel();
0054   thePlaquette = cmssw_numbering.module();
0055 }
0056 
0057 // constructor from name string
0058 PixelEndcapNameUpgrade::PixelEndcapNameUpgrade(std::string name)
0059     : PixelModuleName(false), thePart(mO), theDisk(0), theBlade(0), thePannel(0), thePlaquette(0) {
0060   // parse the name string
0061   // first, check to make sure this is an FPix name, should start with "FPix_"
0062   // also check to make sure the needed parts are present
0063   if ((name.substr(0, 5) != "FPix_") || (name.find("_B") == string::npos) || (name.find("_D") == string::npos) ||
0064       (name.find("_BLD") == string::npos) || (name.find("_PNL") == string::npos) ||
0065       (name.find("_PLQ") == string::npos)) {
0066     edm::LogError("BadNameString|SiPixel")
0067         << "Bad name string in PixelEndcapNameUpgrade::PixelEndcapNameUpgrade(std::string): " << name;
0068     return;
0069   }
0070   // strip off ROC part if it's there
0071   if (name.find("_ROC") != string::npos)
0072     name = name.substr(0, name.find("_ROC"));
0073   // get the half cylinder
0074   string hcString = name.substr(name.find("_B") + 2, name.find("_D") - name.find("_B") - 2);
0075   if (hcString == "mO")
0076     thePart = mO;
0077   else if (hcString == "mI")
0078     thePart = mI;
0079   else if (hcString == "pO")
0080     thePart = pO;
0081   else if (hcString == "pI")
0082     thePart = pI;
0083   else {
0084     edm::LogError("BadNameString|SiPixel")
0085         << "Unable to determine half cylinder in PixelEndcapNameUpgrade::PixelEndcapNameUpgrade(std::string): " << name;
0086   }
0087   // get the disk
0088   string diskString = name.substr(name.find("_D") + 2, name.find("_BLD") - name.find("_D") - 2);
0089   if (diskString == "1")
0090     theDisk = 1;
0091   else if (diskString == "2")
0092     theDisk = 2;
0093   else if (diskString == "3")
0094     theDisk = 3;
0095   else {
0096     edm::LogError("BadNameString|SiPixel")
0097         << "Unable to determine disk number in PixelEndcapNameUpgrade::PixelEndcapNameUpgrade(std::string): " << name;
0098   }
0099   // get the blade
0100   string bladeString = name.substr(name.find("_BLD") + 4, name.find("_PNL") - name.find("_BLD") - 4);
0101   // since atoi() doesn't report errors, do it the long way
0102   if (bladeString == "1")
0103     theBlade = 1;
0104   else if (bladeString == "2")
0105     theBlade = 2;
0106   else if (bladeString == "3")
0107     theBlade = 3;
0108   else if (bladeString == "4")
0109     theBlade = 4;
0110   else if (bladeString == "5")
0111     theBlade = 5;
0112   else if (bladeString == "6")
0113     theBlade = 6;
0114   else if (bladeString == "7")
0115     theBlade = 7;
0116   else if (bladeString == "8")
0117     theBlade = 8;
0118   else if (bladeString == "9")
0119     theBlade = 9;
0120   else if (bladeString == "10")
0121     theBlade = 10;
0122   else if (bladeString == "11")
0123     theBlade = 11;
0124   else if (bladeString == "12")
0125     theBlade = 12;
0126   else if (bladeString == "13")
0127     theBlade = 13;
0128   else if (bladeString == "14")
0129     theBlade = 14;
0130   else if (bladeString == "15")
0131     theBlade = 15;
0132   else if (bladeString == "16")
0133     theBlade = 16;
0134   else if (bladeString == "17")
0135     theBlade = 17;
0136   else {
0137     edm::LogError("BadNameString|SiPixel")
0138         << "Unable to determine blade number in PixelEndcapNameUpgrade::PixelEndcapNameUpgrade(std::string): " << name;
0139   }
0140   // find the panel
0141   string panelString = name.substr(name.find("_PNL") + 4, name.find("_PLQ") - name.find("_PNL") - 4);
0142   if (panelString == "1")
0143     thePannel = 1;
0144   else if (panelString == "2")
0145     thePannel = 2;
0146   else {
0147     edm::LogError("BadNameString|SiPixel")
0148         << "Unable to determine panel number in PixelEndcapNameUpgrade::PixelEndcapNameUpgrade(std::string): " << name;
0149   }
0150   // find the plaquette
0151   string plaquetteString = name.substr(name.find("_PLQ") + 4, name.size() - name.find("_PLQ") - 4);
0152   if (plaquetteString == "1")
0153     thePlaquette = 1;
0154   else {
0155     edm::LogError("BadNameString|SiPixel")
0156         << "Unable to determine plaquette number in PixelEndcapNameUpgrade::PixelEndcapNameUpgrade(std::string): "
0157         << name;
0158   }
0159 
0160 }  // PixelEndcapNameUpgrade::PixelEndcapNameUpgrade(std::string name)
0161 
0162 PixelModuleName::ModuleType PixelEndcapNameUpgrade::moduleType() const {
0163   ModuleType type = v2x8;
0164   if (pannelName() == 1) {
0165     if (plaquetteName() == 1) {
0166       type = v2x8;
0167     }
0168   } else {
0169     if (plaquetteName() == 1) {
0170       type = v2x8;
0171     }
0172   }
0173   return type;
0174 }
0175 
0176 bool PixelEndcapNameUpgrade::operator==(const PixelModuleName& other) const {
0177   return other.isBarrel() ? false : (dynamic_cast<const PixelEndcapNameUpgrade&>(other) == *this);
0178 }
0179 
0180 string PixelEndcapNameUpgrade::name() const {
0181   std::ostringstream stm;
0182   stm << "FPix_B" << thePart << "_D" << theDisk << "_BLD" << theBlade << "_PNL" << thePannel << "_PLQ" << thePlaquette;
0183   return stm.str();
0184 }
0185 
0186 std::ostream& operator<<(std::ostream& out, const PixelEndcapNameUpgrade::HalfCylinder& t) {
0187   switch (t) {
0188     case (PixelEndcapNameUpgrade::pI): {
0189       out << "pI";
0190       break;
0191     }
0192     case (PixelEndcapNameUpgrade::pO): {
0193       out << "pO";
0194       break;
0195     }
0196     case (PixelEndcapNameUpgrade::mI): {
0197       out << "mI";
0198       break;
0199     }
0200     case (PixelEndcapNameUpgrade::mO): {
0201       out << "mO";
0202       break;
0203     }
0204     default:
0205       out << "unknown";
0206   };
0207   return out;
0208 }
0209 
0210 // return the DetId
0211 PXFDetId PixelEndcapNameUpgrade::getDetId() {
0212   uint32_t side = 0;
0213   uint32_t disk = 0;
0214   uint32_t blade = 0;
0215   uint32_t panel = 0;
0216   uint32_t module = 0;
0217 
0218   // figure out the side
0219   HalfCylinder hc = halfCylinder();
0220   if (hc == mO || hc == mI)
0221     side = 1;
0222   else if (hc == pO || hc == pI)
0223     side = 2;
0224 
0225   // get disk/blade/panel/module numbers from PixelEndcapNameUpgrade object
0226   disk = static_cast<uint32_t>(diskName());
0227   uint32_t tmpBlade = static_cast<uint32_t>(bladeName());
0228   panel = static_cast<uint32_t>(pannelName());
0229   module = static_cast<uint32_t>(plaquetteName());
0230 
0231   // convert blade numbering to cmssw convention
0232   bool outer = false;
0233   outer = (hc == mO) || (hc == pO);
0234   /*
0235   //iasonas1
0236   if (outer) {blade = 57 - tmpBlade;}
0237   else       {blade = 23 - tmpBlade;}
0238   
0239 */
0240   //iasonas2    m/pI:1-6,18-31,49-56. m/pO:7-17,32-48.
0241   if (outer) {
0242     if (tmpBlade >= 7 && tmpBlade <= 17)
0243       theBlade = tmpBlade + 6;
0244     else if (tmpBlade >= 32 && tmpBlade <= 48)
0245       theBlade = 60 - tmpBlade;
0246   } else {  //inner
0247     if (tmpBlade <= 6)
0248       theBlade = 7 - tmpBlade;
0249     else if (tmpBlade >= 18 && tmpBlade <= 31)
0250       theBlade = 38 - tmpBlade;
0251     else if (tmpBlade >= 49 && tmpBlade <= 56)
0252       theBlade = 77 - tmpBlade;
0253   }
0254 
0255   // create and return the DetId
0256   return PXFDetId(side, disk, blade, panel, module);
0257 
0258 }  // PXFDetId PixelEndcapNameUpgrade::getDetId()