CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PixelEndcapName.cc
Go to the documentation of this file.
2 
3 #include <sstream>
4 
6 
8 
9 using namespace std;
10 
13 {
14  PXFDetId cmssw_numbering(id);
15  int side = cmssw_numbering.side();
16 
17  int tmpBlade = cmssw_numbering.blade();
18  bool outer = false;
19  if (tmpBlade >= 7 && tmpBlade <= 18) {
20  outer = true;
21  theBlade = tmpBlade-6;
22  } else if( tmpBlade <=6 ) {
23  theBlade = 7-tmpBlade;
24  } else if( tmpBlade >= 19) {
25  theBlade = 31-tmpBlade;
26  }
27 
28 
29  if( side == 1 && outer ) thePart = mO;
30  else if( side == 1 && !outer ) thePart = mI;
31  else if( side == 2 && outer ) thePart = pO;
32  else if( side == 2 && !outer ) thePart = pI;
33 
34 
35  theDisk = cmssw_numbering.disk();
36  thePannel = cmssw_numbering.panel();
37  thePlaquette = cmssw_numbering.module();
38 }
39 
40 // constructor from name string
42  : PixelModuleName(false), thePart(mO), theDisk(0),
43  theBlade(0), thePannel(0), thePlaquette(0) {
44 
45  // parse the name string
46  // first, check to make sure this is an FPix name, should start with "FPix_"
47  // also check to make sure the needed parts are present
48  if ( (name.substr(0, 5) != "FPix_") ||
49  (name.find("_B") == string::npos) ||
50  (name.find("_D") == string::npos) ||
51  (name.find("_BLD") == string::npos) ||
52  (name.find("_PNL") == string::npos) ||
53  (name.find("_PLQ") == string::npos) ) {
54  edm::LogError ("BadNameString|SiPixel")
55  << "Bad name string in PixelEndcapName::PixelEndcapName(std::string): "
56  << name;
57  return;
58  }
59 
60  // strip off ROC part if it's there
61  if (name.find("_ROC") != string::npos)
62  name = name.substr(0, name.find("_ROC"));
63 
64  // get the half cylinder
65  string hcString = name.substr(name.find("_B")+2, name.find("_D")-name.find("_B")-2);
66  if (hcString == "mO") thePart = mO;
67  else if (hcString == "mI") thePart = mI;
68  else if (hcString == "pO") thePart = pO;
69  else if (hcString == "pI") thePart = pI;
70  else {
71  edm::LogError ("BadNameString|SiPixel")
72  << "Unable to determine half cylinder in PixelEndcapName::PixelEndcapName(std::string): "
73  << name;
74  }
75 
76  // get the disk
77  string diskString = name.substr(name.find("_D")+2, name.find("_BLD")-name.find("_D")-2);
78  if (diskString == "1") theDisk = 1;
79  else if (diskString == "2") theDisk = 2;
80  else if (diskString == "3") theDisk = 3;
81  else {
82  edm::LogError ("BadNameString|SiPixel")
83  << "Unable to determine disk number in PixelEndcapName::PixelEndcapName(std::string): "
84  << name;
85  }
86 
87  // get the blade
88  string bladeString = name.substr(name.find("_BLD")+4, name.find("_PNL")-name.find("_BLD")-4);
89  // since atoi() doesn't report errors, do it the long way
90  if (bladeString == "1") theBlade = 1;
91  else if (bladeString == "2") theBlade = 2;
92  else if (bladeString == "3") theBlade = 3;
93  else if (bladeString == "4") theBlade = 4;
94  else if (bladeString == "5") theBlade = 5;
95  else if (bladeString == "6") theBlade = 6;
96  else if (bladeString == "7") theBlade = 7;
97  else if (bladeString == "8") theBlade = 8;
98  else if (bladeString == "9") theBlade = 9;
99  else if (bladeString == "10") theBlade = 10;
100  else if (bladeString == "11") theBlade = 11;
101  else if (bladeString == "12") theBlade = 12;
102  else {
103  edm::LogError ("BadNameString|SiPixel")
104  << "Unable to determine blade number in PixelEndcapName::PixelEndcapName(std::string): "
105  << name;
106  }
107 
108  // find the panel
109  string panelString = name.substr(name.find("_PNL")+4, name.find("_PLQ")-name.find("_PNL")-4);
110  if (panelString == "1") thePannel = 1;
111  else if (panelString == "2") thePannel = 2;
112  else {
113  edm::LogError ("BadNameString|SiPixel")
114  << "Unable to determine panel number in PixelEndcapName::PixelEndcapName(std::string): "
115  << name;
116  }
117 
118  // find the plaquette
119  string plaquetteString = name.substr(name.find("_PLQ")+4, name.size()-name.find("_PLQ")-4);
120  if (plaquetteString == "1") thePlaquette = 1;
121  else if (plaquetteString == "2") thePlaquette = 2;
122  else if (plaquetteString == "3") thePlaquette = 3;
123  else if (plaquetteString == "4") thePlaquette = 4;
124  else {
125  edm::LogError ("BadNameString|SiPixel")
126  << "Unable to determine plaquette number in PixelEndcapName::PixelEndcapName(std::string): "
127  << name;
128  }
129 
130 } // PixelEndcapName::PixelEndcapName(std::string name)
131 
133 {
134  ModuleType type = v1x2;
135  if (pannelName() == 1) {
136  if (plaquetteName() == 1) { type = v1x2; }
137  else if (plaquetteName() == 2) { type = v2x3; }
138  else if (plaquetteName() == 3) { type = v2x4; }
139  else if (plaquetteName() == 4) { type = v1x5; }
140  }
141  else {
142  if (plaquetteName() == 1) { type = v2x3; }
143  else if (plaquetteName() == 2) { type = v2x4; }
144  else if (plaquetteName() == 3) { type = v2x5; }
145  }
146  return type;
147 }
148 
150 {
151  if (!o.isBarrel()) {
152  const PixelEndcapName * other = dynamic_cast<const PixelEndcapName *>(&o);
153  return ( other
154  && thePart == other->thePart
155  && theDisk == other->theDisk
156  && theBlade == other->theBlade
157  && thePannel == other->thePannel
158  && thePlaquette == other->thePlaquette );
159  } else return false;
160 }
161 
162 
163 string PixelEndcapName::name() const
164 {
165  std::ostringstream stm;
166  stm <<"FPix_B"<<thePart<<"_D"<<theDisk<<"_BLD"<<theBlade<<"_PNL"<<thePannel<<"_PLQ"<<thePlaquette;
167  return stm.str();
168 }
169 
170 std::ostream & operator<<( std::ostream& out, const PixelEndcapName::HalfCylinder& t)
171 {
172  switch (t) {
173  case(PixelEndcapName::pI) : {out << "pI"; break;}
174  case(PixelEndcapName::pO) : {out << "pO"; break;}
175  case(PixelEndcapName::mI) : {out << "mI"; break;}
176  case(PixelEndcapName::mO) : {out << "mO"; break;}
177  default: out << "unknown";
178  };
179  return out;
180 }
181 
182 // return the DetId
184 
185  uint32_t side = 0;
186  uint32_t disk = 0;
187  uint32_t blade = 0;
188  uint32_t panel = 0;
189  uint32_t module = 0;
190 
191  // figure out the side
192  HalfCylinder hc = halfCylinder();
193  if (hc == mO || hc == mI) side = 1;
194  else if (hc == pO || hc == pI) side = 2;
195 
196  // get disk/blade/panel/module numbers from PixelEndcapName object
197  disk = static_cast<uint32_t>(diskName());
198  uint32_t tmpBlade = static_cast<uint32_t>(bladeName());
199  panel = static_cast<uint32_t>(pannelName());
200  module = static_cast<uint32_t>(plaquetteName());
201 
202  // convert blade numbering to cmssw convention
203  bool outer = false;
204  outer = (hc == mO) || (hc == pO);
205  if (outer) {
206  blade = tmpBlade + 6;
207  }
208  else { // inner
209  if (tmpBlade <= 6) blade = 7 - tmpBlade;
210  else if (tmpBlade <= 12) blade = 31 - tmpBlade;
211  }
212 
213  // create and return the DetId
214  return PXFDetId(side, disk, blade, panel, module);
215 
216 } // PXFDetId PixelEndcapName::getDetId()
int plaquetteName() const
plaquetteId (in pannel)
type
Definition: HCALResponse.h:22
unsigned int panel() const
panel id
Definition: PXFDetId.h:52
std::ostream & operator<<(std::ostream &out, const ALILine &li)
Definition: ALILine.cc:187
HalfCylinder thePart
unsigned int blade() const
blade id
Definition: PXFDetId.h:48
PixelEndcapName(const DetId &)
ctor from DetId
int bladeName() const
blade id
virtual bool operator==(const PixelModuleName &) const
check equality of modules from datamemebers
unsigned int module() const
det id
Definition: PXFDetId.h:56
unsigned int disk() const
disk id
Definition: PXFDetId.h:43
PXFDetId getDetId()
return DetId
tuple out
Definition: dbtoconf.py:99
virtual bool isBarrel() const
true for barrel modules
Definition: DetId.h:20
virtual PixelModuleName::ModuleType moduleType() const
module Type
virtual std::string name() const
from base class
int pannelName() const
pannel id
unsigned int side() const
positive or negative id
Definition: PXFDetId.h:38
int diskName() const
disk id
HalfCylinder halfCylinder() const
Definition: vlib.h:209