Go to the documentation of this file.00001 #include "DataFormats/SiPixelDetId/interface/PixelEndcapName.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 PixelEndcapName::PixelEndcapName(const DetId & id)
00012 : PixelModuleName(false)
00013 {
00014 PXFDetId cmssw_numbering(id);
00015 int side = cmssw_numbering.side();
00016
00017 bool outer = false;
00018 theBlade = cmssw_numbering.blade();
00019
00020 if (theBlade >= 1 && theBlade <= 22) {
00021 outer = true;
00022 }
00023 if( side == 1 && outer ) thePart = mO;
00024 else if( side == 1 && !outer ) thePart = mI;
00025 else if( side == 2 && outer ) thePart = pO;
00026 else if( side == 2 && !outer ) thePart = pI;
00027
00028
00029 theDisk = cmssw_numbering.disk();
00030 thePannel = cmssw_numbering.panel();
00031 thePlaquette = cmssw_numbering.module();
00032 }
00033
00034
00035 PixelEndcapName::PixelEndcapName(std::string name)
00036 : PixelModuleName(false), thePart(mO), theDisk(0),
00037 theBlade(0), thePannel(0), thePlaquette(0) {
00038
00039
00040
00041
00042 if ( (name.substr(0, 5) != "FPix_") ||
00043 (name.find("_B") == string::npos) ||
00044 (name.find("_D") == string::npos) ||
00045 (name.find("_BLD") == string::npos) ||
00046 (name.find("_PNL") == string::npos) ||
00047 (name.find("_PLQ") == string::npos) ) {
00048 edm::LogError ("BadNameString|SiPixel")
00049 << "Bad name string in PixelEndcapName::PixelEndcapName(std::string): "
00050 << name;
00051 return;
00052 }
00053
00054
00055 if (name.find("_ROC") != string::npos)
00056 name = name.substr(0, name.find("_ROC"));
00057
00058
00059 string hcString = name.substr(name.find("_B")+2, name.find("_D")-name.find("_B")-2);
00060 if (hcString == "mO") thePart = mO;
00061 else if (hcString == "mI") thePart = mI;
00062 else if (hcString == "pO") thePart = pO;
00063 else if (hcString == "pI") thePart = pI;
00064 else {
00065 edm::LogError ("BadNameString|SiPixel")
00066 << "Unable to determine half cylinder in PixelEndcapName::PixelEndcapName(std::string): "
00067 << name;
00068 }
00069
00070
00071 string diskString = name.substr(name.find("_D")+2, name.find("_BLD")-name.find("_D")-2);
00072 if (diskString == "1") theDisk = 1;
00073 else if (diskString == "2") theDisk = 2;
00074 else if (diskString == "3") theDisk = 3;
00075 else {
00076 edm::LogError ("BadNameString|SiPixel")
00077 << "Unable to determine disk number in PixelEndcapName::PixelEndcapName(std::string): "
00078 << name;
00079 }
00080
00081
00082 string bladeString = name.substr(name.find("_BLD")+4, name.find("_PNL")-name.find("_BLD")-4);
00083
00084 if (bladeString == "1") theBlade = 1;
00085 else if (bladeString == "2") theBlade = 2;
00086 else if (bladeString == "3") theBlade = 3;
00087 else if (bladeString == "4") theBlade = 4;
00088 else if (bladeString == "5") theBlade = 5;
00089 else if (bladeString == "6") theBlade = 6;
00090 else if (bladeString == "7") theBlade = 7;
00091 else if (bladeString == "8") theBlade = 8;
00092 else if (bladeString == "9") theBlade = 9;
00093 else if (bladeString == "10") theBlade = 10;
00094 else if (bladeString == "11") theBlade = 11;
00095 else if (bladeString == "12") theBlade = 12;
00096 else {
00097 edm::LogError ("BadNameString|SiPixel")
00098 << "Unable to determine blade number in PixelEndcapName::PixelEndcapName(std::string): "
00099 << name;
00100 }
00101
00102
00103 string panelString = name.substr(name.find("_PNL")+4, name.find("_PLQ")-name.find("_PNL")-4);
00104 if (panelString == "1") thePannel = 1;
00105 else if (panelString == "2") thePannel = 2;
00106 else {
00107 edm::LogError ("BadNameString|SiPixel")
00108 << "Unable to determine panel number in PixelEndcapName::PixelEndcapName(std::string): "
00109 << name;
00110 }
00111
00112
00113 string plaquetteString = name.substr(name.find("_PLQ")+4, name.size()-name.find("_PLQ")-4);
00114 if (plaquetteString == "1") thePlaquette = 1;
00115 else if (plaquetteString == "2") thePlaquette = 2;
00116 else if (plaquetteString == "3") thePlaquette = 3;
00117 else if (plaquetteString == "4") thePlaquette = 4;
00118 else {
00119 edm::LogError ("BadNameString|SiPixel")
00120 << "Unable to determine plaquette number in PixelEndcapName::PixelEndcapName(std::string): "
00121 << name;
00122 }
00123
00124 }
00125
00126 PixelModuleName::ModuleType PixelEndcapName::moduleType() const
00127 {
00128 ModuleType type = v1x2;
00129 if (pannelName() == 1) {
00130 if (plaquetteName() == 1) { type = v1x2; }
00131 else if (plaquetteName() == 2) { type = v2x3; }
00132 else if (plaquetteName() == 3) { type = v2x4; }
00133 else if (plaquetteName() == 4) { type = v1x5; }
00134 }
00135 else {
00136 if (plaquetteName() == 1) { type = v2x3; }
00137 else if (plaquetteName() == 2) { type = v2x4; }
00138 else if (plaquetteName() == 3) { type = v2x5; }
00139 }
00140 return type;
00141 }
00142
00143 bool PixelEndcapName::operator== (const PixelModuleName & o) const
00144 {
00145 if (!o.isBarrel()) {
00146 const PixelEndcapName * other = dynamic_cast<const PixelEndcapName *>(&o);
00147 return ( other
00148 && thePart == other->thePart
00149 && theDisk == other->theDisk
00150 && theBlade == other->theBlade
00151 && thePannel == other->thePannel
00152 && thePlaquette == other->thePlaquette );
00153 } else return false;
00154 }
00155
00156
00157 string PixelEndcapName::name() const
00158 {
00159 std::ostringstream stm;
00160 stm <<"FPix_B"<<thePart<<"_D"<<theDisk<<"_BLD"<<theBlade<<"_PNL"<<thePannel<<"_PLQ"<<thePlaquette;
00161 return stm.str();
00162 }
00163
00164 std::ostream & operator<<( std::ostream& out, const PixelEndcapName::HalfCylinder& t)
00165 {
00166 switch (t) {
00167 case(PixelEndcapName::pI) : {out << "pI"; break;}
00168 case(PixelEndcapName::pO) : {out << "pO"; break;}
00169 case(PixelEndcapName::mI) : {out << "mI"; break;}
00170 case(PixelEndcapName::mO) : {out << "mO"; break;}
00171 default: out << "unknown";
00172 };
00173 return out;
00174 }
00175
00176
00177 PXFDetId PixelEndcapName::getDetId() {
00178
00179 uint32_t side = 0;
00180 uint32_t disk = 0;
00181 uint32_t blade = 0;
00182 uint32_t panel = 0;
00183 uint32_t module = 0;
00184
00185
00186 HalfCylinder hc = halfCylinder();
00187 if (hc == mO || hc == mI) side = 1;
00188 else if (hc == pO || hc == pI) side = 2;
00189
00190
00191 disk = diskName();
00192 blade = bladeName();
00193 panel = pannelName();
00194 module = plaquetteName();
00195
00196
00197 return PXFDetId(side, disk, blade, panel, module);
00198
00199 }