CMS 3D CMS Logo

PixelEndcapNameUpgrade.cc
Go to the documentation of this file.
2 
3 #include <sstream>
4 
6 
8 
9 using namespace std;
10 
12  PXFDetId cmssw_numbering(id);
13  int side = cmssw_numbering.side();
14  int tmpBlade = cmssw_numbering.blade();
15  bool outer = false;
16 
17  /*
18  // iasonas1-with this we determine inner-outer ring, NOT x-direction
19  if (tmpBlade >= 23 && tmpBlade <= 56) { //23-56-->outer ring
20  outer = true;
21  theBlade = 57-tmpBlade;
22  } else if( tmpBlade <= 22 ) { //1-22-->inner ring
23  theBlade = 23-tmpBlade;
24  } // iasonas1-end
25 
26 */
27  // iasonas2-with this we determine inner-outer x-position (x>0-x<0), NOT ring
28  // m/pI:1-6,18-31,49-56. m/pO:7-17,32-48.
29  if (tmpBlade >= 7 && tmpBlade <= 17) {
30  outer = true;
31  theBlade = tmpBlade - 6; //7...17-->1...11
32  } else if (tmpBlade >= 32 && tmpBlade <= 48) {
33  outer = true;
34  theBlade = 60 - tmpBlade; //32...48-->28...12
35  } else if (tmpBlade <= 6) {
36  theBlade = 7 - tmpBlade; //1...6-->6...1
37  } else if (tmpBlade >= 18 && tmpBlade <= 31) {
38  theBlade = 38 - tmpBlade; //18...31-->20...7
39  } else if (tmpBlade >= 49 && tmpBlade <= 56) {
40  theBlade = 77 - tmpBlade; //49...56-->28...21
41  } // iasonas2-end
42 
43  if (side == 1 && outer)
44  thePart = mO;
45  else if (side == 1 && !outer)
46  thePart = mI;
47  else if (side == 2 && outer)
48  thePart = pO;
49  else if (side == 2 && !outer)
50  thePart = pI;
51 
52  theDisk = cmssw_numbering.disk();
53  thePannel = cmssw_numbering.panel();
54  thePlaquette = cmssw_numbering.module();
55 }
56 
57 // constructor from name string
59  : PixelModuleName(false), thePart(mO), theDisk(0), theBlade(0), thePannel(0), thePlaquette(0) {
60  // parse the name string
61  // first, check to make sure this is an FPix name, should start with "FPix_"
62  // also check to make sure the needed parts are present
63  if ((name.substr(0, 5) != "FPix_") || (name.find("_B") == string::npos) || (name.find("_D") == string::npos) ||
64  (name.find("_BLD") == string::npos) || (name.find("_PNL") == string::npos) ||
65  (name.find("_PLQ") == string::npos)) {
66  edm::LogError("BadNameString|SiPixel")
67  << "Bad name string in PixelEndcapNameUpgrade::PixelEndcapNameUpgrade(std::string): " << name;
68  return;
69  }
70  // strip off ROC part if it's there
71  if (name.find("_ROC") != string::npos)
72  name = name.substr(0, name.find("_ROC"));
73  // get the half cylinder
74  string hcString = name.substr(name.find("_B") + 2, name.find("_D") - name.find("_B") - 2);
75  if (hcString == "mO")
76  thePart = mO;
77  else if (hcString == "mI")
78  thePart = mI;
79  else if (hcString == "pO")
80  thePart = pO;
81  else if (hcString == "pI")
82  thePart = pI;
83  else {
84  edm::LogError("BadNameString|SiPixel")
85  << "Unable to determine half cylinder in PixelEndcapNameUpgrade::PixelEndcapNameUpgrade(std::string): " << name;
86  }
87  // get the disk
88  string diskString = name.substr(name.find("_D") + 2, name.find("_BLD") - name.find("_D") - 2);
89  if (diskString == "1")
90  theDisk = 1;
91  else if (diskString == "2")
92  theDisk = 2;
93  else if (diskString == "3")
94  theDisk = 3;
95  else {
96  edm::LogError("BadNameString|SiPixel")
97  << "Unable to determine disk number in PixelEndcapNameUpgrade::PixelEndcapNameUpgrade(std::string): " << name;
98  }
99  // get the blade
100  string bladeString = name.substr(name.find("_BLD") + 4, name.find("_PNL") - name.find("_BLD") - 4);
101  // since atoi() doesn't report errors, do it the long way
102  if (bladeString == "1")
103  theBlade = 1;
104  else if (bladeString == "2")
105  theBlade = 2;
106  else if (bladeString == "3")
107  theBlade = 3;
108  else if (bladeString == "4")
109  theBlade = 4;
110  else if (bladeString == "5")
111  theBlade = 5;
112  else if (bladeString == "6")
113  theBlade = 6;
114  else if (bladeString == "7")
115  theBlade = 7;
116  else if (bladeString == "8")
117  theBlade = 8;
118  else if (bladeString == "9")
119  theBlade = 9;
120  else if (bladeString == "10")
121  theBlade = 10;
122  else if (bladeString == "11")
123  theBlade = 11;
124  else if (bladeString == "12")
125  theBlade = 12;
126  else if (bladeString == "13")
127  theBlade = 13;
128  else if (bladeString == "14")
129  theBlade = 14;
130  else if (bladeString == "15")
131  theBlade = 15;
132  else if (bladeString == "16")
133  theBlade = 16;
134  else if (bladeString == "17")
135  theBlade = 17;
136  else {
137  edm::LogError("BadNameString|SiPixel")
138  << "Unable to determine blade number in PixelEndcapNameUpgrade::PixelEndcapNameUpgrade(std::string): " << name;
139  }
140  // find the panel
141  string panelString = name.substr(name.find("_PNL") + 4, name.find("_PLQ") - name.find("_PNL") - 4);
142  if (panelString == "1")
143  thePannel = 1;
144  else if (panelString == "2")
145  thePannel = 2;
146  else {
147  edm::LogError("BadNameString|SiPixel")
148  << "Unable to determine panel number in PixelEndcapNameUpgrade::PixelEndcapNameUpgrade(std::string): " << name;
149  }
150  // find the plaquette
151  string plaquetteString = name.substr(name.find("_PLQ") + 4, name.size() - name.find("_PLQ") - 4);
152  if (plaquetteString == "1")
153  thePlaquette = 1;
154  else {
155  edm::LogError("BadNameString|SiPixel")
156  << "Unable to determine plaquette number in PixelEndcapNameUpgrade::PixelEndcapNameUpgrade(std::string): "
157  << name;
158  }
159 
160 } // PixelEndcapNameUpgrade::PixelEndcapNameUpgrade(std::string name)
161 
163  ModuleType type = v2x8;
164  if (pannelName() == 1) {
165  if (plaquetteName() == 1) {
166  type = v2x8;
167  }
168  } else {
169  if (plaquetteName() == 1) {
170  type = v2x8;
171  }
172  }
173  return type;
174 }
175 
177  return other.isBarrel() ? false : (dynamic_cast<const PixelEndcapNameUpgrade&>(other) == *this);
178 }
179 
181  std::ostringstream stm;
182  stm << "FPix_B" << thePart << "_D" << theDisk << "_BLD" << theBlade << "_PNL" << thePannel << "_PLQ" << thePlaquette;
183  return stm.str();
184 }
185 
186 std::ostream& operator<<(std::ostream& out, const PixelEndcapNameUpgrade::HalfCylinder& t) {
187  switch (t) {
189  out << "pI";
190  break;
191  }
193  out << "pO";
194  break;
195  }
197  out << "mI";
198  break;
199  }
201  out << "mO";
202  break;
203  }
204  default:
205  out << "unknown";
206  };
207  return out;
208 }
209 
210 // return the DetId
212  uint32_t side = 0;
213  uint32_t disk = 0;
214  uint32_t blade = 0;
215  uint32_t panel = 0;
216  uint32_t module = 0;
217 
218  // figure out the side
219  HalfCylinder hc = halfCylinder();
220  if (hc == mO || hc == mI)
221  side = 1;
222  else if (hc == pO || hc == pI)
223  side = 2;
224 
225  // get disk/blade/panel/module numbers from PixelEndcapNameUpgrade object
226  disk = static_cast<uint32_t>(diskName());
227  uint32_t tmpBlade = static_cast<uint32_t>(bladeName());
228  panel = static_cast<uint32_t>(pannelName());
229  module = static_cast<uint32_t>(plaquetteName());
230 
231  // convert blade numbering to cmssw convention
232  bool outer = false;
233  outer = (hc == mO) || (hc == pO);
234  /*
235  //iasonas1
236  if (outer) {blade = 57 - tmpBlade;}
237  else {blade = 23 - tmpBlade;}
238 
239 */
240  //iasonas2 m/pI:1-6,18-31,49-56. m/pO:7-17,32-48.
241  if (outer) {
242  if (tmpBlade >= 7 && tmpBlade <= 17)
243  theBlade = tmpBlade + 6;
244  else if (tmpBlade >= 32 && tmpBlade <= 48)
245  theBlade = 60 - tmpBlade;
246  } else { //inner
247  if (tmpBlade <= 6)
248  theBlade = 7 - tmpBlade;
249  else if (tmpBlade >= 18 && tmpBlade <= 31)
250  theBlade = 38 - tmpBlade;
251  else if (tmpBlade >= 49 && tmpBlade <= 56)
252  theBlade = 77 - tmpBlade;
253  }
254 
255  // create and return the DetId
256  return PXFDetId(side, disk, blade, panel, module);
257 
258 } // PXFDetId PixelEndcapNameUpgrade::getDetId()
std::ostream & operator<<(std::ostream &out, const PixelEndcapNameUpgrade::HalfCylinder &t)
int pannelName() const
pannel id
unsigned int disk() const
disk id
Definition: PXFDetId.h:35
PXFDetId getDetId()
return DetId
HalfCylinder halfCylinder() const
PixelModuleName::ModuleType moduleType() const override
module Type
bool operator==(const PixelModuleName &) const override
check equality of modules from datamemebers
unsigned int side() const
positive or negative id
Definition: PXFDetId.h:32
Log< level::Error, false > LogError
int plaquetteName() const
plaquetteId (in pannel)
PixelEndcapNameUpgrade(const DetId &)
ctor from DetId
int bladeName() const
blade id
unsigned int module() const
det id
Definition: PXFDetId.h:44
unsigned int blade() const
blade id
Definition: PXFDetId.h:38
int diskName() const
disk id
Definition: DetId.h:17
unsigned int panel() const
panel id
Definition: PXFDetId.h:41
std::string name() const override
from base class