8 const std::vector<double>& rad200,
9 double waferSize,
double zMin,
int choice,
10 unsigned int cornerCut,
double cutArea)
13 waferSize_(waferSize),
17 cutFracArea_(cutArea) {
22 <<
"HGCalWaferType: initialized with waferR's " << waferSize_ <<
":" 25 <<
":" <<
rad200_.size() <<
" parameters for R:";
38 yc[0] = ypos + 0.5 *
R_;
42 yc[2] = ypos + 0.5 *
R_;
44 yc[3] = ypos - 0.5 *
R_;
48 yc[5] = ypos - 0.5 *
R_;
49 std::pair<double, double> rv =
rLimits(zpos);
50 std::vector<int> fine, coarse;
55 else if (rpos <= rv.second)
56 coarse.emplace_back(k);
70 else if (coarse.size() >= 4 && fine.size() <= 1)
72 else if (coarse.size() < 2 && fine.empty())
74 else if (!fine.empty())
77 unsigned int kmax = (type == -1) ? fine.size() : coarse.size();
78 std::vector<double> xcn, ycn;
79 for (
unsigned int k = 0;
k < kmax; ++
k) {
80 unsigned int k1 = (type == -1) ? fine[
k] : coarse[
k];
81 unsigned int k2 = (k1 == xc.size() - 1) ? 0 : k1 + 1;
82 bool ok = ((type == -1)
83 ? (
std::find(fine.begin(), fine.end(), k2) != fine.end())
84 : (
std::find(coarse.begin(), coarse.end(), k2) !=
86 xcn.emplace_back(xc[k1]);
87 ycn.emplace_back(yc[k1]);
89 double rr = (type == -1) ? rv.first : rv.second;
90 std::pair<double, double>
xy =
92 xcn.emplace_back(
xy.first);
93 ycn.emplace_back(
xy.second);
102 <<
"HGCalWaferType: position " << xpos <<
":" << ypos <<
":" << zpos
104 <<
":" << rv.first <<
":" << rv.second <<
" corners|type " << fine.size()
105 <<
":" << coarse.size() <<
":" << fracArea <<
":" <<
type;
116 for (
int i = 1;
i < 5; ++
i) {
127 std::vector<double>
const&
y) {
131 for (
int i = 0;
i <
n; ++
i) {
132 area += ((x[j] + x[
i]) * (y[
i] - y[j]));
139 int k1,
int k2, std::vector<double>
const&
x, std::vector<double>
const&
y,
140 double xpos,
double ypos,
double rr) {
141 double slope = (x[k1] - x[k2]) / (y[k1] - y[k2]);
142 double interc = x[k1] - slope * y[k1];
143 double xx[2],
yy[2], dist[2];
144 double v1 =
std::sqrt((slope * slope + 1) * rr * rr - (interc * interc));
145 yy[0] = (-slope * interc + v1) / (1 + slope * slope);
146 yy[1] = (-slope * interc - v1) / (1 + slope * slope);
147 for (
int i = 0;
i < 2; ++
i) {
148 xx[
i] = (slope * yy[
i] + interc);
150 ((xx[
i] - xpos) * (xx[
i] - xpos)) + ((yy[
i] - ypos) * (yy[
i] - ypos));
152 if (dist[0] > dist[1])
153 return std::pair<double, double>(xx[1], yy[1]);
155 return std::pair<double, double>(xx[0], yy[0]);
const std::vector< double > rad200_
const unsigned int cutValue_
const double cutFracArea_
static const double slope[3]
std::pair< double, double > rLimits(double zpos)
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
int getType(double xpos, double ypos, double zpos)
double areaPolygon(std::vector< double > const &, std::vector< double > const &)
std::pair< double, double > intersection(int, int, std::vector< double > const &, std::vector< double > const &, double xp, double yp, double rr)
static double k_ScaleFromDDD
const std::vector< double > rad100_
Abs< T >::type abs(const T &t)
HGCalWaferType(const std::vector< double > &rad100, const std::vector< double > &rad200, double waferSize, double zMin, int choice, unsigned int cutValue, double cutFracArea)
static uint32_t k_CornerSize
static double k_ScaleToDDD