CMS 3D CMS Logo

HGCalWaferMask.cc
Go to the documentation of this file.
5 
6 #include <algorithm>
7 #include <sstream>
8 
9 //#define EDM_ML_DEBUG
10 
11 bool HGCalWaferMask::maskCell(int u, int v, int n, int ncor, int fcor, int corners) {
12  /*
13 Masks each cell (or not) according to its wafer and cell position (detId) and to the user needs (corners).
14 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.
15 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.
16  */
17  bool mask(false);
18  if (ncor < corners) {
19  mask = true;
20  } else {
21  if (ncor == HGCalGeomTools::k_fourCorners) {
22  switch (fcor) {
23  case (0): {
24  mask = (v >= n);
25  break;
26  }
27  case (1): {
28  mask = (u >= n);
29  break;
30  }
31  case (2): {
32  mask = (u > v);
33  break;
34  }
35  case (3): {
36  mask = (v < n);
37  break;
38  }
39  case (4): {
40  mask = (u < n);
41  break;
42  }
43  default: {
44  mask = (u <= v);
45  break;
46  }
47  }
48  } else {
49  switch (fcor) {
50  case (0): {
51  if (ncor == HGCalGeomTools::k_threeCorners) {
52  mask = !((u > 2 * v) && (v < n));
53  } else {
54  mask = ((u >= n) && (v >= n) && ((u + v) > (3 * n - 2)));
55  }
56  break;
57  }
58  case (1): {
59  if (ncor == HGCalGeomTools::k_threeCorners) {
60  mask = !((u + v) < n);
61  } else {
62  mask = ((u >= n) && (u > v) && ((2 * u - v) > 2 * n));
63  }
64  break;
65  }
66  case (2): {
67  if (ncor == HGCalGeomTools::k_threeCorners) {
68  mask = !((u < n) && (v > u) && (v > (2 * u - 1)));
69  } else {
70  mask = ((u > 2 * v) && (v < n));
71  }
72  break;
73  }
74  case (3): {
75  if (ncor == HGCalGeomTools::k_threeCorners) {
76  mask = !((v >= u) && ((2 * v - u) > (2 * n - 2)));
77  } else {
78  mask = ((u + v) < n);
79  }
80  break;
81  }
82  case (4): {
83  if (ncor == HGCalGeomTools::k_threeCorners) {
84  mask = !((u >= n) && (v >= n) && ((u + v) > (3 * n - 2)));
85  } else {
86  mask = ((u < n) && (v > u) && (v > (2 * u - 1)));
87  }
88  break;
89  }
90  default: {
91  if (ncor == HGCalGeomTools::k_threeCorners) {
92  mask = !((u >= n) && (u > v) && ((2 * u - v) > 2 * n));
93  } else {
94  mask = ((v >= u) && ((2 * v - u) > (2 * n - 2)));
95  }
96  break;
97  }
98  }
99  }
100  }
101 #ifdef EDM_ML_DEBUG
102  edm::LogVerbatim("HGCalGeom") << "Corners: " << ncor << ":" << fcor << " N " << n << " u " << u << " v " << v
103  << " Mask " << mask;
104 #endif
105  return mask;
106 }
107 
108 bool HGCalWaferMask::goodCell(int u, int v, int n, int type, int rotn) {
109  // Needs extension for V17
110  bool good(false);
111  int n2 = n / 2;
112  int n4 = n / 4;
113  int n3 = (n + 1) / 3;
114  switch (type) {
115  case (HGCalTypes::WaferFull): { //WaferFull
116  good = true;
117  break;
118  }
119  case (HGCalTypes::WaferFive): { //WaferFive
120  switch (rotn) {
121  case (HGCalTypes::WaferCorner0): {
122  int u2 = u / 2;
123  good = ((v - u2) < n);
124  break;
125  }
126  case (HGCalTypes::WaferCorner1): {
127  good = ((v + u) < (3 * n - 1));
128  break;
129  }
130  case (HGCalTypes::WaferCorner2): {
131  int v2 = (v + 1) / 2;
132  good = ((u - v2) < n);
133  break;
134  }
135  case (HGCalTypes::WaferCorner3): {
136  int u2 = (u + 1) / 2;
137  good = (u2 <= v);
138  break;
139  }
140  case (HGCalTypes::WaferCorner4): {
141  good = ((v + u) >= n);
142  break;
143  }
144  default: {
145  int v2 = v / 2;
146  good = (u > v2);
147  break;
148  }
149  }
150  break;
151  }
152  case (HGCalTypes::WaferChopTwo): { //WaferChopTwo
153  switch (rotn) {
154  case (HGCalTypes::WaferCorner0): {
155  good = (v < (3 * n2));
156  break;
157  }
158  case (HGCalTypes::WaferCorner1): {
159  good = (u < (3 * n2));
160  break;
161  }
162  case (HGCalTypes::WaferCorner2): {
163  good = ((u - v) <= n2);
164  break;
165  }
166  case (HGCalTypes::WaferCorner3): {
167  good = (v >= n2);
168  break;
169  }
170  case (HGCalTypes::WaferCorner4): {
171  good = (u >= n2);
172  break;
173  }
174  default: {
175  good = ((v - u) < n2);
176  break;
177  }
178  }
179  break;
180  }
181  case (HGCalTypes::WaferChopTwoM): { //WaferChopTwoM
182  switch (rotn) {
183  case (HGCalTypes::WaferCorner0): {
184  good = (v < (5 * n4));
185  break;
186  }
187  case (HGCalTypes::WaferCorner1): {
188  good = (u < (5 * n4));
189  break;
190  }
191  case (HGCalTypes::WaferCorner2): {
192  good = ((u - v) <= n4);
193  break;
194  }
195  case (HGCalTypes::WaferCorner3): {
196  good = (v >= (3 * n4));
197  break;
198  }
199  case (HGCalTypes::WaferCorner4): {
200  good = (u >= (3 * n4));
201  break;
202  }
203  default: {
204  good = ((v - u) < n4);
205  break;
206  }
207  }
208  break;
209  }
210  case (HGCalTypes::WaferHalf): { //WaferHalf
211  switch (rotn) {
212  case (HGCalTypes::WaferCorner0): {
213  good = (v < n);
214  break;
215  }
216  case (HGCalTypes::WaferCorner1): {
217  good = (u < n);
218  break;
219  }
220  case (HGCalTypes::WaferCorner2): {
221  good = (v >= u);
222  break;
223  }
224  case (HGCalTypes::WaferCorner3): {
225  good = (v >= n);
226  break;
227  }
228  case (HGCalTypes::WaferCorner4): {
229  good = (u >= n);
230  break;
231  }
232  default: {
233  good = (u > v);
234  break;
235  }
236  }
237  break;
238  }
239  case (HGCalTypes::WaferSemi): { //WaferSemi
240  switch (rotn) {
241  case (HGCalTypes::WaferCorner0): {
242  good = ((u + v) < (2 * n));
243  break;
244  }
245  case (HGCalTypes::WaferCorner1): {
246  good = ((2 * u - v) < n);
247  break;
248  }
249  case (HGCalTypes::WaferCorner2): {
250  good = ((2 * v - u) >= n);
251  break;
252  }
253  case (HGCalTypes::WaferCorner3): {
254  good = ((u + v) >= (2 * n));
255  break;
256  }
257  case (HGCalTypes::WaferCorner4): {
258  good = ((2 * u - v) > n);
259  break;
260  }
261  default: {
262  good = ((2 * v - u) < n);
263  break;
264  }
265  }
266  break;
267  }
268  case (HGCalTypes::WaferThree): { //WaferThree
269  switch (rotn) {
270  case (HGCalTypes::WaferCorner0): {
271  good = ((v + u) < n);
272  break;
273  }
274  case (HGCalTypes::WaferCorner1): {
275  int v2 = v / 2;
276  good = (u <= v2);
277  break;
278  }
279  case (HGCalTypes::WaferCorner2): {
280  int u2 = (u / 2);
281  good = ((v - u2) >= n);
282  break;
283  }
284  case (HGCalTypes::WaferCorner3): {
285  good = ((v + u) >= (3 * n - 1));
286  break;
287  }
288  case (HGCalTypes::WaferCorner4): {
289  int v2 = ((v + 1) / 2);
290  good = ((u - v2) >= n);
291  break;
292  }
293  default: {
294  int u2 = ((u + 1) / 2);
295  good = (v < u2);
296  break;
297  }
298  }
299  break;
300  }
301  case (HGCalTypes::WaferSemi2): { //WaferSemi2
302  switch (rotn) {
303  case (HGCalTypes::WaferCorner0): {
304  good = ((u + v) < (4 * n3));
305  break;
306  }
307  case (HGCalTypes::WaferCorner1): {
308  good = ((2 * u - v) < n2);
309  break;
310  }
311  case (HGCalTypes::WaferCorner2): {
312  int u2 = ((u + 1) / 2);
313  good = ((v - u2) >= (3 * n4));
314  break;
315  }
316  case (HGCalTypes::WaferCorner3): {
317  good = ((u + v) >= (5 * n2));
318  break;
319  }
320  case (HGCalTypes::WaferCorner4): {
321  good = ((2 * u - v) > (3 * n2));
322  break;
323  }
324  default: {
325  int u2 = ((n == 8) ? ((u + 1) / 2) : (u / 2));
326  good = ((v - u2) < n4);
327  break;
328  }
329  }
330  break;
331  }
332  case (HGCalTypes::WaferFive2): { //WaferFive2
333  switch (rotn) {
334  case (HGCalTypes::WaferCorner0): {
335  good = ((2 * v - u) <= (3 * n2));
336  break;
337  }
338  case (HGCalTypes::WaferCorner1): {
339  good = ((u + v) < (5 * n2));
340  break;
341  }
342  case (HGCalTypes::WaferCorner2): {
343  good = ((2 * u - v) >= (3 * n2));
344  break;
345  }
346  case (HGCalTypes::WaferCorner3): {
347  good = ((2 * v - u) >= n3);
348  break;
349  }
350  case (HGCalTypes::WaferCorner4): {
351  good = ((u + v) > (4 * n3));
352  break;
353  }
354  default: {
355  good = ((2 * u - v) >= n2);
356  break;
357  }
358  }
359  break;
360  }
361  case (HGCalTypes::WaferHalf2): { //WaferHalf2
362  switch (rotn) {
363  case (HGCalTypes::WaferCorner0): {
364  good = (v <= (3 * n4));
365  break;
366  }
367  case (HGCalTypes::WaferCorner1): {
368  good = (u < (3 * n4));
369  break;
370  }
371  case (HGCalTypes::WaferCorner2): {
372  good = ((v - u) >= n4);
373  break;
374  }
375  case (HGCalTypes::WaferCorner3): {
376  good = (v >= (5 * n4));
377  break;
378  }
379  case (HGCalTypes::WaferCorner4): {
380  good = (u >= (5 * n4));
381  break;
382  }
383  default: {
384  good = ((u - v) >= n4);
385  break;
386  }
387  }
388  break;
389  }
390  }
391 #ifdef EDM_ML_DEBUG
392  edm::LogVerbatim("HGCalGeom") << "u|v " << u << ":" << v << " N " << n << " type " << type << " rot " << rotn
393  << " good " << good;
394 #endif
395  return good;
396 }
397 
398 int HGCalWaferMask::getRotation(int zside, int type, int rotn) {
399  // Needs extension for V17
400  if (rotn >= HGCalTypes::WaferCornerMax)
402  int newrotn(rotn);
403  if ((zside < 0) && (type != HGCalTypes::WaferFull)) {
404  if ((type == HGCalTypes::WaferFive) || (type == HGCalTypes::WaferFive2)) { //WaferFive/WaferFive2
405  static constexpr int rot1[HGCalTypes::WaferCornerMax] = {HGCalTypes::WaferCorner4,
411  newrotn = rot1[rotn];
412  } else if ((type == HGCalTypes::WaferThree) || (type == HGCalTypes::WaferSemi) ||
413  (type == HGCalTypes::WaferSemi2)) { //WaferThree/WaferSemi/WaferSemi2
414  static constexpr int rot2[HGCalTypes::WaferCornerMax] = {HGCalTypes::WaferCorner2,
420  newrotn = rot2[rotn];
421  } else { //WaferHalf/WaferChopTwo/WaferChopTwoM/WaferHalf2
422  static constexpr int rot3[HGCalTypes::WaferCornerMax] = {HGCalTypes::WaferCorner3,
428  newrotn = rot3[rotn];
429  }
430  }
431 #ifdef EDM_ML_DEBUG
432  edm::LogVerbatim("HGCalGeom") << "zside " << zside << " type " << type << " rotn " << rotn << ":" << newrotn;
433 #endif
434  return newrotn;
435 }
436 
437 std::pair<int, int> HGCalWaferMask::getTypeMode(const double& xpos,
438  const double& ypos,
439  const double& delX,
440  const double& delY,
441  const double& rin,
442  const double& rout,
443  const int& wType,
444  const int& mode,
445  bool debug) {
446  // No need to extend this for V17 -- use flat file information only
447  int ncor(0), iok(0);
449 
450  static constexpr int corners = 6;
451  static constexpr int base = 10;
452  double rin2 = rin * rin;
453  double rout2 = rout * rout;
454  double dx0[corners] = {HGCalTypes::c00 * delX,
455  HGCalTypes::c10 * delX,
456  HGCalTypes::c10 * delX,
457  HGCalTypes::c00 * delX,
458  -HGCalTypes::c10 * delX,
459  -HGCalTypes::c10 * delX};
460  double dy0[corners] = {-HGCalTypes::c10 * delY,
461  -HGCalTypes::c50 * delY,
462  HGCalTypes::c50 * delY,
463  HGCalTypes::c10 * delY,
464  HGCalTypes::c50 * delY,
465  -HGCalTypes::c50 * delY};
466  double xc[corners], yc[corners];
467  for (int k = 0; k < corners; ++k) {
468  xc[k] = xpos + dx0[k];
469  yc[k] = ypos + dy0[k];
470  double rpos2 = (xc[k] * xc[k] + yc[k] * yc[k]);
471  if (rpos2 <= rout2 && rpos2 >= rin2) {
472  ++ncor;
473  iok = iok * base + 1;
474  } else {
475  iok *= base;
476  }
477  }
478  if (debug)
479  edm::LogVerbatim("HGCalGeom") << "I/p " << xpos << ":" << ypos << ":" << delX << ":" << delY << ":" << rin << ":"
480  << rout << ":" << wType << ":" << mode << " Corners " << ncor << " iok " << iok;
481 
482  static constexpr int ipat5[corners] = {101111, 110111, 111011, 111101, 111110, 11111};
483  static constexpr int ipat4[corners] = {100111, 110011, 111001, 111100, 11110, 1111};
484  static constexpr int ipat3[corners] = {100011, 110001, 111000, 11100, 1110, 111};
485  static constexpr int ipat2[corners] = {11, 100001, 110000, 11000, 1100, 110};
486  double dx1[corners] = {HGCalTypes::c50 * delX,
487  HGCalTypes::c10 * delX,
488  HGCalTypes::c50 * delX,
489  -HGCalTypes::c50 * delX,
490  -HGCalTypes::c10 * delX,
491  -HGCalTypes::c50 * delX};
492  double dy1[corners] = {-HGCalTypes::c75 * delY,
493  HGCalTypes::c00 * delY,
494  HGCalTypes::c75 * delY,
495  HGCalTypes::c75 * delY,
496  HGCalTypes::c00 * delY,
497  -HGCalTypes::c75 * delY};
498  double dx2[corners] = {HGCalTypes::c50 * delX,
499  -HGCalTypes::c50 * delX,
500  -HGCalTypes::c10 * delX,
501  -HGCalTypes::c50 * delX,
502  HGCalTypes::c50 * delX,
503  HGCalTypes::c10 * delX};
504  double dy2[corners] = {HGCalTypes::c75 * delY,
505  HGCalTypes::c75 * delY,
506  HGCalTypes::c00 * delY,
507  -HGCalTypes::c75 * delY,
508  -HGCalTypes::c75 * delY,
509  HGCalTypes::c00 * delY};
510  double dx3[corners] = {HGCalTypes::c22 * delX,
511  HGCalTypes::c10 * delX,
512  HGCalTypes::c77 * delX,
513  -HGCalTypes::c22 * delX,
514  -HGCalTypes::c10 * delX,
515  -HGCalTypes::c77 * delX};
516  double dy3[corners] = {-HGCalTypes::c88 * delY,
517  -HGCalTypes::c27 * delY,
518  HGCalTypes::c61 * delY,
519  HGCalTypes::c88 * delY,
520  HGCalTypes::c27 * delY,
521  -HGCalTypes::c61 * delY};
522  double dx4[corners] = {HGCalTypes::c22 * delX,
523  -HGCalTypes::c77 * delX,
524  -HGCalTypes::c10 * delX,
525  -HGCalTypes::c22 * delX,
526  HGCalTypes::c77 * delX,
527  HGCalTypes::c10 * delX};
528  double dy4[corners] = {HGCalTypes::c88 * delY,
529  HGCalTypes::c61 * delY,
530  -HGCalTypes::c27 * delY,
531  -HGCalTypes::c88 * delY,
532  -HGCalTypes::c61 * delY,
533  HGCalTypes::c27 * delY};
534  double dx5[corners] = {-HGCalTypes::c50 * delX,
535  -HGCalTypes::c10 * delX,
536  -HGCalTypes::c50 * delX,
537  HGCalTypes::c50 * delX,
538  HGCalTypes::c10 * delX,
539  HGCalTypes::c50 * delX};
540  double dy5[corners] = {HGCalTypes::c75 * delY,
541  HGCalTypes::c00 * delY,
542  -HGCalTypes::c75 * delY,
543  -HGCalTypes::c75 * delY,
544  HGCalTypes::c00 * delY,
545  HGCalTypes::c75 * delY};
546  double dx6[corners] = {-HGCalTypes::c77 * delX,
547  -HGCalTypes::c10 * delX,
548  -HGCalTypes::c22 * delX,
549  HGCalTypes::c77 * delX,
550  HGCalTypes::c10 * delX,
551  HGCalTypes::c22 * delX};
552  double dy6[corners] = {HGCalTypes::c61 * delY,
553  -HGCalTypes::c27 * delY,
554  -HGCalTypes::c88 * delY,
555  -HGCalTypes::c61 * delY,
556  HGCalTypes::c27 * delY,
557  HGCalTypes::c88 * delY};
558  double dx7[corners] = {-HGCalTypes::c22 * delX,
559  -HGCalTypes::c10 * delX,
560  -HGCalTypes::c77 * delX,
561  HGCalTypes::c22 * delX,
562  HGCalTypes::c10 * delX,
563  HGCalTypes::c77 * delX};
564  double dy7[corners] = {HGCalTypes::c88 * delY,
565  HGCalTypes::c27 * delY,
566  -HGCalTypes::c61 * delY,
567  -HGCalTypes::c88 * delY,
568  -HGCalTypes::c27 * delY,
569  HGCalTypes::c61 * delY};
570  double dx8[corners] = {HGCalTypes::c77 * delX,
571  HGCalTypes::c10 * delX,
572  HGCalTypes::c22 * delX,
573  -HGCalTypes::c77 * delX,
574  -HGCalTypes::c10 * delX,
575  -HGCalTypes::c22 * delX};
576  double dy8[corners] = {-HGCalTypes::c61 * delY,
577  HGCalTypes::c27 * delY,
578  HGCalTypes::c88 * delY,
579  HGCalTypes::c61 * delY,
580  -HGCalTypes::c27 * delY,
581  -HGCalTypes::c88 * delY};
582  double dx9[corners] = {-HGCalTypes::c22 * delX,
583  HGCalTypes::c77 * delX,
584  HGCalTypes::c10 * delX,
585  HGCalTypes::c22 * delX,
586  -HGCalTypes::c77 * delX,
587  -HGCalTypes::c10 * delX};
588  double dy9[corners] = {-HGCalTypes::c88 * delY,
589  -HGCalTypes::c61 * delY,
590  HGCalTypes::c27 * delY,
591  HGCalTypes::c88 * delY,
592  HGCalTypes::c61 * delY,
593  -HGCalTypes::c27 * delY};
594 
595  if (ncor == HGCalGeomTools::k_allCorners) {
596  } else if (ncor == HGCalGeomTools::k_fiveCorners) {
597  rotn = static_cast<int>(std::find(ipat5, ipat5 + 6, iok) - ipat5);
599  } else if (ncor == HGCalGeomTools::k_fourCorners) {
600  rotn = static_cast<int>(std::find(ipat4, ipat4 + 6, iok) - ipat4);
602  double rpos12 = ((xpos + dx1[rotn]) * (xpos + dx1[rotn]) + (ypos + dy1[rotn]) * (ypos + dy1[rotn]));
603  double rpos22(0);
604  if (rpos12 <= rout2 && rpos12 >= rin2) {
605  rpos22 = ((xpos + dx2[rotn]) * (xpos + dx2[rotn]) + (ypos + dy2[rotn]) * (ypos + dy2[rotn]));
606  if (rpos22 <= rout2 && rpos22 >= rin2)
608  }
609  if (debug)
610  edm::LogVerbatim("HGCalGeom") << "Test for Chop2 " << std::sqrt(rpos12) << ":" << std::sqrt(rpos22) << " Type "
611  << type;
612  if ((type == HGCalTypes::WaferHalf) && (wType == 0)) {
613  rpos12 = ((xpos + dx3[rotn]) * (xpos + dx3[rotn]) + (ypos + dy3[rotn]) * (ypos + dy3[rotn]));
614  if (rpos12 <= rout2 && rpos12 >= rin2) {
615  rpos22 = ((xpos + dx4[rotn]) * (xpos + dx4[rotn]) + (ypos + dy4[rotn]) * (ypos + dy4[rotn]));
616  if (rpos22 <= rout2 && rpos22 >= rin2)
618  }
619  if (debug)
620  edm::LogVerbatim("HGCalGeom") << "Test for Chop2M " << std::sqrt(rpos12) << ":" << std::sqrt(rpos22) << " Type "
621  << type;
622  }
623  } else if (ncor == HGCalGeomTools::k_threeCorners) {
624  rotn = static_cast<int>(std::find(ipat3, ipat3 + 6, iok) - ipat3);
626  double rpos12 = ((xpos + dx7[rotn]) * (xpos + dx7[rotn]) + (ypos + dy7[rotn]) * (ypos + dy7[rotn]));
627  double rpos22(0);
628  if (rpos12 <= rout2 && rpos12 >= rin2) {
629  rpos22 = ((xpos + dx8[rotn]) * (xpos + dx8[rotn]) + (ypos + dy8[rotn]) * (ypos + dy8[rotn]));
630  if (rpos22 <= rout2 && rpos22 >= rin2)
632  }
633  if (debug)
634  edm::LogVerbatim("HGCalGeom") << "Test for Five2 " << std::sqrt(rpos12) << ":" << std::sqrt(rpos22) << " Type "
635  << type;
636  if ((type == HGCalTypes::WaferThree) && (wType == 0)) {
637  rpos12 = ((xpos + dx1[rotn]) * (xpos + dx1[rotn]) + (ypos + dy1[rotn]) * (ypos + dy1[rotn]));
638  if (rpos12 <= rout2 && rpos12 >= rin2) {
639  rpos22 = ((xpos + dx5[rotn]) * (xpos + dx5[rotn]) + (ypos + dy5[rotn]) * (ypos + dy5[rotn]));
640  if (rpos22 <= rout2 && rpos22 >= rin2)
642  }
643  if (debug)
644  edm::LogVerbatim("HGCalGeom") << "Test for Semi " << std::sqrt(rpos12) << ":" << std::sqrt(rpos22) << " Type "
645  << type;
646  }
647  if ((type == HGCalTypes::WaferThree) && (wType == 0)) {
648  rpos12 = ((xpos + dx3[rotn]) * (xpos + dx3[rotn]) + (ypos + dy3[rotn]) * (ypos + dy3[rotn]));
649  if (rpos12 <= rout2 && rpos12 >= rin2) {
650  rpos22 = ((xpos + dx6[rotn]) * (xpos + dx6[rotn]) + (ypos + dy6[rotn]) * (ypos + dy6[rotn]));
651  if (rpos22 <= rout2 && rpos22 >= rin2)
653  }
654  if (debug)
655  edm::LogVerbatim("HGCalGeom") << "Test for SemiM " << std::sqrt(rpos12) << ":" << std::sqrt(rpos22) << " Type "
656  << type;
657  }
658  } else if (ncor == HGCalGeomTools::k_twoCorners) {
659  rotn = static_cast<int>(std::find(ipat2, ipat2 + 6, iok) - ipat2);
661  double rpos12 = ((xpos + dx7[rotn]) * (xpos + dx7[rotn]) + (ypos + dy7[rotn]) * (ypos + dy7[rotn]));
662  double rpos22(0);
663  if (rpos12 <= rout2 && rpos12 >= rin2) {
664  rpos22 = ((xpos + dx9[rotn]) * (xpos + dx9[rotn]) + (ypos + dy9[rotn]) * (ypos + dy9[rotn]));
665  if (rpos22 <= rout2 && rpos22 >= rin2)
667  else
669  }
670  if (debug)
671  edm::LogVerbatim("HGCalGeom") << "Test for Half2 " << std::sqrt(rpos12) << ":" << std::sqrt(rpos22) << " Type "
672  << type;
673  } else {
675  }
676 
677  if (debug)
678  edm::LogVerbatim("HGCalGeom") << "I/p " << xpos << ":" << ypos << ":" << delX << ":" << delY << ":" << rin << ":"
679  << rout << ":" << wType << ":" << mode << " o/p " << iok << ":" << ncor << ":" << type
680  << ":" << rotn;
681  return ((mode == 0) ? std::make_pair(ncor, rotn) : std::make_pair(type, (rotn + HGCalWaferMask::k_OffsetRotation)));
682 }
683 
685  double xpos, double ypos, double delX, double delY, double rin, double rout, int part, int rotn, bool debug) {
686  // Needs extension for V17
688  return false;
689  if (rotn < 0 || rotn > HGCalTypes::WaferCornerMax)
690  return false;
691  double rin2 = rin * rin;
692  double rout2 = rout * rout;
693  double rpos2(0);
694  static constexpr int corners = HGCalTypes::WaferCornerMax;
695  static constexpr int corner2 = 2 * HGCalTypes::WaferCornerMax;
696  static constexpr int base = 10;
697  static constexpr int base2 = 100;
698  double dx0[corners] = {HGCalTypes::c00 * delX,
699  HGCalTypes::c10 * delX,
700  HGCalTypes::c10 * delX,
701  HGCalTypes::c00 * delX,
702  -HGCalTypes::c10 * delX,
703  -HGCalTypes::c10 * delX};
704  double dy0[corners] = {-HGCalTypes::c10 * delY,
705  -HGCalTypes::c50 * delY,
706  HGCalTypes::c50 * delY,
707  HGCalTypes::c10 * delY,
708  HGCalTypes::c50 * delY,
709  -HGCalTypes::c50 * delY};
710  double dx1[corners] = {HGCalTypes::c50 * delX,
711  HGCalTypes::c10 * delX,
712  HGCalTypes::c50 * delX,
713  -HGCalTypes::c50 * delX,
714  -HGCalTypes::c10 * delX,
715  -HGCalTypes::c50 * delX};
716  double dy1[corners] = {-HGCalTypes::c75 * delY,
717  HGCalTypes::c00 * delY,
718  HGCalTypes::c75 * delY,
719  HGCalTypes::c75 * delY,
720  HGCalTypes::c00 * delY,
721  -HGCalTypes::c75 * delY};
722  double dx2[corner2] = {HGCalTypes::c22 * delX,
723  HGCalTypes::c77 * delX,
724  HGCalTypes::c10 * delX,
725  HGCalTypes::c10 * delX,
726  HGCalTypes::c77 * delX,
727  HGCalTypes::c22 * delX,
728  -HGCalTypes::c22 * delX,
729  -HGCalTypes::c77 * delX,
730  -HGCalTypes::c10 * delX,
731  -HGCalTypes::c10 * delX,
732  -HGCalTypes::c77 * delX,
733  -HGCalTypes::c22 * delX};
734  double dy2[corner2] = {-HGCalTypes::c88 * delY,
735  -HGCalTypes::c61 * delY,
736  -HGCalTypes::c27 * delY,
737  HGCalTypes::c27 * delY,
738  HGCalTypes::c61 * delY,
739  HGCalTypes::c88 * delY,
740  HGCalTypes::c88 * delY,
741  HGCalTypes::c61 * delY,
742  HGCalTypes::c27 * delY,
743  -HGCalTypes::c27 * delY,
744  -HGCalTypes::c61 * delY,
745  -HGCalTypes::c88 * delY};
746  bool ok(true);
747  int ncf(-1);
748  switch (part) {
749  case (HGCalTypes::WaferThree): {
750  static constexpr int nc0[corners] = {450, 150, 201, 312, 423, 534};
751  int nc = nc0[rotn];
752  for (int k1 = 0; k1 < 3; ++k1) {
753  int k = nc % base;
754  double xc1 = xpos + dx0[k];
755  double yc1 = ypos + dy0[k];
756  rpos2 = (xc1 * xc1 + yc1 * yc1);
757  if ((rpos2 > rout2) || (rpos2 < rin2)) {
758  ok = false;
759  ncf = k;
760  break;
761  }
762  nc /= base;
763  }
764  break;
765  }
766  case (HGCalTypes::WaferSemi2): {
767  static constexpr int nc10[corners] = {450, 150, 201, 312, 423, 534};
768  static constexpr int nc11[corners] = {700, 902, 1104, 106, 308, 510};
769  int nc = nc10[rotn];
770  for (int k1 = 0; k1 < 3; ++k1) {
771  int k = nc % base;
772  double xc1 = xpos + dx0[k];
773  double yc1 = ypos + dy0[k];
774  rpos2 = (xc1 * xc1 + yc1 * yc1);
775  if ((rpos2 > rout2) || (rpos2 < rin2)) {
776  ok = false;
777  ncf = k;
778  break;
779  }
780  nc /= base;
781  }
782  nc = nc11[rotn];
783  for (int k1 = 0; k1 < 2; ++k1) {
784  int k = nc % base2;
785  double xc1 = xpos + dx2[k];
786  double yc1 = ypos + dy2[k];
787  rpos2 = (xc1 * xc1 + yc1 * yc1);
788  if ((rpos2 > rout2) || (rpos2 < rin2)) {
789  ok = false;
790  ncf = k + base2;
791  break;
792  }
793  nc /= base2;
794  }
795  break;
796  }
797  case (HGCalTypes::WaferSemi): {
798  static constexpr int nc20[corners] = {450, 150, 201, 312, 423, 534};
799  static constexpr int nc21[corners] = {30, 14, 25, 30, 41, 52};
800  int nc = nc20[rotn];
801  for (int k1 = 0; k1 < 3; ++k1) {
802  int k = nc % base;
803  double xc1 = xpos + dx0[k];
804  double yc1 = ypos + dy0[k];
805  rpos2 = (xc1 * xc1 + yc1 * yc1);
806  if ((rpos2 > rout2) || (rpos2 < rin2)) {
807  ok = false;
808  ncf = k;
809  break;
810  }
811  nc /= base;
812  }
813  nc = nc21[rotn];
814  for (int k1 = 0; k1 < 2; ++k1) {
815  int k = nc % base;
816  double xc1 = xpos + dx1[k];
817  double yc1 = ypos + dy1[k];
818  rpos2 = (xc1 * xc1 + yc1 * yc1);
819  if ((rpos2 > rout2) || (rpos2 < rin2)) {
820  ok = false;
821  ncf = k + base2;
822  break;
823  }
824  nc /= base;
825  }
826  break;
827  }
828  case (HGCalTypes::WaferHalf): {
829  static constexpr int nc3[corners] = {3450, 1450, 2501, 3012, 4123, 5234};
830  int nc = nc3[rotn];
831  for (int k1 = 0; k1 < 4; ++k1) {
832  int k = nc % base;
833  double xc1 = xpos + dx0[k];
834  double yc1 = ypos + dy0[k];
835  rpos2 = (xc1 * xc1 + yc1 * yc1);
836  if ((rpos2 > rout2) || (rpos2 < rin2)) {
837  ok = false;
838  ncf = k;
839  break;
840  }
841  nc /= base;
842  }
843  break;
844  }
845  case (HGCalTypes::WaferChopTwoM): {
846  static constexpr int nc40[corners] = {3450, 1450, 2501, 3012, 4123, 5234};
847  static constexpr int nc41[corners] = {500, 702, 904, 1106, 108, 310};
848  int nc = nc40[rotn];
849  for (int k1 = 0; k1 < 4; ++k1) {
850  int k = nc % base;
851  double xc1 = xpos + dx0[k];
852  double yc1 = ypos + dy0[k];
853  rpos2 = (xc1 * xc1 + yc1 * yc1);
854  if ((rpos2 > rout2) || (rpos2 < rin2)) {
855  ok = false;
856  ncf = k;
857  break;
858  }
859  nc /= base;
860  }
861  nc = nc41[rotn];
862  for (int k1 = 0; k1 < 2; ++k1) {
863  int k = nc % base2;
864  double xc1 = xpos + dx2[k];
865  double yc1 = ypos + dy2[k];
866  rpos2 = (xc1 * xc1 + yc1 * yc1);
867  if ((rpos2 > rout2) || (rpos2 < rin2)) {
868  ok = false;
869  ncf = k + base2;
870  break;
871  }
872  nc /= base2;
873  }
874  break;
875  }
876  case (HGCalTypes::WaferChopTwo): {
877  static constexpr int nc50[corners] = {3450, 1450, 2501, 3012, 4123, 5234};
878  static constexpr int nc51[corners] = {20, 13, 24, 35, 40, 51};
879  int nc = nc50[rotn];
880  for (int k1 = 0; k1 < 4; ++k1) {
881  int k = nc % base;
882  double xc1 = xpos + dx0[k];
883  double yc1 = ypos + dy0[k];
884  rpos2 = (xc1 * xc1 + yc1 * yc1);
885  if ((rpos2 > rout2) || (rpos2 < rin2)) {
886  ok = false;
887  ncf = k;
888  break;
889  }
890  nc /= base;
891  }
892  nc = nc51[rotn];
893  for (int k1 = 0; k1 < 2; ++k1) {
894  int k = nc % base;
895  double xc1 = xpos + dx1[k];
896  double yc1 = ypos + dy1[k];
897  rpos2 = (xc1 * xc1 + yc1 * yc1);
898  if ((rpos2 > rout2) || (rpos2 < rin2)) {
899  ok = false;
900  ncf = k + base2;
901  break;
902  }
903  nc /= base;
904  }
905  break;
906  }
907  case (HGCalTypes::WaferFive): {
908  static constexpr int nc6[corners] = {23450, 13450, 24501, 35012, 40123, 51234};
909  int nc = nc6[rotn];
910  for (int k1 = 0; k1 < 5; ++k1) {
911  int k = nc % base;
912  double xc1 = xpos + dx0[k];
913  double yc1 = ypos + dy0[k];
914  rpos2 = (xc1 * xc1 + yc1 * yc1);
915  if ((rpos2 > rout2) || (rpos2 < rin2)) {
916  ok = false;
917  ncf = k;
918  break;
919  }
920  }
921  break;
922  }
923  case (HGCalTypes::WaferFive2): {
924  static constexpr int nc60[corners] = {450, 150, 201, 312, 423, 534};
925  static constexpr int nc61[corners] = {601, 803, 1005, 7, 209, 411};
926  int nc = nc60[rotn];
927  for (int k1 = 0; k1 < 3; ++k1) {
928  int k = nc % base;
929  double xc1 = xpos + dx0[k];
930  double yc1 = ypos + dy0[k];
931  rpos2 = (xc1 * xc1 + yc1 * yc1);
932  if ((rpos2 > rout2) || (rpos2 < rin2)) {
933  ok = false;
934  ncf = k;
935  break;
936  }
937  nc /= base;
938  }
939  nc = nc61[rotn];
940  for (int k1 = 0; k1 < 2; ++k1) {
941  int k = nc % base2;
942  double xc1 = xpos + dx2[k];
943  double yc1 = ypos + dy2[k];
944  rpos2 = (xc1 * xc1 + yc1 * yc1);
945  if ((rpos2 > rout2) || (rpos2 < rin2)) {
946  ok = false;
947  ncf = k + base2;
948  break;
949  }
950  nc /= base2;
951  }
952  break;
953  }
954  case (HGCalTypes::WaferHalf2): {
955  static constexpr int nc70[corners] = {45, 50, 1, 12, 23, 34};
956  static constexpr int nc71[corners] = {611, 801, 1003, 5, 207, 409};
957  int nc = nc70[rotn];
958  for (int k1 = 0; k1 < 2; ++k1) {
959  int k = nc % base;
960  double xc1 = xpos + dx0[k];
961  double yc1 = ypos + dy0[k];
962  rpos2 = (xc1 * xc1 + yc1 * yc1);
963  if ((rpos2 > rout2) || (rpos2 < rin2)) {
964  ok = false;
965  ncf = k;
966  break;
967  }
968  nc /= base;
969  }
970  nc = nc71[rotn];
971  for (int k1 = 0; k1 < 2; ++k1) {
972  int k = nc % base2;
973  double xc1 = xpos + dx2[k];
974  double yc1 = ypos + dy2[k];
975  rpos2 = (xc1 * xc1 + yc1 * yc1);
976  if ((rpos2 > rout2) || (rpos2 < rin2)) {
977  ok = false;
978  ncf = k + base2;
979  break;
980  }
981  nc /= base2;
982  }
983  break;
984  }
985  default: {
986  for (int k = 0; k < corners; ++k) {
987  double xc1 = xpos + dx0[k];
988  double yc1 = ypos + dy0[k];
989  rpos2 = (xc1 * xc1 + yc1 * yc1);
990  if ((rpos2 > rout2) || (rpos2 < rin2)) {
991  ok = false;
992  ncf = k;
993  break;
994  }
995  }
996  break;
997  }
998  }
999  if (debug || (!ok))
1000  edm::LogVerbatim("HGCalGeom") << "I/p "
1001  << ":" << xpos << ":" << ypos << ":" << delX << ":" << delY << ":" << rin << ":"
1002  << rout << ":" << part << ":" << rotn << " Results " << ok << ":" << ncf << " R "
1003  << rin2 << ":" << rout2 << ":" << rpos2;
1004  return ok;
1005 }
1006 
1007 std::vector<std::pair<double, double> > HGCalWaferMask::waferXY(
1008  int part, int ori, int zside, double delX, double delY, double xpos, double ypos) {
1009  // Good for V15 and V16 versions
1010  std::vector<std::pair<double, double> > xy;
1011  int orient = getRotation(-zside, part, ori);
1012 #ifdef EDM_ML_DEBUG
1013  edm::LogVerbatim("HGCalGeom") << "Part " << part << " zSide " << zside << " Orient " << ori << ":" << orient;
1014 #endif
1015  /*
1016  The exact contour of partial wafers are obtained by joining points on
1017  the circumference of a full wafer.
1018  Numbering the points along the edges of a hexagonal wafer, starting from
1019  the bottom corner:
1020 
1021  3
1022  15 18
1023  9 8
1024  19 14
1025  4 2
1026  16 23
1027  10 7
1028  20 13
1029  5 1
1030  17 22
1031  11 6
1032  21 12
1033  0
1034 
1035  Depending on the wafer type and orientation index, the corners
1036  are chosen in the variable *np*
1037  */
1038  double dx[24] = {HGCalTypes::c00 * delX, HGCalTypes::c10 * delX, HGCalTypes::c10 * delX, HGCalTypes::c00 * delX,
1039  -HGCalTypes::c10 * delX, -HGCalTypes::c10 * delX, HGCalTypes::c50 * delX, HGCalTypes::c10 * delX,
1040  HGCalTypes::c50 * delX, -HGCalTypes::c50 * delX, -HGCalTypes::c10 * delX, -HGCalTypes::c50 * delX,
1041  HGCalTypes::c22 * delX, HGCalTypes::c10 * delX, HGCalTypes::c77 * delX, -HGCalTypes::c22 * delX,
1042  -HGCalTypes::c10 * delX, -HGCalTypes::c77 * delX, HGCalTypes::c22 * delX, -HGCalTypes::c77 * delX,
1043  -HGCalTypes::c10 * delX, -HGCalTypes::c22 * delX, HGCalTypes::c77 * delX, HGCalTypes::c10 * delX};
1044  double dy[24] = {-HGCalTypes::c10 * delY, -HGCalTypes::c50 * delY, HGCalTypes::c50 * delY, HGCalTypes::c10 * delY,
1045  HGCalTypes::c50 * delY, -HGCalTypes::c50 * delY, -HGCalTypes::c75 * delY, HGCalTypes::c00 * delY,
1046  HGCalTypes::c75 * delY, HGCalTypes::c75 * delY, HGCalTypes::c00 * delY, -HGCalTypes::c75 * delY,
1047  -HGCalTypes::c88 * delY, -HGCalTypes::c27 * delY, HGCalTypes::c61 * delY, HGCalTypes::c88 * delY,
1048  HGCalTypes::c27 * delY, -HGCalTypes::c61 * delY, HGCalTypes::c88 * delY, HGCalTypes::c61 * delY,
1049  -HGCalTypes::c27 * delY, -HGCalTypes::c88 * delY, -HGCalTypes::c61 * delY, HGCalTypes::c27 * delY};
1050  if (part == HGCalTypes::WaferFull) {
1051  int np[7] = {0, 1, 2, 3, 4, 5, 0};
1052  for (int k = 0; k < 7; ++k)
1053  xy.push_back(std::make_pair((xpos + dx[np[k]]), (ypos + dy[np[k]])));
1054  } else if (part == HGCalTypes::WaferFive) {
1055  int np[6][6] = {{0, 2, 3, 4, 5, 0},
1056  {1, 3, 4, 5, 0, 1},
1057  {2, 4, 5, 0, 1, 2},
1058  {3, 5, 0, 1, 2, 3},
1059  {4, 0, 1, 2, 3, 4},
1060  {5, 1, 2, 3, 4, 5}};
1061  for (int k = 0; k < 6; ++k) {
1062  xy.push_back(std::make_pair((xpos + dx[np[orient][k]]), (ypos + dy[np[orient][k]])));
1063 #ifdef EDM_ML_DEBUG
1064  edm::LogVerbatim("HGCalGeom") << k << ":" << np[orient][k] << ":" << dx[np[orient][k]] << ":"
1065  << dy[np[orient][k]];
1066 #endif
1067  }
1068  } else if (part == HGCalTypes::WaferHalf) {
1069  int np[6][5] = {
1070  {0, 3, 4, 5, 0}, {1, 4, 5, 0, 1}, {2, 5, 0, 1, 2}, {3, 0, 1, 2, 3}, {4, 1, 2, 3, 4}, {5, 2, 3, 4, 5}};
1071  for (int k = 0; k < 5; ++k) {
1072  xy.push_back(std::make_pair((xpos + dx[np[orient][k]]), (ypos + dy[np[orient][k]])));
1073 #ifdef EDM_ML_DEBUG
1074  edm::LogVerbatim("HGCalGeom") << k << ":" << np[orient][k] << ":" << dx[np[orient][k]] << ":"
1075  << dy[np[orient][k]];
1076 #endif
1077  }
1078  } else if (part == HGCalTypes::WaferThree) {
1079  int np[6][4] = {{0, 4, 5, 0}, {1, 5, 0, 1}, {2, 0, 1, 2}, {3, 1, 2, 3}, {4, 2, 3, 4}, {5, 3, 4, 5}};
1080  for (int k = 0; k < 4; ++k) {
1081  xy.push_back(std::make_pair((xpos + dx[np[orient][k]]), (ypos + dy[np[orient][k]])));
1082 #ifdef EDM_ML_DEBUG
1083  edm::LogVerbatim("HGCalGeom") << k << ":" << np[orient][k] << ":" << dx[np[orient][k]] << ":"
1084  << dy[np[orient][k]];
1085 #endif
1086  }
1087  } else if (part == HGCalTypes::WaferChopTwo) {
1088  int np[6][7] = {{6, 8, 3, 4, 5, 0, 6},
1089  {7, 9, 4, 5, 0, 1, 7},
1090  {8, 10, 5, 0, 1, 2, 8},
1091  {9, 11, 0, 1, 2, 3, 9},
1092  {10, 6, 1, 2, 3, 4, 10},
1093  {11, 7, 2, 3, 4, 5, 11}};
1094  for (int k = 0; k < 7; ++k) {
1095  xy.push_back(std::make_pair((xpos + dx[np[orient][k]]), (ypos + dy[np[orient][k]])));
1096 #ifdef EDM_ML_DEBUG
1097  edm::LogVerbatim("HGCalGeom") << k << ":" << np[orient][k] << ":" << dx[np[orient][k]] << ":"
1098  << dy[np[orient][k]];
1099 #endif
1100  }
1101  } else if (part == HGCalTypes::WaferSemi) {
1102  int np[6][6] = {{6, 9, 4, 5, 0, 6},
1103  {7, 10, 5, 0, 1, 7},
1104  {8, 11, 0, 1, 2, 8},
1105  {9, 6, 1, 2, 3, 9},
1106  {10, 7, 2, 3, 4, 10},
1107  {11, 8, 3, 4, 5, 11}};
1108  for (int k = 0; k < 6; ++k) {
1109  xy.push_back(std::make_pair((xpos + dx[np[orient][k]]), (ypos + dy[np[orient][k]])));
1110 #ifdef EDM_ML_DEBUG
1111  edm::LogVerbatim("HGCalGeom") << k << ":" << np[orient][k] << ":" << dx[np[orient][k]] << ":"
1112  << dy[np[orient][k]];
1113 #endif
1114  }
1115  } else if (part == HGCalTypes::WaferChopTwoM) {
1116  int np[6][7] = {{12, 18, 3, 4, 5, 0, 12},
1117  {13, 19, 4, 5, 0, 1, 13},
1118  {14, 20, 5, 0, 1, 2, 14},
1119  {15, 21, 0, 1, 2, 3, 15},
1120  {16, 22, 1, 2, 3, 4, 16},
1121  {17, 23, 2, 3, 4, 5, 17}};
1122  for (int k = 0; k < 7; ++k) {
1123  xy.push_back(std::make_pair((xpos + dx[np[orient][k]]), (ypos + dy[np[orient][k]])));
1124 #ifdef EDM_ML_DEBUG
1125  edm::LogVerbatim("HGCalGeom") << k << ":" << np[orient][k] << ":" << dx[np[orient][k]] << ":"
1126  << dy[np[orient][k]];
1127 #endif
1128  }
1129  } else if (part == HGCalTypes::WaferSemi2) {
1130  int np[6][6] = {{12, 19, 4, 5, 0, 12},
1131  {13, 20, 5, 0, 1, 13},
1132  {14, 21, 0, 1, 2, 14},
1133  {15, 22, 1, 2, 3, 15},
1134  {16, 23, 2, 3, 4, 16},
1135  {17, 18, 3, 4, 5, 17}};
1136  for (int k = 0; k < 6; ++k) {
1137  xy.push_back(std::make_pair((xpos + dx[np[orient][k]]), (ypos + dy[np[orient][k]])));
1138 #ifdef EDM_ML_DEBUG
1139  edm::LogVerbatim("HGCalGeom") << k << ":" << np[orient][k] << ":" << dx[np[orient][k]] << ":"
1140  << dy[np[orient][k]];
1141 #endif
1142  }
1143  } else if (part == HGCalTypes::WaferFive2) {
1144  int np[6][6] = {{22, 15, 4, 5, 0, 22},
1145  {23, 16, 5, 0, 1, 23},
1146  {18, 17, 0, 1, 2, 18},
1147  {19, 12, 1, 2, 3, 19},
1148  {20, 13, 2, 3, 4, 20},
1149  {21, 14, 3, 4, 5, 21}};
1150  for (int k = 0; k < 6; ++k) {
1151  xy.push_back(std::make_pair((xpos + dx[np[orient][k]]), (ypos + dy[np[orient][k]])));
1152 #ifdef EDM_ML_DEBUG
1153  edm::LogVerbatim("HGCalGeom") << k << ":" << np[orient][k] << ":" << dx[np[orient][k]] << ":"
1154  << dy[np[orient][k]];
1155 #endif
1156  }
1157  } else if (part == HGCalTypes::WaferHalf2) {
1158  int np[6][5] = {{21, 15, 4, 5, 21},
1159  {22, 16, 5, 0, 22},
1160  {23, 17, 0, 1, 23},
1161  {18, 12, 1, 2, 18},
1162  {19, 13, 2, 3, 19},
1163  {20, 14, 3, 4, 20}};
1164  for (int k = 0; k < 5; ++k) {
1165  xy.push_back(std::make_pair((xpos + dx[np[orient][k]]), (ypos + dy[np[orient][k]])));
1166 #ifdef EDM_ML_DEBUG
1167  edm::LogVerbatim("HGCalGeom") << k << ":" << np[orient][k] << ":" << dx[np[orient][k]] << ":"
1168  << dy[np[orient][k]];
1169 #endif
1170  }
1171  }
1172 #ifdef EDM_ML_DEBUG
1173  edm::LogVerbatim("HGCalGeom") << "I/p: " << part << ":" << ori << ":" << zside << ":" << delX << ":" << delY << ":"
1174  << xpos << ":" << ypos << " O/p having " << xy.size() << " points:";
1175  std::ostringstream st1;
1176  for (unsigned int i = 0; i < xy.size(); ++i)
1177  st1 << " [" << i << "] " << xy[i].first << ":" << xy[i].second;
1178  edm::LogVerbatim("HGCalGeom") << st1.str();
1179 #endif
1180  return xy;
1181 }
1182 
1183 std::vector<std::pair<double, double> > HGCalWaferMask::waferXY(
1184  int part, int place, double delX, double delY, double xpos, double ypos) {
1185  std::vector<std::pair<double, double> > xy;
1186  // Good for V17 version and uses partial wafer type & placement index
1187 #ifdef EDM_ML_DEBUG
1188  edm::LogVerbatim("HGCalGeom") << "Part " << part << " Placement Index " << place;
1189 #endif
1190  /*
1191  The exact contour of partial wafers are obtained by joining points on
1192  the circumference of a full wafer.
1193  Numbering the points along the edges of a hexagonal wafer, starting from
1194  the bottom corner:
1195 
1196  3
1197  15 18
1198  9 8
1199  19 14
1200  4 2
1201  16 23
1202  10 7
1203  20 13
1204  5 1
1205  17 22
1206  11 6
1207  21 12
1208  0
1209 
1210  Depending on the wafer type and placement index, the corners
1211  are chosen in the variable *np*
1212  */
1213  double dx[24] = {HGCalTypes::c00 * delX, HGCalTypes::c10 * delX, HGCalTypes::c10 * delX, HGCalTypes::c00 * delX,
1214  -HGCalTypes::c10 * delX, -HGCalTypes::c10 * delX, HGCalTypes::c50 * delX, HGCalTypes::c10 * delX,
1215  HGCalTypes::c50 * delX, -HGCalTypes::c50 * delX, -HGCalTypes::c10 * delX, -HGCalTypes::c50 * delX,
1216  HGCalTypes::c22 * delX, HGCalTypes::c10 * delX, HGCalTypes::c77 * delX, -HGCalTypes::c22 * delX,
1217  -HGCalTypes::c10 * delX, -HGCalTypes::c77 * delX, HGCalTypes::c22 * delX, -HGCalTypes::c77 * delX,
1218  -HGCalTypes::c10 * delX, -HGCalTypes::c22 * delX, HGCalTypes::c77 * delX, HGCalTypes::c10 * delX};
1219  double dy[24] = {-HGCalTypes::c10 * delY, -HGCalTypes::c50 * delY, HGCalTypes::c50 * delY, HGCalTypes::c10 * delY,
1220  HGCalTypes::c50 * delY, -HGCalTypes::c50 * delY, -HGCalTypes::c75 * delY, HGCalTypes::c00 * delY,
1221  HGCalTypes::c75 * delY, HGCalTypes::c75 * delY, HGCalTypes::c00 * delY, -HGCalTypes::c75 * delY,
1222  -HGCalTypes::c88 * delY, -HGCalTypes::c27 * delY, HGCalTypes::c61 * delY, HGCalTypes::c88 * delY,
1223  HGCalTypes::c27 * delY, -HGCalTypes::c61 * delY, HGCalTypes::c88 * delY, HGCalTypes::c61 * delY,
1224  -HGCalTypes::c27 * delY, -HGCalTypes::c88 * delY, -HGCalTypes::c61 * delY, HGCalTypes::c27 * delY};
1225  if (part == HGCalTypes::WaferFull) {
1226  int np[7] = {0, 1, 2, 3, 4, 5, 0};
1227  for (int k = 0; k < 7; ++k)
1228  xy.push_back(std::make_pair((xpos + dx[np[k]]), (ypos + dy[np[k]])));
1229  } else if (part == HGCalTypes::WaferLDTop) {
1230  int np[12][5] = {{0, 1, 4, 5, 0},
1231  {1, 2, 5, 0, 1},
1232  {2, 3, 0, 1, 2},
1233  {3, 4, 1, 2, 3},
1234  {4, 5, 2, 3, 4},
1235  {5, 0, 3, 4, 5},
1236  {0, 1, 2, 5, 0},
1237  {5, 0, 1, 4, 5},
1238  {4, 5, 0, 3, 4},
1239  {3, 4, 5, 2, 3},
1240  {2, 3, 4, 1, 2},
1241  {1, 2, 3, 0, 1}};
1242  for (int k = 0; k < 5; ++k) {
1243  xy.push_back(std::make_pair((xpos + dx[np[place][k]]), (ypos + dy[np[place][k]])));
1244 #ifdef EDM_ML_DEBUG
1245  edm::LogVerbatim("HGCalGeom") << k << ":" << np[place][k] << ":" << dx[np[place][k]] << ":" << dy[np[place][k]];
1246 #endif
1247  }
1248  } else if (part == HGCalTypes::WaferLDBottom) {
1249  int np[12][5] = {{1, 2, 3, 4, 1},
1250  {2, 3, 4, 5, 2},
1251  {3, 4, 5, 0, 3},
1252  {4, 5, 0, 1, 4},
1253  {5, 0, 1, 2, 5},
1254  {0, 1, 2, 3, 0},
1255  {5, 2, 3, 4, 5},
1256  {4, 1, 2, 3, 4},
1257  {3, 0, 1, 2, 3},
1258  {2, 5, 0, 1, 2},
1259  {1, 4, 5, 0, 1},
1260  {0, 3, 4, 5, 0}};
1261  for (int k = 0; k < 5; ++k) {
1262  xy.push_back(std::make_pair((xpos + dx[np[place][k]]), (ypos + dy[np[place][k]])));
1263 #ifdef EDM_ML_DEBUG
1264  edm::LogVerbatim("HGCalGeom") << k << ":" << np[place][k] << ":" << dx[np[place][k]] << ":" << dy[np[place][k]];
1265 #endif
1266  }
1267  } else if (part == HGCalTypes::WaferLDLeft) {
1268  int np[12][6] = {{0, 1, 2, 8, 11, 0},
1269  {1, 2, 3, 9, 6, 1},
1270  {2, 3, 4, 10, 7, 2},
1271  {3, 4, 5, 11, 8, 3},
1272  {4, 5, 0, 6, 9, 4},
1273  {5, 0, 1, 7, 10, 5},
1274  {0, 6, 9, 4, 5, 0},
1275  {5, 11, 8, 3, 4, 5},
1276  {4, 10, 7, 2, 3, 4},
1277  {3, 9, 6, 1, 2, 3},
1278  {2, 8, 11, 0, 1, 2},
1279  {1, 7, 10, 5, 0, 1}};
1280  for (int k = 0; k < 6; ++k) {
1281  xy.push_back(std::make_pair((xpos + dx[np[place][k]]), (ypos + dy[np[place][k]])));
1282 #ifdef EDM_ML_DEBUG
1283  edm::LogVerbatim("HGCalGeom") << k << ":" << np[place][k] << ":" << dx[np[place][k]] << ":" << dy[np[place][k]];
1284 #endif
1285  }
1286  } else if (part == HGCalTypes::WaferLDRight) {
1287  int np[12][6] = {{5, 11, 8, 3, 4, 5},
1288  {0, 6, 9, 4, 5, 0},
1289  {1, 7, 10, 5, 0, 1},
1290  {2, 8, 11, 0, 1, 2},
1291  {3, 9, 6, 1, 2, 3},
1292  {4, 10, 7, 2, 3, 4},
1293  {1, 2, 3, 9, 6, 1},
1294  {0, 1, 2, 8, 11, 0},
1295  {5, 0, 1, 7, 10, 5},
1296  {4, 5, 0, 6, 9, 4},
1297  {3, 4, 5, 11, 8, 3},
1298  {2, 3, 4, 10, 7, 2}};
1299  for (int k = 0; k < 6; ++k) {
1300  xy.push_back(std::make_pair((xpos + dx[np[place][k]]), (ypos + dy[np[place][k]])));
1301 #ifdef EDM_ML_DEBUG
1302  edm::LogVerbatim("HGCalGeom") << k << ":" << np[place][k] << ":" << dx[np[place][k]] << ":" << dy[np[place][k]];
1303 #endif
1304  }
1305  } else if (part == HGCalTypes::WaferLDFive) {
1306  int np[12][6] = {{0, 1, 2, 3, 5, 0},
1307  {1, 2, 3, 4, 0, 1},
1308  {2, 3, 4, 5, 1, 2},
1309  {3, 4, 5, 0, 2, 3},
1310  {4, 5, 0, 1, 3, 4},
1311  {5, 0, 1, 2, 4, 5},
1312  {0, 1, 3, 4, 5, 0},
1313  {5, 0, 2, 3, 4, 5},
1314  {4, 5, 1, 2, 3, 4},
1315  {3, 4, 0, 1, 2, 3},
1316  {2, 3, 5, 0, 1, 2},
1317  {1, 2, 4, 5, 0, 1}};
1318  for (int k = 0; k < 6; ++k) {
1319  xy.push_back(std::make_pair((xpos + dx[np[place][k]]), (ypos + dy[np[place][k]])));
1320 #ifdef EDM_ML_DEBUG
1321  edm::LogVerbatim("HGCalGeom") << k << ":" << np[place][k] << ":" << dx[np[place][k]] << ":" << dy[np[place][k]];
1322 #endif
1323  }
1324  } else if (part == HGCalTypes::WaferLDThree) {
1325  int np[12][4] = {{5, 3, 4, 5},
1326  {0, 4, 5, 0},
1327  {1, 5, 0, 1},
1328  {2, 0, 1, 2},
1329  {3, 1, 2, 3},
1330  {4, 2, 3, 4},
1331  {1, 2, 3, 1},
1332  {0, 1, 2, 0},
1333  {5, 0, 1, 5},
1334  {4, 5, 0, 4},
1335  {3, 4, 5, 3},
1336  {2, 3, 4, 2}};
1337  for (int k = 0; k < 4; ++k) {
1338  xy.push_back(std::make_pair((xpos + dx[np[place][k]]), (ypos + dy[np[place][k]])));
1339 #ifdef EDM_ML_DEBUG
1340  edm::LogVerbatim("HGCalGeom") << k << ":" << np[place][k] << ":" << dx[np[place][k]] << ":" << dy[np[place][k]];
1341 #endif
1342  }
1343  } else if (part == HGCalTypes::WaferHDTop) {
1344  int np[12][5] = {{0, 22, 16, 5, 0},
1345  {1, 23, 17, 0, 1},
1346  {2, 18, 12, 1, 2},
1347  {3, 19, 13, 2, 3},
1348  {4, 20, 14, 3, 4},
1349  {5, 21, 15, 4, 5},
1350  {0, 1, 23, 17, 0},
1351  {5, 0, 22, 16, 5},
1352  {4, 5, 21, 15, 4},
1353  {3, 4, 20, 14, 3},
1354  {2, 3, 19, 13, 2},
1355  {1, 2, 18, 12, 1}};
1356  for (int k = 0; k < 5; ++k) {
1357  xy.push_back(std::make_pair((xpos + dx[np[place][k]]), (ypos + dy[np[place][k]])));
1358 #ifdef EDM_ML_DEBUG
1359  edm::LogVerbatim("HGCalGeom") << k << ":" << np[place][k] << ":" << dx[np[place][k]] << ":" << dy[np[place][k]];
1360 #endif
1361  }
1362  } else if (part == HGCalTypes::WaferHDBottom) {
1363  int np[12][7] = {{1, 2, 3, 4, 16, 22, 1},
1364  {2, 3, 4, 5, 17, 23, 2},
1365  {3, 4, 5, 0, 12, 18, 3},
1366  {4, 5, 0, 1, 13, 19, 4},
1367  {5, 0, 1, 2, 14, 20, 5},
1368  {0, 1, 2, 3, 15, 21, 0},
1369  {5, 17, 23, 2, 3, 4, 5},
1370  {4, 16, 22, 1, 2, 3, 4},
1371  {3, 15, 21, 0, 1, 2, 3},
1372  {2, 14, 20, 5, 0, 1, 2},
1373  {1, 13, 19, 4, 5, 0, 1},
1374  {0, 12, 18, 3, 4, 5, 0}};
1375  for (int k = 0; k < 7; ++k) {
1376  xy.push_back(std::make_pair((xpos + dx[np[place][k]]), (ypos + dy[np[place][k]])));
1377 #ifdef EDM_ML_DEBUG
1378  edm::LogVerbatim("HGCalGeom") << k << ":" << np[place][k] << ":" << dx[np[place][k]] << ":" << dy[np[place][k]];
1379 #endif
1380  }
1381  } else if (part == HGCalTypes::WaferHDLeft) {
1382  int np[12][6] = {{0, 1, 2, 14, 21, 0},
1383  {1, 2, 3, 15, 22, 1},
1384  {2, 3, 4, 16, 23, 2},
1385  {3, 4, 5, 17, 18, 3},
1386  {4, 5, 0, 12, 19, 4},
1387  {5, 0, 1, 13, 20, 5},
1388  {0, 12, 19, 4, 5, 0},
1389  {5, 17, 18, 3, 4, 5},
1390  {4, 16, 23, 2, 3, 4},
1391  {3, 18, 22, 1, 2, 3},
1392  {2, 14, 21, 0, 1, 2},
1393  {1, 13, 20, 5, 0, 1}};
1394  for (int k = 0; k < 6; ++k) {
1395  xy.push_back(std::make_pair((xpos + dx[np[place][k]]), (ypos + dy[np[place][k]])));
1396 #ifdef EDM_ML_DEBUG
1397  edm::LogVerbatim("HGCalGeom") << k << ":" << np[place][k] << ":" << dx[np[place][k]] << ":" << dy[np[place][k]];
1398 #endif
1399  }
1400  } else if (part == HGCalTypes::WaferHDRight) {
1401  int np[12][6] = {{5, 17, 18, 3, 4, 5},
1402  {0, 12, 19, 4, 5, 0},
1403  {1, 13, 20, 5, 0, 1},
1404  {2, 14, 21, 0, 1, 2},
1405  {3, 15, 22, 1, 2, 3},
1406  {4, 16, 23, 2, 3, 4},
1407  {1, 2, 3, 15, 22, 1},
1408  {0, 1, 2, 14, 21, 0},
1409  {5, 0, 1, 13, 20, 5},
1410  {4, 5, 0, 12, 19, 4},
1411  {3, 4, 5, 17, 18, 3},
1412  {2, 3, 4, 16, 23, 2}};
1413  for (int k = 0; k < 6; ++k) {
1414  xy.push_back(std::make_pair((xpos + dx[np[place][k]]), (ypos + dy[np[place][k]])));
1415 #ifdef EDM_ML_DEBUG
1416  edm::LogVerbatim("HGCalGeom") << k << ":" << np[place][k] << ":" << dx[np[place][k]] << ":" << dy[np[place][k]];
1417 #endif
1418  }
1419  } else if (part == HGCalTypes::WaferHDFive) {
1420  int np[12][6] = {{0, 1, 2, 18, 17, 0},
1421  {1, 2, 3, 19, 12, 1},
1422  {2, 3, 4, 20, 13, 2},
1423  {3, 4, 5, 21, 14, 3},
1424  {4, 5, 0, 22, 15, 4},
1425  {5, 0, 1, 23, 16, 5},
1426  {0, 22, 15, 4, 5, 0},
1427  {5, 21, 14, 3, 4, 5},
1428  {4, 20, 13, 2, 3, 4},
1429  {3, 19, 12, 1, 2, 3},
1430  {2, 18, 17, 0, 1, 2},
1431  {1, 23, 16, 5, 0, 1}};
1432  for (int k = 0; k < 6; ++k) {
1433  xy.push_back(std::make_pair((xpos + dx[np[place][k]]), (ypos + dy[np[place][k]])));
1434 #ifdef EDM_ML_DEBUG
1435  edm::LogVerbatim("HGCalGeom") << k << ":" << np[place][k] << ":" << dx[np[place][k]] << ":" << dy[np[place][k]];
1436 #endif
1437  }
1438  }
1439 #ifdef EDM_ML_DEBUG
1440  edm::LogVerbatim("HGCalGeom") << "I/p: " << part << ":" << place << ":" << delX << ":" << delY << ":" << xpos << ":"
1441  << ypos << " O/p having " << xy.size() << " points:";
1442  std::ostringstream st1;
1443  for (unsigned int i = 0; i < xy.size(); ++i)
1444  st1 << " [" << i << "] " << xy[i].first << ":" << xy[i].second;
1445  edm::LogVerbatim("HGCalGeom") << st1.str();
1446 #endif
1447  return xy;
1448 }
Log< level::Info, true > LogVerbatim
static constexpr int32_t WaferHalf2
Definition: HGCalTypes.h:42
static constexpr int32_t WaferFive2
Definition: HGCalTypes.h:43
static constexpr int32_t WaferSizeMax
Definition: HGCalTypes.h:75
static constexpr int32_t WaferLDThree
Definition: HGCalTypes.h:49
static constexpr int k_fourCorners
static std::vector< std::pair< double, double > > waferXY(int part, int orient, int zside, double delX, double delY, double xpos, double ypos)
static bool goodCell(int u, int v, int N, int type, int rotn)
static constexpr int32_t WaferOut
Definition: HGCalTypes.h:55
base
Main Program
Definition: newFWLiteAna.py:92
static constexpr int k_twoCorners
static constexpr int32_t WaferThree
Definition: HGCalTypes.h:41
static constexpr double c50
Definition: HGCalTypes.h:81
static constexpr int32_t WaferHDFive
Definition: HGCalTypes.h:54
static constexpr double c88
Definition: HGCalTypes.h:85
int zside(DetId const &)
static int getRotation(int zside, int type, int rotn)
static constexpr double c27
Definition: HGCalTypes.h:80
static constexpr double c10
Definition: HGCalTypes.h:86
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
static constexpr int32_t WaferSemi2
Definition: HGCalTypes.h:40
static constexpr int32_t WaferHDLeft
Definition: HGCalTypes.h:52
constexpr uint32_t mask
Definition: gpuClustering.h:24
static bool goodTypeMode(double xpos, double ypos, double delX, double delY, double rin, double rout, int part, int rotn, bool debug=false)
U second(std::pair< T, U > const &p)
static constexpr int32_t WaferFull
Definition: HGCalTypes.h:34
static constexpr int32_t WaferHalf
Definition: HGCalTypes.h:38
static constexpr int32_t WaferLDBottom
Definition: HGCalTypes.h:45
int np
Definition: AMPTWrapper.h:43
static constexpr int32_t WaferCorner1
Definition: HGCalTypes.h:13
T sqrt(T t)
Definition: SSEVec.h:19
static constexpr int32_t WaferCorner5
Definition: HGCalTypes.h:17
static constexpr int32_t WaferLDRight
Definition: HGCalTypes.h:47
static constexpr int32_t WaferCorner4
Definition: HGCalTypes.h:16
static constexpr int32_t WaferCornerMax
Definition: HGCalTypes.h:74
static constexpr int32_t WaferCorner2
Definition: HGCalTypes.h:14
static constexpr int32_t WaferLDFive
Definition: HGCalTypes.h:48
static constexpr int32_t WaferCorner0
Definition: HGCalTypes.h:12
static constexpr int32_t WaferLDLeft
Definition: HGCalTypes.h:46
static constexpr double c00
Definition: HGCalTypes.h:77
static constexpr int32_t WaferHDBottom
Definition: HGCalTypes.h:51
static constexpr int32_t WaferCorner3
Definition: HGCalTypes.h:15
static constexpr int32_t WaferHDRight
Definition: HGCalTypes.h:53
#define debug
Definition: HDRShower.cc:19
static constexpr int k_fiveCorners
static constexpr int32_t WaferChopTwoM
Definition: HGCalTypes.h:37
auto const good
min quality of good
part
Definition: HCALResponse.h:20
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 debug=false)
static constexpr double c77
Definition: HGCalTypes.h:84
static constexpr double c61
Definition: HGCalTypes.h:82
static constexpr int k_OffsetRotation
static constexpr int k_threeCorners
static constexpr int32_t WaferLDTop
Definition: HGCalTypes.h:44
static constexpr double c75
Definition: HGCalTypes.h:83
static constexpr double c22
Definition: HGCalTypes.h:78
static constexpr int32_t WaferHDTop
Definition: HGCalTypes.h:50
static constexpr int32_t WaferFive
Definition: HGCalTypes.h:35
static constexpr int32_t WaferSemi
Definition: HGCalTypes.h:39
static constexpr int k_allCorners
static constexpr int32_t WaferChopTwo
Definition: HGCalTypes.h:36
static bool maskCell(int u, int v, int N, int ncor, int fcor, int corners)