From 65e8ce5d7d47885106f3e2ab7ef1eaa616d7edbf Mon Sep 17 00:00:00 2001 From: Pruthvi Suryadevara Date: Tue, 28 May 2024 09:14:31 +0200 Subject: [PATCH] correction to cell shapes --- .../interface/HGCalWaferMask.h | 6 +- Geometry/HGCalCommonData/src/HGCalCellUV.cc | 22 +++---- .../HGCalCommonData/src/HGCalWaferMask.cc | 61 +++++++++---------- SimG4CMS/Calo/plugins/HGCalMouseBiteTester.cc | 9 ++- 4 files changed, 47 insertions(+), 51 deletions(-) diff --git a/Geometry/HGCalCommonData/interface/HGCalWaferMask.h b/Geometry/HGCalCommonData/interface/HGCalWaferMask.h index 91225fa908c70..febf606218794 100644 --- a/Geometry/HGCalCommonData/interface/HGCalWaferMask.h +++ b/Geometry/HGCalCommonData/interface/HGCalWaferMask.h @@ -79,9 +79,9 @@ class HGCalWaferMask { static constexpr double tan_60_ = sqrt3_; static constexpr std::array tan_1 = { {-sqrt3_, sqrt3_, 0.0, -sqrt3_, sqrt3_, 0.0, sqrt3_, -sqrt3_, 0.0, sqrt3_, -sqrt3_, 0.0}}; - static constexpr std::array 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 cot_1 = { - {sqrt3_, -sqrt3_, 0.0, sqrt3_, -sqrt3_, 0.0, -sqrt3_, sqrt3_, 0.0, -sqrt3_, sqrt3_, 0.0}}; + static constexpr std::array 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 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 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 diff --git a/Geometry/HGCalCommonData/src/HGCalCellUV.cc b/Geometry/HGCalCommonData/src/HGCalCellUV.cc index 6f10a3b196c5c..6925116580ed3 100644 --- a/Geometry/HGCalCommonData/src/HGCalCellUV.cc +++ b/Geometry/HGCalCommonData/src/HGCalCellUV.cc @@ -372,13 +372,10 @@ std::pair HGCalCellUV::cellUVFromXY2( // for v18 HGCalWaferMask::maskCut(HGCalTypes::WaferLDTop, placement, waferSize_, 0.0, false); if ((criterion[0] * yloc) + (criterion[1] * xloc) < -criterion[2]) { std::pair xy1 = hgcalcell_->cellUV2XY1(u, v, placement, 1); - std::pair 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 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; @@ -411,13 +408,10 @@ std::pair HGCalCellUV::cellUVFromXY2( // for v18 HGCalWaferMask::maskCut(HGCalTypes::WaferHDBottom, placement, waferSize_, 0.0, false); if ((criterion[0] * yloc) + (criterion[1] * xloc) < -criterion[2]) { std::pair xy1 = hgcalcell_->cellUV2XY1(u, v, placement, 0); - std::pair 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 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 { diff --git a/Geometry/HGCalCommonData/src/HGCalWaferMask.cc b/Geometry/HGCalCommonData/src/HGCalWaferMask.cc index 03e8f7f440a55..da5c8ca03313a 100644 --- a/Geometry/HGCalCommonData/src/HGCalWaferMask.cc +++ b/Geometry/HGCalCommonData/src/HGCalWaferMask.cc @@ -7,7 +7,7 @@ #include #include #include - +#include //#define EDM_ML_DEBUG bool HGCalWaferMask::maskCell(int u, int v, int n, int ncor, int fcor, int corners) { @@ -2017,83 +2017,82 @@ std::array HGCalWaferMask::maskCut( std::array 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; } diff --git a/SimG4CMS/Calo/plugins/HGCalMouseBiteTester.cc b/SimG4CMS/Calo/plugins/HGCalMouseBiteTester.cc index 8f5ebbb880090..e0747d5aa415b 100644 --- a/SimG4CMS/Calo/plugins/HGCalMouseBiteTester.cc +++ b/SimG4CMS/Calo/plugins/HGCalMouseBiteTester.cc @@ -107,7 +107,7 @@ void HGCalMouseBiteTester::analyze(const edm::Event& iEvent, const edm::EventSet int frontBack = HGCalTypes::layerFrontBack(layertype); const std::vector 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_); @@ -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(rand()) / RAND_MAX) - r2; double yi = (2 * R2 * static_cast(rand()) / RAND_MAX) - R2; @@ -166,7 +166,6 @@ 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 uv5; if (hgcons_.v17OrLess()) { @@ -174,6 +173,10 @@ void HGCalMouseBiteTester::analyze(const edm::Event& iEvent, const edm::EventSet } 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_)) {