Skip to content

Commit

Permalink
Code check and format
Browse files Browse the repository at this point in the history
  • Loading branch information
Sunanda committed Nov 30, 2023
1 parent fc5cb9a commit f4294f0
Show file tree
Hide file tree
Showing 6 changed files with 191 additions and 118 deletions.
10 changes: 8 additions & 2 deletions Geometry/HGCalCommonData/interface/HGCalCellUV.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,14 @@ class HGCalCellUV {
std::pair<int32_t, int32_t> cellUVFromXY2(
double xloc, double yloc, int32_t placement, int32_t type, bool extend, bool debug) const;

std::pair<int32_t, int32_t> cellUVFromXY2( // for v18
double xloc, double yloc, int32_t placement, int32_t type, int32_t partial, bool extend, bool debug) const;
std::pair<int32_t, int32_t> cellUVFromXY2( // for v18
double xloc,
double yloc,
int32_t placement,
int32_t type,
int32_t partial,
bool extend,
bool debug) const;

std::pair<int32_t, int32_t> cellUVFromXY3(
double xloc, double yloc, int32_t placement, int32_t type, bool extend, bool debug) const;
Expand Down
3 changes: 2 additions & 1 deletion Geometry/HGCalCommonData/interface/HGCalWaferMask.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ class HGCalWaferMask {
const double& ypos,
const bool& v17);

static std::array<double, 4> maskCut(const int& part, const int& place, const double& waferSize, const double& offset, const bool& v17OrLess);
static std::array<double, 4> maskCut(
const int& part, const int& place, const double& waferSize, const double& offset, const bool& v17OrLess);

private:
static constexpr double sqrt3_ = 1.732050807568877; // std::sqrt(3.0) in double precision
Expand Down
84 changes: 55 additions & 29 deletions Geometry/HGCalCommonData/src/HGCalCellUV.cc
Original file line number Diff line number Diff line change
Expand Up @@ -278,9 +278,14 @@ std::pair<int, int> HGCalCellUV::cellUVFromXY4(double xloc,
return uv;
}


std::pair<int32_t, int32_t> HGCalCellUV::cellUVFromXY1( // for v17
double xloc, double yloc, int32_t placement, int32_t type, int32_t partial, bool extend, bool debug) const {
double xloc,
double yloc,
int32_t placement,
int32_t type,
int32_t partial,
bool extend,
bool debug) const {
if (type != 0)
type = 1;
double cellX = (extend) ? cellXTotal_[type] : cellX_[type];
Expand Down Expand Up @@ -333,34 +338,47 @@ std::pair<int32_t, int32_t> HGCalCellUV::cellUVFromXY1( // for v17
return std::make_pair(u, v);
}


std::pair<int32_t, int32_t> HGCalCellUV::cellUVFromXY2( // for v18
double xloc, double yloc, int32_t placement, int32_t type, int32_t partial, bool extend, bool debug) const {
std::pair<int32_t, int32_t> HGCalCellUV::cellUVFromXY2( // for v18
double xloc,
double yloc,
int32_t placement,
int32_t type,
int32_t partial,
bool extend,
bool debug) const {
if (type != 0)
type = 1;
std::pair<int, int> uv = HGCalCellUV::cellUVFromXY1(xloc, yloc, placement, type, extend, debug);
int u = uv.first;
int v = uv.second;
if ((partial != HGCalTypes::WaferFull) && (type == 1)) {
if (u == 1 && v == 8){
std::array<double, 4> criterion = HGCalWaferMask::maskCut(HGCalTypes::WaferLDThree, placement, waferSize_, 0.0, 0);
if ((criterion[0]*yloc) + (criterion[1]*xloc) < -criterion[2]){
if (u == 1 && v == 8) {
std::array<double, 4> criterion =
HGCalWaferMask::maskCut(HGCalTypes::WaferLDThree, placement, waferSize_, 0.0, false);
if ((criterion[0] * yloc) + (criterion[1] * xloc) < -criterion[2]) {
++u;
++v;
++v;
}
}
if (u == 15 && v == 15){
std::array<double, 4> criterion = HGCalWaferMask::maskCut(HGCalTypes::WaferLDThree, placement, waferSize_, 0.0, 0);
if ((criterion[0]*yloc) + (criterion[1]*xloc) < -criterion[2]){
if (u == 15 && v == 15) {
std::array<double, 4> criterion =
HGCalWaferMask::maskCut(HGCalTypes::WaferLDThree, placement, waferSize_, 0.0, false);
if ((criterion[0] * yloc) + (criterion[1] * xloc) < -criterion[2]) {
--u;
}
}
if (u * HGCalTypes::edgeWaferLDTop[0] + v * HGCalTypes::edgeWaferLDTop[1] == HGCalTypes::edgeWaferLDTop[2] + 1) {
std::array<double, 4> criterion = HGCalWaferMask::maskCut(HGCalTypes::WaferLDTop, placement, waferSize_, 0.0, 0);
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> criterion =
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))) {
--u;
if ((v - u) >= ncell_[1])
--v;
Expand All @@ -372,26 +390,34 @@ std::pair<int32_t, int32_t> HGCalCellUV::cellUVFromXY2( // for v18
}
}
} else if ((partial != HGCalTypes::WaferFull) && (type == 0)) {
if (u == 10 && v == 0){
std::array<double, 4> criterion = HGCalWaferMask::maskCut(HGCalTypes::WaferHDTop, placement, waferSize_, 0.0, 0);
if ((criterion[0]*yloc) + (criterion[1]*xloc) < -criterion[2]){
if (u == 10 && v == 0) {
std::array<double, 4> criterion =
HGCalWaferMask::maskCut(HGCalTypes::WaferHDTop, placement, waferSize_, 0.0, false);
if ((criterion[0] * yloc) + (criterion[1] * xloc) < -criterion[2]) {
--u;
}
}
if (u == 10 && v == 21){
std::array<double, 4> criterion = HGCalWaferMask::maskCut(HGCalTypes::WaferHDTop, placement, waferSize_, 0.0, 0);
if ((criterion[0]*yloc) + (criterion[1]*xloc) < -criterion[2]){
if (u == 10 && v == 21) {
std::array<double, 4> criterion =
HGCalWaferMask::maskCut(HGCalTypes::WaferHDTop, placement, waferSize_, 0.0, false);
if ((criterion[0] * yloc) + (criterion[1] * xloc) < -criterion[2]) {
--u;
--v;
--v;
}
}
if (u * HGCalTypes::edgeWaferHDBottom[0] + v * HGCalTypes::edgeWaferHDBottom[1] ==
HGCalTypes::edgeWaferHDBottom[2] + 1) {
std::array<double, 4> criterion = HGCalWaferMask::maskCut(HGCalTypes::WaferHDBottom, placement, waferSize_, 0.0, 0);
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> criterion =
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))) {
++u;
++v;
} else {
Expand Down
84 changes: 59 additions & 25 deletions Geometry/HGCalCommonData/src/HGCalWaferMask.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include "Geometry/HGCalCommonData/interface/HGCalCell.h"

#include <algorithm>
#include <array>
#include <array>
#include <sstream>

//#define EDM_ML_DEBUG
Expand Down Expand Up @@ -1970,59 +1970,93 @@ std::vector<std::pair<double, double> > HGCalWaferMask::waferXY(const int& part,
return xy;
}

std::array<double, 4> HGCalWaferMask::maskCut(const int& part, const int& placement, const double& waferSize, const double& offset, const bool& v17OrLess) {
std::array<double, 4> HGCalWaferMask::maskCut(
const int& part, const int& placement, const double& waferSize, const double& offset, const bool& v17OrLess) {
double c22(HGCalTypes::c22), c27(HGCalTypes::c27);
if (v17OrLess) {
c22 = HGCalTypes::c22O;
c27 = HGCalTypes::c27O;
}
double delX = 0.5 * waferSize;
double delY = 2 * delX / sqrt3_;
double tresh = std::abs(offset/ cos_1[placement]);
double tresh = std::abs(offset / cos_1[placement]);
std::array<double, 4> criterion;
switch (part) {
case (HGCalTypes::WaferLDTop): {
criterion[0] = tan_1[placement]; criterion[1] = 1.0; criterion[2] = 0.0; criterion[3] = tresh;
case (HGCalTypes::WaferLDTop): {
criterion[0] = tan_1[placement];
criterion[1] = 1.0;
criterion[2] = 0.0;
criterion[3] = tresh;
break;
}
case (HGCalTypes::WaferLDBottom): {
criterion[0] = -tan_1[placement]; criterion[1] = -1.0; criterion[2] = 0.0; criterion[3] = tresh;
case (HGCalTypes::WaferLDBottom): {
criterion[0] = -tan_1[placement];
criterion[1] = -1.0;
criterion[2] = 0.0;
criterion[3] = tresh;
break;
}
case (HGCalTypes::WaferLDLeft): {
criterion[0] = 1.0; criterion[1] = -tan_1[placement]; criterion[2] = 0.0; criterion[3] = tresh;
case (HGCalTypes::WaferLDLeft): {
criterion[0] = 1.0;
criterion[1] = -tan_1[placement];
criterion[2] = 0.0;
criterion[3] = tresh;
break;
}
case (HGCalTypes::WaferLDRight): {
criterion[0] = -1.0; criterion[1] = tan_1[placement]; criterion[2] = 0.0; criterion[3] = tresh;
case (HGCalTypes::WaferLDRight): {
criterion[0] = -1.0;
criterion[1] = tan_1[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[3] = tresh;
case (HGCalTypes::WaferLDFive): {
criterion[0] = 1;
criterion[1] = -tan_1[placement];
criterion[2] = ((HGCalTypes::c50 * delY) / cos_1[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[3] = tresh;
case (HGCalTypes::WaferLDThree): {
criterion[0] = -1;
criterion[1] = tan_1[placement];
criterion[2] = -((HGCalTypes::c50 * delY) / cos_1[placement]);
criterion[3] = tresh;
break;
}
case (HGCalTypes::WaferHDTop): {
criterion[0] = tan_1[placement]; criterion[1] = 1; criterion[2] = ((c22 * delX) / cos_1[placement]); criterion[3] = tresh;
case (HGCalTypes::WaferHDTop): {
criterion[0] = tan_1[placement];
criterion[1] = 1;
criterion[2] = ((c22 * delX) / cos_1[placement]);
criterion[3] = tresh;
break;
}
case (HGCalTypes::WaferHDBottom): {
criterion[0] = -tan_1[placement]; criterion[1] = -1; criterion[2] = -((c22 * delX) / cos_1[placement]); criterion[3] = tresh;
case (HGCalTypes::WaferHDBottom): {
criterion[0] = -tan_1[placement];
criterion[1] = -1;
criterion[2] = -((c22 * delX) / cos_1[placement]);
criterion[3] = tresh;
break;
}
case (HGCalTypes::WaferHDLeft): {
criterion[0] = 1.0; criterion[1] = -tan_1[placement]; criterion[2] = ((c27 * delY) / cos_1[placement]); criterion[3] = tresh;
case (HGCalTypes::WaferHDLeft): {
criterion[0] = 1.0;
criterion[1] = -tan_1[placement];
criterion[2] = ((c27 * delY) / cos_1[placement]);
criterion[3] = tresh;
break;
}
case (HGCalTypes::WaferHDRight): {
criterion[0] = -1.0; criterion[1] = tan_1[placement]; criterion[2] = -((c27 * delY) / cos_1[placement]); criterion[3] = tresh;
case (HGCalTypes::WaferHDRight): {
criterion[0] = -1.0;
criterion[1] = tan_1[placement];
criterion[2] = -((c27 * delY) / cos_1[placement]);
criterion[3] = tresh;
break;
}
case (HGCalTypes::WaferHDFive): {
criterion[0] = -1.0; criterion[1] = tan_1[placement]; criterion[2] = ((c27 * delY) / cos_1[placement]); criterion[3] = tresh;
case (HGCalTypes::WaferHDFive): {
criterion[0] = -1.0;
criterion[1] = tan_1[placement];
criterion[2] = ((c27 * delY) / cos_1[placement]);
criterion[3] = tresh;
break;
}
}
Expand Down
Loading

0 comments on commit f4294f0

Please sign in to comment.