Go to the documentation of this file.00001 #include "DataFormats/SiPixelDetId/interface/PixelEndcapNameUpgrade.h"
00002
00003 #include <sstream>
00004
00005 #include "DataFormats/SiPixelDetId/interface/PXFDetId.h"
00006
00007 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00008
00009 using namespace std;
00010
00011
00012
00013
00014 PixelEndcapNameUpgrade::PixelEndcapNameUpgrade(const DetId & id)
00015 : PixelModuleName(false)
00016 {
00017 PXFDetId cmssw_numbering(id);
00018 int side = cmssw_numbering.side();
00019 int tmpBlade = cmssw_numbering.blade();
00020 bool outer = false;
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 if (tmpBlade>=7 && tmpBlade<=17) {
00035 outer = true;
00036 theBlade = tmpBlade-6;
00037 } else if (tmpBlade>=32 && tmpBlade<=48) {
00038 outer = true;
00039 theBlade = 60-tmpBlade;
00040 } else if( tmpBlade<=6 ) {
00041 theBlade = 7-tmpBlade;
00042 } else if( tmpBlade>=18 && tmpBlade<=31 ) {
00043 theBlade = 38-tmpBlade;
00044 } else if( tmpBlade>=49 && tmpBlade<=56 ) {
00045 theBlade = 77-tmpBlade;
00046 }
00047
00048 if( side == 1 && outer ) thePart = mO;
00049 else if( side == 1 && !outer ) thePart = mI;
00050 else if( side == 2 && outer ) thePart = pO;
00051 else if( side == 2 && !outer ) thePart = pI;
00052
00053 theDisk = cmssw_numbering.disk();
00054 thePannel = cmssw_numbering.panel();
00055 thePlaquette = cmssw_numbering.module();
00056
00057 }
00058
00059
00060
00061 PixelEndcapNameUpgrade::PixelEndcapNameUpgrade(std::string name)
00062 : PixelModuleName(false), thePart(mO), theDisk(0),
00063 theBlade(0), thePannel(0), thePlaquette(0) {
00064
00065
00066
00067 if ( (name.substr(0, 5) != "FPix_") ||
00068 (name.find("_B") == string::npos) ||
00069 (name.find("_D") == string::npos) ||
00070 (name.find("_BLD") == string::npos) ||
00071 (name.find("_PNL") == string::npos) ||
00072 (name.find("_PLQ") == string::npos) ) {
00073 edm::LogError ("BadNameString|SiPixel")
00074 << "Bad name string in PixelEndcapNameUpgrade::PixelEndcapNameUpgrade(std::string): "
00075 << name;
00076 return;
00077 }
00078
00079 if (name.find("_ROC") != string::npos)
00080 name = name.substr(0, name.find("_ROC"));
00081
00082 string hcString = name.substr(name.find("_B")+2, name.find("_D")-name.find("_B")-2);
00083 if (hcString == "mO") thePart = mO;
00084 else if (hcString == "mI") thePart = mI;
00085 else if (hcString == "pO") thePart = pO;
00086 else if (hcString == "pI") thePart = pI;
00087 else {
00088 edm::LogError ("BadNameString|SiPixel")
00089 << "Unable to determine half cylinder in PixelEndcapNameUpgrade::PixelEndcapNameUpgrade(std::string): "
00090 << name;
00091 }
00092
00093 string diskString = name.substr(name.find("_D")+2, name.find("_BLD")-name.find("_D")-2);
00094 if (diskString == "1") theDisk = 1;
00095 else if (diskString == "2") theDisk = 2;
00096 else if (diskString == "3") theDisk = 3;
00097 else {
00098 edm::LogError ("BadNameString|SiPixel")
00099 << "Unable to determine disk number in PixelEndcapNameUpgrade::PixelEndcapNameUpgrade(std::string): "
00100 << name;
00101 }
00102
00103 string bladeString = name.substr(name.find("_BLD")+4, name.find("_PNL")-name.find("_BLD")-4);
00104
00105 if (bladeString == "1") theBlade = 1;
00106 else if (bladeString == "2") theBlade = 2;
00107 else if (bladeString == "3") theBlade = 3;
00108 else if (bladeString == "4") theBlade = 4;
00109 else if (bladeString == "5") theBlade = 5;
00110 else if (bladeString == "6") theBlade = 6;
00111 else if (bladeString == "7") theBlade = 7;
00112 else if (bladeString == "8") theBlade = 8;
00113 else if (bladeString == "9") theBlade = 9;
00114 else if (bladeString == "10") theBlade = 10;
00115 else if (bladeString == "11") theBlade = 11;
00116 else if (bladeString == "12") theBlade = 12;
00117 else if (bladeString == "13") theBlade = 13;
00118 else if (bladeString == "14") theBlade = 14;
00119 else if (bladeString == "15") theBlade = 15;
00120 else if (bladeString == "16") theBlade = 16;
00121 else if (bladeString == "17") theBlade = 17;
00122 else {
00123 edm::LogError ("BadNameString|SiPixel")
00124 << "Unable to determine blade number in PixelEndcapNameUpgrade::PixelEndcapNameUpgrade(std::string): "
00125 << name;
00126 }
00127
00128 string panelString = name.substr(name.find("_PNL")+4, name.find("_PLQ")-name.find("_PNL")-4);
00129 if (panelString == "1") thePannel = 1;
00130 else if (panelString == "2") thePannel = 2;
00131 else {
00132 edm::LogError ("BadNameString|SiPixel")
00133 << "Unable to determine panel number in PixelEndcapNameUpgrade::PixelEndcapNameUpgrade(std::string): "
00134 << name;
00135 }
00136
00137 string plaquetteString = name.substr(name.find("_PLQ")+4, name.size()-name.find("_PLQ")-4);
00138 if (plaquetteString == "1") thePlaquette = 1;
00139 else {
00140 edm::LogError ("BadNameString|SiPixel")
00141 << "Unable to determine plaquette number in PixelEndcapNameUpgrade::PixelEndcapNameUpgrade(std::string): "
00142 << name;
00143 }
00144
00145 }
00146
00147
00148 PixelModuleName::ModuleType PixelEndcapNameUpgrade::moduleType() const
00149 {
00150 ModuleType type = v2x8;
00151 if (pannelName() == 1) {
00152 if (plaquetteName() == 1) { type = v2x8; }
00153 }
00154 else {
00155 if (plaquetteName() == 1) { type = v2x8; }
00156 }
00157 return type;
00158 }
00159
00160
00161 bool PixelEndcapNameUpgrade::operator== (const PixelModuleName & o) const
00162 {
00163 if (!o.isBarrel()) {
00164 const PixelEndcapNameUpgrade * other = dynamic_cast<const PixelEndcapNameUpgrade *>(&o);
00165 return ( other
00166 && thePart == other->thePart
00167 && theDisk == other->theDisk
00168 && theBlade == other->theBlade
00169 && thePannel == other->thePannel
00170 && thePlaquette == other->thePlaquette );
00171 } else return false;
00172 }
00173
00174 string PixelEndcapNameUpgrade::name() const
00175 {
00176 std::ostringstream stm;
00177 stm <<"FPix_B"<<thePart<<"_D"<<theDisk<<"_BLD"<<theBlade<<"_PNL"<<thePannel<<"_PLQ"<<thePlaquette;
00178 return stm.str();
00179 }
00180
00181 std::ostream & operator<<( std::ostream& out, const PixelEndcapNameUpgrade::HalfCylinder& t)
00182 {
00183 switch (t) {
00184 case(PixelEndcapNameUpgrade::pI) : {out << "pI"; break;}
00185 case(PixelEndcapNameUpgrade::pO) : {out << "pO"; break;}
00186 case(PixelEndcapNameUpgrade::mI) : {out << "mI"; break;}
00187 case(PixelEndcapNameUpgrade::mO) : {out << "mO"; break;}
00188 default: out << "unknown";
00189 };
00190 return out;
00191 }
00192
00193
00194
00195 PXFDetId PixelEndcapNameUpgrade::getDetId() {
00196
00197 uint32_t side = 0;
00198 uint32_t disk = 0;
00199 uint32_t blade = 0;
00200 uint32_t panel = 0;
00201 uint32_t module = 0;
00202
00203
00204 HalfCylinder hc = halfCylinder();
00205 if (hc == mO || hc == mI) side = 1;
00206 else if (hc == pO || hc == pI) side = 2;
00207
00208
00209 disk = static_cast<uint32_t>(diskName());
00210 uint32_t tmpBlade = static_cast<uint32_t>(bladeName());
00211 panel = static_cast<uint32_t>(pannelName());
00212 module = static_cast<uint32_t>(plaquetteName());
00213
00214
00215 bool outer = false;
00216 outer = (hc == mO) || (hc == pO);
00217
00218
00219
00220
00221
00222
00223
00224 if (outer) {
00225 if (tmpBlade>=7 && tmpBlade<=17) theBlade = tmpBlade+6;
00226 else if (tmpBlade>=32 && tmpBlade<=48) theBlade = 60-tmpBlade;
00227 } else {
00228 if (tmpBlade<=6 ) theBlade = 7-tmpBlade;
00229 else if (tmpBlade>=18 && tmpBlade<=31) theBlade = 38-tmpBlade;
00230 else if (tmpBlade>=49 && tmpBlade<=56) theBlade = 77-tmpBlade;
00231 }
00232
00233
00234 return PXFDetId(side, disk, blade, panel, module);
00235
00236 }
00237
00238
00239
00240
00241
00242
00243
00244
00245