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