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  // for V15 and V16
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));
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 - 1);
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 - 1);
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 - 1));
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 - 1);
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 + 1));
247  break;
248  }
249  case (HGCalTypes::WaferCorner2): {
250  good = ((2 * v - u) >= (n - 2));
251  break;
252  }
253  case (HGCalTypes::WaferCorner3): {
254  good = ((u + v) >= (2 * n - 2));
255  break;
256  }
257  case (HGCalTypes::WaferCorner4): {
258  good = ((2 * u - v) >= (n - 1));
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  good = ((2 * u - v) <= 1);
276  break;
277  }
278  case (HGCalTypes::WaferCorner2): {
279  int u2 = ((u > 0) ? (u / 2) : 0);
280  int uv = v - u2;
281  good = (uv >= (n - 1));
282  break;
283  }
284  case (HGCalTypes::WaferCorner3): {
285  good = ((v + u) >= (3 * n - 2));
286  break;
287  }
288  case (HGCalTypes::WaferCorner4): {
289  int uv = 2 * u - v;
290  good = (uv >= (2 * n - 1));
291  break;
292  }
293  default: {
294  int uv = u - 2 * v;
295  good = (uv >= 0);
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 + 1));
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 - 1));
314  break;
315  }
316  case (HGCalTypes::WaferCorner3): {
317  good = ((u + v) >= (5 * n2 - 1));
318  break;
319  }
320  case (HGCalTypes::WaferCorner4): {
321  good = ((2 * u - v) >= (3 * n2));
322  break;
323  }
324  default: {
325  int u2 = (u + 1) / 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 - 1);
373  break;
374  }
375  case (HGCalTypes::WaferCorner3): {
376  good = (v >= (5 * n4 - 1));
377  break;
378  }
379  case (HGCalTypes::WaferCorner4): {
380  good = (u >= (5 * n4 - 1));
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 bool HGCalWaferMask::goodCell(int u, int v, int waferType) {
399  // for V17
400  bool good(false);
401  switch (waferType) {
402  case (HGCalTypes::WaferFull): { //WaferFull
403  good = true;
404  break;
405  }
406  case (HGCalTypes::WaferLDTop): {
408  break;
409  }
410  case (HGCalTypes::WaferLDBottom): {
413  break;
414  }
415  case (HGCalTypes::WaferLDLeft): {
416  good =
418  break;
419  }
420  case (HGCalTypes::WaferLDRight): {
423  break;
424  }
425  case (HGCalTypes::WaferLDFive): {
426  good =
428  break;
429  }
430  case (HGCalTypes::WaferLDThree): {
433  break;
434  }
435  case (HGCalTypes::WaferHDTop): {
437  break;
438  }
439  case (HGCalTypes::WaferHDBottom): {
442  break;
443  }
444  case (HGCalTypes::WaferHDLeft): {
445  good =
447  break;
448  }
449  case (HGCalTypes::WaferHDRight): {
452  break;
453  }
454  case (HGCalTypes::WaferHDFive): {
455  good =
457  break;
458  }
459  }
460 #ifdef EDM_ML_DEBUG
461  edm::LogVerbatim("HGCalGeom") << "u|v " << u << ":" << v << " WaferType " << waferType << " good " << good;
462 #endif
463  return good;
464 }
465 
466 int HGCalWaferMask::getRotation(int zside, int type, int rotn) {
467  // Needs extension for V17
468  if (rotn >= HGCalTypes::WaferCornerMax)
470  int newrotn(rotn);
471  if ((zside < 0) && (type != HGCalTypes::WaferFull)) {
472  if ((type == HGCalTypes::WaferFive) || (type == HGCalTypes::WaferFive2)) { //WaferFive/WaferFive2
473  static constexpr int rot1[HGCalTypes::WaferCornerMax] = {HGCalTypes::WaferCorner4,
479  newrotn = rot1[rotn];
480  } else if ((type == HGCalTypes::WaferThree) || (type == HGCalTypes::WaferSemi) ||
481  (type == HGCalTypes::WaferSemi2)) { //WaferThree/WaferSemi/WaferSemi2
482  static constexpr int rot2[HGCalTypes::WaferCornerMax] = {HGCalTypes::WaferCorner2,
488  newrotn = rot2[rotn];
489  } else { //WaferHalf/WaferChopTwo/WaferChopTwoM/WaferHalf2
490  static constexpr int rot3[HGCalTypes::WaferCornerMax] = {HGCalTypes::WaferCorner3,
496  newrotn = rot3[rotn];
497  }
498  }
499 #ifdef EDM_ML_DEBUG
500  edm::LogVerbatim("HGCalGeom") << "zside " << zside << " type " << type << " rotn " << rotn << ":" << newrotn;
501 #endif
502  return newrotn;
503 }
504 
505 std::pair<int, int> HGCalWaferMask::getTypeMode(const double& xpos,
506  const double& ypos,
507  const double& delX,
508  const double& delY,
509  const double& rin,
510  const double& rout,
511  const int& wType,
512  const int& mode,
513  bool debug) {
514  // No need to extend this for V17 -- use flat file information only
515  int ncor(0), iok(0);
517 
518  static constexpr int corners = 6;
519  static constexpr int base = 10;
520  double rin2 = rin * rin;
521  double rout2 = rout * rout;
522  double dx0[corners] = {HGCalTypes::c00 * delX,
523  HGCalTypes::c10 * delX,
524  HGCalTypes::c10 * delX,
525  HGCalTypes::c00 * delX,
526  -HGCalTypes::c10 * delX,
527  -HGCalTypes::c10 * delX};
528  double dy0[corners] = {-HGCalTypes::c10 * delY,
529  -HGCalTypes::c50 * delY,
530  HGCalTypes::c50 * delY,
531  HGCalTypes::c10 * delY,
532  HGCalTypes::c50 * delY,
533  -HGCalTypes::c50 * delY};
534  double xc[corners], yc[corners];
535  for (int k = 0; k < corners; ++k) {
536  xc[k] = xpos + dx0[k];
537  yc[k] = ypos + dy0[k];
538  double rpos2 = (xc[k] * xc[k] + yc[k] * yc[k]);
539  if (rpos2 <= rout2 && rpos2 >= rin2) {
540  ++ncor;
541  iok = iok * base + 1;
542  } else {
543  iok *= base;
544  }
545  }
546  if (debug)
547  edm::LogVerbatim("HGCalGeom") << "I/p " << xpos << ":" << ypos << ":" << delX << ":" << delY << ":" << rin << ":"
548  << rout << ":" << wType << ":" << mode << " Corners " << ncor << " iok " << iok;
549 
550  static constexpr int ipat5[corners] = {101111, 110111, 111011, 111101, 111110, 11111};
551  static constexpr int ipat4[corners] = {100111, 110011, 111001, 111100, 11110, 1111};
552  static constexpr int ipat3[corners] = {100011, 110001, 111000, 11100, 1110, 111};
553  static constexpr int ipat2[corners] = {11, 100001, 110000, 11000, 1100, 110};
554  double dx1[corners] = {HGCalTypes::c50 * delX,
555  HGCalTypes::c10 * delX,
556  HGCalTypes::c50 * delX,
557  -HGCalTypes::c50 * delX,
558  -HGCalTypes::c10 * delX,
559  -HGCalTypes::c50 * delX};
560  double dy1[corners] = {-HGCalTypes::c75 * delY,
561  HGCalTypes::c00 * delY,
562  HGCalTypes::c75 * delY,
563  HGCalTypes::c75 * delY,
564  HGCalTypes::c00 * delY,
565  -HGCalTypes::c75 * delY};
566  double dx2[corners] = {HGCalTypes::c50 * delX,
567  -HGCalTypes::c50 * delX,
568  -HGCalTypes::c10 * delX,
569  -HGCalTypes::c50 * delX,
570  HGCalTypes::c50 * delX,
571  HGCalTypes::c10 * delX};
572  double dy2[corners] = {HGCalTypes::c75 * delY,
573  HGCalTypes::c75 * delY,
574  HGCalTypes::c00 * delY,
575  -HGCalTypes::c75 * delY,
576  -HGCalTypes::c75 * delY,
577  HGCalTypes::c00 * delY};
578  double dx3[corners] = {HGCalTypes::c22 * delX,
579  HGCalTypes::c10 * delX,
580  HGCalTypes::c77 * delX,
581  -HGCalTypes::c22 * delX,
582  -HGCalTypes::c10 * delX,
583  -HGCalTypes::c77 * delX};
584  double dy3[corners] = {-HGCalTypes::c88 * delY,
585  -HGCalTypes::c27 * delY,
586  HGCalTypes::c61 * delY,
587  HGCalTypes::c88 * delY,
588  HGCalTypes::c27 * delY,
589  -HGCalTypes::c61 * delY};
590  double dx4[corners] = {HGCalTypes::c22 * delX,
591  -HGCalTypes::c77 * delX,
592  -HGCalTypes::c10 * delX,
593  -HGCalTypes::c22 * delX,
594  HGCalTypes::c77 * delX,
595  HGCalTypes::c10 * delX};
596  double dy4[corners] = {HGCalTypes::c88 * delY,
597  HGCalTypes::c61 * delY,
598  -HGCalTypes::c27 * delY,
599  -HGCalTypes::c88 * delY,
600  -HGCalTypes::c61 * delY,
601  HGCalTypes::c27 * delY};
602  double dx5[corners] = {-HGCalTypes::c50 * delX,
603  -HGCalTypes::c10 * delX,
604  -HGCalTypes::c50 * delX,
605  HGCalTypes::c50 * delX,
606  HGCalTypes::c10 * delX,
607  HGCalTypes::c50 * delX};
608  double dy5[corners] = {HGCalTypes::c75 * delY,
609  HGCalTypes::c00 * delY,
610  -HGCalTypes::c75 * delY,
611  -HGCalTypes::c75 * delY,
612  HGCalTypes::c00 * delY,
613  HGCalTypes::c75 * delY};
614  double dx6[corners] = {-HGCalTypes::c77 * delX,
615  -HGCalTypes::c10 * delX,
616  -HGCalTypes::c22 * delX,
617  HGCalTypes::c77 * delX,
618  HGCalTypes::c10 * delX,
619  HGCalTypes::c22 * delX};
620  double dy6[corners] = {HGCalTypes::c61 * delY,
621  -HGCalTypes::c27 * delY,
622  -HGCalTypes::c88 * delY,
623  -HGCalTypes::c61 * delY,
624  HGCalTypes::c27 * delY,
625  HGCalTypes::c88 * delY};
626  double dx7[corners] = {-HGCalTypes::c22 * delX,
627  -HGCalTypes::c10 * delX,
628  -HGCalTypes::c77 * delX,
629  HGCalTypes::c22 * delX,
630  HGCalTypes::c10 * delX,
631  HGCalTypes::c77 * delX};
632  double dy7[corners] = {HGCalTypes::c88 * delY,
633  HGCalTypes::c27 * delY,
634  -HGCalTypes::c61 * delY,
635  -HGCalTypes::c88 * delY,
636  -HGCalTypes::c27 * delY,
637  HGCalTypes::c61 * delY};
638  double dx8[corners] = {HGCalTypes::c77 * delX,
639  HGCalTypes::c10 * delX,
640  HGCalTypes::c22 * delX,
641  -HGCalTypes::c77 * delX,
642  -HGCalTypes::c10 * delX,
643  -HGCalTypes::c22 * delX};
644  double dy8[corners] = {-HGCalTypes::c61 * delY,
645  HGCalTypes::c27 * delY,
646  HGCalTypes::c88 * delY,
647  HGCalTypes::c61 * delY,
648  -HGCalTypes::c27 * delY,
649  -HGCalTypes::c88 * delY};
650  double dx9[corners] = {-HGCalTypes::c22 * delX,
651  HGCalTypes::c77 * delX,
652  HGCalTypes::c10 * delX,
653  HGCalTypes::c22 * delX,
654  -HGCalTypes::c77 * delX,
655  -HGCalTypes::c10 * delX};
656  double dy9[corners] = {-HGCalTypes::c88 * delY,
657  -HGCalTypes::c61 * delY,
658  HGCalTypes::c27 * delY,
659  HGCalTypes::c88 * delY,
660  HGCalTypes::c61 * delY,
661  -HGCalTypes::c27 * delY};
662 
663  if (ncor == HGCalGeomTools::k_allCorners) {
664  } else if (ncor == HGCalGeomTools::k_fiveCorners) {
665  rotn = static_cast<int>(std::find(ipat5, ipat5 + 6, iok) - ipat5);
667  } else if (ncor == HGCalGeomTools::k_fourCorners) {
668  rotn = static_cast<int>(std::find(ipat4, ipat4 + 6, iok) - ipat4);
670  double rpos12 = ((xpos + dx1[rotn]) * (xpos + dx1[rotn]) + (ypos + dy1[rotn]) * (ypos + dy1[rotn]));
671  double rpos22(0);
672  if (rpos12 <= rout2 && rpos12 >= rin2) {
673  rpos22 = ((xpos + dx2[rotn]) * (xpos + dx2[rotn]) + (ypos + dy2[rotn]) * (ypos + dy2[rotn]));
674  if (rpos22 <= rout2 && rpos22 >= rin2)
676  }
677  if (debug)
678  edm::LogVerbatim("HGCalGeom") << "Test for Chop2 " << std::sqrt(rpos12) << ":" << std::sqrt(rpos22) << " Type "
679  << type;
680  if ((type == HGCalTypes::WaferHalf) && (wType == 0)) {
681  rpos12 = ((xpos + dx3[rotn]) * (xpos + dx3[rotn]) + (ypos + dy3[rotn]) * (ypos + dy3[rotn]));
682  if (rpos12 <= rout2 && rpos12 >= rin2) {
683  rpos22 = ((xpos + dx4[rotn]) * (xpos + dx4[rotn]) + (ypos + dy4[rotn]) * (ypos + dy4[rotn]));
684  if (rpos22 <= rout2 && rpos22 >= rin2)
686  }
687  if (debug)
688  edm::LogVerbatim("HGCalGeom") << "Test for Chop2M " << std::sqrt(rpos12) << ":" << std::sqrt(rpos22) << " Type "
689  << type;
690  }
691  } else if (ncor == HGCalGeomTools::k_threeCorners) {
692  rotn = static_cast<int>(std::find(ipat3, ipat3 + 6, iok) - ipat3);
694  double rpos12 = ((xpos + dx7[rotn]) * (xpos + dx7[rotn]) + (ypos + dy7[rotn]) * (ypos + dy7[rotn]));
695  double rpos22(0);
696  if (rpos12 <= rout2 && rpos12 >= rin2) {
697  rpos22 = ((xpos + dx8[rotn]) * (xpos + dx8[rotn]) + (ypos + dy8[rotn]) * (ypos + dy8[rotn]));
698  if (rpos22 <= rout2 && rpos22 >= rin2)
700  }
701  if (debug)
702  edm::LogVerbatim("HGCalGeom") << "Test for Five2 " << std::sqrt(rpos12) << ":" << std::sqrt(rpos22) << " Type "
703  << type;
704  if ((type == HGCalTypes::WaferThree) && (wType == 0)) {
705  rpos12 = ((xpos + dx1[rotn]) * (xpos + dx1[rotn]) + (ypos + dy1[rotn]) * (ypos + dy1[rotn]));
706  if (rpos12 <= rout2 && rpos12 >= rin2) {
707  rpos22 = ((xpos + dx5[rotn]) * (xpos + dx5[rotn]) + (ypos + dy5[rotn]) * (ypos + dy5[rotn]));
708  if (rpos22 <= rout2 && rpos22 >= rin2)
710  }
711  if (debug)
712  edm::LogVerbatim("HGCalGeom") << "Test for Semi " << std::sqrt(rpos12) << ":" << std::sqrt(rpos22) << " Type "
713  << type;
714  }
715  if ((type == HGCalTypes::WaferThree) && (wType == 0)) {
716  rpos12 = ((xpos + dx3[rotn]) * (xpos + dx3[rotn]) + (ypos + dy3[rotn]) * (ypos + dy3[rotn]));
717  if (rpos12 <= rout2 && rpos12 >= rin2) {
718  rpos22 = ((xpos + dx6[rotn]) * (xpos + dx6[rotn]) + (ypos + dy6[rotn]) * (ypos + dy6[rotn]));
719  if (rpos22 <= rout2 && rpos22 >= rin2)
721  }
722  if (debug)
723  edm::LogVerbatim("HGCalGeom") << "Test for SemiM " << std::sqrt(rpos12) << ":" << std::sqrt(rpos22) << " Type "
724  << type;
725  }
726  } else if (ncor == HGCalGeomTools::k_twoCorners) {
727  rotn = static_cast<int>(std::find(ipat2, ipat2 + 6, iok) - ipat2);
729  double rpos12 = ((xpos + dx7[rotn]) * (xpos + dx7[rotn]) + (ypos + dy7[rotn]) * (ypos + dy7[rotn]));
730  double rpos22(0);
731  if (rpos12 <= rout2 && rpos12 >= rin2) {
732  rpos22 = ((xpos + dx9[rotn]) * (xpos + dx9[rotn]) + (ypos + dy9[rotn]) * (ypos + dy9[rotn]));
733  if (rpos22 <= rout2 && rpos22 >= rin2)
735  else
737  }
738  if (debug)
739  edm::LogVerbatim("HGCalGeom") << "Test for Half2 " << std::sqrt(rpos12) << ":" << std::sqrt(rpos22) << " Type "
740  << type;
741  } else {
743  }
744 
745  if (debug)
746  edm::LogVerbatim("HGCalGeom") << "I/p " << xpos << ":" << ypos << ":" << delX << ":" << delY << ":" << rin << ":"
747  << rout << ":" << wType << ":" << mode << " o/p " << iok << ":" << ncor << ":" << type
748  << ":" << rotn;
749  return ((mode == 0) ? std::make_pair(ncor, rotn) : std::make_pair(type, (rotn + HGCalTypes::k_OffsetRotation)));
750 }
751 
753  double xpos, double ypos, double delX, double delY, double rin, double rout, int part, int rotn, bool debug) {
754  // Needs extension for V17
756  return false;
757  if (rotn < 0 || rotn > HGCalTypes::WaferCornerMax)
758  return false;
759  double rin2 = rin * rin;
760  double rout2 = rout * rout;
761  double rpos2(0);
762  static constexpr int corners = HGCalTypes::WaferCornerMax;
763  static constexpr int corner2 = 2 * HGCalTypes::WaferCornerMax;
764  static constexpr int base = 10;
765  static constexpr int base2 = 100;
766  double dx0[corners] = {HGCalTypes::c00 * delX,
767  HGCalTypes::c10 * delX,
768  HGCalTypes::c10 * delX,
769  HGCalTypes::c00 * delX,
770  -HGCalTypes::c10 * delX,
771  -HGCalTypes::c10 * delX};
772  double dy0[corners] = {-HGCalTypes::c10 * delY,
773  -HGCalTypes::c50 * delY,
774  HGCalTypes::c50 * delY,
775  HGCalTypes::c10 * delY,
776  HGCalTypes::c50 * delY,
777  -HGCalTypes::c50 * delY};
778  double dx1[corners] = {HGCalTypes::c50 * delX,
779  HGCalTypes::c10 * delX,
780  HGCalTypes::c50 * delX,
781  -HGCalTypes::c50 * delX,
782  -HGCalTypes::c10 * delX,
783  -HGCalTypes::c50 * delX};
784  double dy1[corners] = {-HGCalTypes::c75 * delY,
785  HGCalTypes::c00 * delY,
786  HGCalTypes::c75 * delY,
787  HGCalTypes::c75 * delY,
788  HGCalTypes::c00 * delY,
789  -HGCalTypes::c75 * delY};
790  double dx2[corner2] = {HGCalTypes::c22 * delX,
791  HGCalTypes::c77 * delX,
792  HGCalTypes::c10 * delX,
793  HGCalTypes::c10 * delX,
794  HGCalTypes::c77 * delX,
795  HGCalTypes::c22 * delX,
796  -HGCalTypes::c22 * delX,
797  -HGCalTypes::c77 * delX,
798  -HGCalTypes::c10 * delX,
799  -HGCalTypes::c10 * delX,
800  -HGCalTypes::c77 * delX,
801  -HGCalTypes::c22 * delX};
802  double dy2[corner2] = {-HGCalTypes::c88 * delY,
803  -HGCalTypes::c61 * delY,
804  -HGCalTypes::c27 * delY,
805  HGCalTypes::c27 * delY,
806  HGCalTypes::c61 * delY,
807  HGCalTypes::c88 * delY,
808  HGCalTypes::c88 * delY,
809  HGCalTypes::c61 * delY,
810  HGCalTypes::c27 * delY,
811  -HGCalTypes::c27 * delY,
812  -HGCalTypes::c61 * delY,
813  -HGCalTypes::c88 * delY};
814  bool ok(true);
815  int ncf(-1);
816  switch (part) {
817  case (HGCalTypes::WaferThree): {
818  static constexpr int nc0[corners] = {450, 150, 201, 312, 423, 534};
819  int nc = nc0[rotn];
820  for (int k1 = 0; k1 < 3; ++k1) {
821  int k = nc % base;
822  double xc1 = xpos + dx0[k];
823  double yc1 = ypos + dy0[k];
824  rpos2 = (xc1 * xc1 + yc1 * yc1);
825  if ((rpos2 > rout2) || (rpos2 < rin2)) {
826  ok = false;
827  ncf = k;
828  break;
829  }
830  nc /= base;
831  }
832  break;
833  }
834  case (HGCalTypes::WaferSemi2): {
835  static constexpr int nc10[corners] = {450, 150, 201, 312, 423, 534};
836  static constexpr int nc11[corners] = {700, 902, 1104, 106, 308, 510};
837  int nc = nc10[rotn];
838  for (int k1 = 0; k1 < 3; ++k1) {
839  int k = nc % base;
840  double xc1 = xpos + dx0[k];
841  double yc1 = ypos + dy0[k];
842  rpos2 = (xc1 * xc1 + yc1 * yc1);
843  if ((rpos2 > rout2) || (rpos2 < rin2)) {
844  ok = false;
845  ncf = k;
846  break;
847  }
848  nc /= base;
849  }
850  nc = nc11[rotn];
851  for (int k1 = 0; k1 < 2; ++k1) {
852  int k = nc % base2;
853  double xc1 = xpos + dx2[k];
854  double yc1 = ypos + dy2[k];
855  rpos2 = (xc1 * xc1 + yc1 * yc1);
856  if ((rpos2 > rout2) || (rpos2 < rin2)) {
857  ok = false;
858  ncf = k + base2;
859  break;
860  }
861  nc /= base2;
862  }
863  break;
864  }
865  case (HGCalTypes::WaferSemi): {
866  static constexpr int nc20[corners] = {450, 150, 201, 312, 423, 534};
867  static constexpr int nc21[corners] = {30, 14, 25, 30, 41, 52};
868  int nc = nc20[rotn];
869  for (int k1 = 0; k1 < 3; ++k1) {
870  int k = nc % base;
871  double xc1 = xpos + dx0[k];
872  double yc1 = ypos + dy0[k];
873  rpos2 = (xc1 * xc1 + yc1 * yc1);
874  if ((rpos2 > rout2) || (rpos2 < rin2)) {
875  ok = false;
876  ncf = k;
877  break;
878  }
879  nc /= base;
880  }
881  nc = nc21[rotn];
882  for (int k1 = 0; k1 < 2; ++k1) {
883  int k = nc % base;
884  double xc1 = xpos + dx1[k];
885  double yc1 = ypos + dy1[k];
886  rpos2 = (xc1 * xc1 + yc1 * yc1);
887  if ((rpos2 > rout2) || (rpos2 < rin2)) {
888  ok = false;
889  ncf = k + base2;
890  break;
891  }
892  nc /= base;
893  }
894  break;
895  }
896  case (HGCalTypes::WaferHalf): {
897  static constexpr int nc3[corners] = {3450, 1450, 2501, 3012, 4123, 5234};
898  int nc = nc3[rotn];
899  for (int k1 = 0; k1 < 4; ++k1) {
900  int k = nc % base;
901  double xc1 = xpos + dx0[k];
902  double yc1 = ypos + dy0[k];
903  rpos2 = (xc1 * xc1 + yc1 * yc1);
904  if ((rpos2 > rout2) || (rpos2 < rin2)) {
905  ok = false;
906  ncf = k;
907  break;
908  }
909  nc /= base;
910  }
911  break;
912  }
913  case (HGCalTypes::WaferChopTwoM): {
914  static constexpr int nc40[corners] = {3450, 1450, 2501, 3012, 4123, 5234};
915  static constexpr int nc41[corners] = {500, 702, 904, 1106, 108, 310};
916  int nc = nc40[rotn];
917  for (int k1 = 0; k1 < 4; ++k1) {
918  int k = nc % base;
919  double xc1 = xpos + dx0[k];
920  double yc1 = ypos + dy0[k];
921  rpos2 = (xc1 * xc1 + yc1 * yc1);
922  if ((rpos2 > rout2) || (rpos2 < rin2)) {
923  ok = false;
924  ncf = k;
925  break;
926  }
927  nc /= base;
928  }
929  nc = nc41[rotn];
930  for (int k1 = 0; k1 < 2; ++k1) {
931  int k = nc % base2;
932  double xc1 = xpos + dx2[k];
933  double yc1 = ypos + dy2[k];
934  rpos2 = (xc1 * xc1 + yc1 * yc1);
935  if ((rpos2 > rout2) || (rpos2 < rin2)) {
936  ok = false;
937  ncf = k + base2;
938  break;
939  }
940  nc /= base2;
941  }
942  break;
943  }
944  case (HGCalTypes::WaferChopTwo): {
945  static constexpr int nc50[corners] = {3450, 1450, 2501, 3012, 4123, 5234};
946  static constexpr int nc51[corners] = {20, 13, 24, 35, 40, 51};
947  int nc = nc50[rotn];
948  for (int k1 = 0; k1 < 4; ++k1) {
949  int k = nc % base;
950  double xc1 = xpos + dx0[k];
951  double yc1 = ypos + dy0[k];
952  rpos2 = (xc1 * xc1 + yc1 * yc1);
953  if ((rpos2 > rout2) || (rpos2 < rin2)) {
954  ok = false;
955  ncf = k;
956  break;
957  }
958  nc /= base;
959  }
960  nc = nc51[rotn];
961  for (int k1 = 0; k1 < 2; ++k1) {
962  int k = nc % base;
963  double xc1 = xpos + dx1[k];
964  double yc1 = ypos + dy1[k];
965  rpos2 = (xc1 * xc1 + yc1 * yc1);
966  if ((rpos2 > rout2) || (rpos2 < rin2)) {
967  ok = false;
968  ncf = k + base2;
969  break;
970  }
971  nc /= base;
972  }
973  break;
974  }
975  case (HGCalTypes::WaferFive): {
976  static constexpr int nc6[corners] = {23450, 13450, 24501, 35012, 40123, 51234};
977  int nc = nc6[rotn];
978  for (int k1 = 0; k1 < 5; ++k1) {
979  int k = nc % base;
980  double xc1 = xpos + dx0[k];
981  double yc1 = ypos + dy0[k];
982  rpos2 = (xc1 * xc1 + yc1 * yc1);
983  if ((rpos2 > rout2) || (rpos2 < rin2)) {
984  ok = false;
985  ncf = k;
986  break;
987  }
988  }
989  break;
990  }
991  case (HGCalTypes::WaferFive2): {
992  static constexpr int nc60[corners] = {450, 150, 201, 312, 423, 534};
993  static constexpr int nc61[corners] = {601, 803, 1005, 7, 209, 411};
994  int nc = nc60[rotn];
995  for (int k1 = 0; k1 < 3; ++k1) {
996  int k = nc % base;
997  double xc1 = xpos + dx0[k];
998  double yc1 = ypos + dy0[k];
999  rpos2 = (xc1 * xc1 + yc1 * yc1);
1000  if ((rpos2 > rout2) || (rpos2 < rin2)) {
1001  ok = false;
1002  ncf = k;
1003  break;
1004  }
1005  nc /= base;
1006  }
1007  nc = nc61[rotn];
1008  for (int k1 = 0; k1 < 2; ++k1) {
1009  int k = nc % base2;
1010  double xc1 = xpos + dx2[k];
1011  double yc1 = ypos + dy2[k];
1012  rpos2 = (xc1 * xc1 + yc1 * yc1);
1013  if ((rpos2 > rout2) || (rpos2 < rin2)) {
1014  ok = false;
1015  ncf = k + base2;
1016  break;
1017  }
1018  nc /= base2;
1019  }
1020  break;
1021  }
1022  case (HGCalTypes::WaferHalf2): {
1023  static constexpr int nc70[corners] = {45, 50, 1, 12, 23, 34};
1024  static constexpr int nc71[corners] = {611, 801, 1003, 5, 207, 409};
1025  int nc = nc70[rotn];
1026  for (int k1 = 0; k1 < 2; ++k1) {
1027  int k = nc % base;
1028  double xc1 = xpos + dx0[k];
1029  double yc1 = ypos + dy0[k];
1030  rpos2 = (xc1 * xc1 + yc1 * yc1);
1031  if ((rpos2 > rout2) || (rpos2 < rin2)) {
1032  ok = false;
1033  ncf = k;
1034  break;
1035  }
1036  nc /= base;
1037  }
1038  nc = nc71[rotn];
1039  for (int k1 = 0; k1 < 2; ++k1) {
1040  int k = nc % base2;
1041  double xc1 = xpos + dx2[k];
1042  double yc1 = ypos + dy2[k];
1043  rpos2 = (xc1 * xc1 + yc1 * yc1);
1044  if ((rpos2 > rout2) || (rpos2 < rin2)) {
1045  ok = false;
1046  ncf = k + base2;
1047  break;
1048  }
1049  nc /= base2;
1050  }
1051  break;
1052  }
1053  default: {
1054  for (int k = 0; k < corners; ++k) {
1055  double xc1 = xpos + dx0[k];
1056  double yc1 = ypos + dy0[k];
1057  rpos2 = (xc1 * xc1 + yc1 * yc1);
1058  if ((rpos2 > rout2) || (rpos2 < rin2)) {
1059  ok = false;
1060  ncf = k;
1061  break;
1062  }
1063  }
1064  break;
1065  }
1066  }
1067  if (debug || (!ok))
1068  edm::LogVerbatim("HGCalGeom") << "I/p "
1069  << ":" << xpos << ":" << ypos << ":" << delX << ":" << delY << ":" << rin << ":"
1070  << rout << ":" << part << ":" << rotn << " Results " << ok << ":" << ncf << " R "
1071  << rin2 << ":" << rout2 << ":" << rpos2;
1072  return ok;
1073 }
1074 
1075 std::vector<std::pair<double, double> > HGCalWaferMask::waferXY(
1076  int part, int ori, int zside, double waferSize, double offset, double xpos, double ypos) {
1077  // Good for V15 and V16 versions
1078  std::vector<std::pair<double, double> > xy;
1079  int orient = getRotation(-zside, part, ori);
1080 #ifdef EDM_ML_DEBUG
1081  edm::LogVerbatim("HGCalGeom") << "Part " << part << " zSide " << zside << " Orient " << ori << ":" << orient;
1082 #endif
1083  /*
1084  The exact contour of partial wafers are obtained by joining points on
1085  the circumference of a full wafer.
1086  Numbering the points along the edges of a hexagonal wafer, starting from
1087  the bottom corner:
1088 
1089  3
1090  15 18
1091  9 8
1092  19 14
1093  4 2
1094  16 23
1095  10 7
1096  20 13
1097  5 1
1098  17 22
1099  11 6
1100  21 12
1101  0
1102 
1103  Depending on the wafer type and orientation index, the corners
1104  are chosen in the variable *np*
1105  */
1106  double delX = 0.5 * waferSize;
1107  double delY = delX / sin_60_;
1108  double dx[48] = {HGCalTypes::c00 * delX, HGCalTypes::c10 * delX, HGCalTypes::c10 * delX, HGCalTypes::c00 * delX,
1109  -HGCalTypes::c10 * delX, -HGCalTypes::c10 * delX, HGCalTypes::c50 * delX, HGCalTypes::c10 * delX,
1110  HGCalTypes::c50 * delX, -HGCalTypes::c50 * delX, -HGCalTypes::c10 * delX, -HGCalTypes::c50 * delX,
1111  HGCalTypes::c22 * delX, HGCalTypes::c10 * delX, HGCalTypes::c77 * delX, -HGCalTypes::c22 * delX,
1112  -HGCalTypes::c10 * delX, -HGCalTypes::c77 * delX, HGCalTypes::c22 * delX, -HGCalTypes::c77 * delX,
1113  -HGCalTypes::c10 * delX, -HGCalTypes::c22 * delX, HGCalTypes::c77 * delX, HGCalTypes::c10 * delX,
1114  HGCalTypes::c50 * delX, HGCalTypes::c10 * delX, HGCalTypes::c50 * delX, -HGCalTypes::c50 * delX,
1115  -HGCalTypes::c10 * delX, -HGCalTypes::c50 * delX, HGCalTypes::c50 * delX, HGCalTypes::c10 * delX,
1116  HGCalTypes::c50 * delX, -HGCalTypes::c50 * delX, -HGCalTypes::c10 * delX, -HGCalTypes::c50 * delX,
1117  HGCalTypes::c22 * delX, HGCalTypes::c10 * delX, HGCalTypes::c77 * delX, -HGCalTypes::c22 * delX,
1118  -HGCalTypes::c10 * delX, -HGCalTypes::c77 * delX, HGCalTypes::c22 * delX, -HGCalTypes::c77 * delX,
1119  -HGCalTypes::c10 * delX, -HGCalTypes::c22 * delX, HGCalTypes::c77 * delX, HGCalTypes::c10 * delX};
1120  double dy[48] = {-HGCalTypes::c10 * delY, -HGCalTypes::c50 * delY, HGCalTypes::c50 * delY, HGCalTypes::c10 * delY,
1121  HGCalTypes::c50 * delY, -HGCalTypes::c50 * delY, -HGCalTypes::c75 * delY, HGCalTypes::c00 * delY,
1122  HGCalTypes::c75 * delY, HGCalTypes::c75 * delY, HGCalTypes::c00 * delY, -HGCalTypes::c75 * delY,
1123  -HGCalTypes::c88 * delY, -HGCalTypes::c27 * delY, HGCalTypes::c61 * delY, HGCalTypes::c88 * delY,
1124  HGCalTypes::c27 * delY, -HGCalTypes::c61 * delY, HGCalTypes::c88 * delY, HGCalTypes::c61 * delY,
1125  -HGCalTypes::c27 * delY, -HGCalTypes::c88 * delY, -HGCalTypes::c61 * delY, HGCalTypes::c27 * delY,
1126  -HGCalTypes::c75 * delY, HGCalTypes::c00 * delY, -HGCalTypes::c75 * delY, HGCalTypes::c00 * delY,
1127  HGCalTypes::c75 * delY, HGCalTypes::c75 * delY, HGCalTypes::c00 * delY, -HGCalTypes::c75 * delY,
1128  HGCalTypes::c75 * delY, HGCalTypes::c75 * delY, HGCalTypes::c00 * delY, -HGCalTypes::c75 * delY,
1129  -HGCalTypes::c88 * delY, -HGCalTypes::c27 * delY, HGCalTypes::c61 * delY, HGCalTypes::c88 * delY,
1130  HGCalTypes::c27 * delY, -HGCalTypes::c61 * delY, HGCalTypes::c88 * delY, HGCalTypes::c61 * delY,
1131  -HGCalTypes::c27 * delY, -HGCalTypes::c88 * delY, -HGCalTypes::c61 * delY, HGCalTypes::c27 * delY};
1132 
1133  double offsetx[48] = {0.0,
1134  -offset,
1135  -offset,
1136  0.0,
1137  offset,
1138  offset,
1139  -offset * cos_60_,
1140  -offset,
1141  -offset * cos_60_,
1142  offset * cos_60_,
1143  offset,
1144  offset * cos_60_,
1145  -offset * cos_60_,
1146  -offset,
1147  -offset * cos_60_,
1148  offset * cos_60_,
1149  offset,
1150  offset * cos_60_,
1151  -offset * cos_60_,
1152  offset * cos_60_,
1153  offset,
1154  offset * cos_60_,
1155  -offset * cos_60_,
1156  -offset,
1157  0.0,
1158  -offset,
1159  -offset,
1160  0.0,
1161  offset,
1162  offset,
1163  0.0,
1164  offset,
1165  offset,
1166  0.0,
1167  -offset,
1168  -offset,
1169  0.0,
1170  -offset,
1171  -offset,
1172  0.0,
1173  offset,
1174  offset,
1175  0.0,
1176  offset,
1177  offset,
1178  0.0,
1179  -offset,
1180  -offset};
1181  double offsety[48] = {offset / sin_60_,
1182  offset / tan_60_,
1183  -offset / tan_60_,
1184  -offset / sin_60_,
1185  -offset / tan_60_,
1186  offset / tan_60_,
1187  offset * sin_60_,
1188  0.0,
1189  -offset * sin_60_,
1190  -offset * sin_60_,
1191  0.0,
1192  offset * sin_60_,
1193  offset * sin_60_,
1194  0.0,
1195  -offset * sin_60_,
1196  -offset * sin_60_,
1197  0.0,
1198  offset * sin_60_,
1199  -offset * sin_60_,
1200  -offset * sin_60_,
1201  0.0,
1202  offset * sin_60_,
1203  offset * sin_60_,
1204  0.0,
1205  offset / sin_60_,
1206  offset / tan_60_,
1207  -offset / tan_60_,
1208  -offset / sin_60_,
1209  -offset / tan_60_,
1210  -offset / sin_60_,
1211  -offset / tan_60_,
1212  offset / tan_60_,
1213  offset / sin_60_,
1214  offset / tan_60_,
1215  -offset / tan_60_,
1216  offset / tan_60_,
1217  offset / sin_60_,
1218  offset / tan_60_,
1219  -offset / tan_60_,
1220  -offset / sin_60_,
1221  -offset / tan_60_,
1222  offset / tan_60_,
1223  -offset / sin_60_,
1224  -offset / tan_60_,
1225  offset / tan_60_,
1226  offset / sin_60_,
1227  offset / tan_60_,
1228  -offset / tan_60_};
1229 
1230  if (part == HGCalTypes::WaferFull) {
1231  int np[7] = {0, 1, 2, 3, 4, 5, 0};
1232  for (int k = 0; k < 7; ++k)
1233  xy.push_back(std::make_pair((xpos + dx[np[k]] + offsetx[np[k]]), (ypos + dy[np[k]] + offsety[np[k]])));
1234  } else if (part == HGCalTypes::WaferFive) {
1235  int np[6][6] = {{0, 2, 3, 4, 5, 0},
1236  {1, 3, 4, 5, 0, 1},
1237  {2, 4, 5, 0, 1, 2},
1238  {3, 5, 0, 1, 2, 3},
1239  {4, 0, 1, 2, 3, 4},
1240  {5, 1, 2, 3, 4, 5}};
1241  for (int k = 0; k < 6; ++k) {
1242  xy.push_back(std::make_pair((xpos + dx[np[orient][k]] + offsetx[np[orient][k]]),
1243  (ypos + dy[np[orient][k]] + offsety[np[orient][k]])));
1244 #ifdef EDM_ML_DEBUG
1245  edm::LogVerbatim("HGCalGeom") << k << ":" << np[orient][k] << ":" << dx[np[orient][k]] + offsetx[np[orient][k]]
1246  << ":" << dy[np[orient][k]] + offsety[np[orient][k]];
1247 #endif
1248  }
1249  } else if (part == HGCalTypes::WaferHalf) {
1250  int np[6][5] = {
1251  {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}};
1252  for (int k = 0; k < 5; ++k) {
1253  xy.push_back(std::make_pair((xpos + dx[np[orient][k]] + offsetx[np[orient][k]]),
1254  (ypos + dy[np[orient][k]] + offsety[np[orient][k]])));
1255 #ifdef EDM_ML_DEBUG
1256  edm::LogVerbatim("HGCalGeom") << k << ":" << np[orient][k] << ":" << dx[np[orient][k]] + offsetx[np[orient][k]]
1257  << ":" << dy[np[orient][k]] + offsety[np[orient][k]];
1258 #endif
1259  }
1260  } else if (part == HGCalTypes::WaferThree) {
1261  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}};
1262  for (int k = 0; k < 4; ++k) {
1263  xy.push_back(std::make_pair((xpos + dx[np[orient][k]] + offsetx[np[orient][k]]),
1264  (ypos + dy[np[orient][k]] + offsety[np[orient][k]])));
1265 #ifdef EDM_ML_DEBUG
1266  edm::LogVerbatim("HGCalGeom") << k << ":" << np[orient][k] << ":" << dx[np[orient][k]] + offsetx[np[orient][k]]
1267  << ":" << dy[np[orient][k]] + offsety[np[orient][k]];
1268 #endif
1269  }
1270  } else if (part == HGCalTypes::WaferChopTwo) {
1271  int np[6][7] = {{24, 32, 3, 4, 5, 0, 24},
1272  {25, 33, 4, 5, 0, 1, 25},
1273  {26, 34, 5, 0, 1, 2, 26},
1274  {27, 35, 0, 1, 2, 3, 27},
1275  {28, 30, 1, 2, 3, 4, 28},
1276  {29, 31, 2, 3, 4, 5, 29}};
1277  for (int k = 0; k < 7; ++k) {
1278  xy.push_back(std::make_pair((xpos + dx[np[orient][k]] + offsetx[np[orient][k]]),
1279  (ypos + dy[np[orient][k]] + offsety[np[orient][k]])));
1280 #ifdef EDM_ML_DEBUG
1281  edm::LogVerbatim("HGCalGeom") << k << ":" << np[orient][k] << ":" << dx[np[orient][k]] + offsetx[np[orient][k]]
1282  << ":" << dy[np[orient][k]] + offsety[np[orient][k]];
1283 #endif
1284  }
1285  } else if (part == HGCalTypes::WaferSemi) {
1286  int np[6][6] = {{6, 9, 4, 5, 0, 6},
1287  {7, 10, 5, 0, 1, 7},
1288  {8, 11, 0, 1, 2, 8},
1289  {9, 6, 1, 2, 3, 9},
1290  {10, 7, 2, 3, 4, 10},
1291  {11, 8, 3, 4, 5, 11}};
1292  for (int k = 0; k < 6; ++k) {
1293  xy.push_back(std::make_pair((xpos + dx[np[orient][k]] + offsetx[np[orient][k]]),
1294  (ypos + dy[np[orient][k]] + offsety[np[orient][k]])));
1295 #ifdef EDM_ML_DEBUG
1296  edm::LogVerbatim("HGCalGeom") << k << ":" << np[orient][k] << ":" << dx[np[orient][k]] + offsetx[np[orient][k]]
1297  << ":" << dy[np[orient][k]] + offsety[np[orient][k]];
1298 #endif
1299  }
1300  } else if (part == HGCalTypes::WaferChopTwoM) {
1301  int np[6][7] = {{36, 42, 3, 4, 5, 0, 36},
1302  {37, 43, 4, 5, 0, 1, 37},
1303  {38, 44, 5, 0, 1, 2, 38},
1304  {39, 45, 0, 1, 2, 3, 39},
1305  {40, 46, 1, 2, 3, 4, 40},
1306  {41, 47, 2, 3, 4, 5, 41}};
1307  for (int k = 0; k < 7; ++k) {
1308  xy.push_back(std::make_pair((xpos + dx[np[orient][k]] + offsetx[np[orient][k]]),
1309  (ypos + dy[np[orient][k]] + offsety[np[orient][k]])));
1310 #ifdef EDM_ML_DEBUG
1311  edm::LogVerbatim("HGCalGeom") << k << ":" << np[orient][k] << ":" << dx[np[orient][k]] + offsetx[np[orient][k]]
1312  << ":" << dy[np[orient][k]] + offsety[np[orient][k]];
1313 #endif
1314  }
1315  } else if (part == HGCalTypes::WaferSemi2) {
1316  int np[6][6] = {{12, 19, 4, 5, 0, 12},
1317  {13, 20, 5, 0, 1, 13},
1318  {14, 21, 0, 1, 2, 14},
1319  {15, 22, 1, 2, 3, 15},
1320  {16, 23, 2, 3, 4, 16},
1321  {17, 18, 3, 4, 5, 17}};
1322  for (int k = 0; k < 6; ++k) {
1323  xy.push_back(std::make_pair((xpos + dx[np[orient][k]] + offsetx[np[orient][k]]),
1324  (ypos + dy[np[orient][k]] + offsety[np[orient][k]])));
1325 #ifdef EDM_ML_DEBUG
1326  edm::LogVerbatim("HGCalGeom") << k << ":" << np[orient][k] << ":" << dx[np[orient][k]] + offsetx[np[orient][k]]
1327  << ":" << dy[np[orient][k]] + offsety[np[orient][k]];
1328 #endif
1329  }
1330  } else if (part == HGCalTypes::WaferFive2) {
1331  int np[6][6] = {{22, 15, 4, 5, 0, 22},
1332  {23, 16, 5, 0, 1, 23},
1333  {18, 17, 0, 1, 2, 18},
1334  {19, 12, 1, 2, 3, 19},
1335  {20, 13, 2, 3, 4, 20},
1336  {21, 14, 3, 4, 5, 21}};
1337  for (int k = 0; k < 6; ++k) {
1338  xy.push_back(std::make_pair((xpos + dx[np[orient][k]] + offsetx[np[orient][k]]),
1339  (ypos + dy[np[orient][k]] + offsety[np[orient][k]])));
1340 #ifdef EDM_ML_DEBUG
1341  edm::LogVerbatim("HGCalGeom") << k << ":" << np[orient][k] << ":" << dx[np[orient][k]] + offsetx[np[orient][k]]
1342  << ":" << dy[np[orient][k]] + offsety[np[orient][k]];
1343 #endif
1344  }
1345  } else if (part == HGCalTypes::WaferHalf2) {
1346  int np[6][5] = {{45, 39, 4, 5, 45},
1347  {46, 40, 5, 0, 46},
1348  {47, 41, 0, 1, 47},
1349  {42, 36, 1, 2, 42},
1350  {43, 37, 2, 3, 43},
1351  {44, 38, 3, 4, 44}};
1352  for (int k = 0; k < 5; ++k) {
1353  xy.push_back(std::make_pair((xpos + dx[np[orient][k]] + offsetx[np[orient][k]]),
1354  (ypos + dy[np[orient][k]] + offsety[np[orient][k]])));
1355 #ifdef EDM_ML_DEBUG
1356  edm::LogVerbatim("HGCalGeom") << k << ":" << np[orient][k] << ":" << dx[np[orient][k]] + offsetx[np[orient][k]]
1357  << ":" << dy[np[orient][k]] + offsety[np[orient][k]];
1358 #endif
1359  }
1360  }
1361 #ifdef EDM_ML_DEBUG
1362  edm::LogVerbatim("HGCalGeom") << "I/p: " << part << ":" << ori << ":" << zside << ":" << delX << ":" << delY << ":"
1363  << xpos << ":" << ypos << " O/p having " << xy.size() << " points:";
1364  std::ostringstream st1;
1365  for (unsigned int i = 0; i < xy.size(); ++i)
1366  st1 << " [" << i << "] " << xy[i].first << ":" << xy[i].second;
1367  edm::LogVerbatim("HGCalGeom") << st1.str();
1368 #endif
1369  return xy;
1370 }
1371 
1372 std::vector<std::pair<double, double> > HGCalWaferMask::waferXY(
1373  int part, int place, double waferSize, double offset, double xpos, double ypos) {
1374  std::vector<std::pair<double, double> > xy;
1375  // Good for V17 version and uses partial wafer type & placement index
1376 #ifdef EDM_ML_DEBUG
1377  edm::LogVerbatim("HGCalGeom") << "Part " << part << " Placement Index " << place;
1378 #endif
1379  /*
1380  The exact contour of partial wafers are obtained by joining points on
1381  the circumference of a full wafer.
1382  Numbering the points along the edges of a hexagonal wafer, starting from
1383  the bottom corner:
1384  3
1385  15 18
1386  9 8
1387  19 14
1388  4 2
1389  16 23
1390  10 7
1391  20 13
1392  5 1
1393  17 22
1394  11 6
1395  21 12
1396  0
1397  Depending on the wafer type and placement index, the corners
1398  are chosen in the variable *np*
1399  The points 24-35 are the same as points 12-23 with different offset
1400  */
1401  double delX = 0.5 * waferSize;
1402  double delY = delX / sin_60_;
1403  double dx[60] = {
1404  HGCalTypes::c00 * delX, HGCalTypes::c10 * delX, HGCalTypes::c10 * delX, HGCalTypes::c00 * delX,
1405  -HGCalTypes::c10 * delX, -HGCalTypes::c10 * delX, HGCalTypes::c50 * delX, HGCalTypes::c10 * delX,
1406  HGCalTypes::c50 * delX, -HGCalTypes::c50 * delX, -HGCalTypes::c10 * delX, -HGCalTypes::c50 * delX,
1407  HGCalTypes::c22 * delX, HGCalTypes::c10 * delX, HGCalTypes::c77 * delX, -HGCalTypes::c22 * delX,
1408  -HGCalTypes::c10 * delX, -HGCalTypes::c77 * delX, HGCalTypes::c22 * delX, -HGCalTypes::c77 * delX,
1409  -HGCalTypes::c10 * delX, -HGCalTypes::c22 * delX, HGCalTypes::c77 * delX, HGCalTypes::c10 * delX,
1410  HGCalTypes::c22 * delX, HGCalTypes::c10 * delX, HGCalTypes::c77 * delX, -HGCalTypes::c22 * delX,
1411  -HGCalTypes::c10 * delX, -HGCalTypes::c77 * delX, HGCalTypes::c22 * delX, -HGCalTypes::c77 * delX,
1412  -HGCalTypes::c10 * delX, -HGCalTypes::c22 * delX, HGCalTypes::c77 * delX, HGCalTypes::c10 * delX,
1413  HGCalTypes::c00 * delX, HGCalTypes::c10 * delX, HGCalTypes::c10 * delX, HGCalTypes::c00 * delX,
1414  -HGCalTypes::c10 * delX, -HGCalTypes::c10 * delX, HGCalTypes::c00 * delX, HGCalTypes::c10 * delX,
1415  HGCalTypes::c10 * delX, HGCalTypes::c00 * delX, -HGCalTypes::c10 * delX, -HGCalTypes::c10 * delX,
1416  HGCalTypes::c00 * delX, HGCalTypes::c10 * delX, HGCalTypes::c10 * delX, HGCalTypes::c00 * delX,
1417  -HGCalTypes::c10 * delX, -HGCalTypes::c10 * delX, HGCalTypes::c00 * delX, HGCalTypes::c10 * delX,
1418  HGCalTypes::c10 * delX, HGCalTypes::c00 * delX, -HGCalTypes::c10 * delX, -HGCalTypes::c10 * delX,
1419  };
1420  double dy[60] = {
1421  -HGCalTypes::c10 * delY, -HGCalTypes::c50 * delY, HGCalTypes::c50 * delY, HGCalTypes::c10 * delY,
1422  HGCalTypes::c50 * delY, -HGCalTypes::c50 * delY, -HGCalTypes::c75 * delY, HGCalTypes::c00 * delY,
1423  HGCalTypes::c75 * delY, HGCalTypes::c75 * delY, HGCalTypes::c00 * delY, -HGCalTypes::c75 * delY,
1424  -HGCalTypes::c88 * delY, -HGCalTypes::c27 * delY, HGCalTypes::c61 * delY, HGCalTypes::c88 * delY,
1425  HGCalTypes::c27 * delY, -HGCalTypes::c61 * delY, HGCalTypes::c88 * delY, HGCalTypes::c61 * delY,
1426  -HGCalTypes::c27 * delY, -HGCalTypes::c88 * delY, -HGCalTypes::c61 * delY, HGCalTypes::c27 * delY,
1427  -HGCalTypes::c88 * delY, -HGCalTypes::c27 * delY, HGCalTypes::c61 * delY, HGCalTypes::c88 * delY,
1428  HGCalTypes::c27 * delY, -HGCalTypes::c61 * delY, HGCalTypes::c88 * delY, HGCalTypes::c61 * delY,
1429  -HGCalTypes::c27 * delY, -HGCalTypes::c88 * delY, -HGCalTypes::c61 * delY, HGCalTypes::c27 * delY,
1430  -HGCalTypes::c10 * delY, -HGCalTypes::c50 * delY, HGCalTypes::c50 * delY, HGCalTypes::c10 * delY,
1431  HGCalTypes::c50 * delY, -HGCalTypes::c50 * delY, -HGCalTypes::c10 * delY, -HGCalTypes::c50 * delY,
1432  HGCalTypes::c50 * delY, HGCalTypes::c10 * delY, HGCalTypes::c50 * delY, -HGCalTypes::c50 * delY,
1433  -HGCalTypes::c10 * delY, -HGCalTypes::c50 * delY, HGCalTypes::c50 * delY, HGCalTypes::c10 * delY,
1434  HGCalTypes::c50 * delY, -HGCalTypes::c50 * delY, -HGCalTypes::c10 * delY, -HGCalTypes::c50 * delY,
1435  HGCalTypes::c50 * delY, HGCalTypes::c10 * delY, HGCalTypes::c50 * delY, -HGCalTypes::c50 * delY,
1436  };
1437 
1438  double offsetx[60] = {0.0,
1439  -offset,
1440  -offset,
1441  0.0,
1442  offset,
1443  offset,
1444  -offset * cos_60_,
1445  -offset,
1446  -offset * cos_60_,
1447  offset * cos_60_,
1448  offset,
1449  offset * cos_60_,
1450  -offset * cos_60_,
1451  -offset,
1452  -offset * cos_60_,
1453  offset * cos_60_,
1454  offset,
1455  offset * cos_60_,
1456  -offset * cos_60_,
1457  offset * cos_60_,
1458  offset,
1459  offset * cos_60_,
1460  -offset * cos_60_,
1461  -offset,
1462  0.0,
1463  -offset,
1464  -offset,
1465  0.0,
1466  offset,
1467  offset,
1468  0.0,
1469  offset,
1470  offset,
1471  0.0,
1472  -offset,
1473  -offset,
1474  -offset,
1475  -offset / cos_60_,
1476  -offset,
1477  offset,
1478  offset / cos_60_,
1479  offset,
1480  offset,
1481  -offset,
1482  -offset / cos_60_,
1483  -offset,
1484  offset,
1485  offset / cos_60_,
1486  -offset * cos_60_,
1487  -offset,
1488  -offset * cos_60_,
1489  offset * cos_60_,
1490  offset,
1491  offset * cos_60_,
1492  offset * cos_60_,
1493  -offset * cos_60_,
1494  -offset,
1495  -offset * cos_60_,
1496  offset * cos_60_,
1497  offset};
1498  double offsety[60] = {offset / sin_60_,
1499  offset / tan_60_,
1500  -offset / tan_60_,
1501  -offset / sin_60_,
1502  -offset / tan_60_,
1503  offset / tan_60_,
1504  offset * sin_60_,
1505  0.0,
1506  -offset * sin_60_,
1507  -offset * sin_60_,
1508  0.0,
1509  offset * sin_60_,
1510  offset * sin_60_,
1511  0.0,
1512  -offset * sin_60_,
1513  -offset * sin_60_,
1514  0.0,
1515  offset * sin_60_,
1516  -offset * sin_60_,
1517  -offset * sin_60_,
1518  0.0,
1519  offset * sin_60_,
1520  offset * sin_60_,
1521  0.0,
1522  offset / sin_60_,
1523  offset / tan_60_,
1524  -offset / tan_60_,
1525  -offset / sin_60_,
1526  -offset / tan_60_,
1527  offset / tan_60_,
1528  -offset / sin_60_,
1529  -offset / tan_60_,
1530  offset / tan_60_,
1531  offset / sin_60_,
1532  offset / tan_60_,
1533  -offset / tan_60_,
1534  offset * tan_60_,
1535  0,
1536  -offset * tan_60_,
1537  -offset * tan_60_,
1538  0,
1539  offset * tan_60_,
1540  offset * tan_60_,
1541  offset * tan_60_,
1542  0,
1543  -offset * tan_60_,
1544  -offset * tan_60_,
1545  0,
1546  offset * sin_60_,
1547  0,
1548  -offset * sin_60_,
1549  -offset * sin_60_,
1550  0,
1551  offset * sin_60_,
1552  offset * sin_60_,
1553  offset * sin_60_,
1554  0,
1555  -offset * sin_60_,
1556  -offset * sin_60_,
1557  0};
1558 
1559  if (part == HGCalTypes::WaferFull) {
1560  int np[7] = {0, 1, 2, 3, 4, 5, 0};
1561  for (int k = 0; k < 7; ++k)
1562  xy.push_back(std::make_pair((xpos + dx[np[k]] + offsetx[np[k]]), (ypos + dy[np[k]] + offsety[np[k]])));
1563  } else if (part == HGCalTypes::WaferLDTop) {
1564  int np[12][5] = {{0, 1, 4, 5, 0},
1565  {1, 2, 5, 0, 1},
1566  {2, 3, 0, 1, 2},
1567  {3, 4, 1, 2, 3},
1568  {4, 5, 2, 3, 4},
1569  {5, 0, 3, 4, 5},
1570  {0, 1, 2, 5, 0},
1571  {5, 0, 1, 4, 5},
1572  {4, 5, 0, 3, 4},
1573  {3, 4, 5, 2, 3},
1574  {2, 3, 4, 1, 2},
1575  {1, 2, 3, 0, 1}};
1576  for (int k = 0; k < 5; ++k) {
1577  xy.push_back(std::make_pair((xpos + dx[np[place][k]] + offsetx[np[place][k]]),
1578  (ypos + dy[np[place][k]] + offsety[np[place][k]])));
1579 #ifdef EDM_ML_DEBUG
1580  edm::LogVerbatim("HGCalGeom") << k << ":" << np[place][k] << ":" << dx[np[place][k]] + offsetx[np[place][k]]
1581  << ":" << dy[np[place][k]] + offsety[np[place][k]];
1582 #endif
1583  }
1584  } else if (part == HGCalTypes::WaferLDBottom) {
1585  int np[12][5] = {{1, 2, 3, 4, 1},
1586  {2, 3, 4, 5, 2},
1587  {3, 4, 5, 0, 3},
1588  {4, 5, 0, 1, 4},
1589  {5, 0, 1, 2, 5},
1590  {0, 1, 2, 3, 0},
1591  {5, 2, 3, 4, 5},
1592  {4, 1, 2, 3, 4},
1593  {3, 0, 1, 2, 3},
1594  {2, 5, 0, 1, 2},
1595  {1, 4, 5, 0, 1},
1596  {0, 3, 4, 5, 0}};
1597  for (int k = 0; k < 5; ++k) {
1598  xy.push_back(std::make_pair((xpos + dx[np[place][k]] + offsetx[np[place][k]]),
1599  (ypos + dy[np[place][k]] + offsety[np[place][k]])));
1600 #ifdef EDM_ML_DEBUG
1601  edm::LogVerbatim("HGCalGeom") << k << ":" << np[place][k] << ":" << dx[np[place][k]] + offsetx[np[place][k]]
1602  << ":" << dy[np[place][k]] + offsety[np[place][k]];
1603 #endif
1604  }
1605  } else if (part == HGCalTypes::WaferLDLeft) {
1606  int np[12][6] = {{0, 1, 2, 8, 11, 0},
1607  {1, 2, 3, 9, 6, 1},
1608  {2, 3, 4, 10, 7, 2},
1609  {3, 4, 5, 11, 8, 3},
1610  {4, 5, 0, 6, 9, 4},
1611  {5, 0, 1, 7, 10, 5},
1612  {0, 6, 9, 4, 5, 0},
1613  {5, 11, 8, 3, 4, 5},
1614  {4, 10, 7, 2, 3, 4},
1615  {3, 9, 6, 1, 2, 3},
1616  {2, 8, 11, 0, 1, 2},
1617  {1, 7, 10, 5, 0, 1}};
1618  for (int k = 0; k < 6; ++k) {
1619  xy.push_back(std::make_pair((xpos + dx[np[place][k]] + offsetx[np[place][k]]),
1620  (ypos + dy[np[place][k]] + offsety[np[place][k]])));
1621 #ifdef EDM_ML_DEBUG
1622  edm::LogVerbatim("HGCalGeom") << k << ":" << np[place][k] << ":" << dx[np[place][k]] + offsetx[np[place][k]]
1623  << ":" << dy[np[place][k]] + offsety[np[place][k]];
1624 #endif
1625  }
1626  } else if (part == HGCalTypes::WaferLDRight) {
1627  int np[12][6] = {{5, 11, 8, 3, 4, 5},
1628  {0, 6, 9, 4, 5, 0},
1629  {1, 7, 10, 5, 0, 1},
1630  {2, 8, 11, 0, 1, 2},
1631  {3, 9, 6, 1, 2, 3},
1632  {4, 10, 7, 2, 3, 4},
1633  {1, 2, 3, 9, 6, 1},
1634  {0, 1, 2, 8, 11, 0},
1635  {5, 0, 1, 7, 10, 5},
1636  {4, 5, 0, 6, 9, 4},
1637  {3, 4, 5, 11, 8, 3},
1638  {2, 3, 4, 10, 7, 2}};
1639  for (int k = 0; k < 6; ++k) {
1640  xy.push_back(std::make_pair((xpos + dx[np[place][k]] + offsetx[np[place][k]]),
1641  (ypos + dy[np[place][k]] + offsety[np[place][k]])));
1642 #ifdef EDM_ML_DEBUG
1643  edm::LogVerbatim("HGCalGeom") << k << ":" << np[place][k] << ":" << dx[np[place][k]] + offsetx[np[place][k]]
1644  << ":" << dy[np[place][k]] + offsety[np[place][k]];
1645 #endif
1646  }
1647  } else if (part == HGCalTypes::WaferLDFive) {
1648  int np[12][6] = {{0, 1, 2, 57, 53, 0},
1649  {1, 2, 3, 58, 48, 1},
1650  {2, 3, 4, 59, 49, 2},
1651  {3, 4, 5, 54, 50, 3},
1652  {4, 5, 0, 55, 51, 4},
1653  {5, 0, 1, 56, 52, 5},
1654  {0, 1, 3, 58, 53, 0},
1655  {5, 0, 2, 57, 52, 5},
1656  {4, 5, 1, 56, 51, 4},
1657  {3, 4, 0, 55, 50, 3},
1658  {2, 3, 5, 54, 49, 2},
1659  {1, 2, 4, 59, 48, 1}};
1660  for (int k = 0; k < 6; ++k) {
1661  xy.push_back(std::make_pair((xpos + dx[np[place][k]] + offsetx[np[place][k]]),
1662  (ypos + dy[np[place][k]] + offsety[np[place][k]])));
1663 #ifdef EDM_ML_DEBUG
1664  edm::LogVerbatim("HGCalGeom") << k << ":" << np[place][k] << ":" << dx[np[place][k]] + offsetx[np[place][k]]
1665  << ":" << dy[np[place][k]] + offsety[np[place][k]];
1666 #endif
1667  }
1668  } else if (part == HGCalTypes::WaferLDThree) {
1669  int np[12][4] = {{41, 45, 4, 41},
1670  {36, 46, 5, 36},
1671  {37, 47, 0, 37},
1672  {38, 42, 1, 38},
1673  {39, 43, 2, 39},
1674  {40, 44, 3, 40},
1675  {43, 2, 39, 43},
1676  {42, 1, 38, 42},
1677  {47, 0, 37, 47},
1678  {46, 5, 36, 46},
1679  {45, 4, 41, 45},
1680  {44, 3, 40, 44}};
1681  for (int k = 0; k < 4; ++k) {
1682  xy.push_back(std::make_pair((xpos + dx[np[place][k]] + offsetx[np[place][k]]),
1683  (ypos + dy[np[place][k]] + offsety[np[place][k]])));
1684 #ifdef EDM_ML_DEBUG
1685  edm::LogVerbatim("HGCalGeom") << k << ":" << np[place][k] << ":" << dx[np[place][k]] + offsetx[np[place][k]]
1686  << ":" << dy[np[place][k]] + offsety[np[place][k]];
1687 #endif
1688  }
1689  } else if (part == HGCalTypes::WaferHDTop) {
1690  int np[12][5] = {{0, 34, 28, 5, 0},
1691  {1, 35, 29, 0, 1},
1692  {2, 30, 24, 1, 2},
1693  {3, 31, 25, 2, 3},
1694  {4, 32, 26, 3, 4},
1695  {5, 33, 27, 4, 5},
1696  {0, 1, 35, 29, 0},
1697  {5, 0, 34, 28, 5},
1698  {4, 5, 33, 27, 4},
1699  {3, 4, 32, 26, 3},
1700  {2, 3, 31, 25, 2},
1701  {1, 2, 30, 24, 1}};
1702  for (int k = 0; k < 5; ++k) {
1703  xy.push_back(std::make_pair((xpos + dx[np[place][k]] + offsetx[np[place][k]]),
1704  (ypos + dy[np[place][k]] + offsety[np[place][k]])));
1705 #ifdef EDM_ML_DEBUG
1706  edm::LogVerbatim("HGCalGeom") << k << ":" << np[place][k] << ":" << dx[np[place][k]] + offsetx[np[place][k]]
1707  << ":" << dy[np[place][k]] + offsety[np[place][k]];
1708 #endif
1709  }
1710  } else if (part == HGCalTypes::WaferHDBottom) {
1711  int np[12][7] = {{1, 2, 3, 4, 28, 34, 1},
1712  {2, 3, 4, 5, 29, 35, 2},
1713  {3, 4, 5, 0, 24, 30, 3},
1714  {4, 5, 0, 1, 25, 31, 4},
1715  {5, 0, 1, 2, 26, 32, 5},
1716  {0, 1, 2, 3, 27, 33, 0},
1717  {5, 29, 35, 2, 3, 4, 5},
1718  {4, 28, 34, 1, 2, 3, 4},
1719  {3, 27, 33, 0, 1, 2, 3},
1720  {2, 26, 32, 5, 0, 1, 2},
1721  {1, 25, 31, 4, 5, 0, 1},
1722  {0, 24, 30, 3, 4, 5, 0}};
1723  for (int k = 0; k < 7; ++k) {
1724  xy.push_back(std::make_pair((xpos + dx[np[place][k]] + offsetx[np[place][k]]),
1725  (ypos + dy[np[place][k]] + offsety[np[place][k]])));
1726 #ifdef EDM_ML_DEBUG
1727  edm::LogVerbatim("HGCalGeom") << k << ":" << np[place][k] << ":" << dx[np[place][k]] + offsetx[np[place][k]]
1728  << ":" << dy[np[place][k]] + offsety[np[place][k]];
1729 #endif
1730  }
1731  } else if (part == HGCalTypes::WaferHDLeft) {
1732  int np[12][6] = {{0, 1, 2, 14, 21, 0},
1733  {1, 2, 3, 15, 22, 1},
1734  {2, 3, 4, 16, 23, 2},
1735  {3, 4, 5, 17, 18, 3},
1736  {4, 5, 0, 12, 19, 4},
1737  {5, 0, 1, 13, 20, 5},
1738  {0, 12, 19, 4, 5, 0},
1739  {5, 17, 18, 3, 4, 5},
1740  {4, 16, 23, 2, 3, 4},
1741  {3, 15, 22, 1, 2, 3},
1742  {2, 14, 21, 0, 1, 2},
1743  {1, 13, 20, 5, 0, 1}};
1744  for (int k = 0; k < 6; ++k) {
1745  xy.push_back(std::make_pair((xpos + dx[np[place][k]] + offsetx[np[place][k]]),
1746  (ypos + dy[np[place][k]] + offsety[np[place][k]])));
1747 #ifdef EDM_ML_DEBUG
1748  edm::LogVerbatim("HGCalGeom") << k << ":" << np[place][k] << ":" << dx[np[place][k]] + offsetx[np[place][k]]
1749  << ":" << dy[np[place][k]] + offsety[np[place][k]];
1750 #endif
1751  }
1752  } else if (part == HGCalTypes::WaferHDRight) {
1753  int np[12][6] = {{5, 17, 18, 3, 4, 5},
1754  {0, 12, 19, 4, 5, 0},
1755  {1, 13, 20, 5, 0, 1},
1756  {2, 14, 21, 0, 1, 2},
1757  {3, 15, 22, 1, 2, 3},
1758  {4, 16, 23, 2, 3, 4},
1759  {1, 2, 3, 15, 22, 1},
1760  {0, 1, 2, 14, 21, 0},
1761  {5, 0, 1, 13, 20, 5},
1762  {4, 5, 0, 12, 19, 4},
1763  {3, 4, 5, 17, 18, 3},
1764  {2, 3, 4, 16, 23, 2}};
1765  for (int k = 0; k < 6; ++k) {
1766  xy.push_back(std::make_pair((xpos + dx[np[place][k]] + offsetx[np[place][k]]),
1767  (ypos + dy[np[place][k]] + offsety[np[place][k]])));
1768 #ifdef EDM_ML_DEBUG
1769  edm::LogVerbatim("HGCalGeom") << k << ":" << np[place][k] << ":" << dx[np[place][k]] + offsetx[np[place][k]]
1770  << ":" << dy[np[place][k]] + offsety[np[place][k]];
1771 #endif
1772  }
1773  } else if (part == HGCalTypes::WaferHDFive) {
1774  int np[12][6] = {{0, 1, 2, 18, 17, 0},
1775  {1, 2, 3, 19, 12, 1},
1776  {2, 3, 4, 20, 13, 2},
1777  {3, 4, 5, 21, 14, 3},
1778  {4, 5, 0, 22, 15, 4},
1779  {5, 0, 1, 23, 16, 5},
1780  {0, 22, 15, 4, 5, 0},
1781  {5, 21, 14, 3, 4, 5},
1782  {4, 20, 13, 2, 3, 4},
1783  {3, 19, 12, 1, 2, 3},
1784  {2, 18, 17, 0, 1, 2},
1785  {1, 23, 16, 5, 0, 1}};
1786  for (int k = 0; k < 6; ++k) {
1787  xy.push_back(std::make_pair((xpos + dx[np[place][k]] + offsetx[np[place][k]]),
1788  (ypos + dy[np[place][k]] + offsety[np[place][k]])));
1789 #ifdef EDM_ML_DEBUG
1790  edm::LogVerbatim("HGCalGeom") << k << ":" << np[place][k] << ":" << dx[np[place][k]] + offsetx[np[place][k]]
1791  << ":" << dy[np[place][k]] + offsety[np[place][k]];
1792 #endif
1793  }
1794  }
1795 #ifdef EDM_ML_DEBUG
1796  edm::LogVerbatim("HGCalGeom") << "I/p: " << part << ":" << place << ":" << delX << ":" << delY << ":" << xpos << ":"
1797  << ypos << " O/p having " << xy.size() << " points:";
1798  std::ostringstream st1;
1799  for (unsigned int i = 0; i < xy.size(); ++i)
1800  st1 << " [" << i << "] " << xy[i].first << ":" << xy[i].second;
1801  edm::LogVerbatim("HGCalGeom") << st1.str();
1802 #endif
1803  return xy;
1804 }
static constexpr std::array< int, 3 > edgeWaferHDBottom
Definition: HGCalTypes.h:86
static constexpr std::array< int, 3 > edgeWaferLDFive
Definition: HGCalTypes.h:83
Log< level::Info, true > LogVerbatim
static constexpr int32_t WaferHalf2
Definition: HGCalTypes.h:43
static constexpr std::array< int, 3 > edgeWaferLDLeft
Definition: HGCalTypes.h:81
static constexpr int32_t WaferFive2
Definition: HGCalTypes.h:44
static constexpr std::array< int, 3 > edgeWaferLDTop
Definition: HGCalTypes.h:79
static constexpr std::array< int, 3 > edgeWaferHDLeft
Definition: HGCalTypes.h:87
static constexpr int k_OffsetRotation
Definition: HGCalTypes.h:91
static constexpr int32_t WaferSizeMax
Definition: HGCalTypes.h:76
static constexpr int32_t WaferLDThree
Definition: HGCalTypes.h:50
static constexpr int k_fourCorners
static constexpr std::array< int, 3 > edgeWaferLDThree
Definition: HGCalTypes.h:84
static bool goodCell(int u, int v, int N, int type, int rotn)
static constexpr int32_t WaferOut
Definition: HGCalTypes.h:56
base
Main Program
Definition: newFWLiteAna.py:92
static constexpr int k_twoCorners
static constexpr int32_t WaferThree
Definition: HGCalTypes.h:42
static constexpr double c50
Definition: HGCalTypes.h:97
static constexpr int32_t WaferHDFive
Definition: HGCalTypes.h:55
static constexpr double c88
Definition: HGCalTypes.h:101
int zside(DetId const &)
static int getRotation(int zside, int type, int rotn)
static constexpr double c27
Definition: HGCalTypes.h:96
static constexpr double c10
Definition: HGCalTypes.h:102
static constexpr double sin_60_
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:41
static std::vector< std::pair< double, double > > waferXY(int part, int orient, int zside, double waferSize, double offset, double xpos, double ypos)
static constexpr int32_t WaferHDLeft
Definition: HGCalTypes.h:53
constexpr uint32_t mask
Definition: gpuClustering.h:26
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:35
static constexpr int32_t WaferHalf
Definition: HGCalTypes.h:39
static constexpr int32_t WaferLDBottom
Definition: HGCalTypes.h:46
int np
Definition: AMPTWrapper.h:43
static constexpr double tan_60_
static constexpr int32_t WaferCorner1
Definition: HGCalTypes.h:14
T sqrt(T t)
Definition: SSEVec.h:19
static constexpr int32_t WaferCorner5
Definition: HGCalTypes.h:18
static constexpr int32_t WaferLDRight
Definition: HGCalTypes.h:48
static constexpr int32_t WaferCorner4
Definition: HGCalTypes.h:17
static constexpr int32_t WaferCornerMax
Definition: HGCalTypes.h:75
static constexpr int32_t WaferCorner2
Definition: HGCalTypes.h:15
static constexpr int32_t WaferLDFive
Definition: HGCalTypes.h:49
static constexpr int32_t WaferCorner0
Definition: HGCalTypes.h:13
static constexpr int32_t WaferLDLeft
Definition: HGCalTypes.h:47
static constexpr double c00
Definition: HGCalTypes.h:93
static constexpr int32_t WaferHDBottom
Definition: HGCalTypes.h:52
static constexpr int32_t WaferCorner3
Definition: HGCalTypes.h:16
static constexpr std::array< int, 3 > edgeWaferHDTop
Definition: HGCalTypes.h:85
static constexpr int32_t WaferHDRight
Definition: HGCalTypes.h:54
#define debug
Definition: HDRShower.cc:19
static constexpr int k_fiveCorners
static constexpr int32_t WaferChopTwoM
Definition: HGCalTypes.h:38
static constexpr std::array< int, 3 > edgeWaferLDRight
Definition: HGCalTypes.h:82
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:100
static constexpr double c61
Definition: HGCalTypes.h:98
static constexpr double cos_60_
static constexpr int k_threeCorners
static constexpr int32_t WaferLDTop
Definition: HGCalTypes.h:45
static constexpr double c75
Definition: HGCalTypes.h:99
static constexpr double c22
Definition: HGCalTypes.h:94
static constexpr std::array< int, 3 > edgeWaferHDFive
Definition: HGCalTypes.h:89
static constexpr int32_t WaferHDTop
Definition: HGCalTypes.h:51
static constexpr int32_t WaferFive
Definition: HGCalTypes.h:36
static constexpr int32_t WaferSemi
Definition: HGCalTypes.h:40
static constexpr std::array< int, 3 > edgeWaferHDRight
Definition: HGCalTypes.h:88
static constexpr int k_allCorners
static constexpr std::array< int, 3 > edgeWaferLDBottom
Definition: HGCalTypes.h:80
static constexpr int32_t WaferChopTwo
Definition: HGCalTypes.h:37
static bool maskCell(int u, int v, int N, int ncor, int fcor, int corners)