CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PixelBarrelName.cc
Go to the documentation of this file.
2 
3 #include <sstream>
4 #include <iostream>
5 
8 
9 using namespace std;
10 
11 
14 {
15 
16 // uint32_t rawId = id.rawId();
17  PXBDetId cmssw_numbering(id);
18 
19 
20  theLayer = cmssw_numbering.layer();
21 
22  int oldModule = cmssw_numbering.module() -4; if (oldModule<=0) oldModule--;
23 
24  int oldLadder = cmssw_numbering.ladder();
25  if (theLayer == 1) {
26  if (oldLadder <= 5) oldLadder = 6-oldLadder;
27  else if (oldLadder >= 6 && oldLadder <= 15 ) oldLadder = 5-oldLadder;
28  else if (oldLadder >= 16) oldLadder = 26-oldLadder;
29  }
30  else if (theLayer == 2) {
31  if (oldLadder <= 8) oldLadder = 9-oldLadder;
32  else if (oldLadder >= 9 && oldLadder <= 24) oldLadder = 8-oldLadder;
33  else if (oldLadder >= 25) oldLadder = 41-oldLadder;
34  }
35  else if (theLayer == 3) {
36  if (oldLadder <= 11) oldLadder = 12-oldLadder;
37  else if (oldLadder >= 12 && oldLadder <= 33) oldLadder = 11-oldLadder;
38  else if (oldLadder >= 34) oldLadder = 56-oldLadder;
39  }
40 
41  //
42  // part
43  //
44  if (oldModule < 0 && oldLadder < 0) thePart = mO;
45  else if (oldModule > 0 && oldLadder < 0) thePart = pO;
46  else if (oldModule < 0 && oldLadder > 0) thePart = mI;
47  else if (oldModule > 0 && oldLadder > 0) thePart = pI;
48 
49 
50  //
51  // ladder
52  //
53  theLadder = abs(oldLadder);
54 
55  //
56  // module
57  //
58  theModule = abs(oldModule);
59 
60 }
61 
62 // constructor from name string
64  : PixelModuleName(true), thePart(mO), theLayer(0),
65  theModule(0), theLadder(0) {
66 
67  // parse the name string
68  // first, check to make sure this is an BPix name, should start with "BPix_"
69  // also check to make sure the needed parts are present
70  if ( (name.substr(0, 5) != "BPix_") ||
71  (name.find("_B") == string::npos) ||
72  (name.find("_LYR") == string::npos) ||
73  (name.find("_LDR") == string::npos) ||
74  (name.find("_MOD") == string::npos) ) {
75  edm::LogError ("BadNameString|SiPixel")
76  << "Bad name string in PixelBarrelName::PixelBarrelName(std::string): "
77  << name;
78  return;
79  }
80 
81  // strip off ROC part if it's there
82  if (name.find("_ROC") != string::npos)
83  name = name.substr(0, name.find("_ROC"));
84 
85  // find shell
86  string shellString = name.substr(name.find("_B")+2, name.find("_SEC")-name.find("_B")-2);
87  if (shellString == "mO") thePart = mO;
88  else if (shellString == "mI") thePart = mI;
89  else if (shellString == "pO") thePart = pO;
90  else if (shellString == "pI") thePart = pI;
91  else {
92  edm::LogError ("BadNameString|SiPixel")
93  << "Unable to determine shell in PixelBarrelName::PixelBarrelName(std::string): "
94  << name;
95  }
96 
97  // find the layer
98  string layerString = name.substr(name.find("_LYR")+4, name.find("_LDR")-name.find("_LYR")-4);
99  if (layerString == "1") theLayer = 1;
100  else if (layerString == "2") theLayer = 2;
101  else if (layerString == "3") theLayer = 3;
102  else {
103  edm::LogError ("BadNameString|SiPixel")
104  << "Unable to determine layer in PixelBarrelName::PixelBarrelName(std::string): "
105  << name;
106  }
107 
108  // find the ladder
109  string ladderString = name.substr(name.find("_LDR")+4, name.find("_MOD")-name.find("_LDR")-4);
110  if (ladderString == "1H") theLadder = 1;
111  else if (ladderString == "10H" && theLayer == 1) theLadder = 10;
112  else if (ladderString == "16H" && theLayer == 2) theLadder = 16;
113  else if (ladderString == "22H" && theLayer == 3) theLadder = 22;
114  else if (ladderString.substr(ladderString.size()-1, 1) == "F") {
115  int ladderNum = atoi(ladderString.substr(0, ladderString.size() -1).c_str());
116  if (theLayer == 1 && ladderNum > 1 && ladderNum < 10) theLadder = ladderNum;
117  else if (theLayer == 2 && ladderNum > 1 && ladderNum < 16) theLadder = ladderNum;
118  else if (theLayer == 3 && ladderNum > 1 && ladderNum < 22) theLadder = ladderNum;
119  else {
120  edm::LogError ("BadNameString|SiPixel")
121  << "Unable to determine ladder in PixelBarrelName::PixelBarrelName(std::string): "
122  << name;
123  }
124  } // full ladders
125  else {
126  edm::LogError ("BadNameString|SiPixel")
127  << "Unable to determine ladder in PixelBarrelName::PixelBarrelName(std::string): "
128  << name;
129  }
130 
131  // find the module
132  string moduleString = name.substr(name.find("_MOD")+4, name.size()-name.find("_MOD")-4);
133  if (moduleString == "1") theModule = 1;
134  else if (moduleString == "2") theModule = 2;
135  else if (moduleString == "3") theModule = 3;
136  else if (moduleString == "4") theModule = 4;
137  else {
138  edm::LogError ("BadNameString|SiPixel")
139  << "Unable to determine module in PixelBarrelName::PixelBarrelName(std::string): "
140  << name;
141  }
142 
143 } // PixelBarrelName::PixelBarrelName(std::string name)
144 
146 {
147  int sector = 0;
148  if (theLayer==1) {
149  switch (theLadder) {
150  case 1 : case 2: {sector = 1; break;}
151  case 3 : {sector = 2; break;}
152  case 4 : {sector = 3; break;}
153  case 5 : {sector = 4; break;}
154  case 6 : {sector = 5; break;}
155  case 7 : {sector = 6; break;}
156  case 8 : {sector = 7; break;}
157  case 9 : case 10:{sector = 8; break;}
158  default: ;
159  };
160  } else if (theLayer==2) {
161  switch (theLadder) {
162  case 1 : case 2: {sector = 1; break;}
163  case 3 : case 4: {sector = 2; break;}
164  case 5 : case 6: {sector = 3; break;}
165  case 7 : case 8: {sector = 4; break;}
166  case 9 : case 10: {sector = 5; break;}
167  case 11 : case 12: {sector = 6; break;}
168  case 13 : case 14: {sector = 7; break;}
169  case 15 : case 16: {sector = 8; break;}
170  default: ;
171  };
172  } else if (theLayer==3) {
173  switch (theLadder) {
174  case 1 : case 2: case 3: {sector = 1; break;}
175  case 4 : case 5: case 6: {sector = 2; break;}
176  case 7 : case 8: case 9: {sector = 3; break;}
177  case 10 : case 11: {sector = 4; break;}
178  case 12 : case 13: {sector = 5; break;}
179  case 14 : case 15: case 16: {sector = 6; break;}
180  case 17 : case 18: case 19: {sector = 7; break;}
181  case 20 : case 21: case 22: {sector = 8; break;}
182  default: ;
183  };
184  }
185  return sector;
186 
187 }
188 
190 {
191  bool halfModule = false;
192  if (theLadder == 1) halfModule = true;
193  if (theLayer == 1 && theLadder == 10) halfModule = true;
194  if (theLayer == 2 && theLadder == 16) halfModule = true;
195  if (theLayer == 3 && theLadder == 22) halfModule = true;
196  return halfModule;
197 }
198 
200 {
202 }
203 
205 {
206  if ( o.isBarrel() ) {
207  const PixelBarrelName *other = dynamic_cast<const PixelBarrelName*>(&o);
208  return ( other
209  && thePart == other->thePart
210  && theLayer == other->theLayer
211  && theModule == other->theModule
212  && theLadder == other->theLadder);
213  } else return false;
214 }
215 
216 string PixelBarrelName::name() const
217 {
218  std::ostringstream stm;
219 
220  stm<<"BPix_B"<<thePart<<"_SEC"<<sectorName()<<"_LYR"<<theLayer<<"_LDR"<<theLadder;
221  if ( isHalfModule() ) stm <<"H"; else stm <<"F";
222  stm << "_MOD" << theModule;
223 
224  return stm.str();
225 }
226 
227 // return the DetId
229 
230  uint32_t layer = 0;
231  uint32_t ladder = 0;
232  uint32_t module = 0;
233 
234  layer = layerName();
235  uint32_t tmpLadder = ladderName();
236  uint32_t tmpModule = moduleName();
237 
238  // translate the ladder number from the naming convention to the cmssw convention
239  bool outer = false;
240  Shell shell = thePart;
241  outer = (shell == mO) || (shell == pO);
242  if (outer) {
243  if (layer == 1)
244  ladder = tmpLadder + 5;
245  else if (layer == 2)
246  ladder = tmpLadder + 8;
247  else if (layer == 3)
248  ladder = tmpLadder + 11;
249  } // outer
250  else { // inner
251  if (layer == 1) {
252  if (tmpLadder <= 5) ladder = 6 - tmpLadder;
253  else if (tmpLadder <= 10) ladder = 26 - tmpLadder;
254  } // layer 1
255  else if (layer == 2) {
256  if (tmpLadder <= 8) ladder = 9 - tmpLadder;
257  else if (tmpLadder <= 16) ladder = 41 - tmpLadder;
258  } // layer 2
259  else if (layer == 3) {
260  if (tmpLadder <= 11) ladder = 12 - tmpLadder;
261  else if (tmpLadder <= 22) ladder = 56 - tmpLadder;
262  } // layer 3
263  } // inner
264 
265  // translate the module number from naming convention to cmssw convention
266  // numbering starts at positive z
267  if (shell == pO || shell == pI)
268  module = tmpModule + 4;
269  else // negative z side
270  module = 5 - tmpModule;
271 
272  return PXBDetId(layer, ladder, module);
273 
274 } // PXBDetId PixelBarrelName::getDetId()
275 
276 std::ostream & operator<<( std::ostream& out, const PixelBarrelName::Shell& t)
277 {
278  switch (t) {
279  case(PixelBarrelName::pI) : {out << "pI"; break;}
280  case(PixelBarrelName::pO) : {out << "pO"; break;}
281  case(PixelBarrelName::mI) : {out << "mI"; break;}
282  case(PixelBarrelName::mO) : {out << "mO"; break;}
283  default: out << "unknown";
284  };
285  return out;
286 }
int moduleName() const
module id (index in z)
#define abs(x)
Definition: mlp_lapack.h:159
unsigned int ladder() const
ladder id
Definition: PXBDetId.h:39
std::ostream & operator<<(std::ostream &out, const ALILine &li)
Definition: ALILine.cc:187
unsigned int layer() const
layer id
Definition: PXBDetId.h:35
bool isHalfModule() const
full or half module
int sectorName() const
sector id
unsigned int module() const
det id
Definition: PXBDetId.h:43
virtual bool operator==(const PixelModuleName &) const
check equality of modules from datamemebers
tuple out
Definition: dbtoconf.py:99
virtual bool isBarrel() const
true for barrel modules
Definition: DetId.h:20
int ladderName() const
ladder id (index in phi)
virtual std::string name() const
from base class
int layerName() const
layer id
Shell shell() const
PixelBarrelName(const DetId &)
ctor from DetId
Definition: vlib.h:209
PXBDetId getDetId()
return the DetId
virtual PixelModuleName::ModuleType moduleType() const
module Type