CMS 3D CMS Logo

HGCalCellOffset.cc
Go to the documentation of this file.
4 #include <vector>
5 #include <iostream>
6 
7 //#define EDM_ML_DEBUG
8 
10  double waferSize, int32_t nFine, int32_t nCoarse, double guardRingOffset_, double mouseBiteCut_) {
11  ncell_[0] = nFine;
12  ncell_[1] = nCoarse;
13  hgcalcell_ = std::make_unique<HGCalCell>(waferSize, nFine, nCoarse);
14  for (int k = 0; k < 2; ++k) { // k refers to type of wafer fine or coarse
15  cellX_[k] = waferSize / (3 * ncell_[k]);
16  cellY_[k] = sqrt3By2_ * cellX_[k];
17  // For formulas used please refer to https://indico.cern.ch/event/1297259/contributions/5455745/attachments/2667954/4722855/Cell_centroid.pdf
18  for (int j = 0; j < 6; ++j) { // j refers to type of cell : corner, truncated, extended, truncatedMB, extendedMB
19  if (j == HGCalCell::fullCell) {
20  for (int i = 0; i < 6; ++i) {
21  offsetX[k][j][i] = 0.0;
22  offsetY[k][j][i] = 0.0;
23  cellArea[k][j] = 3 * sqrt3By2_ * cellY_[k];
24  }
25  } else if (j == HGCalCell::cornerCell) { // Offset for corner cells
26  if (k == 0) {
27  double h = (mouseBiteCut_ - sqrt3By2_ * cellY_[k]);
28  double totalArea = 11.0 * sqrt3_ * std::pow(cellY_[k], 2) / 8.0;
29  double cutArea1 = (sqrt3By2_ * cellY_[k] * guardRingOffset_);
30  double cutArea2 = (sqrt3_ * cellY_[k] * guardRingOffset_);
31  double A1 = 2.0 * cellY_[k] * h - std::pow(h, 2) / (sqrt3_);
32  double A2 = sqrt3By2_ * cellY_[k] * cellY_[k];
33  double A3 = sqrt3By2_ * cellY_[k] * cellY_[k] / 4.0;
34  double cutArea3 = A1 + A2 + A3;
35 
36  double x3_1 = -(((2.0 * std::pow(h, 3)) / (3.0 * sqrt3_) - cellY_[k] * std::pow(h, 2)) / A1);
37  double y3_1 = 0;
38  double x3_2 = -(sqrt3By2_ * cellY_[k] / 3);
39  double y3_2 = cellY_[k] / 6.0;
40  double x3_3 = -(cellY_[k] * sqrt3_ / 4.0);
41  double y3_3 = cellY_[k] * 11.0 / 12.0;
42 
43  double x1 = -(3.0 * sqrt3_ * cellY_[k] / 8.0 - sqrt3_ * guardRingOffset_ / 4.0);
44  double y1 = 5.0 * cellY_[k] / 12.0 - guardRingOffset_ / 4.0;
45  double x2 = -((0.5 * cellY_[k] - 0.5 * guardRingOffset_) * sqrt3By2_);
46  double y2 = -(0.5 * cellY_[k] - 0.5 * guardRingOffset_) * 0.5;
47  double x3 = (A1 * x3_1 + A2 * x3_2 + A3 * x3_3) / cutArea3;
48  double y3 = (A1 * y3_1 + A2 * y3_2 + A3 * y3_3) / cutArea3;
49  double cellArea = totalArea - cutArea1 - cutArea2 - cutArea3;
50  double xMag1 =
51  ((5.0 * sqrt3_ * cellY_[k] / 132.0) * totalArea - (cutArea1 * x1) - (cutArea2 * x2) - (cutArea3 * x3)) /
52  (cellArea);
53  double yMag1 =
54  ((19.0 * cellY_[k] / 132.0) * totalArea - (cutArea1 * y1) - (cutArea2 * y2) - (cutArea3 * y3)) /
55  (cellArea);
56 
57  double xMag = 0.5 * xMag1 + sqrt3By2_ * yMag1;
58  double yMag = sqrt3By2_ * xMag1 - 0.5 * yMag1;
59 
60  std::array<double, 6> tempOffsetX = {{(sqrt3By2_ * xMag - 0.5 * yMag),
61  yMag,
62  yMag,
63  (sqrt3By2_ * xMag - 0.5 * yMag),
64  (-sqrt3By2_ * xMag - 0.5 * yMag),
65  (-sqrt3By2_ * xMag - 0.5 * yMag)}};
66  std::array<double, 6> tempOffsetY = {{(0.5 * xMag + sqrt3By2_ * yMag),
67  xMag,
68  -xMag,
69  (-0.5 * xMag - sqrt3By2_ * yMag),
70  (0.5 * xMag - sqrt3By2_ * yMag),
71  (-0.5 * xMag + sqrt3By2_ * yMag)}};
72 
73  for (int i = 0; i < 6; ++i) {
74  offsetX[k][j][i] = tempOffsetX[i];
75  offsetY[k][j][i] = tempOffsetY[i];
76  }
77  } else if (k == 1) {
78  double h = (mouseBiteCut_ - guardRingOffset_) / sqrt3By2_ - cellY_[k] / 2;
79  double totalArea = 11 * sqrt3_ * std::pow(cellY_[k], 2) / 8;
80  double cutArea1 = (sqrt3_ * cellY_[k] * guardRingOffset_);
81  double cutArea2 = (sqrt3By2_ * cellY_[k] * guardRingOffset_) + std::pow(guardRingOffset_, 2) / (2 * sqrt3_);
82  double cutArea3 = sqrt3_ * std::pow((mouseBiteCut_ - guardRingOffset_), 2) - sqrt3By2_ * std::pow(h, 2);
83 
84  double x2_0 = (0.375 * cellY_[k] * cellY_[k] - (0.25 * cellY_[k] * guardRingOffset_) +
85  std::pow(guardRingOffset_, 2) / 18) /
86  (sqrt3By2_ * cellY_[k] + guardRingOffset_ / (2 * sqrt3_));
87  double y2_0 = (sqrt3_ * cellY_[k] * guardRingOffset_ / 4 + std::pow(guardRingOffset_, 2) / (6 * sqrt3_)) /
88  (sqrt3By2_ * cellY_[k] + guardRingOffset_ / (2 * sqrt3_));
89  double x3_1 = -(cellY_[k] - guardRingOffset_ - 2 * (mouseBiteCut_ - guardRingOffset_) / 3) * sqrt3By2_;
90  double y3_1 = 0.5 * (cellY_[k] - guardRingOffset_ - 2 * (mouseBiteCut_ - guardRingOffset_) / 3);
91  double x3_2 = -((3 * cellY_[k] / 2 - h / 3) * sqrt3By2_ + sqrt3_ * h / 6);
92  double y3_2 = -(cellY_[k] / 4 + 4 * h / 6);
93  double A1 = sqrt3_ * std::pow((mouseBiteCut_ - guardRingOffset_), 2);
94  double A2 = sqrt3By2_ * std::pow(h, 2);
95 
96  double x1 = 0;
97  double y1 = 0.5 * cellY_[k] - 0.5 * guardRingOffset_;
98  double x2 = -(1.5 * sqrt3By2_ * cellY_[k] - x2_0 * 0.5 - y2_0 * sqrt3By2_);
99  double y2 = -(0.25 * cellY_[k] - x2_0 * sqrt3By2_ + y2_0 / 2);
100  double x3 = (A1 * x3_1 - A2 * x3_2) / (A1 - A2);
101  double y3 = (A1 * y3_1 - A2 * y3_2) / (A1 - A2);
102  double cellArea = totalArea - cutArea1 - cutArea2 - cutArea3;
103  double xMag1 = ((0.0) * totalArea - (cutArea1 * x1) - (cutArea2 * x2) - (cutArea3 * x3)) / (cellArea);
104  double yMag1 =
105  ((-5 * cellY_[k] / 42) * totalArea - (cutArea1 * y1) - (cutArea2 * y2) - (cutArea3 * y3)) / (cellArea);
106 
107  double xMag = -0.5 * xMag1 - sqrt3By2_ * yMag1;
108  double yMag = sqrt3By2_ * xMag1 - 0.5 * yMag1;
109 
110  std::array<double, 6> tempOffsetX = {{(sqrt3By2_ * xMag - 0.5 * yMag),
111  yMag,
112  yMag,
113  (sqrt3By2_ * xMag - 0.5 * yMag),
114  (-sqrt3By2_ * xMag - 0.5 * yMag),
115  (-sqrt3By2_ * xMag - 0.5 * yMag)}};
116  std::array<double, 6> tempOffsetY = {{(0.5 * xMag + sqrt3By2_ * yMag),
117  xMag,
118  -xMag,
119  (-0.5 * xMag - sqrt3By2_ * yMag),
120  (0.5 * xMag - sqrt3By2_ * yMag),
121  (-0.5 * xMag + sqrt3By2_ * yMag)}};
122  for (int i = 0; i < 6; ++i) {
123  offsetX[k][j][i] = tempOffsetX[i];
124  offsetY[k][j][i] = tempOffsetY[i];
125  }
126  }
127  } else if (j == HGCalCell::truncatedCell) { // Offset for truncated cells
128  double totalArea = (5.0 * sqrt3_ / 4.0) * std::pow(cellY_[k], 2); // Area of cell without any dead zone
129  double cutArea =
130  cellY_[k] * sqrt3_ * guardRingOffset_; // Area of inactive region form guardring and other effects
131  cellArea[k][j] = totalArea - cutArea;
132  double offMag = (((-2.0 / 15.0) * totalArea * cellY_[k]) - ((cellY_[k] - (0.5 * guardRingOffset_)) * cutArea)) /
133  (cellArea[k][j]); // Magnitude of offset
134  // (x, y) coordinates of offset for 6 sides of wafer starting from bottom left edge in clockwise direction
135  // offset_x = -Offset_magnitude * sin(30 + 60*i) i in (0-6)
136  // offset_y = -Offset_magnitude * cos(30 + 60*i) i in (0-6)
137  std::array<double, 6> tempOffsetX = {
138  {-0.5 * offMag, -offMag, -0.5 * offMag, 0.5 * offMag, offMag, 0.5 * offMag}};
139  std::array<double, 6> tempOffsetY = {
140  {-sqrt3By2_ * offMag, 0.0, sqrt3By2_ * offMag, sqrt3By2_ * offMag, 0.0, -sqrt3By2_ * offMag}};
141  for (int i = 0; i < 6; ++i) {
142  offsetX[k][j][i] = tempOffsetX[i];
143  offsetY[k][j][i] = tempOffsetY[i];
144  }
145  } else if (j == HGCalCell::extendedCell) { //Offset for extended cells
146  double totalArea = (7.0 * sqrt3_ / 4.0) * std::pow(cellY_[k], 2); // Area of cell without any dead zone
147  double cutArea =
148  cellY_[k] * sqrt3_ * guardRingOffset_; // Area of inactive region form guardring and other effects
149  cellArea[k][j] = totalArea - cutArea;
150  double offMag = // Magnitude of offset
151  (((5.0 / 42.0) * totalArea * cellY_[k]) - ((cellY_[k] - (0.5 * guardRingOffset_))) * (cutArea)) /
152  (cellArea[k][j]);
153  // (x, y) coordinates of offset for 6 sides of wafer starting from bottom left edge in clockwise direction
154  // offset_x = -Offset_magnitude * sin(30 + 60*i) i in (0-6)
155  // offset_y = -Offset_magnitude * cos(30 + 60*i) i in (0-6)
156  std::array<double, 6> tempOffsetX = {
157  {-0.5 * offMag, -offMag, -0.5 * offMag, 0.5 * offMag, offMag, 0.5 * offMag}};
158  std::array<double, 6> tempOffsetY = {
159  {-sqrt3By2_ * offMag, 0.0, sqrt3By2_ * offMag, sqrt3By2_ * offMag, 0.0, -sqrt3By2_ * offMag}};
160  for (int i = 0; i < 6; ++i) {
161  offsetX[k][j][i] = tempOffsetX[i];
162  offsetY[k][j][i] = tempOffsetY[i];
163  }
164  } else if (j == HGCalCell::truncatedMBCell) {
165  double h = (mouseBiteCut_ - sqrt3By2_ * cellY_[k]);
166  if (h > 0) {
167  double totalArea = 5.0 * sqrt3_ * std::pow(cellY_[k], 2) / 4.0;
168  double cutArea1 = (sqrt3_ * cellY_[k] * guardRingOffset_);
169  double cutArea2 = std::pow(h, 2) / sqrt3By2_;
170 
171  double x1 = -(0.5 * cellY_[k] - 0.5 * guardRingOffset_) * sqrt3By2_;
172  double y1 = -(0.5 * cellY_[k] - 0.5 * guardRingOffset_) * 0.5;
173  double x2 = -((sqrt3By2_ * cellY_[k]) - (2.0 * h) / 3.0);
174  double y2 = 0.5 * cellY_[k] - (2.0 * h) / (3.0 * sqrt3_);
175  double cellArea = totalArea - cutArea1 - cutArea2;
176  double xMag1 = ((sqrt3_ * cellY_[k] / 15.0) * totalArea - (cutArea1 * x1) - (cutArea2 * x2)) / (cellArea);
177  double yMag1 = ((cellY_[k] / 15.0) * totalArea - (cutArea1 * y1) - (cutArea2 * y2)) / (cellArea);
178  double xMag = -yMag1;
179  double yMag = -xMag1;
180 
181  std::array<double, 6> tempOffsetX = {{(sqrt3By2_ * xMag - 0.5 * yMag),
182  (-sqrt3By2_ * xMag - 0.5 * yMag),
183  (-sqrt3By2_ * xMag - 0.5 * yMag),
184  (sqrt3By2_ * xMag - 0.5 * yMag),
185  yMag,
186  yMag}};
187  std::array<double, 6> tempOffsetY = {{(0.5 * xMag + sqrt3By2_ * yMag),
188  (0.5 * xMag - sqrt3By2_ * yMag),
189  (-0.5 * xMag + sqrt3By2_ * yMag),
190  (-0.5 * xMag - sqrt3By2_ * yMag),
191  xMag,
192  -xMag}};
193  for (int i = 0; i < 6; ++i) {
194  offsetX[k][j][i] = tempOffsetX[i];
195  offsetY[k][j][i] = tempOffsetY[i];
196  }
197  } else {
198  std::array<double, 6> tempOffsetX = {{offsetX[k][HGCalCell::truncatedCell][0],
204  std::array<double, 6> tempOffsetY = {{offsetY[k][HGCalCell::truncatedCell][0],
210  for (int i = 0; i < 6; ++i) {
211  offsetX[k][j][i] = tempOffsetX[i];
212  offsetY[k][j][i] = tempOffsetY[i];
213  }
214  }
215  } else if (j == HGCalCell::extendedMBCell) {
216  double h = (mouseBiteCut_ - sqrt3By2_ * cellY_[k]);
217  double A = h / sqrt3By2_ + cellY_[k] / 2.0;
218  double totalArea = 7.0 * sqrt3_ * std::pow(cellY_[k], 2) / 4.0;
219  double cutArea1 = (sqrt3_ * cellY_[k] * guardRingOffset_);
220  double cutArea2 = std::pow(A, 2) * sqrt3By2_;
221 
222  double x1 = -(sqrt3By2_ * cellY_[k] - sqrt3By2_ * guardRingOffset_ / 2.0);
223  double y1 = (0.5 * cellY_[k] - 0.25 * guardRingOffset_);
224  double x2 = -(sqrt3By2_ * 1.5 * cellY_[k] - A / sqrt3_);
225  double y2 = -0.25 * cellY_[k] + A / 3.0;
226  double cellArea = totalArea - cutArea1 - cutArea2;
227  double xMag1 =
228  ((-10.0 * sqrt3_ * cellY_[k] / 168.0) * totalArea - (cutArea1 * x1) - (cutArea2 * x2)) / (cellArea);
229  double yMag1 = ((10.0 * cellY_[k] / 168.0) * totalArea - (cutArea1 * y1) - (cutArea2 * y2)) / (cellArea);
230 
231  double xMag = yMag1;
232  double yMag = -xMag1;
233 
234  std::array<double, 6> tempOffsetX = {{(sqrt3By2_ * xMag - 0.5 * yMag),
235  yMag,
236  yMag,
237  (sqrt3By2_ * xMag - 0.5 * yMag),
238  (-sqrt3By2_ * xMag - 0.5 * yMag),
239  (-sqrt3By2_ * xMag - 0.5 * yMag)}};
240  std::array<double, 6> tempOffsetY = {{(0.5 * xMag + sqrt3By2_ * yMag),
241  xMag,
242  -xMag,
243  (-0.5 * xMag - sqrt3By2_ * yMag),
244  (0.5 * xMag - sqrt3By2_ * yMag),
245  (-0.5 * xMag + sqrt3By2_ * yMag)}};
246  for (int i = 0; i < 6; ++i) {
247  offsetX[k][j][i] = tempOffsetX[i];
248  offsetY[k][j][i] = tempOffsetY[i];
249  }
250  }
251  }
253  ++j) { //For cells in partial wafers
254  if (j == (HGCalCell::halfCell)) {
255  double totalArea = (3.0 * sqrt3_ / 4.0) * std::pow(cellY_[k], 2);
256  double cutArea = cellY_[k] * 2.0 * guardRingOffset_ - std::pow(guardRingOffset_, 2) / sqrt3_;
257  double cellArea = totalArea - cutArea;
258 
259  double x1 = (-cellY_[k] * guardRingOffset_ + 2 * std::pow(guardRingOffset_, 2) / (3 * sqrt3_)) /
260  (2 * cellY_[k] - guardRingOffset_ / sqrt3_);
261  double y1 = 0;
262  double xMag = ((-2.0 * sqrt3_ * cellY_[k] / 9.0) * totalArea - (cutArea * x1)) / (cellArea);
263  double yMag = (0 * totalArea - (cutArea * y1)) / (cellArea);
264 
265  std::array<double, 6> tempOffsetX = {{(-sqrt3By2_ * xMag - 0.5 * yMag),
266  (-sqrt3By2_ * xMag + 0.5 * yMag),
267  yMag,
268  (sqrt3By2_ * xMag + 0.5 * yMag),
269  (sqrt3By2_ * xMag - 0.5 * yMag),
270  -yMag}};
271  std::array<double, 6> tempOffsetY = {{(0.5 * xMag - sqrt3By2_ * yMag),
272  (-sqrt3By2_ * yMag - 0.5 * xMag),
273  -xMag,
274  (-0.5 * xMag + sqrt3By2_ * yMag),
275  (0.5 * xMag + sqrt3By2_ * yMag),
276  xMag}};
277 
278  for (int i = 0; i < 6; ++i) {
281  }
282  } else if (j == (HGCalCell::halfTrunCell)) {
283  double totalArea = 5 * sqrt3_ * std::pow(cellY_[k], 2) / 8;
284  double cutArea1 = (sqrt3By2_ * cellY_[k] * guardRingOffset_);
285  double cutArea2 = (3 * cellY_[k] * guardRingOffset_) / 2 - std::pow(guardRingOffset_, 2) / (2 * sqrt3_);
286 
287  double x1 = -sqrt3_ * cellY_[k] / 4;
288  double y1 = (0.5 * cellY_[k] - 0.5 * guardRingOffset_);
289  double x2 = (-3 * cellY_[k] * guardRingOffset_ / 4 + std::pow(guardRingOffset_, 2) / (3 * sqrt3_)) /
290  (3 * cellY_[k] / 2 - guardRingOffset_ / (2 * sqrt3_));
291  double y2 = (-cellY_[k] * guardRingOffset_ / (2 * sqrt3_) + std::pow(guardRingOffset_, 2) / 18 -
292  3 * std::pow(cellY_[k], 2) / 8) /
293  (3 * cellY_[k] / 2 - guardRingOffset_ / (2 * sqrt3_));
294  double cellArea = totalArea - cutArea1 - cutArea2;
295  double xMag1 = ((-7 * sqrt3_ * cellY_[k] / 30) * totalArea - (cutArea1 * x1) - (cutArea2 * x2)) / (cellArea);
296  double yMag = ((-2 * cellY_[k] / 15) * totalArea - (cutArea1 * y1) - (cutArea2 * y2)) / (cellArea);
297  double xMag = -xMag1;
298 
299  std::array<double, 6> tempOffsetX = {{(-sqrt3By2_ * xMag - 0.5 * yMag),
300  (-sqrt3By2_ * xMag + 0.5 * yMag),
301  yMag,
302  (sqrt3By2_ * xMag + 0.5 * yMag),
303  (sqrt3By2_ * xMag - 0.5 * yMag),
304  -yMag}};
305  std::array<double, 6> tempOffsetY = {{(0.5 * xMag - sqrt3By2_ * yMag),
306  (-sqrt3By2_ * yMag - 0.5 * xMag),
307  -xMag,
308  (-0.5 * xMag + sqrt3By2_ * yMag),
309  (0.5 * xMag + sqrt3By2_ * yMag),
310  xMag}};
311  for (int i = 0; i < 6; ++i) {
314  }
315  } else if (j == (HGCalCell::halfExtCell)) {
316  double totalArea = (7.0 * sqrt3_ / 8.0) * std::pow(cellY_[k], 2);
317  double cutArea1 = cellY_[k] * sqrt3By2_ * guardRingOffset_;
318  double cutArea2 = cellY_[k] * 2.0 * guardRingOffset_ - std::pow(guardRingOffset_, 2) / (2 * sqrt3_);
319  double cellArea = totalArea - cutArea1 - cutArea2;
320 
321  double x1 = -sqrt3By2_ * cellY_[k] / 2;
322  double y1 = -(cellY_[k] - guardRingOffset_ / 2);
323  double x2 = (-cellY_[k] * guardRingOffset_ + std::pow(guardRingOffset_, 2) / (3 * sqrt3_)) /
324  (2 * cellY_[k] - guardRingOffset_ / (2 * sqrt3_));
325  double y2 = (-cellY_[k] * guardRingOffset_ / (2 * sqrt3_) + std::pow(guardRingOffset_, 2) / 18) /
326  (2 * cellY_[k] - guardRingOffset_ / (2 * sqrt3_));
327  double xMag = ((-5 * sqrt3_ * cellY_[k] / 21.0) * totalArea - (cutArea1 * x1) - (cutArea2 * x2)) / (cellArea);
328  double yMag = ((-5 * cellY_[k] / 42.0) * totalArea - (cutArea1 * y1) - (cutArea2 * y2)) / (cellArea);
329 
330  std::array<double, 6> tempOffsetX = {{(-sqrt3By2_ * xMag - 0.5 * yMag),
331  (-sqrt3By2_ * xMag + 0.5 * yMag),
332  yMag,
333  (sqrt3By2_ * xMag + 0.5 * yMag),
334  (sqrt3By2_ * xMag - 0.5 * yMag),
335  -yMag}};
336  std::array<double, 6> tempOffsetY = {{(0.5 * xMag - sqrt3By2_ * yMag),
337  (-sqrt3By2_ * yMag - 0.5 * xMag),
338  -xMag,
339  (-0.5 * xMag + sqrt3By2_ * yMag),
340  (0.5 * xMag + sqrt3By2_ * yMag),
341  xMag}};
342 
343  for (int i = 0; i < 6; ++i) {
346  }
347  } else if (j == (HGCalCell::LDPartial0714Cell)) {
348  if (k == 1) {
349  double totalArea = (9.0 * sqrt3_ / 4.0) * std::pow(cellY_[k], 2);
350  double cutArea1 =
351  (3 * cellY_[k] * sqrt3By2_ * guardRingOffset_) - (std::pow(guardRingOffset_, 2) / (2 * sqrt3_));
352  double cutArea2 = (3 * cellY_[k] * sqrt3By2_ * guardRingOffset_);
353  double cutArea3 = sqrt3_ * std::pow((mouseBiteCut_ - (guardRingOffset_ / sqrt3By2_)), 2) / 2;
354  double x1_0 = ((3.375 * cellY_[k] * cellY_[k]) - (cellY_[k] * 0.75 * guardRingOffset_) +
355  (std::pow(guardRingOffset_, 2) / 18)) /
356  ((3 * cellY_[k] * sqrt3By2_) - (guardRingOffset_ / (2 * sqrt3_)));
357  double y1_0 =
358  ((3 * cellY_[k] * sqrt3By2_ * guardRingOffset_ / 2) - (std::pow(guardRingOffset_, 2) / (6 * sqrt3_))) /
359  ((3 * cellY_[k] * sqrt3By2_) - (guardRingOffset_ / (2 * sqrt3_)));
360 
361  double x2_0 = (3 * sqrt3By2_ * cellY_[k] / 2);
362  double y2_0 = guardRingOffset_ / 2;
363 
364  double x1 = (cellY_[k] / 2 - guardRingOffset_) * sqrt3By2_ + x1_0 * 0.5 + y1_0 * sqrt3By2_;
365  double y1 = cellY_[k] + (cellY_[k] / 2 - guardRingOffset_) * 0.5 - x1_0 * sqrt3By2_ + y1_0 * 0.5;
366 
367  double x2 = x2_0 - sqrt3By2_ * cellY_[k];
368  double y2 = -(cellY_[k] - y2_0);
369 
370  double x3 = sqrt3_ * cellY_[k] - mouseBiteCut_ + (mouseBiteCut_ - (guardRingOffset_ / sqrt3By2_)) / 3;
371  double y3 = -(cellY_[k] - sqrt3_ * (mouseBiteCut_ - (guardRingOffset_ / sqrt3By2_)) / 3 - guardRingOffset_);
372 
373  double cellArea = totalArea - cutArea1 - cutArea2 - cutArea3;
374  double xMag =
375  ((sqrt3_ * cellY_[k] / 8) * totalArea - (cutArea1 * x1) - (cutArea2 * x2) - (cutArea3 * x3)) / (cellArea);
376  double yMag =
377  ((-1 * cellY_[k] / 8) * totalArea - (cutArea1 * y1) - (cutArea2 * y2) - (cutArea3 * y3)) / (cellArea);
378 
379  std::array<double, 6> tempOffsetX = {{(-sqrt3By2_ * xMag - 0.5 * yMag),
380  (-sqrt3By2_ * xMag + 0.5 * yMag),
381  yMag,
382  (sqrt3By2_ * xMag + 0.5 * yMag),
383  (sqrt3By2_ * xMag - 0.5 * yMag),
384  -yMag}};
385  std::array<double, 6> tempOffsetY = {{(0.5 * xMag - sqrt3By2_ * yMag),
386  (-sqrt3By2_ * yMag - 0.5 * xMag),
387  -xMag,
388  (-0.5 * xMag + sqrt3By2_ * yMag),
389  (0.5 * xMag + sqrt3By2_ * yMag),
390  xMag}};
391 
392  for (int i = 0; i < 6; ++i) {
395  }
396  } else {
397  for (int i = 0; i < 6; ++i) {
400  }
401  }
402  } else if (j == (HGCalCell::LDPartial0209Cell)) {
403  if (k == 1) {
404  double totalArea = (23.0 * sqrt3_ / 8.0) * std::pow(cellY_[k], 2);
405  double cutArea1 =
406  (5 * cellY_[k] * sqrt3By2_ * guardRingOffset_) - (std::pow(guardRingOffset_, 2) / (2 * sqrt3_));
407  double cutArea2 = (4 * cellY_[k] * guardRingOffset_);
408  double cutArea3 = std::pow(mouseBiteCut_, 2) / sqrt3_;
409 
410  double x1_0 = (9.375 * cellY_[k] * cellY_[k] - (cellY_[k] * 1.25 * guardRingOffset_) +
411  (std::pow(guardRingOffset_, 2) / 18)) /
412  ((5 * cellY_[k] * sqrt3By2_) - (guardRingOffset_ / (2 * sqrt3_)));
413  double y1_0 =
414  ((5 * cellY_[k] * sqrt3By2_ * guardRingOffset_ / 2) - (std::pow(guardRingOffset_, 2) / (6 * sqrt3_))) /
415  ((5 * cellY_[k] * sqrt3By2_) - (guardRingOffset_ / (2 * sqrt3_)));
416 
417  double x1 = (1.5 * cellY_[k]) * sqrt3By2_ - x1_0 * 0.5 - y1_0 * sqrt3By2_;
418  double y1 = -0.25 * cellY_[k] + x1_0 * sqrt3By2_ - y1_0 * 0.5;
419  double x2 = -(sqrt3By2_ * cellY_[k] - 0.5 * guardRingOffset_);
420  double y2 = 1.5 * cellY_[k];
421  double x3 = -(sqrt3By2_ * cellY_[k] - mouseBiteCut_ / 3);
422  double y3 = 3.5 * cellY_[k] - (5 * mouseBiteCut_) / 3 * sqrt3_;
423 
424  double cellArea = totalArea - cutArea1 - cutArea2 - cutArea3;
425  double xMag =
426  ((-9 * cellY_[k] / (sqrt3_ * 92)) * totalArea - (cutArea1 * x1) - (cutArea2 * x2) - (cutArea3 * x3)) /
427  (cellArea);
428  double yMag =
429  ((199 * cellY_[k] / (sqrt3_ * 276)) * totalArea - (cutArea1 * y1) - (cutArea2 * y2) - (cutArea3 * y3)) /
430  (cellArea);
431 
432  std::array<double, 6> tempOffsetX = {{(-sqrt3By2_ * xMag - 0.5 * yMag),
433  (-sqrt3By2_ * xMag + 0.5 * yMag),
434  yMag,
435  (sqrt3By2_ * xMag + 0.5 * yMag),
436  (sqrt3By2_ * xMag - 0.5 * yMag),
437  -yMag}};
438  std::array<double, 6> tempOffsetY = {{(0.5 * xMag - sqrt3By2_ * yMag),
439  (-sqrt3By2_ * yMag - 0.5 * xMag),
440  -xMag,
441  (-0.5 * xMag + sqrt3By2_ * yMag),
442  (0.5 * xMag + sqrt3By2_ * yMag),
443  xMag}};
444  for (int i = 0; i < 6; ++i) {
447  }
448  } else {
449  for (int i = 0; i < 6; ++i) {
452  }
453  }
454  } else if (j == (HGCalCell::LDPartial0007Cell)) {
455  if (k == 1) {
456  double totalArea = (5.0 * sqrt3_ / 4.0) * std::pow(cellY_[k], 2);
457  double cutArea1 = (cellY_[k] * guardRingOffset_);
458  double cutArea2 = (sqrt3_ * cellY_[k] * guardRingOffset_);
459  double h = cellY_[k] - (sqrt3By2_ * cellY_[k] - mouseBiteCut_) / sqrt3By2_;
460  double cutArea3 = sqrt3_ * std::pow(h, 2) / 2;
461 
462  double x1 = cellY_[k] * sqrt3By2_ - guardRingOffset_ / 2;
463  double y1 = 0;
464  double x2 = 0;
465  double y2 = 0.5 * cellY_[k] - guardRingOffset_ / 2;
466  double x3 = sqrt3By2_ * cellY_[k] - guardRingOffset_ - h / sqrt3_;
467  double y3 = 0.5 * cellY_[k] - guardRingOffset_ - h / 3;
468 
469  double cellArea = totalArea - cutArea1 - cutArea2 - cutArea3;
470  double xMag = ((0.0) * totalArea - (cutArea1 * x1) - (cutArea2 * x2) - (cutArea3 * x3)) / (cellArea);
471  double yMag =
472  ((-2 * cellY_[k] / 15) * totalArea - (cutArea1 * y1) - (cutArea2 * y2) - (cutArea3 * y3)) / (cellArea);
473 
474  std::array<double, 6> tempOffsetX = {{(-sqrt3By2_ * xMag - 0.5 * yMag),
475  (-sqrt3By2_ * xMag + 0.5 * yMag),
476  yMag,
477  (sqrt3By2_ * xMag + 0.5 * yMag),
478  (sqrt3By2_ * xMag - 0.5 * yMag),
479  -yMag}};
480  std::array<double, 6> tempOffsetY = {{(0.5 * xMag - sqrt3By2_ * yMag),
481  (-sqrt3By2_ * yMag - 0.5 * xMag),
482  -xMag,
483  (-0.5 * xMag + sqrt3By2_ * yMag),
484  (0.5 * xMag + sqrt3By2_ * yMag),
485  xMag}};
486  for (int i = 0; i < 6; ++i) {
489  }
490  } else {
491  for (int i = 0; i < 6; ++i) {
494  }
495  }
496  } else if (j == (HGCalCell::LDPartial0815Cell)) {
497  if (k == 1) {
498  double totalArea = sqrt3_ * std::pow(cellY_[k], 2);
499  double cutArea1 = (sqrt3_ * cellY_[k] * guardRingOffset_);
500  double cutArea2 = (sqrt3_ * cellY_[k] * guardRingOffset_) - std::pow(guardRingOffset_, 2) / (2 * sqrt3_);
501  double cutArea3 = sqrt3_ * std::pow((mouseBiteCut_ - guardRingOffset_ / sqrt3By2_), 2) / 2;
502 
503  double x2_0 = (1.5 * cellY_[k] * cellY_[k] - (0.5 * cellY_[k] * guardRingOffset_) +
504  std::pow(guardRingOffset_, 2) / 18) /
505  (sqrt3_ * cellY_[k] - guardRingOffset_ / (2 * sqrt3_));
506  double y2_0 = (sqrt3By2_ * cellY_[k] * guardRingOffset_ - std::pow(guardRingOffset_, 2) / (sqrt3_ * 3)) /
507  (sqrt3_ * cellY_[k] - guardRingOffset_ / (2 * sqrt3_));
508  double x1 = 0;
509  double y1 = 0.5 * cellY_[k] - guardRingOffset_ / 2;
510  double x2 = x2_0 * 0.5 - y2_0 * sqrt3By2_;
511  double y2 = -(cellY_[k] - (x2_0 * sqrt3By2_ + y2_0 * 0.5));
512  double x3 = sqrt3By2_ * cellY_[k] - mouseBiteCut_ + (mouseBiteCut_ - guardRingOffset_ / sqrt3By2_) / 3;
513  double y3 = cellY_[k] - (mouseBiteCut_ - guardRingOffset_ / sqrt3By2_) / sqrt3_ - guardRingOffset_;
514 
515  double cellArea = totalArea - cutArea1 - cutArea2 - cutArea3;
516  double xMag = -((-sqrt3_ * cellY_[k] / 9) * totalArea - (cutArea1 * x1) - (cutArea2 * x2) - (cutArea3 * x3)) /
517  (cellArea);
518  double yMag =
519  ((-cellY_[k] / 15) * totalArea - (cutArea1 * y1) - (cutArea2 * y2) - (cutArea3 * y3)) / (cellArea);
520 
521  std::array<double, 6> tempOffsetX = {{(-sqrt3By2_ * xMag - 0.5 * yMag),
522  (-sqrt3By2_ * xMag + 0.5 * yMag),
523  yMag,
524  (sqrt3By2_ * xMag + 0.5 * yMag),
525  (sqrt3By2_ * xMag - 0.5 * yMag),
526  -yMag}};
527  std::array<double, 6> tempOffsetY = {{(0.5 * xMag - sqrt3By2_ * yMag),
528  (-sqrt3By2_ * yMag - 0.5 * xMag),
529  -xMag,
530  (-0.5 * xMag + sqrt3By2_ * yMag),
531  (0.5 * xMag + sqrt3By2_ * yMag),
532  xMag}};
533  for (int i = 0; i < 6; ++i) {
536  }
537  } else {
538  for (int i = 0; i < 6; ++i) {
541  }
542  }
543  } else if (j == (HGCalCell::LDPartial1415Cell)) {
544  if (k == 1) {
545  double totalArea = 7 * sqrt3_ * std::pow(cellY_[k], 2) / 4;
546  double cutArea1 = (3 * cellY_[k] * guardRingOffset_);
547  double cutArea2 = (2 * sqrt3_ * cellY_[k] * guardRingOffset_) - std::pow(guardRingOffset_, 2) * sqrt3By2_;
548  double cutArea3 = std::pow((mouseBiteCut_ - guardRingOffset_), 2) / sqrt3_;
549 
550  double x2_0 = (6 * cellY_[k] * cellY_[k] - std::pow(guardRingOffset_, 2)) /
551  (2 * sqrt3_ * cellY_[k] - guardRingOffset_ * sqrt3By2_);
552  double y2_0 = (sqrt3_ * cellY_[k] * guardRingOffset_ - std::pow(guardRingOffset_, 2) / sqrt3_) /
553  (2 * sqrt3_ * cellY_[k] - guardRingOffset_ * sqrt3By2_);
554  double x1 = -sqrt3By2_ * cellY_[k] + guardRingOffset_ / 2;
555  double y1 = -cellY_[k];
556  double x2 = sqrt3By2_ * cellY_[k] - x2_0 * 0.5 - y2_0 * sqrt3By2_;
557  double y2 = 0.5 * cellY_[k] - x2_0 * sqrt3By2_ + y2_0 * 0.5;
558  double h = (mouseBiteCut_ - guardRingOffset_) / sqrt3By2_;
559  double x3 = -(cellY_[k] - h / 3 - guardRingOffset_) * sqrt3By2_;
560  double y3 = 5 * h / 6 - 5 * cellY_[k] / 2;
561 
562  double cellArea = totalArea - cutArea1 - cutArea2 - cutArea3;
563  double xMag =
564  ((-2 * cellY_[k] / (7 * sqrt3_)) * totalArea - (cutArea1 * x1) - (cutArea2 * x2) - (cutArea3 * x3)) /
565  (cellArea);
566  double yMag =
567  ((-cellY_[k] / 3) * totalArea - (cutArea1 * y1) - (cutArea2 * y2) - (cutArea3 * y3)) / (cellArea);
568 
569  std::array<double, 6> tempOffsetX = {{(-sqrt3By2_ * xMag - 0.5 * yMag),
570  (-sqrt3By2_ * xMag + 0.5 * yMag),
571  yMag,
572  (sqrt3By2_ * xMag + 0.5 * yMag),
573  (sqrt3By2_ * xMag - 0.5 * yMag),
574  -yMag}};
575  std::array<double, 6> tempOffsetY = {{(0.5 * xMag - sqrt3By2_ * yMag),
576  (-sqrt3By2_ * yMag - 0.5 * xMag),
577  -xMag,
578  (-0.5 * xMag + sqrt3By2_ * yMag),
579  (0.5 * xMag + sqrt3By2_ * yMag),
580  xMag}};
581  for (int i = 0; i < 6; ++i) {
584  }
585  } else {
586  for (int i = 0; i < 6; ++i) {
589  }
590  }
591  } else if (j == (HGCalCell::LDPartial1515Cell)) {
592  if (k == 1) {
593  double totalArea = 7 * sqrt3_ * std::pow(cellY_[k], 2) / 8;
594  double cutArea1 = (2 * cellY_[k] * guardRingOffset_);
595  double cutArea2 = (sqrt3By2_ * cellY_[k] * guardRingOffset_);
596  double cutArea3 = cellY_[k] * (mouseBiteCut_ - guardRingOffset_) - (sqrt3_ * cellY_[k] * cellY_[k] / 8);
597 
598  double x1 = -guardRingOffset_ / 2;
599  double y1 = 0;
600  double x2 = -(sqrt3By2_ * cellY_[k] / 2);
601  double y2 = -(cellY_[k] - 0.5 * guardRingOffset_);
602  double x3 = (cellY_[k] * cellY_[k] / 8 - sqrt3_ * cellY_[k] * (mouseBiteCut_ - guardRingOffset_) / 4) /
603  ((mouseBiteCut_ - guardRingOffset_) - sqrt3_ * cellY_[k] / 8);
604  double y3 =
605  (std::pow((mouseBiteCut_ - guardRingOffset_), 2) / sqrt3_ -
606  (1.25 * cellY_[k] * (mouseBiteCut_ - guardRingOffset_)) + 7 * sqrt3_ * cellY_[k] * cellY_[k] / 48) /
607  ((mouseBiteCut_ - guardRingOffset_) - sqrt3_ * cellY_[k] / 8);
608 
609  double cellArea = totalArea - cutArea1 - cutArea2 - cutArea3;
610  double xMag =
611  (-(cellY_[k] / (sqrt3_)) * totalArea - (cutArea1 * x1) - (cutArea2 * x2) - (cutArea3 * x3)) / (cellArea);
612  double yMag =
613  ((-5 * cellY_[k] / 42) * totalArea - (cutArea1 * y1) - (cutArea2 * y2) - (cutArea3 * y3)) / (cellArea);
614 
615  std::array<double, 6> tempOffsetX = {{(-sqrt3By2_ * xMag - 0.5 * yMag),
616  (-sqrt3By2_ * xMag + 0.5 * yMag),
617  yMag,
618  (sqrt3By2_ * xMag + 0.5 * yMag),
619  (sqrt3By2_ * xMag - 0.5 * yMag),
620  -yMag}};
621  std::array<double, 6> tempOffsetY = {{(0.5 * xMag - sqrt3By2_ * yMag),
622  (-sqrt3By2_ * yMag - 0.5 * xMag),
623  -xMag,
624  (-0.5 * xMag + sqrt3By2_ * yMag),
625  (0.5 * xMag + sqrt3By2_ * yMag),
626  xMag}};
627  for (int i = 0; i < 6; ++i) {
630  }
631  } else {
632  for (int i = 0; i < 6; ++i) {
635  }
636  }
637  } else if (j == (HGCalCell::HDPartial0920Cell)) {
638  if (k == 0) {
639  double totalArea = 37 * sqrt3_ * std::pow(cellY_[k], 2) / 24;
640  double cutArea1 = (4 * cellY_[k] * guardRingOffset_) / sqrt3_;
641  double cutArea2 =
642  (7 * cellY_[k] * guardRingOffset_) / (2 * sqrt3_) - std::pow(guardRingOffset_, 2) / (2 * sqrt3_);
643 
644  double x1 = cellY_[k] / (2 * sqrt3_);
645  double y1 = -(0.5 * cellY_[k] - 0.5 * guardRingOffset_);
646  double x2_0 = ((2.041 * cellY_[k] * cellY_[k]) - (cellY_[k] * 0.583 * guardRingOffset_) +
647  (std::pow(guardRingOffset_, 2) / 18)) /
648  ((7 * cellY_[k] / (2 * sqrt3_)) - (guardRingOffset_ / (2 * sqrt3_)));
649  double y2_0 =
650  ((7 * cellY_[k] * guardRingOffset_ / (4 * sqrt3_)) - std::pow(guardRingOffset_, 2) / (6 * sqrt3_)) /
651  ((7 * cellY_[k] / (2 * sqrt3_)) - (guardRingOffset_ / (2 * sqrt3_)));
652 
653  double x2 = (0.5 * x2_0) - (sqrt3By2_ * y2_0) + (cellY_[k] * 0.5 * sqrt3By2_);
654  double y2 = -(0.5 * y2_0) - (sqrt3By2_ * x2_0) + (cellY_[k] * 1.25);
655  double cellArea = totalArea - cutArea1 - cutArea2;
656  double xMag = ((25 * sqrt3_ * cellY_[k] / 148) * totalArea - (cutArea1 * x1) - (cutArea2 * x2)) / (cellArea);
657  double yMag = ((73 * cellY_[k] / 444) * totalArea - (cutArea1 * y1) - (cutArea2 * y2)) / (cellArea);
658 
659  std::array<double, 6> tempOffsetX = {{(-sqrt3By2_ * xMag - 0.5 * yMag),
660  (-sqrt3By2_ * xMag + 0.5 * yMag),
661  yMag,
662  (sqrt3By2_ * xMag + 0.5 * yMag),
663  (sqrt3By2_ * xMag - 0.5 * yMag),
664  -yMag}};
665  std::array<double, 6> tempOffsetY = {{(0.5 * xMag - sqrt3By2_ * yMag),
666  (-sqrt3By2_ * yMag - 0.5 * xMag),
667  -xMag,
668  (-0.5 * xMag + sqrt3By2_ * yMag),
669  (0.5 * xMag + sqrt3By2_ * yMag),
670  xMag}};
671  for (int i = 0; i < 6; ++i) {
674  }
675  } else {
676  for (int i = 0; i < 6; ++i) {
679  }
680  }
681  } else if (j == (HGCalCell::HDPartial1021Cell)) {
682  if (k == 0) {
683  double totalArea = 11 * sqrt3_ * std::pow(cellY_[k], 2) / 6;
684  double cutArea1 = (5 * cellY_[k] * guardRingOffset_) / (2 * sqrt3_);
685  double cutArea2 =
686  (5 * cellY_[k] * guardRingOffset_) / (2 * sqrt3_) - std::pow(guardRingOffset_, 2) / (2 * sqrt3_);
687 
688  double x1 = -cellY_[k] / (4 * sqrt3_);
689  double y1 = cellY_[k] - 0.5 * guardRingOffset_;
690  double x2_0 = ((1.041 * cellY_[k] * cellY_[k]) - (cellY_[k] * 0.416 * guardRingOffset_) +
691  (std::pow(guardRingOffset_, 2) / 18.0)) /
692  ((5.0 * cellY_[k] / (2.0 * sqrt3_)) - (guardRingOffset_ / (2.0 * sqrt3_)));
693  double y2_0 =
694  ((5.0 * cellY_[k] * guardRingOffset_ / (4.0 * sqrt3_)) - std::pow(guardRingOffset_, 2) / (6 * sqrt3_)) /
695  ((5.0 * cellY_[k] / (2.0 * sqrt3_)) - (guardRingOffset_ / (2.0 * sqrt3_)));
696 
697  double x2 = -(0.5 * x2_0) + (sqrt3By2_ * y2_0) + (cellY_[k] * 1.5 * sqrt3By2_);
698  double y2 = -(0.5 * y2_0) + (sqrt3By2_ * x2_0) - cellY_[k];
699  double cellArea = totalArea - cutArea1 - cutArea2;
700  double xMag =
701  ((47.0 * cellY_[k] / (528.0 * sqrt3_)) * totalArea - (cutArea1 * x1) - (cutArea2 * x2)) / (cellArea);
702  double yMag = ((47.0 * cellY_[k] / 528.0) * totalArea - (cutArea1 * y1) - (cutArea2 * y2)) / (cellArea);
703 
704  std::array<double, 6> tempOffsetX = {{(-sqrt3By2_ * xMag - 0.5 * yMag),
705  (-sqrt3By2_ * xMag + 0.5 * yMag),
706  yMag,
707  (sqrt3By2_ * xMag + 0.5 * yMag),
708  (sqrt3By2_ * xMag - 0.5 * yMag),
709  -yMag}};
710  std::array<double, 6> tempOffsetY = {{(0.5 * xMag - sqrt3By2_ * yMag),
711  (-sqrt3By2_ * yMag - 0.5 * xMag),
712  -xMag,
713  (-0.5 * xMag + sqrt3By2_ * yMag),
714  (0.5 * xMag + sqrt3By2_ * yMag),
715  xMag}};
716  for (int i = 0; i < 6; ++i) {
719  }
720  } else {
721  for (int i = 0; i < 6; ++i) {
724  }
725  }
726  }
727  }
728  }
729 
730 #ifdef EDM_ML_DEBUG
731  edm::LogVerbatim("HGCalGeom") << "HGCalCellOffset initialized with waferSize " << waferSize << " number of cells "
732  << nFine << ":" << nCoarse << " Guardring offset " << guardRingOffset_ << " Mousebite "
733  << mouseBiteCut_;
734 #endif
735 }
736 
737 std::pair<double, double> HGCalCellOffset::cellOffsetUV2XY1(int32_t u, int32_t v, int32_t placementIndex, int32_t type) {
738  if (type != 0)
739  type = 1;
740  double x_off(0), y_off(0);
741  std::pair<int, int> cell = hgcalcell_->cellType(u, v, ncell_[type], placementIndex);
742  int cellPos = cell.first;
743  int cellType = cell.second;
744  if (cellType == HGCalCell::truncatedCell || cellType == HGCalCell::extendedCell) {
745  x_off = offsetX[type][cellType][cellPos - HGCalCell::bottomLeftEdge];
746  y_off = offsetY[type][cellType][cellPos - HGCalCell::bottomLeftEdge];
747  } else if ((cellType == HGCalCell::cornerCell) || (cellType == HGCalCell::truncatedMBCell) ||
748  (cellType == HGCalCell::extendedMBCell)) {
749  // The offset fo corner cells, is flipped along y-axis for 60 degree rotation of wafer
750  // and from forward to backward wafers
751  if (((placementIndex >= HGCalCell::cellPlacementExtra) && (placementIndex % 2 == 0)) ||
752  ((placementIndex < HGCalCell::cellPlacementExtra) && (placementIndex % 2 == 1))) {
753  cellPos = HGCalCell::bottomCorner + (6 + HGCalCell::bottomCorner - cellPos) % 6;
754  }
755  x_off = offsetX[type][cellType][cellPos - HGCalCell::bottomCorner];
756  y_off = offsetY[type][cellType][cellPos - HGCalCell::bottomCorner];
757  if (((placementIndex >= HGCalCell::cellPlacementExtra) && (placementIndex % 2 == 0)) ||
758  ((placementIndex < HGCalCell::cellPlacementExtra) && (placementIndex % 2 == 1))) {
759  x_off = -1 * x_off;
760  }
761  }
762  return std::make_pair(x_off, y_off);
763 }
764 
765 std::pair<double, double> HGCalCellOffset::cellOffsetUV2XY1(
766  int32_t u, int32_t v, int32_t placementIndex, int32_t type, int32_t partialType) {
767  if (type != 0)
768  type = 1;
769  std::pair<double, double> offset = HGCalCellOffset::cellOffsetUV2XY1(u, v, placementIndex, type);
770  double x_off = offset.first;
771  double y_off = offset.second;
772  std::pair<int, int> cell = hgcalcell_->cellType(u, v, ncell_[type], placementIndex, partialType);
773  int cellPos = cell.first;
774  int cellType = cell.second;
776  if (cellType == HGCalCell::truncatedCell || cellType == HGCalCell::extendedCell) {
777  if (cellPos == HGCalCell::topCell) {
778  int Pos(0);
780  x_off = (placementIndex >= HGCalCell::cellPlacementExtra) ? -offsetX[type][cellType][Pos]
781  : offsetX[type][cellType][Pos];
782  y_off = offsetY[type][cellType][Pos];
783  } else if (cellPos == HGCalCell::bottomCell) {
784  int Pos(0);
785  Pos = (placementIndex) % HGCalCell::cellPlacementExtra;
786  x_off = (placementIndex >= HGCalCell::cellPlacementExtra) ? -offsetX[type][cellType][Pos]
787  : offsetX[type][cellType][Pos];
788  y_off = offsetY[type][cellType][Pos];
789  }
790  } else if ((cellType == HGCalCell::halfCell) || (cellType == HGCalCell::halfTrunCell) ||
791  (cellType == HGCalCell::halfExtCell) || (cellType == HGCalCell::LDPartial0714Cell) ||
792  (cellType == HGCalCell::LDPartial0815Cell) || (cellType == HGCalCell::HDPartial0920Cell) ||
793  (cellType == HGCalCell::HDPartial1021Cell)) {
794  int cellType1 = cellType - HGCalCell::partiaclWaferCellsOffset;
795  if (cellType == HGCalCell::halfCell) {
796  std::cout << u << ":" << v << " 2" << std::endl;
797  }
798  if (cellPos == HGCalCell::leftCell) {
799  int placeIndex = placementIndex % HGCalCell::cellPlacementExtra;
800  x_off = offsetPartialX[type][cellType1][placeIndex];
801  y_off = offsetPartialY[type][cellType1][placeIndex];
802  } else if (cellPos == HGCalCell::rightCell) {
803  int placeIndex = (HGCalCell::cellPlacementExtra - placementIndex) % HGCalCell::cellPlacementExtra;
804  x_off = -offsetPartialX[type][cellType1][placeIndex];
805  y_off = offsetPartialY[type][cellType1][placeIndex];
806  }
807  x_off = placementIndex < HGCalCell::cellPlacementExtra ? x_off : -x_off;
808  } else if ((cellType == HGCalCell::LDPartial0209Cell) || (cellType == HGCalCell::LDPartial0007Cell) ||
809  (cellType == HGCalCell::LDPartial1415Cell) || (cellType == HGCalCell::LDPartial1515Cell)) {
810  int cellType1 = cellType - HGCalCell::partiaclWaferCellsOffset;
811  int placeIndex = placementIndex % HGCalCell::cellPlacementExtra;
812  x_off = offsetPartialX[type][cellType1][placeIndex];
813  y_off = offsetPartialY[type][cellType1][placeIndex];
814  x_off = placementIndex < HGCalCell::cellPlacementExtra ? x_off : -x_off;
815  }
816  }
817  return std::make_pair(x_off, y_off);
818 }
819 
820 double HGCalCellOffset::cellAreaUV(int32_t u, int32_t v, int32_t placementIndex, int32_t type, bool reco) {
821  if (type != 0)
822  type = 1;
823  double area(0);
824  std::pair<int, int> cell = hgcalcell_->cellType(u, v, ncell_[type], placementIndex);
825  int cellType = cell.second;
826  area = reco ? cellArea[type][cellType] : HGCalParameters::k_ScaleToDDD2 * cellArea[type][cellType];
827  return area;
828 }
static constexpr int32_t LDPartial0007Cell
Definition: HGCalCell.h:43
Log< level::Info, true > LogVerbatim
static constexpr int32_t fullCell
Definition: HGCalCell.h:28
static constexpr int32_t partiaclCellsPosOffset
Definition: HGCalCell.h:70
int32_t ncell_[2]
double cellArea[2][6]
std::pair< double, double > cellOffsetUV2XY1(int32_t u, int32_t v, int32_t placementIndex, int32_t type)
std::array< std::array< std::array< double, 6 >, 11 >, 2 > offsetPartialX
static constexpr int32_t HDPartial1021Cell
Definition: HGCalCell.h:49
static constexpr int32_t extendedMBCell
Definition: HGCalCell.h:33
static constexpr int32_t HDPartial0920Cell
Definition: HGCalCell.h:48
static constexpr int32_t partiaclWaferCellsOffset
Definition: HGCalCell.h:39
static constexpr int32_t truncatedMBCell
Definition: HGCalCell.h:32
const double sqrt3By2_
static constexpr int32_t leftCell
Definition: HGCalCell.h:66
static constexpr int32_t LDPartial0209Cell
Definition: HGCalCell.h:42
static constexpr int32_t topCell
Definition: HGCalCell.h:68
double cellAreaUV(int32_t u, int32_t v, int32_t placementIndex, int32_t type, bool reco)
static constexpr int32_t halfCell
Definition: HGCalCell.h:36
static constexpr int32_t LDPartial0714Cell
Definition: HGCalCell.h:41
static constexpr int32_t LDPartial1515Cell
Definition: HGCalCell.h:46
const double sqrt3_
static constexpr int32_t bottomLeftEdge
Definition: HGCalCell.h:53
std::array< std::array< std::array< double, 6 >, 6 >, 2 > offsetY
static constexpr int32_t truncatedCell
Definition: HGCalCell.h:30
static constexpr int32_t halfTrunCell
Definition: HGCalCell.h:37
static constexpr int32_t extendedCell
Definition: HGCalCell.h:31
static constexpr int32_t topRightEdge
Definition: HGCalCell.h:56
std::unique_ptr< HGCalCell > hgcalcell_
static constexpr int32_t LDPartial0815Cell
Definition: HGCalCell.h:44
fixed size matrix
static constexpr int32_t LDPartial1415Cell
Definition: HGCalCell.h:45
HGCalCellOffset(double waferSize, int32_t nFine, int32_t nCoarse, double guardRingOffset_, double mouseBiteCut_)
static constexpr int32_t halfExtCell
Definition: HGCalCell.h:38
static constexpr int32_t bottomCorner
Definition: HGCalCell.h:59
static constexpr int32_t cornerCell
Definition: HGCalCell.h:29
static constexpr int32_t rightCell
Definition: HGCalCell.h:67
std::array< std::array< std::array< double, 6 >, 11 >, 2 > offsetPartialY
Definition: APVGainStruct.h:7
static constexpr double k_ScaleToDDD2
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
std::array< std::array< std::array< double, 6 >, 6 >, 2 > offsetX
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29
static constexpr int32_t bottomCell
Definition: HGCalCell.h:69
static constexpr int32_t cellPlacementExtra
Definition: HGCalCell.h:24