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