10 assert(nFine > 0 && nCoarse > 0);
13 for (
int k = 0;
k < 2; ++
k) {
23 for (
int iu = 0; iu < 2 *
ncell_[0]; ++iu) {
33 for (
int iu = 0; iu < 2 *
ncell_[1]; ++iu) {
46 double xloc,
double yloc, int32_t placement, int32_t
type,
bool extend,
bool debug) {
48 double xloc1 = (placement >= 6) ? xloc : -xloc;
49 int rot = placement % 6;
52 double x = xloc1 * fcos[
rot] - yloc * fsin[
rot];
53 double y = xloc1 * fsin[
rot] + yloc * fcos[
rot];
65 int isv = (iu + iw) / 3;
66 int isu = (
iv + iw) / 3;
70 isu = (
iv + iw + 1) / 3;
73 isu = (
iv + iw + 1) / 3;
74 isv = (iu + iw - 1) / 3;
77 isv = (iu + iw - 1) / 3;
80 edm::LogVerbatim(
"HGCalGeom") <<
"cellUVFromXY1: Input " << xloc <<
":" << yloc <<
":" << extend <<
" Output " 82 return std::make_pair(isu, isv);
86 double xloc,
double yloc, int32_t placement, int32_t
type,
bool extend,
bool debug) {
89 double xloc1 = (placement >= 6) ? xloc : -1 * xloc;
90 int rot = placement % 6;
93 double x = xloc1 * fcos[
rot] - yloc * fsin[
rot];
94 double y = xloc1 * fsin[
rot] + yloc * fcos[
rot];
96 int32_t u(-100),
v(-100);
99 double l1 = (
y /
r) + ncell - 1.0;
100 int l2 = std::floor((0.5 *
y + 0.5 *
x /
sqrt3_) /
r + ncell - 4.0 / 3.0);
101 int l3 = std::floor((
x /
sqrt3_) /
r + ncell - 4.0 / 3.0);
102 double l4 = (
y +
sqrt3_ *
x) / (2 *
r) + 2 * ncell - 2;
103 double l5 = (
y -
sqrt3_ *
x) / (2 *
r) - ncell;
104 double u1 = (
y /
r) + ncell + 1.0;
110 for (
int ui = l2 + 1;
ui <
u2;
ui++) {
111 for (
int vi = l3 + 1; vi <
u3; vi++) {
112 int c1 = 2 *
ui - vi;
114 int c5 =
ui - 2 * vi;
115 if ((
c1 <
u1) && (
c1 > l1) && (c4 < u4) && (c4 > l4) && (c5 < u5) && (c5 > l5)) {
124 if (
y < (2 * u -
v - ncell) *
r) {
131 if (
v - u == ncell) {
132 if ((
y +
sqrt3_ *
x) < ((u +
v - 2 * ncell + 1) * 2 *
r)) {
138 if (u == 2 * ncell) {
139 if ((
y -
sqrt3_ *
x) < ((u - 2 *
v + ncell - 1) * 2 *
r)) {
147 edm::LogVerbatim(
"HGCalGeom") <<
"cellUVFromXY2: Input " << xloc <<
":" << yloc <<
":" << extend <<
" Output " << u
149 return std::make_pair(u,
v);
153 double xloc,
double yloc, int32_t placement, int32_t
type,
bool extend,
bool debug) {
156 double xloc1 = (placement >= 6) ? xloc : -xloc;
157 int rot = placement % 6;
160 double xprime = xloc1 * fcos[
rot] - yloc * fsin[
rot];
161 double yprime = xloc1 * fsin[
rot] + yloc * fcos[
rot];
168 double cu = 2 *
x / 3;
169 double cv = -
x / 3 +
y / 2;
170 double cw = -
x / 3 -
y / 2;
172 int iu = std::round(cu);
173 int iv = std::round(
cv);
174 int iw = std::round(cw);
176 if (iu +
iv + iw != 0) {
183 iw = (std::round(cw) == std::floor(cw)) ?
std::ceil(cw) : std::floor(cw);
188 double xcell = (1.5 * (
v - u) + 0.5) *
cellX_[
type];
191 if ((yprime -
sqrt3_ * xprime) < (ycell -
sqrt3_ * xcell)) {
199 if (yprime < ycell) {
206 if ((yprime +
sqrt3_ * xprime) > (ycell +
sqrt3_ * xcell)) {
215 edm::LogVerbatim(
"HGCalGeom") <<
"cellUVFromXY3: Input " << xloc <<
":" << yloc <<
":" << extend <<
" Output " << u
217 return std::make_pair(u,
v);
221 double xloc,
double yloc, int32_t placement, int32_t
type,
bool extend,
bool debug) {
237 std::map<std::pair<int, int>, std::pair<double, double> >& cellPos,
240 std::pair<int, int> uv = std::make_pair(-1, -1);
241 std::map<std::pair<int, int>, std::pair<double, double> >::const_iterator itr;
242 for (itr = cellPos.begin(); itr != cellPos.end(); ++itr) {
243 double delX =
std::abs(xloc - (itr->second).first);
244 double delY =
std::abs(yloc - (itr->second).second);
245 if ((delX < cellX) && (delY < cellY)) {
246 if ((delX < (0.5 * cellX)) || (delY < (2.0 * cellY -
sqrt3_ * delX))) {
252 if ((uv.first < 0) && extend) {
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 < cellXTotal) && (delY < cellYTotal)) {
257 if ((delX < (0.5 * cellXTotal)) || (delY < (2.0 * cellYTotal -
sqrt3_ * delX))) {
265 edm::LogVerbatim(
"HGCalGeom") <<
"cellUVFromXY4: Input " << xloc <<
":" << yloc <<
":" << extend <<
" Output " 266 << uv.first <<
":" << uv.second;
Log< level::Info, true > LogVerbatim
constexpr int32_t ceil(float num)
std::pair< int32_t, int32_t > cellUVFromXY2(double xloc, double yloc, int32_t placement, int32_t type, bool extend, bool debug)
static constexpr double sqrt3_
std::map< std::pair< int32_t, int32_t >, std::pair< double, double > > cellPosFine_[HGCalCell::cellPlacementTotal]
static constexpr int32_t cellPlacementTotal
std::pair< int32_t, int32_t > cellUVFromXY3(double xloc, double yloc, int32_t placement, int32_t type, bool extend, bool debug)
std::pair< int32_t, int32_t > cellUVFromXY1(double xloc, double yloc, int32_t placement, int32_t type, bool extend, bool debug)
Abs< T >::type abs(const T &t)
static constexpr double cos60_
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]
std::pair< int32_t, int32_t > cellUVFromXY4(double xloc, double yloc, int32_t placement, int32_t type, bool extend, bool debug)
static constexpr int32_t cellPlacementExtra