11 assert(nFine > 0 && nCoarse > 0);
14 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;
282 double xloc,
double yloc, int32_t placement, int32_t
type, int32_t partial,
bool extend,
bool debug)
const {
296 double xprime = -1 * (xloc1 * fcos[
rot] - yloc * fsin[
rot]);
297 double yprime = xloc1 * fsin[
rot] + yloc * fcos[
rot];
298 double xcell = -1 * (1.5 * (
v - u) + 0.5) * cellX;
299 double ycell = (
v + u - 2 *
ncell_[
type] + 1) * cellY;
300 if ((yprime -
sqrt3_ * xprime) > (ycell -
sqrt3_ * xcell)) {
317 double xprime = -1 * (xloc1 * fcos[
rot] - yloc * fsin[
rot]);
318 double yprime = xloc1 * fsin[
rot] + yloc * fcos[
rot];
319 double xcell = -1 * (1.5 * (
v - u) + 0.5) * cellX;
320 double ycell = (
v + u - 2 *
ncell_[
type] + 1) * cellY;
321 if ((yprime -
sqrt3_ * xprime) > (ycell -
sqrt3_ * xcell)) {
330 edm::LogVerbatim(
"HGCalGeom") <<
"cellUVFromXY5: Input " << xloc <<
":" << yloc <<
":" << extend <<
" Output " << u
332 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 double sqrt3_
std::map< std::pair< int32_t, int32_t >, std::pair< double, double > > cellPosFine_[HGCalCell::cellPlacementTotal]
static constexpr int32_t cellPlacementTotal
Abs< T >::type abs(const T &t)
static constexpr int32_t WaferHDBottom
static constexpr double cos60_
std::pair< int32_t, int32_t > cellUVFromXY3(double xloc, double yloc, int32_t placement, int32_t type, bool extend, bool debug) const
std::pair< double, double > cellUV2XY1(int32_t u, int32_t v, int32_t placementIndex, int32_t type)
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
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