11 hgcalcell_ = std::make_unique<HGCalCell>(waferSize, nFine, nCoarse);
12 assert(nFine > 0 && nCoarse > 0);
15 for (
int k = 0;
k < 2; ++
k) {
24 for (
int iu = 0; iu < 2 *
ncell_[0]; ++iu) {
34 for (
int iu = 0; iu < 2 *
ncell_[1]; ++iu) {
47 double xloc,
double yloc, int32_t placement, int32_t
type,
bool extend,
bool debug)
const {
56 double x = xloc1 * fcos[
rot] - yloc * fsin[
rot];
57 double y = xloc1 * fsin[
rot] + yloc * fcos[
rot];
65 int iu = std::floor(u / cellY) + 3 * (
ncell_[
type]) - 1;
67 int iw = std::floor(
w / cellY) + 1;
69 int isv = (iu + iw) / 3;
70 int isu = (
iv + iw) / 3;
74 isu = (
iv + iw + 1) / 3;
77 isu = (
iv + iw + 1) / 3;
78 isv = (iu + iw - 1) / 3;
81 isv = (iu + iw - 1) / 3;
84 edm::LogVerbatim(
"HGCalGeom") <<
"cellUVFromXY1: Input " << xloc <<
":" << yloc <<
":" << extend <<
" Output " 86 return std::make_pair(isu, isv);
90 double xloc,
double yloc, int32_t placement, int32_t
type,
bool extend,
bool debug)
const {
100 double x = xloc1 * fcos[
rot] - yloc * fsin[
rot];
101 double y = xloc1 * fsin[
rot] + yloc * fcos[
rot];
103 int32_t u(-100),
v(-100);
106 double l1 = (
y /
r) + ncell - 1.0;
107 int l2 = std::floor((0.5 *
y + 0.5 *
x /
sqrt3_) /
r + ncell - 4.0 / 3.0);
108 int l3 = std::floor((
x /
sqrt3_) /
r + ncell - 4.0 / 3.0);
109 double l4 = (
y +
sqrt3_ *
x) / (2 *
r) + 2 * ncell - 2;
110 double l5 = (
y -
sqrt3_ *
x) / (2 *
r) - ncell;
111 double u1 = (
y /
r) + ncell + 1.0;
117 for (
int ui = l2 + 1;
ui <
u2;
ui++) {
118 for (
int vi = l3 + 1; vi <
u3; vi++) {
119 int c1 = 2 *
ui - vi;
121 int c5 =
ui - 2 * vi;
122 if ((
c1 <
u1) && (
c1 > l1) && (c4 < u4) && (c4 > l4) && (c5 < u5) && (c5 > l5)) {
131 if (
y < (2 * u -
v - ncell) *
r) {
138 if (
v - u == ncell) {
139 if ((
y +
sqrt3_ *
x) < ((u +
v - 2 * ncell + 1) * 2 *
r)) {
145 if (u == 2 * ncell) {
146 if ((
y -
sqrt3_ *
x) < ((u - 2 *
v + ncell - 1) * 2 *
r)) {
154 edm::LogVerbatim(
"HGCalGeom") <<
"cellUVFromXY2: Input " << xloc <<
":" << yloc <<
":" << extend <<
" Output " << u
156 return std::make_pair(u,
v);
160 double xloc,
double yloc, int32_t placement, int32_t
type,
bool extend,
bool debug)
const {
171 double xprime = xloc1 * fcos[
rot] - yloc * fsin[
rot];
172 double yprime = xloc1 * fsin[
rot] + yloc * fcos[
rot];
173 double x = xprime + cellX;
179 double cu = 2 *
x / 3;
180 double cv = -
x / 3 +
y / 2;
181 double cw = -
x / 3 -
y / 2;
183 int iu = std::round(cu);
184 int iv = std::round(
cv);
185 int iw = std::round(cw);
187 if (iu +
iv + iw != 0) {
194 iw = (std::round(cw) == std::floor(cw)) ?
std::ceil(cw) : std::floor(cw);
199 double xcell = (1.5 * (
v - u) + 0.5) *
cellX_[
type];
200 double ycell = (
v + u - 2 *
ncell_[
type] + 1) * cellY;
202 if ((yprime -
sqrt3_ * xprime) < (ycell -
sqrt3_ * xcell)) {
210 if (yprime < ycell) {
217 if ((yprime +
sqrt3_ * xprime) > (ycell +
sqrt3_ * xcell)) {
226 edm::LogVerbatim(
"HGCalGeom") <<
"cellUVFromXY3: Input " << xloc <<
":" << yloc <<
":" << extend <<
" Output " << u
228 return std::make_pair(u,
v);
232 double xloc,
double yloc, int32_t placement, int32_t
type,
bool extend,
bool debug) {
248 std::map<std::pair<int, int>, std::pair<double, double> >& cellPos,
251 std::pair<int, int> uv = std::make_pair(-1, -1);
252 std::map<std::pair<int, int>, std::pair<double, double> >::const_iterator itr;
253 for (itr = cellPos.begin(); itr != cellPos.end(); ++itr) {
254 double delX =
std::abs(xloc - (itr->second).first);
255 double delY =
std::abs(yloc - (itr->second).second);
256 if ((delX < cellX) && (delY < cellY)) {
257 if ((delX < (0.5 * cellX)) || (delY < (2.0 * cellY -
sqrt3_ * delX))) {
263 if ((uv.first < 0) && extend) {
264 for (itr = cellPos.begin(); itr != cellPos.end(); ++itr) {
265 double delX =
std::abs(xloc - (itr->second).first);
266 double delY =
std::abs(yloc - (itr->second).second);
267 if ((delX < cellXTotal) && (delY < cellYTotal)) {
268 if ((delX < (0.5 * cellXTotal)) || (delY < (2.0 * cellYTotal -
sqrt3_ * delX))) {
276 edm::LogVerbatim(
"HGCalGeom") <<
"cellUVFromXY4: Input " << xloc <<
":" << yloc <<
":" << extend <<
" Output " 277 << uv.first <<
":" << uv.second;
302 double xprime = -1 * (xloc1 * fcos[
rot] - yloc * fsin[
rot]);
303 double yprime = xloc1 * fsin[
rot] + yloc * fcos[
rot];
304 double xcell = -1 * (1.5 * (
v - u) + 0.5) * cellX;
305 double ycell = (
v + u - 2 *
ncell_[
type] + 1) * cellY;
306 if ((yprime -
sqrt3_ * xprime) > (ycell -
sqrt3_ * xcell)) {
323 double xprime = -1 * (xloc1 * fcos[
rot] - yloc * fsin[
rot]);
324 double yprime = xloc1 * fsin[
rot] + yloc * fcos[
rot];
325 double xcell = -1 * (1.5 * (
v - u) + 0.5) * cellX;
326 double ycell = (
v + u - 2 *
ncell_[
type] + 1) * cellY;
327 if ((yprime -
sqrt3_ * xprime) > (ycell -
sqrt3_ * xcell)) {
336 edm::LogVerbatim(
"HGCalGeom") <<
"cellUVFromXY5: Input " << xloc <<
":" << yloc <<
":" << extend <<
" Output " << u
338 return std::make_pair(u,
v);
355 if (u == 1 &&
v == 8) {
356 std::array<double, 4> criterion =
358 if ((criterion[0] * yloc) + (criterion[1] * xloc) < -criterion[2]) {
363 if (u == 15 &&
v == 15) {
364 std::array<double, 4> criterion =
366 if ((criterion[0] * yloc) + (criterion[1] * xloc) < -criterion[2]) {
371 std::array<double, 4> criterion =
373 if ((criterion[0] * yloc) + (criterion[1] * xloc) < -criterion[2]) {
374 std::pair<double, double> xy1 =
hgcalcell_->cellUV2XY1(u,
v, placement, 1);
375 std::pair<double, double> xy2 =
hgcalcell_->cellUV2XY1(u - 2,
v - 1, placement, 1);
377 ((((xloc - xy1.first) / (xy2.first - xy1.first)) - ((yloc - xy1.second) / (xy2.second - xy1.second))) >
380 ((((xloc - xy1.first) / (xy2.first - xy1.first)) - ((yloc - xy1.second) / (xy2.second - xy1.second))) <
393 if (u == 10 &&
v == 0) {
394 std::array<double, 4> criterion =
396 if ((criterion[0] * yloc) + (criterion[1] * xloc) < -criterion[2]) {
400 if (u == 10 &&
v == 21) {
401 std::array<double, 4> criterion =
403 if ((criterion[0] * yloc) + (criterion[1] * xloc) < -criterion[2]) {
410 std::array<double, 4> criterion =
412 if ((criterion[0] * yloc) + (criterion[1] * xloc) < -criterion[2]) {
413 std::pair<double, double> xy1 =
hgcalcell_->cellUV2XY1(u,
v, placement, 0);
414 std::pair<double, double> xy2 =
hgcalcell_->cellUV2XY1(u - 2,
v - 1, placement, 0);
416 ((((xloc - xy1.first) / (xy2.first - xy1.first)) - ((yloc - xy1.second) / (xy2.second - xy1.second))) >
419 ((((xloc - xy1.first) / (xy2.first - xy1.first)) - ((yloc - xy1.second) / (xy2.second - xy1.second))) <
430 edm::LogVerbatim(
"HGCalGeom") <<
"cellUVFromXY5: Input " << xloc <<
":" << yloc <<
":" << extend <<
" Output " << u
432 return std::make_pair(u,
v);
static constexpr std::array< int, 3 > edgeWaferHDBottom
Log< level::Info, true > LogVerbatim
constexpr int32_t ceil(float num)
static constexpr std::array< int, 3 > edgeWaferLDTop
std::pair< int32_t, int32_t > cellUVFromXY1(double xloc, double yloc, int32_t placement, int32_t type, bool extend, bool debug) const
static constexpr int32_t WaferLDThree
static constexpr double sqrt3_
std::map< std::pair< int32_t, int32_t >, std::pair< double, double > > cellPosFine_[HGCalCell::cellPlacementTotal]
static constexpr int32_t cellPlacementTotal
static constexpr int32_t WaferFull
static std::array< double, 4 > maskCut(const int &part, const int &place, const double &waferSize, const double &offset, const bool &v17OrLess)
Abs< T >::type abs(const T &t)
static constexpr int32_t WaferHDBottom
static constexpr double cos60_
std::unique_ptr< HGCalCell > hgcalcell_
std::pair< int32_t, int32_t > cellUVFromXY3(double xloc, double yloc, int32_t placement, int32_t type, bool extend, bool debug) const
HGCalCellUV(double waferSize, double separation, int32_t nFine, int32_t nCoarse)
static constexpr double sin60_
std::map< std::pair< int32_t, int32_t >, std::pair< double, double > > cellPosCoarse_[HGCalCell::cellPlacementTotal]
static constexpr int32_t WaferLDTop
static constexpr int32_t WaferHDTop
std::pair< int32_t, int32_t > cellUVFromXY4(double xloc, double yloc, int32_t placement, int32_t type, bool extend, bool debug)
std::pair< int32_t, int32_t > cellUVFromXY2(double xloc, double yloc, int32_t placement, int32_t type, bool extend, bool debug) const
static constexpr int32_t cellPlacementExtra