CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
NumbersPn.cc
Go to the documentation of this file.
1 
7 #include <sstream>
8 #include <iomanip>
9 
12 
14 
15 //-------------------------------------------------------------------------
16 
17 // return the PN index [0-79] from EcalPnDiodeDetId.id().iPnId() [0-9];
18 int NumbersPn::ipnEE( const int ism, const int ipnid ) throw( std::runtime_error ) {
19 
20  if( ism >=1 && ism <= 18 ) {
21 
22  int myFED = -1;
23 
24  if( ism == 1 ) myFED = 0;
25  if( ism == 2 ) myFED = 1;
26  if( ism == 5 ) myFED = 2;
27  if( ism == 6 ) myFED = 3;
28  if( ism == 10 ) myFED = 4;
29  if( ism == 11 ) myFED = 5;
30  if( ism == 14 ) myFED = 6;
31  if( ism == 15 ) myFED = 7;
32 
33  return 10*myFED + (ipnid-1);
34 
35  } else {
36 
37  std::ostringstream s;
38  s << "Wrong SM id determination: iSM = " << ism;
39  throw( std::runtime_error( s.str() ) );
40 
41  }
42 
43 }
44 
45 //-------------------------------------------------------------------------
46 
47 // return the list of PNs for a given crystal
48 void NumbersPn::getPNs( const int ism, const int ix, const int iy, std::vector<int>& PNsInLM ) throw( std::runtime_error ) {
49 
50  int ilm = NumbersPn::iLM(ism, ix, iy );
51 
52  PNsInLM.clear();
53 
54  if( ilm == 0 ) {
55  PNsInLM.push_back(25);
56  PNsInLM.push_back(26);
57  PNsInLM.push_back(27);
58  PNsInLM.push_back(28);
59 
60  PNsInLM.push_back(30);
61  PNsInLM.push_back(31);
62  PNsInLM.push_back(32);
63  PNsInLM.push_back(33);
64 
65  return;
66  }
67  if( ilm == 1 ) {
68  PNsInLM.push_back(25);
69  PNsInLM.push_back(26);
70  PNsInLM.push_back(27);
71  PNsInLM.push_back(28);
72 
73  PNsInLM.push_back(30);
74  PNsInLM.push_back(31);
75  PNsInLM.push_back(32);
76  PNsInLM.push_back(33);
77 
78  return;
79  }
80  if( ilm == 2 ) {
81  PNsInLM.push_back(20);
82  PNsInLM.push_back(21);
83  // PNsInLM.push_back(22);
84  PNsInLM.push_back(23);
85  PNsInLM.push_back(24);
86 
87  PNsInLM.push_back(35);
88  PNsInLM.push_back(36);
89  PNsInLM.push_back(37);
90  PNsInLM.push_back(38);
91  PNsInLM.push_back(39);
92 
93  return;
94  }
95  if( ilm == 3 ) {
96  PNsInLM.push_back(20);
97  PNsInLM.push_back(21);
98  // PNsInLM.push_back(22);
99  PNsInLM.push_back(23);
100  PNsInLM.push_back(24);
101 
102  PNsInLM.push_back(35);
103  PNsInLM.push_back(36);
104  PNsInLM.push_back(37);
105  PNsInLM.push_back(38);
106  PNsInLM.push_back(39);
107 
108  return;
109  }
110  if( ilm == 4 ) {
111  PNsInLM.push_back(20);
112  PNsInLM.push_back(21);
113  // PNsInLM.push_back(22);
114  PNsInLM.push_back(23);
115  PNsInLM.push_back(24);
116 
117  PNsInLM.push_back(35);
118  PNsInLM.push_back(36);
119  PNsInLM.push_back(37);
120  PNsInLM.push_back(38);
121  PNsInLM.push_back(39);
122 
123  return;
124  }
125  if( ilm == 5 ) {
126  PNsInLM.push_back(0);
127  PNsInLM.push_back(1);
128  PNsInLM.push_back(2);
129  PNsInLM.push_back(4);
130  // PNsInLM.push_back(9);
131 
132  PNsInLM.push_back(14);
133  PNsInLM.push_back(15);
134  PNsInLM.push_back(16);
135  PNsInLM.push_back(17);
136  PNsInLM.push_back(18);
137 
138  return;
139  }
140  if( ilm == 6 ) {
141  PNsInLM.push_back(0);
142  PNsInLM.push_back(1);
143  PNsInLM.push_back(2);
144  PNsInLM.push_back(4);
145  // PNsInLM.push_back(9);
146 
147  PNsInLM.push_back(14);
148  PNsInLM.push_back(15);
149  PNsInLM.push_back(16);
150  PNsInLM.push_back(17);
151  PNsInLM.push_back(18);
152 
153  return;
154  }
155  if( ilm == 7 ) {
156  PNsInLM.push_back(0);
157  PNsInLM.push_back(1);
158  PNsInLM.push_back(2);
159  PNsInLM.push_back(4);
160 
161  PNsInLM.push_back(15);
162  PNsInLM.push_back(16);
163  PNsInLM.push_back(17);
164  PNsInLM.push_back(18);
165 
166  return;
167  }
168  if( ilm == 8 ) {
169  PNsInLM.push_back(5);
170  PNsInLM.push_back(6);
171  PNsInLM.push_back(7);
172  PNsInLM.push_back(8);
173 
174  PNsInLM.push_back(11);
175  PNsInLM.push_back(12);
176 
177  return;
178  }
179  if( ilm == 9 ) {
180  PNsInLM.push_back(5);
181  PNsInLM.push_back(6);
182  PNsInLM.push_back(7);
183  PNsInLM.push_back(8);
184 
185  PNsInLM.push_back(11);
186  PNsInLM.push_back(12);
187 
188  return;
189  }
190  if( ilm == 10 ) {
191  PNsInLM.push_back(65);
192  PNsInLM.push_back(66);
193  PNsInLM.push_back(67);
194  PNsInLM.push_back(68);
195 
196  PNsInLM.push_back(70);
197  PNsInLM.push_back(71);
198  PNsInLM.push_back(72);
199  PNsInLM.push_back(73);
200 
201  return;
202  }
203  if( ilm == 11 ) {
204  PNsInLM.push_back(65);
205  PNsInLM.push_back(66);
206  PNsInLM.push_back(67);
207  PNsInLM.push_back(68);
208 
209  PNsInLM.push_back(70);
210  PNsInLM.push_back(71);
211  PNsInLM.push_back(72);
212  PNsInLM.push_back(73);
213 
214  return;
215  }
216  if( ilm == 12 ) {
217  PNsInLM.push_back(60);
218  PNsInLM.push_back(61);
219  PNsInLM.push_back(62);
220  PNsInLM.push_back(63);
221  PNsInLM.push_back(64);
222 
223  PNsInLM.push_back(75);
224  PNsInLM.push_back(76);
225  PNsInLM.push_back(78);
226  PNsInLM.push_back(79);
227 
228  return;
229  }
230  if( ilm == 13 ) {
231  PNsInLM.push_back(60);
232  PNsInLM.push_back(61);
233  PNsInLM.push_back(62);
234  PNsInLM.push_back(63);
235  PNsInLM.push_back(64);
236  PNsInLM.push_back(69);
237 
238  PNsInLM.push_back(74);
239  PNsInLM.push_back(75);
240  PNsInLM.push_back(76);
241  PNsInLM.push_back(77);
242  PNsInLM.push_back(78);
243  PNsInLM.push_back(79);
244 
245  return;
246  }
247  if( ilm == 14 ) {
248  PNsInLM.push_back(60);
249  PNsInLM.push_back(61);
250  PNsInLM.push_back(62);
251  PNsInLM.push_back(63);
252  PNsInLM.push_back(64);
253  PNsInLM.push_back(69);
254 
255  PNsInLM.push_back(74);
256  PNsInLM.push_back(75);
257  PNsInLM.push_back(76);
258  PNsInLM.push_back(77);
259  PNsInLM.push_back(78);
260  PNsInLM.push_back(79);
261 
262  return;
263  }
264  if( ilm == 15 ) {
265  PNsInLM.push_back(40);
266  PNsInLM.push_back(41);
267  PNsInLM.push_back(42);
268  PNsInLM.push_back(43);
269  PNsInLM.push_back(44);
270  PNsInLM.push_back(49);
271 
272  PNsInLM.push_back(54);
273  PNsInLM.push_back(55);
274  PNsInLM.push_back(56);
275  PNsInLM.push_back(57);
276  PNsInLM.push_back(58);
277  PNsInLM.push_back(59);
278 
279  return;
280  }
281  if( ilm == 16 ) {
282  PNsInLM.push_back(40);
283  PNsInLM.push_back(41);
284  PNsInLM.push_back(42);
285  PNsInLM.push_back(43);
286  PNsInLM.push_back(44);
287  PNsInLM.push_back(49);
288 
289  PNsInLM.push_back(54);
290  PNsInLM.push_back(55);
291  PNsInLM.push_back(56);
292  PNsInLM.push_back(57);
293  PNsInLM.push_back(58);
294  PNsInLM.push_back(59);
295 
296  return;
297  }
298  if( ilm == 17 ) {
299  PNsInLM.push_back(40);
300  PNsInLM.push_back(41);
301  PNsInLM.push_back(42);
302  PNsInLM.push_back(43);
303  PNsInLM.push_back(44);
304 
305  PNsInLM.push_back(55);
306  PNsInLM.push_back(56);
307  PNsInLM.push_back(58);
308  PNsInLM.push_back(59);
309 
310  return;
311  }
312  if( ilm == 18 ) {
313  PNsInLM.push_back(45);
314  PNsInLM.push_back(46);
315  PNsInLM.push_back(47);
316  PNsInLM.push_back(48);
317 
318  PNsInLM.push_back(50);
319  PNsInLM.push_back(51);
320  PNsInLM.push_back(52);
321  PNsInLM.push_back(53);
322 
323  return;
324  }
325  if( ilm == 19 ) {
326  PNsInLM.push_back(45);
327  PNsInLM.push_back(46);
328  PNsInLM.push_back(47);
329  PNsInLM.push_back(48);
330 
331  PNsInLM.push_back(50);
332  PNsInLM.push_back(51);
333  PNsInLM.push_back(52);
334  PNsInLM.push_back(53);
335 
336  return;
337  }
338 
339  std::ostringstream s;
340  s << "Wrong LM id determination: iLM = " << ilm;
341  throw( std::runtime_error( s.str() ) );
342 
343 }
344 
345 //-------------------------------------------------------------------------
346 
347 // return the LM for a given crystal
348 int NumbersPn::iLM( const int ism, const int ix, const int iy ) throw( std::runtime_error ) {
349 
350  int iz = 0;
351 
352  if( ism >= 1 && ism <= 9 ) iz = -1;
353  if( ism >= 10 && ism <= 18 ) iz = +1;
354 
355  if( EEDetId::validDetId(ix, iy, iz) ) {
356 
357  // EE-
358  if( ism == 1 ) return 7;
359  if( ism == 2 ) return 8;
360  if( ism == 3 ) return 9;
361  if( ism == 4 ) return 0;
362  if( ism == 5 ) return 1;
363  if( ism == 6 ) return 2;
364  if( ism == 7 ) return 3;
365  if( ism == 8 ) {
366  if(ix<=50) return 4;
367  else return 5;
368  }
369  if( ism == 9 ) return 6;
370 
371  // EE+
372  if( ism == 10 ) return 17;
373  if( ism == 11 ) return 18;
374  if( ism == 12 ) return 19;
375  if( ism == 13 ) return 10;
376  if( ism == 14 ) return 11;
377  if( ism == 15 ) return 12;
378  if( ism == 16 ) return 13;
379  if( ism == 17 ) {
380  if(ix<=50) return 14;
381  else return 15;
382  }
383  if( ism == 18 ) return 16;
384 
385  }
386 
387  std::ostringstream s;
388  s << "Wrong LM id determination: iSM = " << ism << " ix = " << ix << " iy = " << iy;
389  throw( std::runtime_error( s.str() ) );
390 
391 }
392 
393 //-------------------------------------------------------------------------
394 
Some &quot;id&quot; conversions.
static int ipnEE(const int ism, const int ipnid)
Definition: NumbersPn.cc:18
static bool validDetId(int crystal_ix, int crystal_iy, int iz)
Definition: EEDetId.h:248
static int iLM(const int ism, const int ix, const int iy)
Definition: NumbersPn.cc:348
static void getPNs(const int ism, const int ix, const int iy, std::vector< int > &PNsInLM)
Definition: NumbersPn.cc:48
int ism(int ieta, int iphi)
Definition: EcalPyUtils.cc:56