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
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  if (!o.isBarrel()) {
178  const PixelEndcapNameUpgrade* other = dynamic_cast<const PixelEndcapNameUpgrade*>(&o);
179  return (other && thePart == other->thePart && theDisk == other->theDisk && theBlade == other->theBlade &&
180  thePannel == other->thePannel && thePlaquette == other->thePlaquette);
181  } else
182  return false;
183 }
184 
186  std::ostringstream stm;
187  stm << "FPix_B" << thePart << "_D" << theDisk << "_BLD" << theBlade << "_PNL" << thePannel << "_PLQ" << thePlaquette;
188  return stm.str();
189 }
190 
191 std::ostream& operator<<(std::ostream& out, const PixelEndcapNameUpgrade::HalfCylinder& t) {
192  switch (t) {
194  out << "pI";
195  break;
196  }
198  out << "pO";
199  break;
200  }
202  out << "mI";
203  break;
204  }
206  out << "mO";
207  break;
208  }
209  default:
210  out << "unknown";
211  };
212  return out;
213 }
214 
215 // return the DetId
217  uint32_t side = 0;
218  uint32_t disk = 0;
219  uint32_t blade = 0;
220  uint32_t panel = 0;
221  uint32_t module = 0;
222 
223  // figure out the side
225  if (hc == mO || hc == mI)
226  side = 1;
227  else if (hc == pO || hc == pI)
228  side = 2;
229 
230  // get disk/blade/panel/module numbers from PixelEndcapNameUpgrade object
231  disk = static_cast<uint32_t>(diskName());
232  uint32_t tmpBlade = static_cast<uint32_t>(bladeName());
233  panel = static_cast<uint32_t>(pannelName());
234  module = static_cast<uint32_t>(plaquetteName());
235 
236  // convert blade numbering to cmssw convention
237  bool outer = false;
238  outer = (hc == mO) || (hc == pO);
239  /*
240  //iasonas1
241  if (outer) {blade = 57 - tmpBlade;}
242  else {blade = 23 - tmpBlade;}
243 
244 */
245  //iasonas2 m/pI:1-6,18-31,49-56. m/pO:7-17,32-48.
246  if (outer) {
247  if (tmpBlade >= 7 && tmpBlade <= 17)
248  theBlade = tmpBlade + 6;
249  else if (tmpBlade >= 32 && tmpBlade <= 48)
250  theBlade = 60 - tmpBlade;
251  } else { //inner
252  if (tmpBlade <= 6)
253  theBlade = 7 - tmpBlade;
254  else if (tmpBlade >= 18 && tmpBlade <= 31)
255  theBlade = 38 - tmpBlade;
256  else if (tmpBlade >= 49 && tmpBlade <= 56)
257  theBlade = 77 - tmpBlade;
258  }
259 
260  // create and return the DetId
261  return PXFDetId(side, disk, blade, panel, module);
262 
263 } // PXFDetId PixelEndcapNameUpgrade::getDetId()
std::ostream & operator<<(std::ostream &out, const PixelEndcapNameUpgrade::HalfCylinder &t)
type
Definition: HCALResponse.h:21
PixelModuleName::ModuleType moduleType() const override
module Type
unsigned int panel() const
panel id
Definition: PXFDetId.h:41
PXFDetId getDetId()
return DetId
bool operator==(const PixelModuleName &) const override
check equality of modules from datamemebers
int plaquetteName() const
plaquetteId (in pannel)
unsigned int blade() const
blade id
Definition: PXFDetId.h:38
PixelEndcapNameUpgrade(const DetId &)
ctor from DetId
std::string name() const override
from base class
unsigned int module() const
det id
Definition: PXFDetId.h:44
int bladeName() const
blade id
unsigned int disk() const
disk id
Definition: PXFDetId.h:35
int diskName() const
disk id
virtual bool isBarrel() const
true for barrel modules
Definition: DetId.h:18
susybsm::HSCParticleCollection hc
Definition: classes.h:25
unsigned int side() const
positive or negative id
Definition: PXFDetId.h:32
HalfCylinder halfCylinder() const
int pannelName() const
pannel id
Definition: vlib.h:208