Skip to content

Commit

Permalink
correction to cell shapes
Browse files Browse the repository at this point in the history
  • Loading branch information
Pruthvi-ch committed May 28, 2024
1 parent 1234e95 commit 65e8ce5
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 51 deletions.
6 changes: 3 additions & 3 deletions Geometry/HGCalCommonData/interface/HGCalWaferMask.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ class HGCalWaferMask {
static constexpr double tan_60_ = sqrt3_;
static constexpr std::array<double, 12> tan_1 = {
{-sqrt3_, sqrt3_, 0.0, -sqrt3_, sqrt3_, 0.0, sqrt3_, -sqrt3_, 0.0, sqrt3_, -sqrt3_, 0.0}};
static constexpr std::array<double, 12> cos_1 = {{0.5, -0.5, -1.0, -0.5, 0.5, 1.0, -0.5, 0.5, 1.0, 0.5, -0.5, -1.0}};
static constexpr std::array<double, 12> cot_1 = {
{sqrt3_, -sqrt3_, 0.0, sqrt3_, -sqrt3_, 0.0, -sqrt3_, sqrt3_, 0.0, -sqrt3_, sqrt3_, 0.0}};
static constexpr std::array<double, 12> cos_1 = {{0.5, -0.5, -1.0, -0.5, 0.5, 1.0, 0.5, -0.5, -1.0, -0.5, 0.5, 1.0}};
static constexpr std::array<double, 12> sign_1 = {{1.0, -1.0, -1.0, -1.0, 1.0, 1.0, -1.0, 1.0, 1.0, 1.0, -1.0, -1.0}};
static constexpr std::array<double, 12> sign_2 = {{1.0, -1.0, -1.0, -1.0, 1.0, 1.0, 1.0, -1.0, -1.0, -1.0, 1.0, 1.0}};
};

#endif
22 changes: 8 additions & 14 deletions Geometry/HGCalCommonData/src/HGCalCellUV.cc
Original file line number Diff line number Diff line change
Expand Up @@ -372,13 +372,10 @@ std::pair<int32_t, int32_t> HGCalCellUV::cellUVFromXY2( // for v18
HGCalWaferMask::maskCut(HGCalTypes::WaferLDTop, placement, waferSize_, 0.0, false);
if ((criterion[0] * yloc) + (criterion[1] * xloc) < -criterion[2]) {
std::pair<double, double> xy1 = hgcalcell_->cellUV2XY1(u, v, placement, 1);
std::pair<double, double> xy2 = hgcalcell_->cellUV2XY1(u - 2, v - 1, placement, 1);
if (((placement >= HGCalCell::cellPlacementExtra) &&
((((xloc - xy1.first) / (xy2.first - xy1.first)) - ((yloc - xy1.second) / (xy2.second - xy1.second))) >
0.0)) ||
((placement < HGCalCell::cellPlacementExtra) &&
((((xloc - xy1.first) / (xy2.first - xy1.first)) - ((yloc - xy1.second) / (xy2.second - xy1.second))) <
0.0))) {
std::array<double, 4> criterion2 =
HGCalWaferMask::maskCut(HGCalTypes::WaferLDThree, placement, waferSize_, 0.0, false);
if (((criterion2[0] * yloc) + (criterion2[1] * xloc) - (criterion2[0] * xy1.second) -
(criterion2[1] * xy1.first)) < 0.0) {
--u;
if ((v - u) >= ncell_[1])
--v;
Expand Down Expand Up @@ -411,13 +408,10 @@ std::pair<int32_t, int32_t> HGCalCellUV::cellUVFromXY2( // for v18
HGCalWaferMask::maskCut(HGCalTypes::WaferHDBottom, placement, waferSize_, 0.0, false);
if ((criterion[0] * yloc) + (criterion[1] * xloc) < -criterion[2]) {
std::pair<double, double> xy1 = hgcalcell_->cellUV2XY1(u, v, placement, 0);
std::pair<double, double> xy2 = hgcalcell_->cellUV2XY1(u - 2, v - 1, placement, 0);
if (((placement >= HGCalCell::cellPlacementExtra) &&
((((xloc - xy1.first) / (xy2.first - xy1.first)) - ((yloc - xy1.second) / (xy2.second - xy1.second))) >
0.0)) ||
((placement < HGCalCell::cellPlacementExtra) &&
((((xloc - xy1.first) / (xy2.first - xy1.first)) - ((yloc - xy1.second) / (xy2.second - xy1.second))) <
0.0))) {
std::array<double, 4> criterion2 =
HGCalWaferMask::maskCut(HGCalTypes::WaferHDRight, placement, waferSize_, 0.0, false);
if (((criterion2[0] * yloc) + (criterion2[1] * xloc) - (criterion2[0] * xy1.second) -
(criterion2[1] * xy1.first)) < 0.0) {
++u;
++v;
} else {
Expand Down
61 changes: 30 additions & 31 deletions Geometry/HGCalCommonData/src/HGCalWaferMask.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include <algorithm>
#include <array>
#include <sstream>

#include <iostream>
//#define EDM_ML_DEBUG

bool HGCalWaferMask::maskCell(int u, int v, int n, int ncor, int fcor, int corners) {
Expand Down Expand Up @@ -2017,83 +2017,82 @@ std::array<double, 4> HGCalWaferMask::maskCut(
std::array<double, 4> criterion;
switch (part) {
case (HGCalTypes::WaferLDTop): {
criterion[0] = tan_1[placement];
criterion[1] = 1.0;
criterion[0] = -tan_1[placement] * sign_1[placement];
criterion[1] = 1.0 * sign_1[placement];
criterion[2] = 0.0;
criterion[3] = tresh;
break;
}
case (HGCalTypes::WaferLDBottom): {
criterion[0] = -tan_1[placement];
criterion[1] = -1.0;
criterion[0] = tan_1[placement] * sign_1[placement];
criterion[1] = -1.0 * sign_1[placement];
criterion[2] = 0.0;
criterion[3] = tresh;
break;
}
case (HGCalTypes::WaferLDLeft): {
criterion[0] = 1.0;
criterion[1] = -tan_1[placement];
criterion[0] = 1.0 * sign_2[placement];
criterion[1] = tan_1[placement] * sign_2[placement];
criterion[2] = 0.0;
criterion[3] = tresh;
break;
}
case (HGCalTypes::WaferLDRight): {
criterion[0] = -1.0;
criterion[1] = tan_1[placement];
criterion[0] = -1.0 * sign_2[placement];
criterion[1] = -tan_1[placement] * sign_2[placement];
criterion[2] = 0.0;
criterion[3] = tresh;
break;
}
case (HGCalTypes::WaferLDFive): {
criterion[0] = 1;
criterion[1] = -tan_1[placement];
criterion[2] = ((HGCalTypes::c50 * delY) / cos_1[placement]);
criterion[0] = 1 * sign_2[placement];
criterion[1] = tan_1[placement] * sign_2[placement];
criterion[2] = -((HGCalTypes::c50 * delY) / cos_1[placement]) * sign_2[placement];
criterion[3] = tresh;
break;
}
case (HGCalTypes::WaferLDThree): {
criterion[0] = -1;
criterion[1] = tan_1[placement];
criterion[2] = -((HGCalTypes::c50 * delY) / cos_1[placement]);
criterion[0] = -1 * sign_2[placement];
criterion[1] = -tan_1[placement] * sign_2[placement];
criterion[2] = ((HGCalTypes::c50 * delY) / cos_1[placement]) * sign_2[placement];
criterion[3] = tresh;
break;
}
case (HGCalTypes::WaferHDTop): {
criterion[0] = tan_1[placement];
criterion[1] = 1;
criterion[2] = ((c22 * delX) / cos_1[placement]);
criterion[0] = -tan_1[placement] * sign_1[placement];
criterion[1] = 1 * sign_1[placement];
criterion[2] = ((c22 * delX) / cos_1[placement]) * sign_2[placement];
criterion[3] = tresh;
break;
}
case (HGCalTypes::WaferHDBottom): {
criterion[0] = -tan_1[placement];
criterion[1] = -1;
criterion[2] = -((c22 * delX) / cos_1[placement]);
criterion[0] = tan_1[placement] * sign_1[placement];
criterion[1] = -1 * sign_1[placement];
criterion[2] = -((c22 * delX) / cos_1[placement]) * sign_2[placement];
criterion[3] = tresh;
break;
}
case (HGCalTypes::WaferHDLeft): {
criterion[0] = 1.0;
criterion[1] = -tan_1[placement];
criterion[2] = ((c271 * delY) / cos_1[placement]);
criterion[0] = 1.0 * sign_2[placement];
criterion[1] = tan_1[placement] * sign_2[placement];
criterion[2] = ((c271 * delY) / cos_1[placement]) * sign_2[placement];
criterion[3] = tresh;
break;
}
case (HGCalTypes::WaferHDRight): {
criterion[0] = -1.0;
criterion[1] = tan_1[placement];
criterion[2] = -((c271 * delY) / cos_1[placement]);
criterion[0] = -1.0 * sign_2[placement];
criterion[1] = -tan_1[placement] * sign_2[placement];
criterion[2] = ((c271 * delY) / cos_1[placement]) * sign_2[placement];
criterion[3] = tresh;
break;
}
case (HGCalTypes::WaferHDFive): {
criterion[0] = -1.0;
criterion[1] = tan_1[placement];
criterion[2] = ((c271 * delY) / cos_1[placement]);
criterion[0] = 1.0 * sign_2[placement];
criterion[1] = tan_1[placement] * sign_2[placement];
criterion[2] = -((c271 * delY) / cos_1[placement]) * sign_2[placement];
criterion[3] = tresh;
break;
}
}
criterion[1] = (placement > HGCalCell::cellPlacementExtra) ? criterion[1] : -criterion[1];
return criterion;
}
9 changes: 6 additions & 3 deletions SimG4CMS/Calo/plugins/HGCalMouseBiteTester.cc
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ void HGCalMouseBiteTester::analyze(const edm::Event& iEvent, const edm::EventSet
int frontBack = HGCalTypes::layerFrontBack(layertype);
const std::vector<double> angle_{90.0, 30.0};
int index = HGCalWaferIndex::waferIndex(layer_, waferU_, waferV_);
int partialType_ = 0;
int partialType_ = HGCalWaferType::getPartial(index, hgcons_.getParameter()->waferInfoMap_);
int orient = HGCalWaferType::getOrient(index, hgcons_.getParameter()->waferInfoMap_);
int placeIndex_ = HGCalCell::cellPlacementIndex(zside, frontBack, orient);
int waferType_ = HGCalWaferType::getType(index, hgcons_.getParameter()->waferInfoMap_);
Expand Down Expand Up @@ -135,7 +135,7 @@ void HGCalMouseBiteTester::analyze(const edm::Event& iEvent, const edm::EventSet
<< " WaferType " << waferType_ << " Partial " << partialType_ << " WaferX " << x0
<< " WaferY " << y0 << "\n\n";
auto start_t = std::chrono::high_resolution_clock::now();

std::cout << "v17 ? " << hgcons_.v17OrLess() << std::endl;
for (int i = 0; i < nTrials_; i++) {
double xi = (2 * r2 * static_cast<double>(rand()) / RAND_MAX) - r2;
double yi = (2 * R2 * static_cast<double>(rand()) / RAND_MAX) - R2;
Expand Down Expand Up @@ -166,14 +166,17 @@ void HGCalMouseBiteTester::analyze(const edm::Event& iEvent, const edm::EventSet
}
}
if (goodPoint) { //Only allowing (x, y) inside a partial wafer 11, placement index 2
partialType_ = HGCalWaferType::getPartial(index, hgcons_.getParameter()->waferInfoMap_);
G4ThreeVector point(xi, yi, 0.0);
std::pair<int32_t, int32_t> uv5;
if (hgcons_.v17OrLess()) {
uv5 = wafer.cellUVFromXY1(xi, yi, placeIndex_, waferType_, partialType_, true, false);
} else {
uv5 = wafer.cellUVFromXY2(xi, yi, placeIndex_, waferType_, partialType_, true, false);
}
if (guardRing_.exclude(point, zside, frontBack, layer_, waferU_, waferV_)) {
guard_ring << xi << "," << yi << std::endl;
}

if (guardRingPartial_.exclude(point, zside, frontBack, layer_, waferU_, waferV_)) {
guard_ring_partial << xi << "," << yi << std::endl;
} else if (mouseBite_.exclude(point, zside, layer_, waferU_, waferV_)) {
Expand Down

0 comments on commit 65e8ce5

Please sign in to comment.