CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
HGCalCell.cc
Go to the documentation of this file.
2 #include <vector>
3 
4 HGCalCell::HGCalCell(double waferSize, int32_t nFine, int32_t nCoarse) {
5  ncell_[0] = nFine;
6  ncell_[1] = nCoarse;
7  for (int k = 0; k < 2; ++k) {
8  cellX_[k] = waferSize / (3 * ncell_[k]);
9  cellY_[k] = sqrt3By2_ * cellX_[k];
10  }
11 }
12 
13 std::pair<double, double> HGCalCell::HGCalCellUV2XY1(int32_t u, int32_t v, int32_t placementIndex, int32_t type) {
14  if (type != 0)
15  type = 1;
16  double x(0), y(0);
17  switch (placementIndex) {
19  x = (1.5 * (v - u) + 0.5) * cellX_[type];
20  y = (v + u - 2 * ncell_[type] + 1) * cellY_[type];
21  break;
23  x = (1.5 * (v - ncell_[type]) + 1.0) * cellX_[type];
24  y = (2 * u - v - ncell_[type]) * cellY_[type];
25  break;
27  x = (1.5 * (u - ncell_[type]) + 0.5) * cellX_[type];
28  y = -(2 * v - u - ncell_[type] + 1) * cellY_[type];
29  break;
31  x = -(1.5 * (v - u) + 0.5) * cellX_[type];
32  y = -(v + u - 2 * ncell_[type] + 1) * cellY_[type];
33  break;
35  x = -(1.5 * (v - ncell_[type]) + 1) * cellX_[type];
36  y = -(2 * u - v - ncell_[type]) * cellY_[type];
37  break;
39  x = -(1.5 * (u - ncell_[type]) + 0.5) * cellX_[type];
40  y = (2 * v - u - ncell_[type] + 1) * cellY_[type];
41  break;
43  x = (1.5 * (u - v) - 0.5) * cellX_[type];
44  y = (v + u - 2 * ncell_[type] + 1) * cellY_[type];
45  break;
47  x = -(1.5 * (v - ncell_[type]) + 1.0) * cellX_[type];
48  y = (2 * u - v - ncell_[type]) * cellY_[type];
49  break;
51  x = -(1.5 * (u - ncell_[type]) + 0.5) * cellX_[type];
52  y = -(2 * v - u - ncell_[type] + 1) * cellY_[type];
53  break;
55  x = -(1.5 * (u - v) - 0.5) * cellX_[type];
56  y = -(v + u - 2 * ncell_[type] + 1) * cellY_[type];
57  break;
59  x = (1.5 * (v - ncell_[type]) + 1) * cellX_[type];
60  y = -(2 * u - v - ncell_[type]) * cellY_[type];
61  break;
62  default:
63  x = (1.5 * (u - ncell_[type]) + 0.5) * cellX_[type];
64  y = (2 * v - u - ncell_[type] + 1) * cellY_[type];
65  break;
66  }
67  return std::make_pair(x, y);
68 }
69 
70 std::pair<double, double> HGCalCell::HGCalCellUV2XY2(int32_t u, int32_t v, int32_t placementIndex, int32_t type) {
71  if (type != 0)
72  type = 1;
73  double x(0), y(0);
74  if (placementIndex < HGCalCell::cellPlacementExtra) {
75  double x0 = (1.5 * (u - v) - 0.5) * cellX_[type];
76  double y0 = (u + v - 2 * ncell_[type] + 1) * cellY_[type];
77  const std::vector<double> fcos = {1.0, 0.5, -0.5, -1.0, -0.5, 0.5};
78  const std::vector<double> fsin = {0.0, sqrt3By2_, sqrt3By2_, 0.0, -sqrt3By2_, -sqrt3By2_};
79  x = x0 * fcos[placementIndex] - y0 * fsin[placementIndex];
80  y = x0 * fsin[placementIndex] + y0 * fcos[placementIndex];
81  } else {
82  double x0 = (1.5 * (v - ncell_[type]) + 1.0) * cellX_[type];
83  double y0 = (2 * u - v - ncell_[type]) * cellY_[type];
84  const std::vector<double> fcos = {0.5, 1.0, 0.5, -0.5, -1.0, -0.5};
85  const std::vector<double> fsin = {sqrt3By2_, 0.0, -sqrt3By2_, -sqrt3By2_, 0.0, sqrt3By2_};
86  x = x0 * fcos[placementIndex - HGCalCell::cellPlacementExtra] -
87  y0 * fsin[placementIndex - HGCalCell::cellPlacementExtra];
88  y = x0 * fsin[placementIndex - HGCalCell::cellPlacementExtra] +
89  y0 * fcos[placementIndex - HGCalCell::cellPlacementExtra];
90  }
91  return std::make_pair(x, y);
92 }
93 
94 std::pair<int, int> HGCalCell::HGCalCellUV2Cell(int32_t u, int32_t v, int32_t placementIndex, int32_t type) {
95  if (type != 0)
96  type = 1;
97  int cell(0), cellx(0), cellt(HGCalCell::fullCell);
98  if (placementIndex >= HGCalCell::cellPlacementExtra) {
99  const std::vector<int> itype0 = {0, 7, 8, 9, 10, 11, 6, 3, 4, 5, 4, 5, 3};
100  const std::vector<int> itype1 = {0, 0, 1, 2, 3, 4, 5, 0, 1, 2, 0, 1, 2};
101  const std::vector<int> itype2 = {0, 11, 6, 7, 8, 9, 10, 5, 3, 4, 3, 4, 5};
102  const std::vector<int> itype3 = {0, 4, 5, 0, 1, 2, 3, 2, 0, 1, 2, 0, 1};
103  const std::vector<int> itype4 = {0, 9, 10, 11, 6, 7, 8, 4, 5, 3, 5, 3, 4};
104  const std::vector<int> itype5 = {0, 2, 3, 4, 5, 0, 1, 1, 2, 0, 1, 2, 0};
105  if (u == 0 && v == 0) {
106  cellx = 1;
107  cellt = HGCalCell::cornerCell;
108  } else if (u == 0 && (v - u) == (ncell_[type] - 1)) {
109  cellx = 2;
110  cellt = HGCalCell::cornerCell;
111  } else if ((v - u) == (ncell_[type] - 1) && v == (2 * ncell_[type] - 1)) {
112  cellx = 3;
113  cellt = HGCalCell::cornerCell;
114  } else if (u == (2 * ncell_[type] - 1) && v == (2 * ncell_[type] - 1)) {
115  cellx = 4;
116  cellt = HGCalCell::cornerCell;
117  } else if (u == (2 * ncell_[type] - 1) && (u - v) == ncell_[type]) {
118  cellx = 5;
119  cellt = HGCalCell::cornerCell;
120  } else if ((u - v) == ncell_[type] && v == 0) {
121  cellx = 6;
122  cellt = HGCalCell::cornerCell;
123  } else if (u == 0) {
124  cellx = 7;
125  cellt = HGCalCell::truncatedCell;
126  } else if ((v - u) == (ncell_[type] - 1)) {
127  cellx = 10;
128  cellt = HGCalCell::extendedCell;
129  } else if (v == (2 * ncell_[type] - 1)) {
130  cellx = 8;
131  cellt = HGCalCell::truncatedCell;
132  } else if (u == (2 * ncell_[type] - 1)) {
133  cellx = 11;
134  cellt = HGCalCell::extendedCell;
135  } else if ((u - v) == ncell_[type]) {
136  cellx = 9;
137  cellt = HGCalCell::truncatedCell;
138  } else if (v == 0) {
139  cellx = 12;
140  cellt = HGCalCell::extendedCell;
141  }
142  switch (placementIndex) {
144  cell = itype0[cellx];
145  break;
147  cell = itype1[cellx];
148  break;
150  cell = itype2[cellx];
151  break;
153  cell = itype3[cellx];
154  break;
156  cell = itype4[cellx];
157  break;
158  default:
159  cell = itype5[cellx];
160  break;
161  }
162  } else {
163  const std::vector<int> itype0 = {0, 1, 2, 3, 4, 5, 0, 1, 2, 0, 0, 1, 2};
164  const std::vector<int> itype1 = {0, 8, 9, 10, 11, 6, 7, 4, 5, 3, 4, 5, 3};
165  const std::vector<int> itype2 = {0, 3, 4, 5, 0, 1, 2, 2, 0, 1, 1, 2, 0};
166  const std::vector<int> itype3 = {0, 10, 11, 6, 7, 8, 9, 5, 3, 4, 5, 3, 4};
167  const std::vector<int> itype4 = {0, 5, 0, 1, 2, 3, 4, 0, 1, 2, 2, 0, 1};
168  const std::vector<int> itype5 = {0, 6, 7, 8, 9, 10, 11, 3, 4, 5, 3, 4, 5};
169  if (u == 0 && v == 0) {
170  cellx = 1;
171  cellt = HGCalCell::cornerCell;
172  } else if (v == 0 && (u - v) == (ncell_[type])) {
173  cellx = 2;
174  cellt = HGCalCell::cornerCell;
175  } else if ((u - v) == (ncell_[type]) && u == (2 * ncell_[type] - 1)) {
176  cellx = 3;
177  cellt = HGCalCell::cornerCell;
178  } else if (u == (2 * ncell_[type] - 1) && v == (2 * ncell_[type] - 1)) {
179  cellx = 4;
180  cellt = HGCalCell::cornerCell;
181  } else if (v == (2 * ncell_[type] - 1) && (v - u) == (ncell_[type] - 1)) {
182  cellx = 5;
183  cellt = HGCalCell::cornerCell;
184  } else if ((v - u) == (ncell_[type] - 1) && u == 0) {
185  cellx = 6;
186  cellt = HGCalCell::cornerCell;
187  } else if (v == 0) {
188  cellx = 10;
189  cellt = HGCalCell::extendedCell;
190  } else if ((u - v) == ncell_[type]) {
191  cellx = 7;
192  cellt = HGCalCell::truncatedCell;
193  } else if (u == (2 * ncell_[type] - 1)) {
194  cellx = 11;
195  cellt = HGCalCell::extendedCell;
196  } else if (v == (2 * ncell_[type] - 1)) {
197  cellx = 8;
198  cellt = HGCalCell::truncatedCell;
199  } else if ((v - u) == (ncell_[type] - 1)) {
200  cellx = 12;
201  cellt = HGCalCell::extendedCell;
202  } else if (u == 0) {
203  cellx = 9;
204  cellt = HGCalCell::truncatedCell;
205  }
206  switch (placementIndex) {
208  cell = itype0[cellx];
209  break;
211  cell = itype1[cellx];
212  break;
214  cell = itype2[cellx];
215  break;
217  cell = itype3[cellx];
218  break;
220  cell = itype4[cellx];
221  break;
222  default:
223  cell = itype5[cellx];
224  break;
225  }
226  }
227  return std::make_pair(cell, cellt);
228 }
229 
230 int HGCalCell::HGCalCellPlacementIndex(int32_t iz, int32_t fwdBack, int32_t orient) {
231  int32_t indx = ((iz * fwdBack) > 0) ? orient : (orient + HGCalCell::cellPlacementExtra);
232  return indx;
233 }
static constexpr int32_t fullCell
Definition: HGCalCell.h:35
const double sqrt3By2_
Definition: HGCalCell.h:46
std::pair< int32_t, int32_t > HGCalCellUV2Cell(int32_t u, int32_t v, int32_t placementIndex, int32_t type)
Definition: HGCalCell.cc:94
static constexpr int32_t cellPlacementIndex8
Definition: HGCalCell.h:26
static constexpr int32_t cellPlacementIndex3
Definition: HGCalCell.h:21
int32_t ncell_[2]
Definition: HGCalCell.h:47
static constexpr int32_t cellPlacementIndex10
Definition: HGCalCell.h:28
static constexpr int32_t cellPlacementIndex0
Definition: HGCalCell.h:18
std::pair< double, double > HGCalCellUV2XY2(int32_t u, int32_t v, int32_t placementIndex, int32_t type)
Definition: HGCalCell.cc:70
static constexpr int32_t cellPlacementIndex9
Definition: HGCalCell.h:27
static int32_t HGCalCellPlacementIndex(int32_t iz, int32_t fwdBack, int32_t orient)
Definition: HGCalCell.cc:230
HGCalCell(double waferSize, int32_t nFine, int32_t nCoarse)
Definition: HGCalCell.cc:4
std::pair< double, double > HGCalCellUV2XY1(int32_t u, int32_t v, int32_t placementIndex, int32_t type)
Definition: HGCalCell.cc:13
static constexpr int32_t cellPlacementIndex7
Definition: HGCalCell.h:25
static constexpr int32_t truncatedCell
Definition: HGCalCell.h:37
static constexpr int32_t extendedCell
Definition: HGCalCell.h:38
static constexpr int32_t cellPlacementIndex11
Definition: HGCalCell.h:29
static constexpr int32_t cornerCell
Definition: HGCalCell.h:36
static constexpr int32_t cellPlacementIndex4
Definition: HGCalCell.h:22
static constexpr int32_t cellPlacementIndex1
Definition: HGCalCell.h:19
double cellX_[2]
Definition: HGCalCell.h:48
static constexpr int32_t cellPlacementIndex6
Definition: HGCalCell.h:24
double cellY_[2]
Definition: HGCalCell.h:48
static constexpr int32_t cellPlacementIndex2
Definition: HGCalCell.h:20
static constexpr int32_t cellPlacementExtra
Definition: HGCalCell.h:31