Back to home page

Project CMSSW displayed by LXR

 
 

    


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

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& o) const {
0177   if (!o.isBarrel()) {
0178     const PixelEndcapNameUpgrade* other = dynamic_cast<const PixelEndcapNameUpgrade*>(&o);
0179     return (other && thePart == other->thePart && theDisk == other->theDisk && theBlade == other->theBlade &&
0180             thePannel == other->thePannel && thePlaquette == other->thePlaquette);
0181   } else
0182     return false;
0183 }
0184 
0185 string PixelEndcapNameUpgrade::name() const {
0186   std::ostringstream stm;
0187   stm << "FPix_B" << thePart << "_D" << theDisk << "_BLD" << theBlade << "_PNL" << thePannel << "_PLQ" << thePlaquette;
0188   return stm.str();
0189 }
0190 
0191 std::ostream& operator<<(std::ostream& out, const PixelEndcapNameUpgrade::HalfCylinder& t) {
0192   switch (t) {
0193     case (PixelEndcapNameUpgrade::pI): {
0194       out << "pI";
0195       break;
0196     }
0197     case (PixelEndcapNameUpgrade::pO): {
0198       out << "pO";
0199       break;
0200     }
0201     case (PixelEndcapNameUpgrade::mI): {
0202       out << "mI";
0203       break;
0204     }
0205     case (PixelEndcapNameUpgrade::mO): {
0206       out << "mO";
0207       break;
0208     }
0209     default:
0210       out << "unknown";
0211   };
0212   return out;
0213 }
0214 
0215 // return the DetId
0216 PXFDetId PixelEndcapNameUpgrade::getDetId() {
0217   uint32_t side = 0;
0218   uint32_t disk = 0;
0219   uint32_t blade = 0;
0220   uint32_t panel = 0;
0221   uint32_t module = 0;
0222 
0223   // figure out the side
0224   HalfCylinder hc = halfCylinder();
0225   if (hc == mO || hc == mI)
0226     side = 1;
0227   else if (hc == pO || hc == pI)
0228     side = 2;
0229 
0230   // get disk/blade/panel/module numbers from PixelEndcapNameUpgrade object
0231   disk = static_cast<uint32_t>(diskName());
0232   uint32_t tmpBlade = static_cast<uint32_t>(bladeName());
0233   panel = static_cast<uint32_t>(pannelName());
0234   module = static_cast<uint32_t>(plaquetteName());
0235 
0236   // convert blade numbering to cmssw convention
0237   bool outer = false;
0238   outer = (hc == mO) || (hc == pO);
0239   /*
0240   //iasonas1
0241   if (outer) {blade = 57 - tmpBlade;}
0242   else       {blade = 23 - tmpBlade;}
0243   
0244 */
0245   //iasonas2    m/pI:1-6,18-31,49-56. m/pO:7-17,32-48.
0246   if (outer) {
0247     if (tmpBlade >= 7 && tmpBlade <= 17)
0248       theBlade = tmpBlade + 6;
0249     else if (tmpBlade >= 32 && tmpBlade <= 48)
0250       theBlade = 60 - tmpBlade;
0251   } else {  //inner
0252     if (tmpBlade <= 6)
0253       theBlade = 7 - tmpBlade;
0254     else if (tmpBlade >= 18 && tmpBlade <= 31)
0255       theBlade = 38 - tmpBlade;
0256     else if (tmpBlade >= 49 && tmpBlade <= 56)
0257       theBlade = 77 - tmpBlade;
0258   }
0259 
0260   // create and return the DetId
0261   return PXFDetId(side, disk, blade, panel, module);
0262 
0263 }  // PXFDetId PixelEndcapNameUpgrade::getDetId()