CMS 3D CMS Logo

HGCalWaferMask.cc
Go to the documentation of this file.
5 
6 #include <algorithm>
7 //#define EDM_ML_DEBUG
8 
9 bool HGCalWaferMask::maskCell(int u, int v, int n, int ncor, int fcor, int corners) {
10  /*
11 Masks each cell (or not) according to its wafer and cell position (detId) and to the user needs (corners).
12 Each wafer has k_CornerSize corners which are defined in anti-clockwise order starting from the corner at the top, which is always #0. 'ncor' denotes the number of corners inside the physical region. 'fcor' is the defined to be the first corner that appears inside the detector's physical volume in anti-clockwise order.
13 The argument 'corners' controls the types of wafers the user wants: for instance, corners=3 masks all wafers that have at least 3 corners inside the physical region.
14  */
15  bool mask(false);
16  if (ncor < corners) {
17  mask = true;
18  } else {
19  if (ncor == HGCalGeomTools::k_fourCorners) {
20  switch (fcor) {
21  case (0): {
22  mask = (v >= n);
23  break;
24  }
25  case (1): {
26  mask = (u >= n);
27  break;
28  }
29  case (2): {
30  mask = (u > v);
31  break;
32  }
33  case (3): {
34  mask = (v < n);
35  break;
36  }
37  case (4): {
38  mask = (u < n);
39  break;
40  }
41  default: {
42  mask = (u <= v);
43  break;
44  }
45  }
46  } else {
47  switch (fcor) {
48  case (0): {
49  if (ncor == HGCalGeomTools::k_threeCorners) {
50  mask = !((u > 2 * v) && (v < n));
51  } else {
52  mask = ((u >= n) && (v >= n) && ((u + v) > (3 * n - 2)));
53  }
54  break;
55  }
56  case (1): {
57  if (ncor == HGCalGeomTools::k_threeCorners) {
58  mask = !((u + v) < n);
59  } else {
60  mask = ((u >= n) && (u > v) && ((2 * u - v) > 2 * n));
61  }
62  break;
63  }
64  case (2): {
65  if (ncor == HGCalGeomTools::k_threeCorners) {
66  mask = !((u < n) && (v > u) && (v > (2 * u - 1)));
67  } else {
68  mask = ((u > 2 * v) && (v < n));
69  }
70  break;
71  }
72  case (3): {
73  if (ncor == HGCalGeomTools::k_threeCorners) {
74  mask = !((v >= u) && ((2 * v - u) > (2 * n - 2)));
75  } else {
76  mask = ((u + v) < n);
77  }
78  break;
79  }
80  case (4): {
81  if (ncor == HGCalGeomTools::k_threeCorners) {
82  mask = !((u >= n) && (v >= n) && ((u + v) > (3 * n - 2)));
83  } else {
84  mask = ((u < n) && (v > u) && (v > (2 * u - 1)));
85  }
86  break;
87  }
88  default: {
89  if (ncor == HGCalGeomTools::k_threeCorners) {
90  mask = !((u >= n) && (u > v) && ((2 * u - v) > 2 * n));
91  } else {
92  mask = ((v >= u) && ((2 * v - u) > (2 * n - 2)));
93  }
94  break;
95  }
96  }
97  }
98  }
99 #ifdef EDM_ML_DEBUG
100  edm::LogVerbatim("HGCalGeom") << "Corners: " << ncor << ":" << fcor << " N " << n << " u " << u << " v " << v
101  << " Mask " << mask;
102 #endif
103  return mask;
104 }
105 
106 bool HGCalWaferMask::goodCell(int u, int v, int n, int type, int rotn) {
107  bool good(false);
108  int n2 = n / 2;
109  int n4 = n / 4;
110  switch (type) {
111  case (HGCalTypes::WaferFull): { //WaferFull
112  good = true;
113  break;
114  }
115  case (HGCalTypes::WaferFive): { //WaferFive
116  switch (rotn) {
117  case (HGCalTypes::WaferCorner0): {
118  int u2 = u / 2;
119  good = ((v - u2) < n);
120  break;
121  }
122  case (HGCalTypes::WaferCorner1): {
123  good = ((v + u) < (3 * n - 1));
124  break;
125  }
126  case (HGCalTypes::WaferCorner2): {
127  int v2 = (v + 1) / 2;
128  good = ((u - v2) < n);
129  break;
130  }
131  case (HGCalTypes::WaferCorner3): {
132  int u2 = (u + 1) / 2;
133  good = (u2 <= v);
134  break;
135  }
136  case (HGCalTypes::WaferCorner4): {
137  good = ((v + u) >= n);
138  break;
139  }
140  default: {
141  int v2 = v / 2;
142  good = (u > v2);
143  break;
144  }
145  }
146  break;
147  }
148  case (HGCalTypes::WaferChopTwo): { //WaferChopTwo
149  switch (rotn) {
150  case (HGCalTypes::WaferCorner0): {
151  good = (v < (3 * n2));
152  break;
153  }
154  case (HGCalTypes::WaferCorner1): {
155  good = (u < (3 * n2));
156  break;
157  }
158  case (HGCalTypes::WaferCorner2): {
159  good = ((u - v) <= n2);
160  break;
161  }
162  case (HGCalTypes::WaferCorner3): {
163  good = (v >= n2);
164  break;
165  }
166  case (HGCalTypes::WaferCorner4): {
167  good = (u >= n2);
168  break;
169  }
170  default: {
171  good = ((v - u) < n2);
172  break;
173  }
174  }
175  break;
176  }
177  case (HGCalTypes::WaferChopTwoM): { //WaferChopTwoM
178  switch (rotn) {
179  case (HGCalTypes::WaferCorner0): {
180  good = (v < (5 * n4));
181  break;
182  }
183  case (HGCalTypes::WaferCorner1): {
184  good = (u < (5 * n4));
185  break;
186  }
187  case (HGCalTypes::WaferCorner2): {
188  good = ((u - v) <= n4);
189  break;
190  }
191  case (HGCalTypes::WaferCorner3): {
192  good = (v >= (3 * n4));
193  break;
194  }
195  case (HGCalTypes::WaferCorner4): {
196  good = (u >= (3 * n4));
197  break;
198  }
199  default: {
200  good = ((v - u) < n4);
201  break;
202  }
203  }
204  break;
205  }
206  case (HGCalTypes::WaferHalf): { //WaferHalf
207  switch (rotn) {
208  case (HGCalTypes::WaferCorner0): {
209  good = (v < n);
210  break;
211  }
212  case (HGCalTypes::WaferCorner1): {
213  good = (u < n);
214  break;
215  }
216  case (HGCalTypes::WaferCorner2): {
217  good = (v >= u);
218  break;
219  }
220  case (HGCalTypes::WaferCorner3): {
221  good = (v >= n);
222  break;
223  }
224  case (HGCalTypes::WaferCorner4): {
225  good = (u >= n);
226  break;
227  }
228  default: {
229  good = (u > v);
230  break;
231  }
232  }
233  break;
234  }
235  case (HGCalTypes::WaferSemi): { //WaferSemi
236  switch (rotn) {
237  case (HGCalTypes::WaferCorner0): {
238  good = ((u + v) < (2 * n));
239  break;
240  }
241  case (HGCalTypes::WaferCorner1): {
242  good = ((2 * u - v) < n);
243  break;
244  }
245  case (HGCalTypes::WaferCorner2): {
246  good = ((2 * v - u) >= n);
247  break;
248  }
249  case (HGCalTypes::WaferCorner3): {
250  good = ((u + v) >= (2 * n));
251  break;
252  }
253  case (HGCalTypes::WaferCorner4): {
254  good = ((2 * u - v) > n);
255  break;
256  }
257  default: {
258  good = ((2 * v - u) < n);
259  break;
260  }
261  }
262  break;
263  }
264  case (HGCalTypes::WaferThree): { //WaferThree
265  switch (rotn) {
266  case (HGCalTypes::WaferCorner0): {
267  good = ((v + u) < n);
268  break;
269  }
270  case (HGCalTypes::WaferCorner1): {
271  int v2 = v / 2;
272  good = (u <= v2);
273  break;
274  }
275  case (HGCalTypes::WaferCorner2): {
276  int u2 = (u / 2);
277  good = ((v - u2) >= n);
278  break;
279  }
280  case (HGCalTypes::WaferCorner3): {
281  good = ((v + u) >= (3 * n - 1));
282  break;
283  }
284  case (HGCalTypes::WaferCorner4): {
285  int v2 = ((v + 1) / 2);
286  good = ((u - v2) >= n);
287  break;
288  }
289  default: {
290  int u2 = ((u + 1) / 2);
291  good = (v < u2);
292  break;
293  }
294  }
295  break;
296  }
297  case (HGCalTypes::WaferSemi2): { //WaferSemi2
298  switch (rotn) {
299  case (HGCalTypes::WaferCorner0): {
300  int n3 = (n + 1) / 3;
301  good = ((u + v) < (4 * n3));
302  break;
303  }
304  case (HGCalTypes::WaferCorner1): {
305  good = ((2 * u - v) < n2);
306  break;
307  }
308  case (HGCalTypes::WaferCorner2): {
309  int u2 = ((u + 1) / 2);
310  good = ((v - u2) >= (3 * n4));
311  break;
312  }
313  case (HGCalTypes::WaferCorner3): {
314  good = ((u + v) >= (5 * n2));
315  break;
316  }
317  case (HGCalTypes::WaferCorner4): {
318  good = ((2 * u - v) > (3 * n2));
319  break;
320  }
321  default: {
322  int u2 = ((n == 8) ? ((u + 1) / 2) : (u / 2));
323  good = ((v - u2) < n4);
324  break;
325  }
326  }
327  break;
328  }
329  }
330 #ifdef EDM_ML_DEBUG
331  edm::LogVerbatim("HGCalGeom") << "u|v " << u << ":" << v << " N " << n << " type " << type << " rot " << rotn
332  << " good " << good;
333 #endif
334  return good;
335 }
336 
337 int HGCalWaferMask::getRotation(int zside, int type, int rotn) {
338  if (rotn >= HGCalTypes::WaferCornerMax)
340  int newrotn(rotn);
341  if ((zside < 0) && (type != HGCalTypes::WaferFull)) {
342  if (type == HGCalTypes::WaferFive) { //WaferFive
343  static const int rot1[HGCalTypes::WaferCornerMax] = {HGCalTypes::WaferCorner4,
349  newrotn = rot1[rotn];
350  } else if ((type == HGCalTypes::WaferThree) || (type == HGCalTypes::WaferSemi) ||
351  (type == HGCalTypes::WaferSemi2)) { //WaferThree/WaferSemi/WaferSemi2
352  static const int rot2[HGCalTypes::WaferCornerMax] = {HGCalTypes::WaferCorner2,
358  newrotn = rot2[rotn];
359  } else { //WaferHalf/WaferChopTwo/WaferChopTwoM
360  static const int rot3[HGCalTypes::WaferCornerMax] = {HGCalTypes::WaferCorner3,
366  newrotn = rot3[rotn];
367  }
368  }
369 #ifdef EDM_ML_DEBUG
370  edm::LogVerbatim("HGCalGeom") << "zside " << zside << " type " << type << " rotn " << rotn << ":" << newrotn;
371 #endif
372  return newrotn;
373 }
374 
375 std::pair<int, int> HGCalWaferMask::getTypeMode(const double& xpos,
376  const double& ypos,
377  const double& delX,
378  const double& delY,
379  const double& rin,
380  const double& rout,
381  const int& wType,
382  const int& mode,
383  bool debug) {
384  int ncor(0), iok(0);
386 
387  static const int corners = 6;
388  static const int base = 10;
389  double rin2 = rin * rin;
390  double rout2 = rout * rout;
391  double dx0[corners] = {
392  0.0, HGCalTypes::c10 * delX, HGCalTypes::c10 * delX, 0.0, -HGCalTypes::c10 * delX, -HGCalTypes::c10 * delX};
393  double dy0[corners] = {-HGCalTypes::c10 * delY,
394  -HGCalTypes::c50 * delY,
395  HGCalTypes::c50 * delY,
396  HGCalTypes::c10 * delY,
397  HGCalTypes::c50 * delY,
398  -HGCalTypes::c50 * delY};
399  double xc[corners], yc[corners];
400  for (int k = 0; k < corners; ++k) {
401  xc[k] = xpos + dx0[k];
402  yc[k] = ypos + dy0[k];
403  double rpos2 = (xc[k] * xc[k] + yc[k] * yc[k]);
404  if (rpos2 <= rout2 && rpos2 >= rin2) {
405  ++ncor;
406  iok = iok * base + 1;
407  } else {
408  iok *= base;
409  }
410  }
411  if (debug)
412  edm::LogVerbatim("HGCalGeom") << "I/p " << xpos << ":" << ypos << ":" << delX << ":" << delY << ":" << rin << ":"
413  << rout << ":" << wType << ":" << mode << " Corners " << ncor << " iok " << iok;
414 
415  static const int ipat5[corners] = {101111, 110111, 111011, 111101, 111110, 11111};
416  static const int ipat4[corners] = {100111, 110011, 111001, 111100, 11110, 1111};
417  static const int ipat3[corners] = {100011, 110001, 111000, 11100, 1110, 111};
418  double dx1[corners] = {HGCalTypes::c50 * delX,
419  HGCalTypes::c10 * delX,
420  HGCalTypes::c50 * delX,
421  -HGCalTypes::c50 * delX,
422  -HGCalTypes::c10 * delX,
423  -HGCalTypes::c50 * delX};
424  double dy1[corners] = {
425  -HGCalTypes::c75 * delY, 0.0, HGCalTypes::c75 * delY, HGCalTypes::c75 * delY, 0.0, -HGCalTypes::c75 * delY};
426  double dx2[corners] = {HGCalTypes::c50 * delX,
427  -HGCalTypes::c50 * delX,
428  -HGCalTypes::c10 * delX,
429  -HGCalTypes::c50 * delX,
430  HGCalTypes::c50 * delX,
431  HGCalTypes::c10 * delX};
432  double dy2[corners] = {
433  HGCalTypes::c75 * delY, HGCalTypes::c75 * delY, 0.0, -HGCalTypes::c75 * delY, -HGCalTypes::c75 * delY, 0.0};
434  double dx3[corners] = {
435  HGCalTypes::c22 * delX, delX, HGCalTypes::c77 * delX, -HGCalTypes::c22 * delX, -delX, -HGCalTypes::c77 * delX};
436  double dy3[corners] = {-HGCalTypes::c88 * delY,
437  -HGCalTypes::c27 * delY,
438  HGCalTypes::c61 * delY,
439  HGCalTypes::c88 * delY,
440  HGCalTypes::c27 * delY,
441  -HGCalTypes::c61 * delY};
442  double dx4[corners] = {HGCalTypes::c22 * delX,
443  -HGCalTypes::c77 * delX,
444  -delX,
445  -HGCalTypes::c22 * delX,
446  HGCalTypes::c77 * delX,
447  HGCalTypes::c10 * delX};
448  double dy4[corners] = {HGCalTypes::c88 * delY,
449  HGCalTypes::c61 * delY,
450  -HGCalTypes::c27 * delY,
451  -HGCalTypes::c88 * delY,
452  -HGCalTypes::c61 * delY,
453  HGCalTypes::c27 * delY};
454  double dx5[corners] = {-HGCalTypes::c50 * delX,
455  -HGCalTypes::c10 * delX,
456  -HGCalTypes::c50 * delX,
457  HGCalTypes::c50 * delX,
458  HGCalTypes::c10 * delX,
459  HGCalTypes::c50 * delX};
460  double dy5[corners] = {
461  HGCalTypes::c75 * delY, 0.0, -HGCalTypes::c75 * delY, -HGCalTypes::c75 * delY, 0.0, HGCalTypes::c75 * delY};
462  double dx6[corners] = {-HGCalTypes::c77 * delX,
463  -HGCalTypes::c10 * delX,
464  -HGCalTypes::c22 * delX,
465  HGCalTypes::c77 * delX,
466  HGCalTypes::c10 * delX,
467  HGCalTypes::c22 * delX};
468  double dy6[corners] = {HGCalTypes::c61 * delY,
469  -HGCalTypes::c27 * delY,
470  -HGCalTypes::c88 * delY,
471  -HGCalTypes::c61 * delY,
472  HGCalTypes::c27 * delY,
473  HGCalTypes::c88 * delY};
474 
475  if (ncor == HGCalGeomTools::k_allCorners) {
476  } else if (ncor == HGCalGeomTools::k_fiveCorners) {
477  rotn = static_cast<int>(std::find(ipat5, ipat5 + 6, iok) - ipat5);
479  } else if (ncor == HGCalGeomTools::k_fourCorners) {
480  rotn = static_cast<int>(std::find(ipat4, ipat4 + 6, iok) - ipat4);
482  double rpos12 = ((xpos + dx1[rotn]) * (xpos + dx1[rotn]) + (ypos + dy1[rotn]) * (ypos + dy1[rotn]));
483  double rpos22(0);
484  if (rpos12 <= rout2 && rpos12 >= rin2) {
485  rpos22 = ((xpos + dx2[rotn]) * (xpos + dx2[rotn]) + (ypos + dy2[rotn]) * (ypos + dy2[rotn]));
486  if (rpos22 <= rout2 && rpos22 >= rin2)
488  }
489  if (debug)
490  edm::LogVerbatim("HGCalGeom") << "Test for Chop2 " << std::sqrt(rpos12) << ":" << std::sqrt(rpos22) << " Type "
491  << type;
492  if ((type == HGCalTypes::WaferHalf) && (wType == 0)) {
493  rpos12 = ((xpos + dx3[rotn]) * (xpos + dx3[rotn]) + (ypos + dy3[rotn]) * (ypos + dy3[rotn]));
494  if (rpos12 <= rout2 && rpos12 >= rin2) {
495  rpos22 = ((xpos + dx4[rotn]) * (xpos + dx4[rotn]) + (ypos + dy4[rotn]) * (ypos + dy4[rotn]));
496  if (rpos22 <= rout2 && rpos22 >= rin2)
498  }
499  if (debug)
500  edm::LogVerbatim("HGCalGeom") << "Test for Chop2M " << std::sqrt(rpos12) << ":" << std::sqrt(rpos22) << " Type "
501  << type;
502  }
503  } else if (ncor == HGCalGeomTools::k_threeCorners) {
504  rotn = static_cast<int>(std::find(ipat3, ipat3 + 6, iok) - ipat3);
506  double rpos12 = ((xpos + dx1[rotn]) * (xpos + dx1[rotn]) + (ypos + dy1[rotn]) * (ypos + dy1[rotn]));
507  double rpos22(0);
508  if (rpos12 <= rout2 && rpos12 >= rin2) {
509  rpos22 = ((xpos + dx5[rotn]) * (xpos + dx5[rotn]) + (ypos + dy5[rotn]) * (ypos + dy5[rotn]));
510  if (rpos22 <= rout2 && rpos22 >= rin2)
512  }
513  if (debug)
514  edm::LogVerbatim("HGCalGeom") << "Test for Semi " << std::sqrt(rpos12) << ":" << std::sqrt(rpos22) << " Type "
515  << type;
516  if ((type == HGCalTypes::WaferThree) && (wType == 0)) {
517  rpos12 = ((xpos + dx3[rotn]) * (xpos + dx3[rotn]) + (ypos + dy3[rotn]) * (ypos + dy3[rotn]));
518  if (rpos12 <= rout2 && rpos12 >= rin2) {
519  rpos22 = ((xpos + dx6[rotn]) * (xpos + dx6[rotn]) + (ypos + dy6[rotn]) * (ypos + dy6[rotn]));
520  if (rpos22 <= rout2 && rpos22 >= rin2)
522  }
523  if (debug)
524  edm::LogVerbatim("HGCalGeom") << "Test for SemiM " << std::sqrt(rpos12) << ":" << std::sqrt(rpos22) << " Type "
525  << type;
526  }
527  } else {
529  }
530 
531  if (debug)
532  edm::LogVerbatim("HGCalGeom") << "I/p " << xpos << ":" << ypos << ":" << delX << ":" << delY << ":" << rin << ":"
533  << rout << ":" << wType << ":" << mode << " o/p " << iok << ":" << ncor << ":" << type
534  << ":" << rotn;
535  return ((mode == 0) ? std::make_pair(ncor, rotn) : std::make_pair(type, (rotn + HGCalWaferMask::k_OffsetRotation)));
536 }
537 
539  double xpos, double ypos, double delX, double delY, double rin, double rout, int part, int rotn, bool debug) {
541  return false;
542  if (rotn < 0 || rotn > HGCalTypes::WaferCornerMax)
543  return false;
544  double rin2 = rin * rin;
545  double rout2 = rout * rout;
546  static const int corners = HGCalTypes::WaferCornerMax;
547  static const int corner2 = 2 * HGCalTypes::WaferCornerMax;
548  static const int base = 10;
549  static const int base2 = 100;
550  double dx0[corners] = {
551  0.0, HGCalTypes::c10 * delX, HGCalTypes::c10 * delX, 0.0, -HGCalTypes::c10 * delX, -HGCalTypes::c10 * delX};
552  double dy0[corners] = {-HGCalTypes::c10 * delY,
553  -HGCalTypes::c50 * delY,
554  HGCalTypes::c50 * delY,
555  HGCalTypes::c10 * delY,
556  HGCalTypes::c50 * delY,
557  -HGCalTypes::c50 * delY};
558  double dx1[corners] = {HGCalTypes::c50 * delX,
559  HGCalTypes::c10 * delX,
560  HGCalTypes::c50 * delX,
561  -HGCalTypes::c50 * delX,
562  -HGCalTypes::c10 * delX,
563  -HGCalTypes::c50 * delX};
564  double dy1[corners] = {
565  -HGCalTypes::c75 * delY, 0.0, HGCalTypes::c75 * delY, HGCalTypes::c75 * delY, 0.0, -HGCalTypes::c75 * delY};
566  double dx2[corner2] = {HGCalTypes::c22 * delX,
567  HGCalTypes::c77 * delX,
568  HGCalTypes::c10 * delX,
569  HGCalTypes::c10 * delX,
570  HGCalTypes::c77 * delX,
571  HGCalTypes::c22 * delX,
572  -HGCalTypes::c22 * delX,
573  -HGCalTypes::c77 * delX,
574  -HGCalTypes::c10 * delX,
575  -HGCalTypes::c10 * delX,
576  -HGCalTypes::c77 * delX,
577  -HGCalTypes::c22 * delX};
578  double dy2[corner2] = {-HGCalTypes::c88 * delY,
579  -HGCalTypes::c61 * delY,
580  -HGCalTypes::c27 * delY,
581  HGCalTypes::c27 * delY,
582  HGCalTypes::c61 * delY,
583  HGCalTypes::c88 * delY,
584  HGCalTypes::c88 * delY,
585  HGCalTypes::c61 * delY,
586  HGCalTypes::c27 * delY,
587  -HGCalTypes::c27 * delY,
588  -HGCalTypes::c61 * delY,
589  -HGCalTypes::c88 * delY};
590  bool ok(true);
591  int ncf(-1);
592  switch (part) {
593  case (HGCalTypes::WaferThree): {
594  static const int nc0[corners] = {450, 150, 201, 312, 423, 534};
595  int nc = nc0[rotn];
596  for (int k1 = 0; k1 < 3; ++k1) {
597  int k = nc % base;
598  double xc1 = xpos + dx0[k];
599  double yc1 = ypos + dy0[k];
600  double rpos2 = (xc1 * xc1 + yc1 * yc1);
601  if ((rpos2 > rout2) || (rpos2 < rin2)) {
602  ok = false;
603  ncf = k;
604  break;
605  }
606  nc /= base;
607  }
608  break;
609  }
610  case (HGCalTypes::WaferSemi2): {
611  static const int nc10[corners] = {450, 150, 201, 312, 423, 534};
612  static const int nc11[corners] = {700, 902, 1104, 106, 308, 510};
613  int nc = nc10[rotn];
614  for (int k1 = 0; k1 < 3; ++k1) {
615  int k = nc % base;
616  double xc1 = xpos + dx0[k];
617  double yc1 = ypos + dy0[k];
618  double rpos2 = (xc1 * xc1 + yc1 * yc1);
619  if ((rpos2 > rout2) || (rpos2 < rin2)) {
620  ok = false;
621  ncf = k;
622  break;
623  }
624  nc /= base;
625  }
626  nc = nc11[rotn];
627  for (int k1 = 0; k1 < 2; ++k1) {
628  int k = nc % base2;
629  double xc1 = xpos + dx2[k];
630  double yc1 = ypos + dy2[k];
631  double rpos2 = (xc1 * xc1 + yc1 * yc1);
632  if ((rpos2 > rout2) || (rpos2 < rin2)) {
633  ok = false;
634  ncf = k + base2;
635  break;
636  }
637  nc /= base2;
638  }
639  break;
640  }
641  case (HGCalTypes::WaferSemi): {
642  static const int nc20[corners] = {450, 150, 201, 312, 423, 534};
643  static const int nc21[corners] = {30, 14, 25, 30, 41, 52};
644  int nc = nc20[rotn];
645  for (int k1 = 0; k1 < 3; ++k1) {
646  int k = nc % base;
647  double xc1 = xpos + dx0[k];
648  double yc1 = ypos + dy0[k];
649  double rpos2 = (xc1 * xc1 + yc1 * yc1);
650  if ((rpos2 > rout2) || (rpos2 < rin2)) {
651  ok = false;
652  ncf = k;
653  break;
654  }
655  nc /= base;
656  }
657  nc = nc21[rotn];
658  for (int k1 = 0; k1 < 2; ++k1) {
659  int k = nc % base;
660  double xc1 = xpos + dx1[k];
661  double yc1 = ypos + dy1[k];
662  double rpos2 = (xc1 * xc1 + yc1 * yc1);
663  if ((rpos2 > rout2) || (rpos2 < rin2)) {
664  ok = false;
665  ncf = k + base2;
666  break;
667  }
668  nc /= base;
669  }
670  break;
671  }
672  case (HGCalTypes::WaferHalf): {
673  static const int nc3[corners] = {3450, 1450, 2501, 3012, 4123, 5234};
674  int nc = nc3[rotn];
675  for (int k1 = 0; k1 < 4; ++k1) {
676  int k = nc % base;
677  double xc1 = xpos + dx0[k];
678  double yc1 = ypos + dy0[k];
679  double rpos2 = (xc1 * xc1 + yc1 * yc1);
680  if ((rpos2 > rout2) || (rpos2 < rin2)) {
681  ok = false;
682  ncf = k;
683  break;
684  }
685  nc /= base;
686  }
687  break;
688  }
689  case (HGCalTypes::WaferChopTwoM): {
690  static const int nc40[corners] = {3450, 1450, 2501, 3012, 4123, 5234};
691  static const int nc41[corners] = {500, 702, 904, 1106, 108, 310};
692  int nc = nc40[rotn];
693  for (int k1 = 0; k1 < 4; ++k1) {
694  int k = nc % base;
695  double xc1 = xpos + dx0[k];
696  double yc1 = ypos + dy0[k];
697  double rpos2 = (xc1 * xc1 + yc1 * yc1);
698  if ((rpos2 > rout2) || (rpos2 < rin2)) {
699  ok = false;
700  ncf = k;
701  break;
702  }
703  nc /= base;
704  }
705  nc = nc41[rotn];
706  for (int k1 = 0; k1 < 2; ++k1) {
707  int k = nc % base2;
708  double xc1 = xpos + dx2[k];
709  double yc1 = ypos + dy2[k];
710  double rpos2 = (xc1 * xc1 + yc1 * yc1);
711  if ((rpos2 > rout2) || (rpos2 < rin2)) {
712  ok = false;
713  ncf = k + base2;
714  break;
715  }
716  nc /= base2;
717  }
718  break;
719  }
720  case (HGCalTypes::WaferChopTwo): {
721  static const int nc50[corners] = {3450, 1450, 2501, 3012, 4123, 5234};
722  static const int nc51[corners] = {20, 13, 24, 35, 40, 51};
723  int nc = nc50[rotn];
724  for (int k1 = 0; k1 < 4; ++k1) {
725  int k = nc % base;
726  double xc1 = xpos + dx0[k];
727  double yc1 = ypos + dy0[k];
728  double rpos2 = (xc1 * xc1 + yc1 * yc1);
729  if ((rpos2 > rout2) || (rpos2 < rin2)) {
730  ok = false;
731  ncf = k;
732  break;
733  }
734  nc /= base;
735  }
736  nc = nc51[rotn];
737  for (int k1 = 0; k1 < 2; ++k1) {
738  int k = nc % base;
739  double xc1 = xpos + dx1[k];
740  double yc1 = ypos + dy1[k];
741  double rpos2 = (xc1 * xc1 + yc1 * yc1);
742  if ((rpos2 > rout2) || (rpos2 < rin2)) {
743  ok = false;
744  ncf = k + base2;
745  break;
746  }
747  nc /= base;
748  }
749  break;
750  }
751  case (HGCalTypes::WaferFive): {
752  static const int nc6[corners] = {23450, 13450, 24501, 35012, 40123, 51234};
753  int nc = nc6[rotn];
754  for (int k1 = 0; k1 < 5; ++k1) {
755  int k = nc % base;
756  double xc1 = xpos + dx0[k];
757  double yc1 = ypos + dy0[k];
758  double rpos2 = (xc1 * xc1 + yc1 * yc1);
759  if ((rpos2 > rout2) || (rpos2 < rin2)) {
760  ok = false;
761  ncf = k;
762  break;
763  }
764  }
765  break;
766  }
767  default: {
768  for (int k = 0; k < corners; ++k) {
769  double xc1 = xpos + dx0[k];
770  double yc1 = ypos + dy0[k];
771  double rpos2 = (xc1 * xc1 + yc1 * yc1);
772  if ((rpos2 > rout2) || (rpos2 < rin2)) {
773  ok = false;
774  ncf = k;
775  break;
776  }
777  }
778  break;
779  }
780  }
781  if (debug)
782  edm::LogVerbatim("HGCalGeom") << "I/p "
783  << ":" << xpos << ":" << ypos << ":" << delX << ":" << delY << ":" << rin << ":"
784  << rout << ":" << part << ":" << rotn << " Results " << ok << ":" << ncf;
785  return ok;
786 }
HGCalTypes::WaferChopTwo
Definition: HGCalTypes.h:52
MessageLogger.h
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
HGCalWaferMask::goodCell
static bool goodCell(int u, int v, int N, int type, int rotn)
Definition: HGCalWaferMask.cc:106
HGCalTypes::WaferCornerMax
static constexpr int32_t WaferCornerMax
Definition: HGCalTypes.h:62
ecaldqm::zside
int zside(DetId const &)
Definition: EcalDQMCommonUtils.cc:189
HGCalWaferMask.h
HGCalTypes::WaferThree
Definition: HGCalTypes.h:57
HGCalTypes::WaferFull
Definition: HGCalTypes.h:50
ALCARECOPromptCalibProdSiPixelAli0T_cff.mode
mode
Definition: ALCARECOPromptCalibProdSiPixelAli0T_cff.py:96
HGCalTypes::WaferCorner1
Definition: HGCalTypes.h:31
HGCalTypes::c75
static constexpr double c75
Definition: HGCalTypes.h:71
HGCalTypes::WaferOut
Definition: HGCalTypes.h:58
findQualityFiles.v
v
Definition: findQualityFiles.py:179
spr::find
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
HGCalTypes::WaferFive
Definition: HGCalTypes.h:51
convertSQLiteXML.ok
bool ok
Definition: convertSQLiteXML.py:98
HGCalTypes::c77
static constexpr double c77
Definition: HGCalTypes.h:72
HGCalWaferMask::getRotation
static int getRotation(int zside, int type, int rotn)
Definition: HGCalWaferMask.cc:337
HGCalGeomTools::k_fiveCorners
static const int k_fiveCorners
Definition: HGCalGeomTools.h:14
debug
#define debug
Definition: HDRShower.cc:19
part
part
Definition: HCALResponse.h:20
HGCalTypes::c22
static constexpr double c22
Definition: HGCalTypes.h:66
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
HGCalTypes::c61
static constexpr double c61
Definition: HGCalTypes.h:70
HGCalGeomTools::k_allCorners
static const int k_allCorners
Definition: HGCalGeomTools.h:13
dqmdumpme.k
k
Definition: dqmdumpme.py:60
HGCalTypes::WaferSizeMax
static constexpr int32_t WaferSizeMax
Definition: HGCalTypes.h:63
HGCalTypes::WaferCorner5
Definition: HGCalTypes.h:35
HGCalTypes::WaferSemi
Definition: HGCalTypes.h:55
HGCalTypes::WaferCorner2
Definition: HGCalTypes.h:32
HGCalWaferMask::getTypeMode
static std::pair< int, int > getTypeMode(const double &xpos, const double &ypos, const double &delX, const double &delY, const double &rin, const double &rout, const int &waferType, const int &mode, bool deug=false)
Definition: HGCalWaferMask.cc:375
HGCalTypes::WaferSemi2
Definition: HGCalTypes.h:56
HGCalWaferMask::goodTypeMode
static bool goodTypeMode(double xpos, double ypos, double delX, double delY, double rin, double rout, int part, int rotn, bool debug)
Definition: HGCalWaferMask.cc:538
type
type
Definition: SiPixelVCal_PayloadInspector.cc:37
gainCalibHelper::gainCalibPI::type
type
Definition: SiPixelGainCalibHelper.h:39
HGCalTypes::c50
static constexpr double c50
Definition: HGCalTypes.h:69
HGCalTypes::WaferCorner4
Definition: HGCalTypes.h:34
HGCalTypes::c88
static constexpr double c88
Definition: HGCalTypes.h:73
HGCalTypes::WaferChopTwoM
Definition: HGCalTypes.h:53
HGCalWaferMask::k_OffsetRotation
static const int k_OffsetRotation
Definition: HGCalWaferMask.h:35
compare_using_db.base2
base2
Definition: compare_using_db.py:175
HGCalGeomTools.h
HGCalTypes::c10
static constexpr double c10
Definition: HGCalTypes.h:74
HGCalTypes::WaferCorner3
Definition: HGCalTypes.h:33
HGCalGeomTools::k_threeCorners
static const int k_threeCorners
Definition: HGCalGeomTools.h:16
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
HGCalTypes::WaferHalf
Definition: HGCalTypes.h:54
HGCalGeomTools::k_fourCorners
static const int k_fourCorners
Definition: HGCalGeomTools.h:15
HGCalTypes::c27
static constexpr double c27
Definition: HGCalTypes.h:68
MetAnalyzer.u2
u2
Definition: MetAnalyzer.py:61
HGCalTypes.h
newFWLiteAna.base
base
Definition: newFWLiteAna.py:92
HGCalWaferMask::maskCell
static bool maskCell(int u, int v, int N, int ncor, int fcor, int corners)
Definition: HGCalWaferMask.cc:9
HGCalTypes::WaferCorner0
Definition: HGCalTypes.h:30