From 84786d77d438868461617af03e38843e2a53fc3d Mon Sep 17 00:00:00 2001 From: Sunanda Date: Mon, 17 Jan 2022 15:38:54 +0100 Subject: [PATCH 01/11] Add first algo to get x,y of cell from u,v in rotated wafers --- .../interface/HGCalGeometryMode.h | 1 + .../HGCalCommonData/interface/HGCalWafer.h | 44 +++++ .../HGCalCommonData/src/HGCalGeometryMode.cc | 1 + Geometry/HGCalCommonData/src/HGCalWafer.cc | 183 ++++++++++++++++++ 4 files changed, 229 insertions(+) create mode 100644 Geometry/HGCalCommonData/interface/HGCalWafer.h create mode 100644 Geometry/HGCalCommonData/src/HGCalWafer.cc diff --git a/Geometry/HGCalCommonData/interface/HGCalGeometryMode.h b/Geometry/HGCalCommonData/interface/HGCalGeometryMode.h index 07fae409aa0de..01469070fe4c6 100644 --- a/Geometry/HGCalCommonData/interface/HGCalGeometryMode.h +++ b/Geometry/HGCalCommonData/interface/HGCalGeometryMode.h @@ -33,6 +33,7 @@ namespace HGCalGeometryMode { TrapezoidFile = 7, Hexagon8Module = 8, TrapezoidModule = 9, + Hexagon8ModuleOrient = 10, }; enum WaferMode { Polyhedra = 0, ExtrudedPolygon = 1 }; } // namespace HGCalGeometryMode diff --git a/Geometry/HGCalCommonData/interface/HGCalWafer.h b/Geometry/HGCalCommonData/interface/HGCalWafer.h new file mode 100644 index 0000000000000..bbe988723e66b --- /dev/null +++ b/Geometry/HGCalCommonData/interface/HGCalWafer.h @@ -0,0 +1,44 @@ +#ifndef Geometry_HGCalCommonData_HGCalWafer_h +#define Geometry_HGCalCommonData_HGCalWafer_h + +#include +#include + +class HGCalWafer { +public: + HGCalWafer(double waferSize, int32_t nFine, int32_t nCoarse); + + static constexpr int32_t WaferOrient0 = 0; + static constexpr int32_t WaferOrient1 = 1; + static constexpr int32_t WaferOrient2 = 2; + static constexpr int32_t WaferOrient3 = 3; + static constexpr int32_t WaferOrient4 = 4; + static constexpr int32_t WaferOrient5 = 5; + + static constexpr int32_t WaferPlacementIndex0 = 0; + static constexpr int32_t WaferPlacementIndex1 = 1; + static constexpr int32_t WaferPlacementIndex2 = 2; + static constexpr int32_t WaferPlacementIndex3 = 3; + static constexpr int32_t WaferPlacementIndex4 = 4; + static constexpr int32_t WaferPlacementIndex5 = 5; + static constexpr int32_t WaferPlacementIndex6 = 6; + static constexpr int32_t WaferPlacementIndex7 = 7; + static constexpr int32_t WaferPlacementIndex8 = 8; + static constexpr int32_t WaferPlacementIndex9 = 9; + static constexpr int32_t WaferPlacementIndex10 = 10; + static constexpr int32_t WaferPlacementIndex11 = 11; + + static constexpr int32_t WaferPlacementExtra = 6; + static constexpr int32_t WaferPlacementOld = 7; + + std::pair HGCalWaferUV2XY(int32_t u, int32_t v, int32_t placementIndex, int32_t type); + int32_t HGCalWaferUV2Cell(int32_t u, int32_t v, int32_t placementIndex, int32_t type); + static int32_t HGCalWaferPlacementIndex(int32_t iz, int32_t fwdBack, int32_t orient); + +private: + const double factor_; + int32_t N_[2]; + double R_[2], r_[2]; +}; + +#endif diff --git a/Geometry/HGCalCommonData/src/HGCalGeometryMode.cc b/Geometry/HGCalCommonData/src/HGCalGeometryMode.cc index 84af1dce96222..f9ef5a04642e3 100644 --- a/Geometry/HGCalCommonData/src/HGCalGeometryMode.cc +++ b/Geometry/HGCalCommonData/src/HGCalGeometryMode.cc @@ -12,6 +12,7 @@ HGCalStringToEnumParser::HGCalStringToEnumParse enumMap["HGCalGeometryMode::TrapezoidFile"] = HGCalGeometryMode::TrapezoidFile; enumMap["HGCalGeometryMode::Hexagon8Module"] = HGCalGeometryMode::Hexagon8Module; enumMap["HGCalGeometryMode::TrapezoidModule"] = HGCalGeometryMode::TrapezoidModule; + enumMap["HGCalGeometryMode::Hexagon8ModuleOrient"] = HGCalGeometryMode::Hexagon8ModuleOrient; } template <> diff --git a/Geometry/HGCalCommonData/src/HGCalWafer.cc b/Geometry/HGCalCommonData/src/HGCalWafer.cc new file mode 100644 index 0000000000000..f61f252f1492b --- /dev/null +++ b/Geometry/HGCalCommonData/src/HGCalWafer.cc @@ -0,0 +1,183 @@ +#include "Geometry/HGCalCommonData/interface/HGCalWafer.h" +#include + +HGCalWafer::HGCalWafer(double waferSize, int32_t nFine, int32_t nCoarse) : factor_(0.5 * std::sqrt(3.0)) { + N_[0] = nFine; + N_[1] = nCoarse; + for (int k = 0; k < 2; ++k) { + R_[k] = waferSize / (3 * N_[k]); + r_[k] = factor_ * R_[k]; + } +} + +std::pair HGCalWafer::HGCalWaferUV2XY(int32_t u, int32_t v, int32_t placementIndex, int32_t type) { + if (type != 0) + type = 1; + double x(0), y(0); + switch (placementIndex) { + case (HGCalWafer::WaferPlacementIndex6): + x = (1.5 * (v - u) + 0.5) * R_[type]; + y = (v + u - 2 * N_[type] + 1) * r_[type]; + break; + case (HGCalWafer::WaferPlacementIndex7): + x = (1.5 * (v - N_[type]) + 1.0) * R_[type]; + y = (2 * u - v - N_[type]) * r_[type]; + break; + case (HGCalWafer::WaferPlacementIndex8): + x = (1.5 * (u - N_[type]) + 0.5) * R_[type]; + y =-(2 * v - u - N_[type] + 1) * r_[type]; + break; + case (HGCalWafer::WaferPlacementIndex9): + x =-(1.5 * (v - u) + 0.5) * R_[type]; + y =-(v + u - 2 * N_[type] + 1) * r_[type]; + break; + case (HGCalWafer::WaferPlacementIndex10): + x =-(1.5 * (v - N_[type]) + 1) * R_[type]; + y =-(2 * u - v - N_[type]) * r_[type]; + break; + case (HGCalWafer::WaferPlacementIndex11): + x =-(1.5 * (u - N_[type]) + 0.5) * R_[type]; + y = (2 * v - u - N_[type] + 1) * r_[type]; + break; + case (HGCalWafer::WaferPlacementIndex0): + x = (1.5 * (u - v) + 0.5) * R_[type]; + y = (v + u - 2 * N_[type] + 1) * r_[type]; + break; + case (HGCalWafer::WaferPlacementIndex1): + x = (1.5 * (v - N_[type]) + 0.5) * R_[type]; + y =-(2 * v - u - N_[type] + 1) * r_[type]; + break; + case (HGCalWafer::WaferPlacementIndex2): + x =-(1.5 * (u - N_[type]) + 1) * R_[type]; + y =-(2 * v - u - N_[type]) * r_[type]; + break; + case (HGCalWafer::WaferPlacementIndex3): + x =-(1.5 * (u - v) + 0.5) * R_[type]; + y =-(v + u - 2 * N_[type] + 1) * r_[type]; + break; + case (HGCalWafer::WaferPlacementIndex4): + x = (1.5 * (u - N_[type]) + 0.5) * R_[type]; + y =-(2 * u - v - N_[type] + 1) * r_[type]; + break; + default: + x = (1.5 * (u - N_[type]) + 1) * R_[type]; + y = (2 * v - u - N_[type]) * r_[type]; + break; + } + return std::make_pair(x, y); +} + +int HGCalWafer::HGCalWaferUV2Cell(int32_t u, int32_t v, int32_t placementIndex, int32_t type) { + if (type != 0) + type = 1; + int cell(0), cellx(0); + if (placementIndex < HGCalWafer::WaferPlacementExtra) { + const std::vector itype0 = {0, 6, 7, 8, 9, 10, 11, 3, 4, 5, 3, 4, 5}; + const std::vector itype1 = {0, 0, 1, 2, 3, 4, 5, 0, 1, 2, 0, 1, 2}; + const std::vector itype2 = {0, 10, 11, 6, 7, 8, 9, 5, 3, 4, 5, 3, 4}; + const std::vector itype3 = {0, 4, 5, 0, 1, 2, 3, 2, 0, 1, 2, 0, 1}; + const std::vector itype4 = {0, 8, 9, 10, 11, 6, 7, 4, 5, 3, 4, 5, 3}; + const std::vector itype5 = {0, 2, 3, 4, 5, 0, 1, 1, 2, 0, 1, 2, 0}; + if (u == 0 && v == 0) + cellx = 1; + else if (u == 0 && (v - u) == (2 * N_[type] - 1)) + cellx = 2; + else if ((v - u) == (N_[type] - 1) && v == (2 * N_[type] - 1)) + cellx = 2; + else if (u == (2 * N_[type] - 1) && v == (2 * N_[type] - 1)) + cellx = 3; + else if (u == (2 * N_[type] - 1) && (u - v) == N_[type]) + cellx = 4; + else if ((u - v) == N_[type] && v == 0) + cellx = 5; + else if (u == 0) + cellx = 6; + else if ((v - u) == (N_[type] - 1)) + cellx = 7; + else if (v == (2 * N_[type] - 1)) + cellx = 8; + else if (u == (2 * N_[type] - 1)) + cellx = 9; + else if ((u - v) == N_[type]) + cellx = 10; + else if (v == 0) + cellx = 11; + switch (placementIndex) { + case (HGCalWafer::WaferPlacementIndex6): + cell = itype0[cellx]; + break; + case (HGCalWafer::WaferPlacementIndex7): + cell = itype1[cellx]; + break; + case (HGCalWafer::WaferPlacementIndex8): + cell = itype2[cellx]; + break; + case (HGCalWafer::WaferPlacementIndex9): + cell = itype3[cellx]; + break; + case (HGCalWafer::WaferPlacementIndex10): + cell = itype4[cellx]; + break; + default: + cell = itype5[cellx]; + break; + } + } else { + const std::vector itype0 = {0, 1, 2, 3, 4, 5, 0, 1, 2, 0, 0, 1, 2}; + const std::vector itype1 = {0, 7, 8, 9, 10, 11, 6, 4, 5, 3, 3, 4, 5}; + const std::vector itype2 = {0, 3, 4, 5, 0, 1, 2, 2, 0, 1, 1, 2, 0}; + const std::vector itype3 = {0, 9, 10, 11, 6, 7, 8, 5, 3, 4, 4, 5, 3}; + const std::vector itype4 = {0, 5, 0, 1, 2, 3, 4, 0, 1, 2, 2, 0, 1}; + const std::vector itype5 = {0, 11, 6, 7, 8, 9, 10, 3, 4, 5, 3, 4, 5}; + if (u == 0 && v == 0) + cellx = 1; + else if (v == 0 && (u - v) == (N_[type] - 1)) + cellx = 2; + else if ((u - v) == (N_[type] - 1) && u == (2 * N_[type] - 1)) + cellx = 2; + else if (u == (2 * N_[type] - 1) && v == (2 * N_[type] - 1)) + cellx = 3; + else if (v == (2 * N_[type] - 1) && (v - u) == N_[type]) + cellx = 4; + else if ((v - u) == N_[type] && u == 0) + cellx = 5; + else if (v == 0) + cellx = 6; + else if ((u - v) == (N_[type] - 1)) + cellx = 7; + else if (u == (2 * N_[type] - 1)) + cellx = 8; + else if (v == (2 * N_[type] - 1)) + cellx = 9; + else if ((v - u) == N_[type]) + cellx = 10; + else if (u == 0) + cellx = 11; + switch (placementIndex) { + case (HGCalWafer::WaferPlacementIndex0): + cell = itype0[cellx]; + break; + case (HGCalWafer::WaferPlacementIndex1): + cell = itype1[cellx]; + break; + case (HGCalWafer::WaferPlacementIndex2): + cell = itype2[cellx]; + break; + case (HGCalWafer::WaferPlacementIndex3): + cell = itype3[cellx]; + break; + case (HGCalWafer::WaferPlacementIndex4): + cell = itype4[cellx]; + break; + default: + cell = itype5[cellx]; + break; + } + } + return cell; +} + +int HGCalWafer::HGCalWaferPlacementIndex(int32_t iz, int32_t fwdBack, int32_t orient) { + int32_t indx = ((iz * fwdBack) > 0) ? orient : (orient + HGCalWafer::WaferPlacementExtra); + return indx; +} From efad9fca3de52651737acd4d07919a2e37652cbe Mon Sep 17 00:00:00 2001 From: Sunanda Date: Mon, 17 Jan 2022 15:47:46 +0100 Subject: [PATCH 02/11] Code check --- .../HGCalCommonData/interface/HGCalWafer.h | 4 +- Geometry/HGCalCommonData/src/HGCalWafer.cc | 178 +++++++++--------- 2 files changed, 91 insertions(+), 91 deletions(-) diff --git a/Geometry/HGCalCommonData/interface/HGCalWafer.h b/Geometry/HGCalCommonData/interface/HGCalWafer.h index bbe988723e66b..98704fff1b825 100644 --- a/Geometry/HGCalCommonData/interface/HGCalWafer.h +++ b/Geometry/HGCalCommonData/interface/HGCalWafer.h @@ -31,9 +31,9 @@ class HGCalWafer { static constexpr int32_t WaferPlacementExtra = 6; static constexpr int32_t WaferPlacementOld = 7; - std::pair HGCalWaferUV2XY(int32_t u, int32_t v, int32_t placementIndex, int32_t type); + std::pair HGCalWaferUV2XY(int32_t u, int32_t v, int32_t placementIndex, int32_t type); int32_t HGCalWaferUV2Cell(int32_t u, int32_t v, int32_t placementIndex, int32_t type); - static int32_t HGCalWaferPlacementIndex(int32_t iz, int32_t fwdBack, int32_t orient); + static int32_t HGCalWaferPlacementIndex(int32_t iz, int32_t fwdBack, int32_t orient); private: const double factor_; diff --git a/Geometry/HGCalCommonData/src/HGCalWafer.cc b/Geometry/HGCalCommonData/src/HGCalWafer.cc index f61f252f1492b..6c95bb9fc6b16 100644 --- a/Geometry/HGCalCommonData/src/HGCalWafer.cc +++ b/Geometry/HGCalCommonData/src/HGCalWafer.cc @@ -5,64 +5,64 @@ HGCalWafer::HGCalWafer(double waferSize, int32_t nFine, int32_t nCoarse) : facto N_[0] = nFine; N_[1] = nCoarse; for (int k = 0; k < 2; ++k) { - R_[k] = waferSize / (3 * N_[k]); + R_[k] = waferSize / (3 * N_[k]); r_[k] = factor_ * R_[k]; } } -std::pair HGCalWafer::HGCalWaferUV2XY(int32_t u, int32_t v, int32_t placementIndex, int32_t type) { +std::pair HGCalWafer::HGCalWaferUV2XY(int32_t u, int32_t v, int32_t placementIndex, int32_t type) { if (type != 0) type = 1; double x(0), y(0); switch (placementIndex) { - case (HGCalWafer::WaferPlacementIndex6): - x = (1.5 * (v - u) + 0.5) * R_[type]; - y = (v + u - 2 * N_[type] + 1) * r_[type]; - break; - case (HGCalWafer::WaferPlacementIndex7): - x = (1.5 * (v - N_[type]) + 1.0) * R_[type]; - y = (2 * u - v - N_[type]) * r_[type]; - break; - case (HGCalWafer::WaferPlacementIndex8): - x = (1.5 * (u - N_[type]) + 0.5) * R_[type]; - y =-(2 * v - u - N_[type] + 1) * r_[type]; - break; - case (HGCalWafer::WaferPlacementIndex9): - x =-(1.5 * (v - u) + 0.5) * R_[type]; - y =-(v + u - 2 * N_[type] + 1) * r_[type]; - break; - case (HGCalWafer::WaferPlacementIndex10): - x =-(1.5 * (v - N_[type]) + 1) * R_[type]; - y =-(2 * u - v - N_[type]) * r_[type]; - break; - case (HGCalWafer::WaferPlacementIndex11): - x =-(1.5 * (u - N_[type]) + 0.5) * R_[type]; - y = (2 * v - u - N_[type] + 1) * r_[type]; - break; - case (HGCalWafer::WaferPlacementIndex0): - x = (1.5 * (u - v) + 0.5) * R_[type]; - y = (v + u - 2 * N_[type] + 1) * r_[type]; - break; - case (HGCalWafer::WaferPlacementIndex1): - x = (1.5 * (v - N_[type]) + 0.5) * R_[type]; - y =-(2 * v - u - N_[type] + 1) * r_[type]; - break; - case (HGCalWafer::WaferPlacementIndex2): - x =-(1.5 * (u - N_[type]) + 1) * R_[type]; - y =-(2 * v - u - N_[type]) * r_[type]; - break; - case (HGCalWafer::WaferPlacementIndex3): - x =-(1.5 * (u - v) + 0.5) * R_[type]; - y =-(v + u - 2 * N_[type] + 1) * r_[type]; - break; - case (HGCalWafer::WaferPlacementIndex4): - x = (1.5 * (u - N_[type]) + 0.5) * R_[type]; - y =-(2 * u - v - N_[type] + 1) * r_[type]; - break; - default: - x = (1.5 * (u - N_[type]) + 1) * R_[type]; - y = (2 * v - u - N_[type]) * r_[type]; - break; + case (HGCalWafer::WaferPlacementIndex6): + x = (1.5 * (v - u) + 0.5) * R_[type]; + y = (v + u - 2 * N_[type] + 1) * r_[type]; + break; + case (HGCalWafer::WaferPlacementIndex7): + x = (1.5 * (v - N_[type]) + 1.0) * R_[type]; + y = (2 * u - v - N_[type]) * r_[type]; + break; + case (HGCalWafer::WaferPlacementIndex8): + x = (1.5 * (u - N_[type]) + 0.5) * R_[type]; + y = -(2 * v - u - N_[type] + 1) * r_[type]; + break; + case (HGCalWafer::WaferPlacementIndex9): + x = -(1.5 * (v - u) + 0.5) * R_[type]; + y = -(v + u - 2 * N_[type] + 1) * r_[type]; + break; + case (HGCalWafer::WaferPlacementIndex10): + x = -(1.5 * (v - N_[type]) + 1) * R_[type]; + y = -(2 * u - v - N_[type]) * r_[type]; + break; + case (HGCalWafer::WaferPlacementIndex11): + x = -(1.5 * (u - N_[type]) + 0.5) * R_[type]; + y = (2 * v - u - N_[type] + 1) * r_[type]; + break; + case (HGCalWafer::WaferPlacementIndex0): + x = (1.5 * (u - v) + 0.5) * R_[type]; + y = (v + u - 2 * N_[type] + 1) * r_[type]; + break; + case (HGCalWafer::WaferPlacementIndex1): + x = (1.5 * (v - N_[type]) + 0.5) * R_[type]; + y = -(2 * v - u - N_[type] + 1) * r_[type]; + break; + case (HGCalWafer::WaferPlacementIndex2): + x = -(1.5 * (u - N_[type]) + 1) * R_[type]; + y = -(2 * v - u - N_[type]) * r_[type]; + break; + case (HGCalWafer::WaferPlacementIndex3): + x = -(1.5 * (u - v) + 0.5) * R_[type]; + y = -(v + u - 2 * N_[type] + 1) * r_[type]; + break; + case (HGCalWafer::WaferPlacementIndex4): + x = (1.5 * (u - N_[type]) + 0.5) * R_[type]; + y = -(2 * u - v - N_[type] + 1) * r_[type]; + break; + default: + x = (1.5 * (u - N_[type]) + 1) * R_[type]; + y = (2 * v - u - N_[type]) * r_[type]; + break; } return std::make_pair(x, y); } @@ -78,7 +78,7 @@ int HGCalWafer::HGCalWaferUV2Cell(int32_t u, int32_t v, int32_t placementIndex, const std::vector itype3 = {0, 4, 5, 0, 1, 2, 3, 2, 0, 1, 2, 0, 1}; const std::vector itype4 = {0, 8, 9, 10, 11, 6, 7, 4, 5, 3, 4, 5, 3}; const std::vector itype5 = {0, 2, 3, 4, 5, 0, 1, 1, 2, 0, 1, 2, 0}; - if (u == 0 && v == 0) + if (u == 0 && v == 0) cellx = 1; else if (u == 0 && (v - u) == (2 * N_[type] - 1)) cellx = 2; @@ -103,24 +103,24 @@ int HGCalWafer::HGCalWaferUV2Cell(int32_t u, int32_t v, int32_t placementIndex, else if (v == 0) cellx = 11; switch (placementIndex) { - case (HGCalWafer::WaferPlacementIndex6): - cell = itype0[cellx]; - break; - case (HGCalWafer::WaferPlacementIndex7): - cell = itype1[cellx]; - break; - case (HGCalWafer::WaferPlacementIndex8): - cell = itype2[cellx]; - break; - case (HGCalWafer::WaferPlacementIndex9): - cell = itype3[cellx]; - break; - case (HGCalWafer::WaferPlacementIndex10): - cell = itype4[cellx]; - break; - default: - cell = itype5[cellx]; - break; + case (HGCalWafer::WaferPlacementIndex6): + cell = itype0[cellx]; + break; + case (HGCalWafer::WaferPlacementIndex7): + cell = itype1[cellx]; + break; + case (HGCalWafer::WaferPlacementIndex8): + cell = itype2[cellx]; + break; + case (HGCalWafer::WaferPlacementIndex9): + cell = itype3[cellx]; + break; + case (HGCalWafer::WaferPlacementIndex10): + cell = itype4[cellx]; + break; + default: + cell = itype5[cellx]; + break; } } else { const std::vector itype0 = {0, 1, 2, 3, 4, 5, 0, 1, 2, 0, 0, 1, 2}; @@ -129,7 +129,7 @@ int HGCalWafer::HGCalWaferUV2Cell(int32_t u, int32_t v, int32_t placementIndex, const std::vector itype3 = {0, 9, 10, 11, 6, 7, 8, 5, 3, 4, 4, 5, 3}; const std::vector itype4 = {0, 5, 0, 1, 2, 3, 4, 0, 1, 2, 2, 0, 1}; const std::vector itype5 = {0, 11, 6, 7, 8, 9, 10, 3, 4, 5, 3, 4, 5}; - if (u == 0 && v == 0) + if (u == 0 && v == 0) cellx = 1; else if (v == 0 && (u - v) == (N_[type] - 1)) cellx = 2; @@ -154,30 +154,30 @@ int HGCalWafer::HGCalWaferUV2Cell(int32_t u, int32_t v, int32_t placementIndex, else if (u == 0) cellx = 11; switch (placementIndex) { - case (HGCalWafer::WaferPlacementIndex0): - cell = itype0[cellx]; - break; - case (HGCalWafer::WaferPlacementIndex1): - cell = itype1[cellx]; - break; - case (HGCalWafer::WaferPlacementIndex2): - cell = itype2[cellx]; - break; - case (HGCalWafer::WaferPlacementIndex3): - cell = itype3[cellx]; - break; - case (HGCalWafer::WaferPlacementIndex4): - cell = itype4[cellx]; - break; - default: - cell = itype5[cellx]; - break; + case (HGCalWafer::WaferPlacementIndex0): + cell = itype0[cellx]; + break; + case (HGCalWafer::WaferPlacementIndex1): + cell = itype1[cellx]; + break; + case (HGCalWafer::WaferPlacementIndex2): + cell = itype2[cellx]; + break; + case (HGCalWafer::WaferPlacementIndex3): + cell = itype3[cellx]; + break; + case (HGCalWafer::WaferPlacementIndex4): + cell = itype4[cellx]; + break; + default: + cell = itype5[cellx]; + break; } } return cell; } -int HGCalWafer::HGCalWaferPlacementIndex(int32_t iz, int32_t fwdBack, int32_t orient) { +int HGCalWafer::HGCalWaferPlacementIndex(int32_t iz, int32_t fwdBack, int32_t orient) { int32_t indx = ((iz * fwdBack) > 0) ? orient : (orient + HGCalWafer::WaferPlacementExtra); return indx; } From d870a36f21ee3f474e379c4b472c8c99e7fa1000 Mon Sep 17 00:00:00 2001 From: Sunanda Date: Wed, 19 Jan 2022 22:43:12 +0100 Subject: [PATCH 03/11] Add a second method for converting u,v to x,y --- .../HGCalCommonData/interface/HGCalWafer.h | 5 +- Geometry/HGCalCommonData/src/HGCalWafer.cc | 28 ++++- .../test/HGCalCellPositionTester.cc | 102 ++++++++++++++++++ .../python/testHGCalCellPositionTester_cfg.py | 37 +++++++ 4 files changed, 167 insertions(+), 5 deletions(-) create mode 100644 Geometry/HGCalCommonData/test/HGCalCellPositionTester.cc create mode 100644 Geometry/HGCalCommonData/test/python/testHGCalCellPositionTester_cfg.py diff --git a/Geometry/HGCalCommonData/interface/HGCalWafer.h b/Geometry/HGCalCommonData/interface/HGCalWafer.h index 98704fff1b825..3b02862708ca7 100644 --- a/Geometry/HGCalCommonData/interface/HGCalWafer.h +++ b/Geometry/HGCalCommonData/interface/HGCalWafer.h @@ -31,12 +31,13 @@ class HGCalWafer { static constexpr int32_t WaferPlacementExtra = 6; static constexpr int32_t WaferPlacementOld = 7; - std::pair HGCalWaferUV2XY(int32_t u, int32_t v, int32_t placementIndex, int32_t type); + std::pair HGCalWaferUV2XY1(int32_t u, int32_t v, int32_t placementIndex, int32_t type); + std::pair HGCalWaferUV2XY2(int32_t u, int32_t v, int32_t placementIndex, int32_t type); int32_t HGCalWaferUV2Cell(int32_t u, int32_t v, int32_t placementIndex, int32_t type); static int32_t HGCalWaferPlacementIndex(int32_t iz, int32_t fwdBack, int32_t orient); private: - const double factor_; + static constexpr double sqrt3By2_ = (0.5 * std::sqrt(3.0)); int32_t N_[2]; double R_[2], r_[2]; }; diff --git a/Geometry/HGCalCommonData/src/HGCalWafer.cc b/Geometry/HGCalCommonData/src/HGCalWafer.cc index 6c95bb9fc6b16..4f86f6f1e26d4 100644 --- a/Geometry/HGCalCommonData/src/HGCalWafer.cc +++ b/Geometry/HGCalCommonData/src/HGCalWafer.cc @@ -1,16 +1,16 @@ #include "Geometry/HGCalCommonData/interface/HGCalWafer.h" #include -HGCalWafer::HGCalWafer(double waferSize, int32_t nFine, int32_t nCoarse) : factor_(0.5 * std::sqrt(3.0)) { +HGCalWafer::HGCalWafer(double waferSize, int32_t nFine, int32_t nCoarse) { N_[0] = nFine; N_[1] = nCoarse; for (int k = 0; k < 2; ++k) { R_[k] = waferSize / (3 * N_[k]); - r_[k] = factor_ * R_[k]; + r_[k] = sqrt3By2_ * R_[k]; } } -std::pair HGCalWafer::HGCalWaferUV2XY(int32_t u, int32_t v, int32_t placementIndex, int32_t type) { +std::pair HGCalWafer::HGCalWaferUV2XY1(int32_t u, int32_t v, int32_t placementIndex, int32_t type) { if (type != 0) type = 1; double x(0), y(0); @@ -67,6 +67,28 @@ std::pair HGCalWafer::HGCalWaferUV2XY(int32_t u, int32_t v, int3 return std::make_pair(x, y); } +std::pair HGCalWafer::HGCalWaferUV2XY2(int32_t u, int32_t v, int32_t placementIndex, int32_t type) { + if (type != 0) + type = 1; + double x(0), y(0); + if (placementIndex < HGCalWafer::WaferPlacementExtra) { + double x0 = (1.5 * (u - v) - 0.5) * R_[type]; + double y0 = (u + v - 2 * N_[type] + 1) * r_[type]; + const std::vector fac1 = {1.0, 0.5, -0.5, -1.0, -0.5, 0.5}; + const std::vector fac2 = {0.0, sqrt3By2_, sqrt3By2_, 0.0, -sqrt3By2_, -sqrt3By2_}; + x = x0 * fac1[placementIndex] - y0 * fac2[placementIndex]; + y = x0 * fac2[placementIndex] + y0 * fac1[placementIndex]; + } else { + double x0 = (1.5 * (v - N_[type]) + 1.0) * R_[type]; + double y0 = (2 * u - v - N_[type]) * r_[type]; + const std::vector fac1 = {0.5, 1.0, 0.5, -0.5, -1.0, -0.5}; + const std::vector fac2 = {sqrt3By2_, 0.0, -sqrt3By2_, -sqrt3By2_, 0.0, sqrt3By2_}; + x = x0 * fac1[placementIndex - HGCalWafer::WaferPlacementExtra] - y0 * fac2[placementIndex - HGCalWafer::WaferPlacementExtra]; + y = x0 * fac2[placementIndex - HGCalWafer::WaferPlacementExtra] + y0 * fac1[placementIndex - HGCalWafer::WaferPlacementExtra]; + } + return std::make_pair(x, y); +} + int HGCalWafer::HGCalWaferUV2Cell(int32_t u, int32_t v, int32_t placementIndex, int32_t type) { if (type != 0) type = 1; diff --git a/Geometry/HGCalCommonData/test/HGCalCellPositionTester.cc b/Geometry/HGCalCommonData/test/HGCalCellPositionTester.cc new file mode 100644 index 0000000000000..28208399d0909 --- /dev/null +++ b/Geometry/HGCalCommonData/test/HGCalCellPositionTester.cc @@ -0,0 +1,102 @@ +// -*- C++ -*- +// +// Package: HGCalCellPositionTester +// Class: HGCalCellPositionTester +// +/**\class HGCalCellPositionTester HGCalCellPositionTester.cc + test/HGCalCellPositionTester.cc + + Description: + + Implementation: + +*/ +// +// Original Author: Sunanda Banerjee +// Created: Mon 2022/01/15 +// +// + +// system include files +#include +#include +#include +#include +#include + +// user include files +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/one/EDAnalyzer.h" + +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/EventSetup.h" +#include "FWCore/Framework/interface/MakerMacros.h" + +#include "FWCore/MessageLogger/interface/MessageLogger.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h" +#include "Geometry/HGCalCommonData/interface/HGCalWafer.h" + +class HGCalCellPositionTester : public edm::one::EDAnalyzer<> { +public: + explicit HGCalCellPositionTester(const edm::ParameterSet&); + ~HGCalCellPositionTester() override {} + static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); + + void beginJob() override {} + void analyze(edm::Event const& iEvent, edm::EventSetup const&) override; + void endJob() override {} + +private: + const double waferSize_; + const int waferType_; + const int placeIndex_; +}; + +HGCalCellPositionTester::HGCalCellPositionTester(const edm::ParameterSet& iC) + : waferSize_(iC.getParameter("WaferSize")), + waferType_(iC.getParameter("WaferType")), + placeIndex_(iC.getParameter("WaferPlacementIndex")) { + edm::LogVerbatim("HGCalGeom") << "Test positions for wafer of size " << waferSize_ << " Type " << waferType_ << " Placement Index " << placeIndex_; +} + +void HGCalCellPositionTester::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + edm::ParameterSetDescription desc; + desc.add("WaferSize", 166.4408); + desc.add("WaferType", 0); + desc.add("WaferPlacementIndex", 7); + descriptions.add("hgcalCellPositionTester", desc); +} + +// ------------ method called to produce the data ------------ +void HGCalCellPositionTester::analyze(const edm::Event&, const edm::EventSetup&) { + const int nFine(12), nCoarse(8); + const double tol(0.00001); + HGCalWafer wafer(waferSize_, nFine, nCoarse); + int nCells = (waferType_ == 0) ? nFine : nCoarse; + int indexMin = (placeIndex_ >= 0) ? placeIndex_ : 0; + int indexMax = (placeIndex_ >= 0) ? placeIndex_ : 11; + edm::LogVerbatim("HGCalGeom") << "\nHGCalCellPositionTester:: nCells " << nCells << " and placement index between " << indexMin << " and " << indexMax << "\n\n"; + for (int placeIndex = indexMin; placeIndex <= indexMax; ++placeIndex) { + for (int iu = 0; iu < 2 * nCells; ++iu) { + for (int iv = 0; iv < 2 * nCells; ++iv) { + int u(iu), v(iv); + if (placeIndex < HGCalWafer::WaferPlacementExtra) { + u = iv; + v = iu; + } + if (((v - u) < nCells) && ((u - v) <= nCells)) { + std::pair xy1 = wafer.HGCalWaferUV2XY1(u, v, placeIndex, waferType_); + std::pair xy2 = wafer.HGCalWaferUV2XY2(u, v, placeIndex, waferType_); + double dx = xy1.first - xy2.first; + double dy = xy1.second - xy2.second; + std::string comment = ((std::abs(dx) > tol) || (std::abs(dy) > tol)) ? " ***** ERROR *****" : ""; + edm::LogVerbatim("HGCalGeom") << "u = " << u << " v = " << v << " type = " << waferType_ << " placement index " << placeIndex << " x "<< xy1.first << ":" << xy2.first << ":" << dx << " y " << xy1.second << ":" << xy2.second << ":" << dy << comment; + } + } + } + } +} + +// define this as a plug-in +DEFINE_FWK_MODULE(HGCalCellPositionTester); diff --git a/Geometry/HGCalCommonData/test/python/testHGCalCellPositionTester_cfg.py b/Geometry/HGCalCommonData/test/python/testHGCalCellPositionTester_cfg.py new file mode 100644 index 0000000000000..e23a08825fd22 --- /dev/null +++ b/Geometry/HGCalCommonData/test/python/testHGCalCellPositionTester_cfg.py @@ -0,0 +1,37 @@ +import FWCore.ParameterSet.Config as cms + +process = cms.Process("PROD") +process.load("SimGeneral.HepPDTESSource.pdt_cfi") +process.load('FWCore.MessageService.MessageLogger_cfi') + +if hasattr(process,'MessageLogger'): + process.MessageLogger.HGCalGeom=dict() + +process.load("IOMC.RandomEngine.IOMC_cff") +process.RandomNumberGeneratorService.generator.initialSeed = 456789 + +process.source = cms.Source("EmptySource") + +process.generator = cms.EDProducer("FlatRandomEGunProducer", + PGunParameters = cms.PSet( + PartID = cms.vint32(14), + MinEta = cms.double(-3.5), + MaxEta = cms.double(3.5), + MinPhi = cms.double(-3.14159265359), + MaxPhi = cms.double(3.14159265359), + MinE = cms.double(9.99), + MaxE = cms.double(10.01) + ), + AddAntiParticle = cms.bool(False), + Verbosity = cms.untracked.int32(0), + firstRun = cms.untracked.uint32(1) + ) + +process.maxEvents = cms.untracked.PSet( + input = cms.untracked.int32(1) +) + +process.load("Geometry.HGCalCommonData.hgcalCellPositionTester_cfi") + + +process.p1 = cms.Path(process.generator*process.hgcalCellPositionTester) From 9cec684de778ca89cef7b0f7703c9471a4ceab75 Mon Sep 17 00:00:00 2001 From: Sunanda Date: Wed, 19 Jan 2022 23:04:36 +0100 Subject: [PATCH 04/11] Small fix --- Geometry/HGCalCommonData/interface/HGCalWafer.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Geometry/HGCalCommonData/interface/HGCalWafer.h b/Geometry/HGCalCommonData/interface/HGCalWafer.h index 3b02862708ca7..fa45e6c2895e6 100644 --- a/Geometry/HGCalCommonData/interface/HGCalWafer.h +++ b/Geometry/HGCalCommonData/interface/HGCalWafer.h @@ -37,7 +37,7 @@ class HGCalWafer { static int32_t HGCalWaferPlacementIndex(int32_t iz, int32_t fwdBack, int32_t orient); private: - static constexpr double sqrt3By2_ = (0.5 * std::sqrt(3.0)); + const double sqrt3By2_ = (0.5 * std::sqrt(3.0)); int32_t N_[2]; double R_[2], r_[2]; }; From 0fa626d62936df0f17d4f1c9c6ba8f6f587848a7 Mon Sep 17 00:00:00 2001 From: Sunanda Date: Wed, 19 Jan 2022 23:15:09 +0100 Subject: [PATCH 05/11] Code Format --- Geometry/HGCalCommonData/src/HGCalWafer.cc | 6 ++-- .../test/HGCalCellPositionTester.cc | 35 +++++++++++-------- 2 files changed, 24 insertions(+), 17 deletions(-) diff --git a/Geometry/HGCalCommonData/src/HGCalWafer.cc b/Geometry/HGCalCommonData/src/HGCalWafer.cc index 4f86f6f1e26d4..789a0d9e041cd 100644 --- a/Geometry/HGCalCommonData/src/HGCalWafer.cc +++ b/Geometry/HGCalCommonData/src/HGCalWafer.cc @@ -83,8 +83,10 @@ std::pair HGCalWafer::HGCalWaferUV2XY2(int32_t u, int32_t v, int double y0 = (2 * u - v - N_[type]) * r_[type]; const std::vector fac1 = {0.5, 1.0, 0.5, -0.5, -1.0, -0.5}; const std::vector fac2 = {sqrt3By2_, 0.0, -sqrt3By2_, -sqrt3By2_, 0.0, sqrt3By2_}; - x = x0 * fac1[placementIndex - HGCalWafer::WaferPlacementExtra] - y0 * fac2[placementIndex - HGCalWafer::WaferPlacementExtra]; - y = x0 * fac2[placementIndex - HGCalWafer::WaferPlacementExtra] + y0 * fac1[placementIndex - HGCalWafer::WaferPlacementExtra]; + x = x0 * fac1[placementIndex - HGCalWafer::WaferPlacementExtra] - + y0 * fac2[placementIndex - HGCalWafer::WaferPlacementExtra]; + y = x0 * fac2[placementIndex - HGCalWafer::WaferPlacementExtra] + + y0 * fac1[placementIndex - HGCalWafer::WaferPlacementExtra]; } return std::make_pair(x, y); } diff --git a/Geometry/HGCalCommonData/test/HGCalCellPositionTester.cc b/Geometry/HGCalCommonData/test/HGCalCellPositionTester.cc index 28208399d0909..7355c2960360f 100644 --- a/Geometry/HGCalCommonData/test/HGCalCellPositionTester.cc +++ b/Geometry/HGCalCommonData/test/HGCalCellPositionTester.cc @@ -57,7 +57,8 @@ HGCalCellPositionTester::HGCalCellPositionTester(const edm::ParameterSet& iC) : waferSize_(iC.getParameter("WaferSize")), waferType_(iC.getParameter("WaferType")), placeIndex_(iC.getParameter("WaferPlacementIndex")) { - edm::LogVerbatim("HGCalGeom") << "Test positions for wafer of size " << waferSize_ << " Type " << waferType_ << " Placement Index " << placeIndex_; + edm::LogVerbatim("HGCalGeom") << "Test positions for wafer of size " << waferSize_ << " Type " << waferType_ + << " Placement Index " << placeIndex_; } void HGCalCellPositionTester::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { @@ -76,23 +77,27 @@ void HGCalCellPositionTester::analyze(const edm::Event&, const edm::EventSetup&) int nCells = (waferType_ == 0) ? nFine : nCoarse; int indexMin = (placeIndex_ >= 0) ? placeIndex_ : 0; int indexMax = (placeIndex_ >= 0) ? placeIndex_ : 11; - edm::LogVerbatim("HGCalGeom") << "\nHGCalCellPositionTester:: nCells " << nCells << " and placement index between " << indexMin << " and " << indexMax << "\n\n"; + edm::LogVerbatim("HGCalGeom") << "\nHGCalCellPositionTester:: nCells " << nCells << " and placement index between " + << indexMin << " and " << indexMax << "\n\n"; for (int placeIndex = indexMin; placeIndex <= indexMax; ++placeIndex) { for (int iu = 0; iu < 2 * nCells; ++iu) { for (int iv = 0; iv < 2 * nCells; ++iv) { - int u(iu), v(iv); - if (placeIndex < HGCalWafer::WaferPlacementExtra) { - u = iv; - v = iu; - } - if (((v - u) < nCells) && ((u - v) <= nCells)) { - std::pair xy1 = wafer.HGCalWaferUV2XY1(u, v, placeIndex, waferType_); - std::pair xy2 = wafer.HGCalWaferUV2XY2(u, v, placeIndex, waferType_); - double dx = xy1.first - xy2.first; - double dy = xy1.second - xy2.second; - std::string comment = ((std::abs(dx) > tol) || (std::abs(dy) > tol)) ? " ***** ERROR *****" : ""; - edm::LogVerbatim("HGCalGeom") << "u = " << u << " v = " << v << " type = " << waferType_ << " placement index " << placeIndex << " x "<< xy1.first << ":" << xy2.first << ":" << dx << " y " << xy1.second << ":" << xy2.second << ":" << dy << comment; - } + int u(iu), v(iv); + if (placeIndex < HGCalWafer::WaferPlacementExtra) { + u = iv; + v = iu; + } + if (((v - u) < nCells) && ((u - v) <= nCells)) { + std::pair xy1 = wafer.HGCalWaferUV2XY1(u, v, placeIndex, waferType_); + std::pair xy2 = wafer.HGCalWaferUV2XY2(u, v, placeIndex, waferType_); + double dx = xy1.first - xy2.first; + double dy = xy1.second - xy2.second; + std::string comment = ((std::abs(dx) > tol) || (std::abs(dy) > tol)) ? " ***** ERROR *****" : ""; + edm::LogVerbatim("HGCalGeom") << "u = " << u << " v = " << v << " type = " << waferType_ + << " placement index " << placeIndex << " x " << xy1.first << ":" << xy2.first + << ":" << dx << " y " << xy1.second << ":" << xy2.second << ":" << dy + << comment; + } } } } From 0d55ab7a4875ddc163731f47151b40b2413e6b5f Mon Sep 17 00:00:00 2001 From: Sunanda Date: Mon, 24 Jan 2022 21:20:46 +0100 Subject: [PATCH 06/11] Correct the codes in HGCalWafer --- .../HGCalCommonData/interface/HGCalWafer.h | 7 +- Geometry/HGCalCommonData/src/HGCalWafer.cc | 104 ++++++++++-------- 2 files changed, 65 insertions(+), 46 deletions(-) diff --git a/Geometry/HGCalCommonData/interface/HGCalWafer.h b/Geometry/HGCalCommonData/interface/HGCalWafer.h index fa45e6c2895e6..c59d81a07e106 100644 --- a/Geometry/HGCalCommonData/interface/HGCalWafer.h +++ b/Geometry/HGCalCommonData/interface/HGCalWafer.h @@ -30,10 +30,15 @@ class HGCalWafer { static constexpr int32_t WaferPlacementExtra = 6; static constexpr int32_t WaferPlacementOld = 7; + static constexpr int32_t WaferPlacementTotal = 12; + + static constexpr int32_t CornerCell = 0; + static constexpr int32_t TruncatedCell = 1; + static constexpr int32_t ExtendedCell = 2; std::pair HGCalWaferUV2XY1(int32_t u, int32_t v, int32_t placementIndex, int32_t type); std::pair HGCalWaferUV2XY2(int32_t u, int32_t v, int32_t placementIndex, int32_t type); - int32_t HGCalWaferUV2Cell(int32_t u, int32_t v, int32_t placementIndex, int32_t type); + std::pair HGCalWaferUV2Cell(int32_t u, int32_t v, int32_t placementIndex, int32_t type); static int32_t HGCalWaferPlacementIndex(int32_t iz, int32_t fwdBack, int32_t orient); private: diff --git a/Geometry/HGCalCommonData/src/HGCalWafer.cc b/Geometry/HGCalCommonData/src/HGCalWafer.cc index 789a0d9e041cd..01670f1d67dfc 100644 --- a/Geometry/HGCalCommonData/src/HGCalWafer.cc +++ b/Geometry/HGCalCommonData/src/HGCalWafer.cc @@ -40,28 +40,28 @@ std::pair HGCalWafer::HGCalWaferUV2XY1(int32_t u, int32_t v, int y = (2 * v - u - N_[type] + 1) * r_[type]; break; case (HGCalWafer::WaferPlacementIndex0): - x = (1.5 * (u - v) + 0.5) * R_[type]; + x = (1.5 * (u - v) - 0.5) * R_[type]; y = (v + u - 2 * N_[type] + 1) * r_[type]; break; case (HGCalWafer::WaferPlacementIndex1): - x = (1.5 * (v - N_[type]) + 0.5) * R_[type]; - y = -(2 * v - u - N_[type] + 1) * r_[type]; + x = -(1.5 * (v - N_[type]) + 1.0) * R_[type]; + y = (2 * u - v - N_[type]) * r_[type]; break; case (HGCalWafer::WaferPlacementIndex2): - x = -(1.5 * (u - N_[type]) + 1) * R_[type]; - y = -(2 * v - u - N_[type]) * r_[type]; + x = -(1.5 * (u - N_[type]) + 0.5) * R_[type]; + y = -(2 * v - u - N_[type] + 1) * r_[type]; break; case (HGCalWafer::WaferPlacementIndex3): - x = -(1.5 * (u - v) + 0.5) * R_[type]; + x = -(1.5 * (u - v) - 0.5) * R_[type]; y = -(v + u - 2 * N_[type] + 1) * r_[type]; break; case (HGCalWafer::WaferPlacementIndex4): - x = (1.5 * (u - N_[type]) + 0.5) * R_[type]; - y = -(2 * u - v - N_[type] + 1) * r_[type]; + x = (1.5 * (v - N_[type]) + 1) * R_[type]; + y = -(2 * u - v - N_[type]) * r_[type]; break; default: - x = (1.5 * (u - N_[type]) + 1) * R_[type]; - y = (2 * v - u - N_[type]) * r_[type]; + x = (1.5 * (u - N_[type]) + 0.5) * R_[type]; + y = (2 * v - u - N_[type] + 1) * r_[type]; break; } return std::make_pair(x, y); @@ -91,41 +91,48 @@ std::pair HGCalWafer::HGCalWaferUV2XY2(int32_t u, int32_t v, int return std::make_pair(x, y); } -int HGCalWafer::HGCalWaferUV2Cell(int32_t u, int32_t v, int32_t placementIndex, int32_t type) { +std::pair HGCalWafer::HGCalWaferUV2Cell(int32_t u, int32_t v, int32_t placementIndex, int32_t type) { if (type != 0) type = 1; - int cell(0), cellx(0); - if (placementIndex < HGCalWafer::WaferPlacementExtra) { + int cell(0), cellx(0), cellt(HGCalWafer::CornerCell); + if (placementIndex >= HGCalWafer::WaferPlacementExtra) { const std::vector itype0 = {0, 6, 7, 8, 9, 10, 11, 3, 4, 5, 3, 4, 5}; const std::vector itype1 = {0, 0, 1, 2, 3, 4, 5, 0, 1, 2, 0, 1, 2}; const std::vector itype2 = {0, 10, 11, 6, 7, 8, 9, 5, 3, 4, 5, 3, 4}; const std::vector itype3 = {0, 4, 5, 0, 1, 2, 3, 2, 0, 1, 2, 0, 1}; const std::vector itype4 = {0, 8, 9, 10, 11, 6, 7, 4, 5, 3, 4, 5, 3}; const std::vector itype5 = {0, 2, 3, 4, 5, 0, 1, 1, 2, 0, 1, 2, 0}; - if (u == 0 && v == 0) + if (u == 0 && v == 0) { + cellx = 0; + } else if (u == 0 && (v - u) == (N_[type] - 1)) { cellx = 1; - else if (u == 0 && (v - u) == (2 * N_[type] - 1)) + } else if ((v - u) == (N_[type] - 1) && v == (2 * N_[type] - 1)) { cellx = 2; - else if ((v - u) == (N_[type] - 1) && v == (2 * N_[type] - 1)) - cellx = 2; - else if (u == (2 * N_[type] - 1) && v == (2 * N_[type] - 1)) + } else if (u == (2 * N_[type] - 1) && v == (2 * N_[type] - 1)) { cellx = 3; - else if (u == (2 * N_[type] - 1) && (u - v) == N_[type]) + } else if (u == (2 * N_[type] - 1) && (u - v) == N_[type]) { cellx = 4; - else if ((u - v) == N_[type] && v == 0) + } else if ((u - v) == N_[type] && v == 0) { cellx = 5; - else if (u == 0) + } else if (u == 0) { cellx = 6; - else if ((v - u) == (N_[type] - 1)) - cellx = 7; - else if (v == (2 * N_[type] - 1)) - cellx = 8; - else if (u == (2 * N_[type] - 1)) + cellt = HGCalWafer::TruncatedCell; + } else if ((v - u) == (N_[type] - 1)) { cellx = 9; - else if ((u - v) == N_[type]) + cellt = HGCalWafer::ExtendedCell; + } else if (v == (2 * N_[type] - 1)) { + cellx = 7; + cellt = HGCalWafer::TruncatedCell; + } else if (u == (2 * N_[type] - 1)) { cellx = 10; - else if (v == 0) + cellt = HGCalWafer::ExtendedCell; + } else if ((u - v) == N_[type]) { + cellx = 8; + cellt = HGCalWafer::TruncatedCell; + } else if (v == 0) { cellx = 11; + cellt = HGCalWafer::ExtendedCell; + } switch (placementIndex) { case (HGCalWafer::WaferPlacementIndex6): cell = itype0[cellx]; @@ -153,30 +160,37 @@ int HGCalWafer::HGCalWaferUV2Cell(int32_t u, int32_t v, int32_t placementIndex, const std::vector itype3 = {0, 9, 10, 11, 6, 7, 8, 5, 3, 4, 4, 5, 3}; const std::vector itype4 = {0, 5, 0, 1, 2, 3, 4, 0, 1, 2, 2, 0, 1}; const std::vector itype5 = {0, 11, 6, 7, 8, 9, 10, 3, 4, 5, 3, 4, 5}; - if (u == 0 && v == 0) + if (u == 0 && v == 0) { + cellx = 0; + } else if (v == 0 && (u - v) == (N_[type])) { cellx = 1; - else if (v == 0 && (u - v) == (N_[type] - 1)) + } else if ((u - v) == (N_[type]) && u == (2 * N_[type] - 1)) { cellx = 2; - else if ((u - v) == (N_[type] - 1) && u == (2 * N_[type] - 1)) - cellx = 2; - else if (u == (2 * N_[type] - 1) && v == (2 * N_[type] - 1)) + } else if (u == (2 * N_[type] - 1) && v == (2 * N_[type] - 1)) { cellx = 3; - else if (v == (2 * N_[type] - 1) && (v - u) == N_[type]) + } else if (v == (2 * N_[type] - 1) && (v - u) == (N_[type]-1)) { cellx = 4; - else if ((v - u) == N_[type] && u == 0) + } else if ((v - u) == (N_[type]-1) && u == 0) { cellx = 5; - else if (v == 0) - cellx = 6; - else if ((u - v) == (N_[type] - 1)) - cellx = 7; - else if (u == (2 * N_[type] - 1)) - cellx = 8; - else if (v == (2 * N_[type] - 1)) + } else if (v == 0) { cellx = 9; - else if ((v - u) == N_[type]) + cellt = HGCalWafer::ExtendedCell; + } else if ((u - v) == N_[type]) { + cellx = 6; + cellt = HGCalWafer::TruncatedCell; + } else if (u == (2 * N_[type] - 1)) { cellx = 10; - else if (u == 0) + cellt = HGCalWafer::ExtendedCell; + } else if (v == (2 * N_[type] - 1)) { + cellx = 7; + cellt = HGCalWafer::TruncatedCell; + } else if ((v - u) == (N_[type]-1)) { cellx = 11; + cellt = HGCalWafer::ExtendedCell; + } else if (u == 0) { + cellx = 8; + cellt = HGCalWafer::TruncatedCell; + } switch (placementIndex) { case (HGCalWafer::WaferPlacementIndex0): cell = itype0[cellx]; @@ -198,7 +212,7 @@ int HGCalWafer::HGCalWaferUV2Cell(int32_t u, int32_t v, int32_t placementIndex, break; } } - return cell; + return std::make_pair(cell, cellt); } int HGCalWafer::HGCalWaferPlacementIndex(int32_t iz, int32_t fwdBack, int32_t orient) { From c86f0d521a6be3d6571adf8d074bf19e18ecd11e Mon Sep 17 00:00:00 2001 From: Sunanda Date: Mon, 24 Jan 2022 21:29:46 +0100 Subject: [PATCH 07/11] Code format --- Geometry/HGCalCommonData/src/HGCalWafer.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Geometry/HGCalCommonData/src/HGCalWafer.cc b/Geometry/HGCalCommonData/src/HGCalWafer.cc index 01670f1d67dfc..f669212632cb2 100644 --- a/Geometry/HGCalCommonData/src/HGCalWafer.cc +++ b/Geometry/HGCalCommonData/src/HGCalWafer.cc @@ -168,9 +168,9 @@ std::pair HGCalWafer::HGCalWaferUV2Cell(int32_t u, int32_t v, int32_t cellx = 2; } else if (u == (2 * N_[type] - 1) && v == (2 * N_[type] - 1)) { cellx = 3; - } else if (v == (2 * N_[type] - 1) && (v - u) == (N_[type]-1)) { + } else if (v == (2 * N_[type] - 1) && (v - u) == (N_[type] - 1)) { cellx = 4; - } else if ((v - u) == (N_[type]-1) && u == 0) { + } else if ((v - u) == (N_[type] - 1) && u == 0) { cellx = 5; } else if (v == 0) { cellx = 9; @@ -184,7 +184,7 @@ std::pair HGCalWafer::HGCalWaferUV2Cell(int32_t u, int32_t v, int32_t } else if (v == (2 * N_[type] - 1)) { cellx = 7; cellt = HGCalWafer::TruncatedCell; - } else if ((v - u) == (N_[type]-1)) { + } else if ((v - u) == (N_[type] - 1)) { cellx = 11; cellt = HGCalWafer::ExtendedCell; } else if (u == 0) { From 342286ff822972600990a7a89724bad5356a9cb4 Mon Sep 17 00:00:00 2001 From: Sunanda Date: Tue, 25 Jan 2022 13:30:46 +0100 Subject: [PATCH 08/11] Take care of Marco's comments --- Geometry/HGCalCommonData/src/HGCalWafer.cc | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Geometry/HGCalCommonData/src/HGCalWafer.cc b/Geometry/HGCalCommonData/src/HGCalWafer.cc index f669212632cb2..50987a8e305f6 100644 --- a/Geometry/HGCalCommonData/src/HGCalWafer.cc +++ b/Geometry/HGCalCommonData/src/HGCalWafer.cc @@ -74,19 +74,19 @@ std::pair HGCalWafer::HGCalWaferUV2XY2(int32_t u, int32_t v, int if (placementIndex < HGCalWafer::WaferPlacementExtra) { double x0 = (1.5 * (u - v) - 0.5) * R_[type]; double y0 = (u + v - 2 * N_[type] + 1) * r_[type]; - const std::vector fac1 = {1.0, 0.5, -0.5, -1.0, -0.5, 0.5}; - const std::vector fac2 = {0.0, sqrt3By2_, sqrt3By2_, 0.0, -sqrt3By2_, -sqrt3By2_}; - x = x0 * fac1[placementIndex] - y0 * fac2[placementIndex]; - y = x0 * fac2[placementIndex] + y0 * fac1[placementIndex]; + const std::vector fcos = {1.0, 0.5, -0.5, -1.0, -0.5, 0.5}; + const std::vector fsin = {0.0, sqrt3By2_, sqrt3By2_, 0.0, -sqrt3By2_, -sqrt3By2_}; + x = x0 * fcos[placementIndex] - y0 * fsin[placementIndex]; + y = x0 * fsin[placementIndex] + y0 * fcos[placementIndex]; } else { double x0 = (1.5 * (v - N_[type]) + 1.0) * R_[type]; double y0 = (2 * u - v - N_[type]) * r_[type]; - const std::vector fac1 = {0.5, 1.0, 0.5, -0.5, -1.0, -0.5}; - const std::vector fac2 = {sqrt3By2_, 0.0, -sqrt3By2_, -sqrt3By2_, 0.0, sqrt3By2_}; - x = x0 * fac1[placementIndex - HGCalWafer::WaferPlacementExtra] - - y0 * fac2[placementIndex - HGCalWafer::WaferPlacementExtra]; - y = x0 * fac2[placementIndex - HGCalWafer::WaferPlacementExtra] + - y0 * fac1[placementIndex - HGCalWafer::WaferPlacementExtra]; + const std::vector fcos = {0.5, 1.0, 0.5, -0.5, -1.0, -0.5}; + const std::vector fsin = {sqrt3By2_, 0.0, -sqrt3By2_, -sqrt3By2_, 0.0, sqrt3By2_}; + x = x0 * fcos[placementIndex - HGCalWafer::WaferPlacementExtra] - + y0 * fsin[placementIndex - HGCalWafer::WaferPlacementExtra]; + y = x0 * fsin[placementIndex - HGCalWafer::WaferPlacementExtra] + + y0 * fcos[placementIndex - HGCalWafer::WaferPlacementExtra]; } return std::make_pair(x, y); } From 7c0e6d64eb0fc738fdd88fe8e40efdab6cc2ee20 Mon Sep 17 00:00:00 2001 From: Sunanda Date: Tue, 25 Jan 2022 23:22:40 +0100 Subject: [PATCH 09/11] Try to match coding convention --- .../HGCalCommonData/interface/HGCalWafer.h | 58 +++--- Geometry/HGCalCommonData/src/HGCalWafer.cc | 182 +++++++++--------- .../test/HGCalCellPositionTester.cc | 14 +- 3 files changed, 127 insertions(+), 127 deletions(-) diff --git a/Geometry/HGCalCommonData/interface/HGCalWafer.h b/Geometry/HGCalCommonData/interface/HGCalWafer.h index c59d81a07e106..6662f993ccc87 100644 --- a/Geometry/HGCalCommonData/interface/HGCalWafer.h +++ b/Geometry/HGCalCommonData/interface/HGCalWafer.h @@ -8,33 +8,33 @@ class HGCalWafer { public: HGCalWafer(double waferSize, int32_t nFine, int32_t nCoarse); - static constexpr int32_t WaferOrient0 = 0; - static constexpr int32_t WaferOrient1 = 1; - static constexpr int32_t WaferOrient2 = 2; - static constexpr int32_t WaferOrient3 = 3; - static constexpr int32_t WaferOrient4 = 4; - static constexpr int32_t WaferOrient5 = 5; - - static constexpr int32_t WaferPlacementIndex0 = 0; - static constexpr int32_t WaferPlacementIndex1 = 1; - static constexpr int32_t WaferPlacementIndex2 = 2; - static constexpr int32_t WaferPlacementIndex3 = 3; - static constexpr int32_t WaferPlacementIndex4 = 4; - static constexpr int32_t WaferPlacementIndex5 = 5; - static constexpr int32_t WaferPlacementIndex6 = 6; - static constexpr int32_t WaferPlacementIndex7 = 7; - static constexpr int32_t WaferPlacementIndex8 = 8; - static constexpr int32_t WaferPlacementIndex9 = 9; - static constexpr int32_t WaferPlacementIndex10 = 10; - static constexpr int32_t WaferPlacementIndex11 = 11; - - static constexpr int32_t WaferPlacementExtra = 6; - static constexpr int32_t WaferPlacementOld = 7; - static constexpr int32_t WaferPlacementTotal = 12; - - static constexpr int32_t CornerCell = 0; - static constexpr int32_t TruncatedCell = 1; - static constexpr int32_t ExtendedCell = 2; + static constexpr int32_t waferOrient0 = 0; + static constexpr int32_t waferOrient1 = 1; + static constexpr int32_t waferOrient2 = 2; + static constexpr int32_t waferOrient3 = 3; + static constexpr int32_t waferOrient4 = 4; + static constexpr int32_t waferOrient5 = 5; + + static constexpr int32_t waferPlacementIndex0 = 0; + static constexpr int32_t waferPlacementIndex1 = 1; + static constexpr int32_t waferPlacementIndex2 = 2; + static constexpr int32_t waferPlacementIndex3 = 3; + static constexpr int32_t waferPlacementIndex4 = 4; + static constexpr int32_t waferPlacementIndex5 = 5; + static constexpr int32_t waferPlacementIndex6 = 6; + static constexpr int32_t waferPlacementIndex7 = 7; + static constexpr int32_t waferPlacementIndex8 = 8; + static constexpr int32_t waferPlacementIndex9 = 9; + static constexpr int32_t waferPlacementIndex10 = 10; + static constexpr int32_t waferPlacementIndex11 = 11; + + static constexpr int32_t waferPlacementExtra = 6; + static constexpr int32_t waferPlacementOld = 7; + static constexpr int32_t waferPlacementTotal = 12; + + static constexpr int32_t cornerCell = 0; + static constexpr int32_t truncatedCell = 1; + static constexpr int32_t extendedCell = 2; std::pair HGCalWaferUV2XY1(int32_t u, int32_t v, int32_t placementIndex, int32_t type); std::pair HGCalWaferUV2XY2(int32_t u, int32_t v, int32_t placementIndex, int32_t type); @@ -43,8 +43,8 @@ class HGCalWafer { private: const double sqrt3By2_ = (0.5 * std::sqrt(3.0)); - int32_t N_[2]; - double R_[2], r_[2]; + int32_t ncell_[2]; + double cellX_[2], cellY_[2]; }; #endif diff --git a/Geometry/HGCalCommonData/src/HGCalWafer.cc b/Geometry/HGCalCommonData/src/HGCalWafer.cc index 50987a8e305f6..5990d0cd8b90a 100644 --- a/Geometry/HGCalCommonData/src/HGCalWafer.cc +++ b/Geometry/HGCalCommonData/src/HGCalWafer.cc @@ -2,11 +2,11 @@ #include HGCalWafer::HGCalWafer(double waferSize, int32_t nFine, int32_t nCoarse) { - N_[0] = nFine; - N_[1] = nCoarse; + ncell_[0] = nFine; + ncell_[1] = nCoarse; for (int k = 0; k < 2; ++k) { - R_[k] = waferSize / (3 * N_[k]); - r_[k] = sqrt3By2_ * R_[k]; + cellX_[k] = waferSize / (3 * ncell_[k]); + cellY_[k] = sqrt3By2_ * cellX_[k]; } } @@ -15,53 +15,53 @@ std::pair HGCalWafer::HGCalWaferUV2XY1(int32_t u, int32_t v, int type = 1; double x(0), y(0); switch (placementIndex) { - case (HGCalWafer::WaferPlacementIndex6): - x = (1.5 * (v - u) + 0.5) * R_[type]; - y = (v + u - 2 * N_[type] + 1) * r_[type]; + case (HGCalWafer::waferPlacementIndex6): + x = (1.5 * (v - u) + 0.5) * cellX_[type]; + y = (v + u - 2 * ncell_[type] + 1) * cellY_[type]; break; - case (HGCalWafer::WaferPlacementIndex7): - x = (1.5 * (v - N_[type]) + 1.0) * R_[type]; - y = (2 * u - v - N_[type]) * r_[type]; + case (HGCalWafer::waferPlacementIndex7): + x = (1.5 * (v - ncell_[type]) + 1.0) * cellX_[type]; + y = (2 * u - v - ncell_[type]) * cellY_[type]; break; - case (HGCalWafer::WaferPlacementIndex8): - x = (1.5 * (u - N_[type]) + 0.5) * R_[type]; - y = -(2 * v - u - N_[type] + 1) * r_[type]; + case (HGCalWafer::waferPlacementIndex8): + x = (1.5 * (u - ncell_[type]) + 0.5) * cellX_[type]; + y = -(2 * v - u - ncell_[type] + 1) * cellY_[type]; break; - case (HGCalWafer::WaferPlacementIndex9): - x = -(1.5 * (v - u) + 0.5) * R_[type]; - y = -(v + u - 2 * N_[type] + 1) * r_[type]; + case (HGCalWafer::waferPlacementIndex9): + x = -(1.5 * (v - u) + 0.5) * cellX_[type]; + y = -(v + u - 2 * ncell_[type] + 1) * cellY_[type]; break; - case (HGCalWafer::WaferPlacementIndex10): - x = -(1.5 * (v - N_[type]) + 1) * R_[type]; - y = -(2 * u - v - N_[type]) * r_[type]; + case (HGCalWafer::waferPlacementIndex10): + x = -(1.5 * (v - ncell_[type]) + 1) * cellX_[type]; + y = -(2 * u - v - ncell_[type]) * cellY_[type]; break; - case (HGCalWafer::WaferPlacementIndex11): - x = -(1.5 * (u - N_[type]) + 0.5) * R_[type]; - y = (2 * v - u - N_[type] + 1) * r_[type]; + case (HGCalWafer::waferPlacementIndex11): + x = -(1.5 * (u - ncell_[type]) + 0.5) * cellX_[type]; + y = (2 * v - u - ncell_[type] + 1) * cellY_[type]; break; - case (HGCalWafer::WaferPlacementIndex0): - x = (1.5 * (u - v) - 0.5) * R_[type]; - y = (v + u - 2 * N_[type] + 1) * r_[type]; + case (HGCalWafer::waferPlacementIndex0): + x = (1.5 * (u - v) - 0.5) * cellX_[type]; + y = (v + u - 2 * ncell_[type] + 1) * cellY_[type]; break; - case (HGCalWafer::WaferPlacementIndex1): - x = -(1.5 * (v - N_[type]) + 1.0) * R_[type]; - y = (2 * u - v - N_[type]) * r_[type]; + case (HGCalWafer::waferPlacementIndex1): + x = -(1.5 * (v - ncell_[type]) + 1.0) * cellX_[type]; + y = (2 * u - v - ncell_[type]) * cellY_[type]; break; - case (HGCalWafer::WaferPlacementIndex2): - x = -(1.5 * (u - N_[type]) + 0.5) * R_[type]; - y = -(2 * v - u - N_[type] + 1) * r_[type]; + case (HGCalWafer::waferPlacementIndex2): + x = -(1.5 * (u - ncell_[type]) + 0.5) * cellX_[type]; + y = -(2 * v - u - ncell_[type] + 1) * cellY_[type]; break; - case (HGCalWafer::WaferPlacementIndex3): - x = -(1.5 * (u - v) - 0.5) * R_[type]; - y = -(v + u - 2 * N_[type] + 1) * r_[type]; + case (HGCalWafer::waferPlacementIndex3): + x = -(1.5 * (u - v) - 0.5) * cellX_[type]; + y = -(v + u - 2 * ncell_[type] + 1) * cellY_[type]; break; - case (HGCalWafer::WaferPlacementIndex4): - x = (1.5 * (v - N_[type]) + 1) * R_[type]; - y = -(2 * u - v - N_[type]) * r_[type]; + case (HGCalWafer::waferPlacementIndex4): + x = (1.5 * (v - ncell_[type]) + 1) * cellX_[type]; + y = -(2 * u - v - ncell_[type]) * cellY_[type]; break; default: - x = (1.5 * (u - N_[type]) + 0.5) * R_[type]; - y = (2 * v - u - N_[type] + 1) * r_[type]; + x = (1.5 * (u - ncell_[type]) + 0.5) * cellX_[type]; + y = (2 * v - u - ncell_[type] + 1) * cellY_[type]; break; } return std::make_pair(x, y); @@ -71,22 +71,22 @@ std::pair HGCalWafer::HGCalWaferUV2XY2(int32_t u, int32_t v, int if (type != 0) type = 1; double x(0), y(0); - if (placementIndex < HGCalWafer::WaferPlacementExtra) { - double x0 = (1.5 * (u - v) - 0.5) * R_[type]; - double y0 = (u + v - 2 * N_[type] + 1) * r_[type]; + if (placementIndex < HGCalWafer::waferPlacementExtra) { + double x0 = (1.5 * (u - v) - 0.5) * cellX_[type]; + double y0 = (u + v - 2 * ncell_[type] + 1) * cellY_[type]; const std::vector fcos = {1.0, 0.5, -0.5, -1.0, -0.5, 0.5}; const std::vector fsin = {0.0, sqrt3By2_, sqrt3By2_, 0.0, -sqrt3By2_, -sqrt3By2_}; x = x0 * fcos[placementIndex] - y0 * fsin[placementIndex]; y = x0 * fsin[placementIndex] + y0 * fcos[placementIndex]; } else { - double x0 = (1.5 * (v - N_[type]) + 1.0) * R_[type]; - double y0 = (2 * u - v - N_[type]) * r_[type]; + double x0 = (1.5 * (v - ncell_[type]) + 1.0) * cellX_[type]; + double y0 = (2 * u - v - ncell_[type]) * cellY_[type]; const std::vector fcos = {0.5, 1.0, 0.5, -0.5, -1.0, -0.5}; const std::vector fsin = {sqrt3By2_, 0.0, -sqrt3By2_, -sqrt3By2_, 0.0, sqrt3By2_}; - x = x0 * fcos[placementIndex - HGCalWafer::WaferPlacementExtra] - - y0 * fsin[placementIndex - HGCalWafer::WaferPlacementExtra]; - y = x0 * fsin[placementIndex - HGCalWafer::WaferPlacementExtra] + - y0 * fcos[placementIndex - HGCalWafer::WaferPlacementExtra]; + x = x0 * fcos[placementIndex - HGCalWafer::waferPlacementExtra] - + y0 * fsin[placementIndex - HGCalWafer::waferPlacementExtra]; + y = x0 * fsin[placementIndex - HGCalWafer::waferPlacementExtra] + + y0 * fcos[placementIndex - HGCalWafer::waferPlacementExtra]; } return std::make_pair(x, y); } @@ -94,8 +94,8 @@ std::pair HGCalWafer::HGCalWaferUV2XY2(int32_t u, int32_t v, int std::pair HGCalWafer::HGCalWaferUV2Cell(int32_t u, int32_t v, int32_t placementIndex, int32_t type) { if (type != 0) type = 1; - int cell(0), cellx(0), cellt(HGCalWafer::CornerCell); - if (placementIndex >= HGCalWafer::WaferPlacementExtra) { + int cell(0), cellx(0), cellt(HGCalWafer::cornerCell); + if (placementIndex >= HGCalWafer::waferPlacementExtra) { const std::vector itype0 = {0, 6, 7, 8, 9, 10, 11, 3, 4, 5, 3, 4, 5}; const std::vector itype1 = {0, 0, 1, 2, 3, 4, 5, 0, 1, 2, 0, 1, 2}; const std::vector itype2 = {0, 10, 11, 6, 7, 8, 9, 5, 3, 4, 5, 3, 4}; @@ -104,49 +104,49 @@ std::pair HGCalWafer::HGCalWaferUV2Cell(int32_t u, int32_t v, int32_t const std::vector itype5 = {0, 2, 3, 4, 5, 0, 1, 1, 2, 0, 1, 2, 0}; if (u == 0 && v == 0) { cellx = 0; - } else if (u == 0 && (v - u) == (N_[type] - 1)) { + } else if (u == 0 && (v - u) == (ncell_[type] - 1)) { cellx = 1; - } else if ((v - u) == (N_[type] - 1) && v == (2 * N_[type] - 1)) { + } else if ((v - u) == (ncell_[type] - 1) && v == (2 * ncell_[type] - 1)) { cellx = 2; - } else if (u == (2 * N_[type] - 1) && v == (2 * N_[type] - 1)) { + } else if (u == (2 * ncell_[type] - 1) && v == (2 * ncell_[type] - 1)) { cellx = 3; - } else if (u == (2 * N_[type] - 1) && (u - v) == N_[type]) { + } else if (u == (2 * ncell_[type] - 1) && (u - v) == ncell_[type]) { cellx = 4; - } else if ((u - v) == N_[type] && v == 0) { + } else if ((u - v) == ncell_[type] && v == 0) { cellx = 5; } else if (u == 0) { cellx = 6; - cellt = HGCalWafer::TruncatedCell; - } else if ((v - u) == (N_[type] - 1)) { + cellt = HGCalWafer::truncatedCell; + } else if ((v - u) == (ncell_[type] - 1)) { cellx = 9; - cellt = HGCalWafer::ExtendedCell; - } else if (v == (2 * N_[type] - 1)) { + cellt = HGCalWafer::extendedCell; + } else if (v == (2 * ncell_[type] - 1)) { cellx = 7; - cellt = HGCalWafer::TruncatedCell; - } else if (u == (2 * N_[type] - 1)) { + cellt = HGCalWafer::truncatedCell; + } else if (u == (2 * ncell_[type] - 1)) { cellx = 10; - cellt = HGCalWafer::ExtendedCell; - } else if ((u - v) == N_[type]) { + cellt = HGCalWafer::extendedCell; + } else if ((u - v) == ncell_[type]) { cellx = 8; - cellt = HGCalWafer::TruncatedCell; + cellt = HGCalWafer::truncatedCell; } else if (v == 0) { cellx = 11; - cellt = HGCalWafer::ExtendedCell; + cellt = HGCalWafer::extendedCell; } switch (placementIndex) { - case (HGCalWafer::WaferPlacementIndex6): + case (HGCalWafer::waferPlacementIndex6): cell = itype0[cellx]; break; - case (HGCalWafer::WaferPlacementIndex7): + case (HGCalWafer::waferPlacementIndex7): cell = itype1[cellx]; break; - case (HGCalWafer::WaferPlacementIndex8): + case (HGCalWafer::waferPlacementIndex8): cell = itype2[cellx]; break; - case (HGCalWafer::WaferPlacementIndex9): + case (HGCalWafer::waferPlacementIndex9): cell = itype3[cellx]; break; - case (HGCalWafer::WaferPlacementIndex10): + case (HGCalWafer::waferPlacementIndex10): cell = itype4[cellx]; break; default: @@ -162,49 +162,49 @@ std::pair HGCalWafer::HGCalWaferUV2Cell(int32_t u, int32_t v, int32_t const std::vector itype5 = {0, 11, 6, 7, 8, 9, 10, 3, 4, 5, 3, 4, 5}; if (u == 0 && v == 0) { cellx = 0; - } else if (v == 0 && (u - v) == (N_[type])) { + } else if (v == 0 && (u - v) == (ncell_[type])) { cellx = 1; - } else if ((u - v) == (N_[type]) && u == (2 * N_[type] - 1)) { + } else if ((u - v) == (ncell_[type]) && u == (2 * ncell_[type] - 1)) { cellx = 2; - } else if (u == (2 * N_[type] - 1) && v == (2 * N_[type] - 1)) { + } else if (u == (2 * ncell_[type] - 1) && v == (2 * ncell_[type] - 1)) { cellx = 3; - } else if (v == (2 * N_[type] - 1) && (v - u) == (N_[type] - 1)) { + } else if (v == (2 * ncell_[type] - 1) && (v - u) == (ncell_[type] - 1)) { cellx = 4; - } else if ((v - u) == (N_[type] - 1) && u == 0) { + } else if ((v - u) == (ncell_[type] - 1) && u == 0) { cellx = 5; } else if (v == 0) { cellx = 9; - cellt = HGCalWafer::ExtendedCell; - } else if ((u - v) == N_[type]) { + cellt = HGCalWafer::extendedCell; + } else if ((u - v) == ncell_[type]) { cellx = 6; - cellt = HGCalWafer::TruncatedCell; - } else if (u == (2 * N_[type] - 1)) { + cellt = HGCalWafer::truncatedCell; + } else if (u == (2 * ncell_[type] - 1)) { cellx = 10; - cellt = HGCalWafer::ExtendedCell; - } else if (v == (2 * N_[type] - 1)) { + cellt = HGCalWafer::extendedCell; + } else if (v == (2 * ncell_[type] - 1)) { cellx = 7; - cellt = HGCalWafer::TruncatedCell; - } else if ((v - u) == (N_[type] - 1)) { + cellt = HGCalWafer::truncatedCell; + } else if ((v - u) == (ncell_[type] - 1)) { cellx = 11; - cellt = HGCalWafer::ExtendedCell; + cellt = HGCalWafer::extendedCell; } else if (u == 0) { cellx = 8; - cellt = HGCalWafer::TruncatedCell; + cellt = HGCalWafer::truncatedCell; } switch (placementIndex) { - case (HGCalWafer::WaferPlacementIndex0): + case (HGCalWafer::waferPlacementIndex0): cell = itype0[cellx]; break; - case (HGCalWafer::WaferPlacementIndex1): + case (HGCalWafer::waferPlacementIndex1): cell = itype1[cellx]; break; - case (HGCalWafer::WaferPlacementIndex2): + case (HGCalWafer::waferPlacementIndex2): cell = itype2[cellx]; break; - case (HGCalWafer::WaferPlacementIndex3): + case (HGCalWafer::waferPlacementIndex3): cell = itype3[cellx]; break; - case (HGCalWafer::WaferPlacementIndex4): + case (HGCalWafer::waferPlacementIndex4): cell = itype4[cellx]; break; default: @@ -216,6 +216,6 @@ std::pair HGCalWafer::HGCalWaferUV2Cell(int32_t u, int32_t v, int32_t } int HGCalWafer::HGCalWaferPlacementIndex(int32_t iz, int32_t fwdBack, int32_t orient) { - int32_t indx = ((iz * fwdBack) > 0) ? orient : (orient + HGCalWafer::WaferPlacementExtra); + int32_t indx = ((iz * fwdBack) > 0) ? orient : (orient + HGCalWafer::waferPlacementExtra); return indx; } diff --git a/Geometry/HGCalCommonData/test/HGCalCellPositionTester.cc b/Geometry/HGCalCommonData/test/HGCalCellPositionTester.cc index 7355c2960360f..6618eeecbfdcb 100644 --- a/Geometry/HGCalCommonData/test/HGCalCellPositionTester.cc +++ b/Geometry/HGCalCommonData/test/HGCalCellPositionTester.cc @@ -54,18 +54,18 @@ class HGCalCellPositionTester : public edm::one::EDAnalyzer<> { }; HGCalCellPositionTester::HGCalCellPositionTester(const edm::ParameterSet& iC) - : waferSize_(iC.getParameter("WaferSize")), - waferType_(iC.getParameter("WaferType")), - placeIndex_(iC.getParameter("WaferPlacementIndex")) { + : waferSize_(iC.getParameter("waferSize")), + waferType_(iC.getParameter("waferType")), + placeIndex_(iC.getParameter("waferPlacementIndex")) { edm::LogVerbatim("HGCalGeom") << "Test positions for wafer of size " << waferSize_ << " Type " << waferType_ << " Placement Index " << placeIndex_; } void HGCalCellPositionTester::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { edm::ParameterSetDescription desc; - desc.add("WaferSize", 166.4408); - desc.add("WaferType", 0); - desc.add("WaferPlacementIndex", 7); + desc.add("waferSize", 166.4408); + desc.add("waferType", 0); + desc.add("waferPlacementIndex", 7); descriptions.add("hgcalCellPositionTester", desc); } @@ -83,7 +83,7 @@ void HGCalCellPositionTester::analyze(const edm::Event&, const edm::EventSetup&) for (int iu = 0; iu < 2 * nCells; ++iu) { for (int iv = 0; iv < 2 * nCells; ++iv) { int u(iu), v(iv); - if (placeIndex < HGCalWafer::WaferPlacementExtra) { + if (placeIndex < HGCalWafer::waferPlacementExtra) { u = iv; v = iu; } From d8bba85243803b7eaf0f223e54a5d185b0b51ebc Mon Sep 17 00:00:00 2001 From: Sunanda Date: Wed, 26 Jan 2022 00:21:11 +0100 Subject: [PATCH 10/11] Change name from HGCalWafer to HGCalCell to conform with the purpose --- .../HGCalCommonData/interface/HGCalCell.h | 50 ++++++++++ .../HGCalCommonData/interface/HGCalWafer.h | 50 ---------- .../src/{HGCalWafer.cc => HGCalCell.cc} | 94 +++++++++---------- .../test/HGCalCellPositionTester.cc | 14 +-- 4 files changed, 104 insertions(+), 104 deletions(-) create mode 100644 Geometry/HGCalCommonData/interface/HGCalCell.h delete mode 100644 Geometry/HGCalCommonData/interface/HGCalWafer.h rename Geometry/HGCalCommonData/src/{HGCalWafer.cc => HGCalCell.cc} (70%) diff --git a/Geometry/HGCalCommonData/interface/HGCalCell.h b/Geometry/HGCalCommonData/interface/HGCalCell.h new file mode 100644 index 0000000000000..53408be01afd7 --- /dev/null +++ b/Geometry/HGCalCommonData/interface/HGCalCell.h @@ -0,0 +1,50 @@ +#ifndef Geometry_HGCalCommonData_HGCalCell_h +#define Geometry_HGCalCommonData_HGCalCell_h + +#include +#include + +class HGCalCell { +public: + HGCalCell(double waferSize, int32_t nFine, int32_t nCoarse); + + static constexpr int32_t waferOrient0 = 0; + static constexpr int32_t waferOrient1 = 1; + static constexpr int32_t waferOrient2 = 2; + static constexpr int32_t waferOrient3 = 3; + static constexpr int32_t waferOrient4 = 4; + static constexpr int32_t waferOrient5 = 5; + + static constexpr int32_t cellPlacementIndex0 = 0; + static constexpr int32_t cellPlacementIndex1 = 1; + static constexpr int32_t cellPlacementIndex2 = 2; + static constexpr int32_t cellPlacementIndex3 = 3; + static constexpr int32_t cellPlacementIndex4 = 4; + static constexpr int32_t cellPlacementIndex5 = 5; + static constexpr int32_t cellPlacementIndex6 = 6; + static constexpr int32_t cellPlacementIndex7 = 7; + static constexpr int32_t cellPlacementIndex8 = 8; + static constexpr int32_t cellPlacementIndex9 = 9; + static constexpr int32_t cellPlacementIndex10 = 10; + static constexpr int32_t cellPlacementIndex11 = 11; + + static constexpr int32_t cellPlacementExtra = 6; + static constexpr int32_t cellPlacementOld = 7; + static constexpr int32_t cellPlacementTotal = 12; + + static constexpr int32_t cornerCell = 0; + static constexpr int32_t truncatedCell = 1; + static constexpr int32_t extendedCell = 2; + + std::pair HGCalCellUV2XY1(int32_t u, int32_t v, int32_t placementIndex, int32_t type); + std::pair HGCalCellUV2XY2(int32_t u, int32_t v, int32_t placementIndex, int32_t type); + std::pair HGCalCellUV2Cell(int32_t u, int32_t v, int32_t placementIndex, int32_t type); + static int32_t HGCalCellPlacementIndex(int32_t iz, int32_t fwdBack, int32_t orient); + +private: + const double sqrt3By2_ = (0.5 * std::sqrt(3.0)); + int32_t ncell_[2]; + double cellX_[2], cellY_[2]; +}; + +#endif diff --git a/Geometry/HGCalCommonData/interface/HGCalWafer.h b/Geometry/HGCalCommonData/interface/HGCalWafer.h deleted file mode 100644 index 6662f993ccc87..0000000000000 --- a/Geometry/HGCalCommonData/interface/HGCalWafer.h +++ /dev/null @@ -1,50 +0,0 @@ -#ifndef Geometry_HGCalCommonData_HGCalWafer_h -#define Geometry_HGCalCommonData_HGCalWafer_h - -#include -#include - -class HGCalWafer { -public: - HGCalWafer(double waferSize, int32_t nFine, int32_t nCoarse); - - static constexpr int32_t waferOrient0 = 0; - static constexpr int32_t waferOrient1 = 1; - static constexpr int32_t waferOrient2 = 2; - static constexpr int32_t waferOrient3 = 3; - static constexpr int32_t waferOrient4 = 4; - static constexpr int32_t waferOrient5 = 5; - - static constexpr int32_t waferPlacementIndex0 = 0; - static constexpr int32_t waferPlacementIndex1 = 1; - static constexpr int32_t waferPlacementIndex2 = 2; - static constexpr int32_t waferPlacementIndex3 = 3; - static constexpr int32_t waferPlacementIndex4 = 4; - static constexpr int32_t waferPlacementIndex5 = 5; - static constexpr int32_t waferPlacementIndex6 = 6; - static constexpr int32_t waferPlacementIndex7 = 7; - static constexpr int32_t waferPlacementIndex8 = 8; - static constexpr int32_t waferPlacementIndex9 = 9; - static constexpr int32_t waferPlacementIndex10 = 10; - static constexpr int32_t waferPlacementIndex11 = 11; - - static constexpr int32_t waferPlacementExtra = 6; - static constexpr int32_t waferPlacementOld = 7; - static constexpr int32_t waferPlacementTotal = 12; - - static constexpr int32_t cornerCell = 0; - static constexpr int32_t truncatedCell = 1; - static constexpr int32_t extendedCell = 2; - - std::pair HGCalWaferUV2XY1(int32_t u, int32_t v, int32_t placementIndex, int32_t type); - std::pair HGCalWaferUV2XY2(int32_t u, int32_t v, int32_t placementIndex, int32_t type); - std::pair HGCalWaferUV2Cell(int32_t u, int32_t v, int32_t placementIndex, int32_t type); - static int32_t HGCalWaferPlacementIndex(int32_t iz, int32_t fwdBack, int32_t orient); - -private: - const double sqrt3By2_ = (0.5 * std::sqrt(3.0)); - int32_t ncell_[2]; - double cellX_[2], cellY_[2]; -}; - -#endif diff --git a/Geometry/HGCalCommonData/src/HGCalWafer.cc b/Geometry/HGCalCommonData/src/HGCalCell.cc similarity index 70% rename from Geometry/HGCalCommonData/src/HGCalWafer.cc rename to Geometry/HGCalCommonData/src/HGCalCell.cc index 5990d0cd8b90a..3fb621949b599 100644 --- a/Geometry/HGCalCommonData/src/HGCalWafer.cc +++ b/Geometry/HGCalCommonData/src/HGCalCell.cc @@ -1,7 +1,7 @@ -#include "Geometry/HGCalCommonData/interface/HGCalWafer.h" +#include "Geometry/HGCalCommonData/interface/HGCalCell.h" #include -HGCalWafer::HGCalWafer(double waferSize, int32_t nFine, int32_t nCoarse) { +HGCalCell::HGCalCell(double waferSize, int32_t nFine, int32_t nCoarse) { ncell_[0] = nFine; ncell_[1] = nCoarse; for (int k = 0; k < 2; ++k) { @@ -10,52 +10,52 @@ HGCalWafer::HGCalWafer(double waferSize, int32_t nFine, int32_t nCoarse) { } } -std::pair HGCalWafer::HGCalWaferUV2XY1(int32_t u, int32_t v, int32_t placementIndex, int32_t type) { +std::pair HGCalCell::HGCalCellUV2XY1(int32_t u, int32_t v, int32_t placementIndex, int32_t type) { if (type != 0) type = 1; double x(0), y(0); switch (placementIndex) { - case (HGCalWafer::waferPlacementIndex6): + case (HGCalCell::cellPlacementIndex6): x = (1.5 * (v - u) + 0.5) * cellX_[type]; y = (v + u - 2 * ncell_[type] + 1) * cellY_[type]; break; - case (HGCalWafer::waferPlacementIndex7): + case (HGCalCell::cellPlacementIndex7): x = (1.5 * (v - ncell_[type]) + 1.0) * cellX_[type]; y = (2 * u - v - ncell_[type]) * cellY_[type]; break; - case (HGCalWafer::waferPlacementIndex8): + case (HGCalCell::cellPlacementIndex8): x = (1.5 * (u - ncell_[type]) + 0.5) * cellX_[type]; y = -(2 * v - u - ncell_[type] + 1) * cellY_[type]; break; - case (HGCalWafer::waferPlacementIndex9): + case (HGCalCell::cellPlacementIndex9): x = -(1.5 * (v - u) + 0.5) * cellX_[type]; y = -(v + u - 2 * ncell_[type] + 1) * cellY_[type]; break; - case (HGCalWafer::waferPlacementIndex10): + case (HGCalCell::cellPlacementIndex10): x = -(1.5 * (v - ncell_[type]) + 1) * cellX_[type]; y = -(2 * u - v - ncell_[type]) * cellY_[type]; break; - case (HGCalWafer::waferPlacementIndex11): + case (HGCalCell::cellPlacementIndex11): x = -(1.5 * (u - ncell_[type]) + 0.5) * cellX_[type]; y = (2 * v - u - ncell_[type] + 1) * cellY_[type]; break; - case (HGCalWafer::waferPlacementIndex0): + case (HGCalCell::cellPlacementIndex0): x = (1.5 * (u - v) - 0.5) * cellX_[type]; y = (v + u - 2 * ncell_[type] + 1) * cellY_[type]; break; - case (HGCalWafer::waferPlacementIndex1): + case (HGCalCell::cellPlacementIndex1): x = -(1.5 * (v - ncell_[type]) + 1.0) * cellX_[type]; y = (2 * u - v - ncell_[type]) * cellY_[type]; break; - case (HGCalWafer::waferPlacementIndex2): + case (HGCalCell::cellPlacementIndex2): x = -(1.5 * (u - ncell_[type]) + 0.5) * cellX_[type]; y = -(2 * v - u - ncell_[type] + 1) * cellY_[type]; break; - case (HGCalWafer::waferPlacementIndex3): + case (HGCalCell::cellPlacementIndex3): x = -(1.5 * (u - v) - 0.5) * cellX_[type]; y = -(v + u - 2 * ncell_[type] + 1) * cellY_[type]; break; - case (HGCalWafer::waferPlacementIndex4): + case (HGCalCell::cellPlacementIndex4): x = (1.5 * (v - ncell_[type]) + 1) * cellX_[type]; y = -(2 * u - v - ncell_[type]) * cellY_[type]; break; @@ -67,11 +67,11 @@ std::pair HGCalWafer::HGCalWaferUV2XY1(int32_t u, int32_t v, int return std::make_pair(x, y); } -std::pair HGCalWafer::HGCalWaferUV2XY2(int32_t u, int32_t v, int32_t placementIndex, int32_t type) { +std::pair HGCalCell::HGCalCellUV2XY2(int32_t u, int32_t v, int32_t placementIndex, int32_t type) { if (type != 0) type = 1; double x(0), y(0); - if (placementIndex < HGCalWafer::waferPlacementExtra) { + if (placementIndex < HGCalCell::cellPlacementExtra) { double x0 = (1.5 * (u - v) - 0.5) * cellX_[type]; double y0 = (u + v - 2 * ncell_[type] + 1) * cellY_[type]; const std::vector fcos = {1.0, 0.5, -0.5, -1.0, -0.5, 0.5}; @@ -83,19 +83,19 @@ std::pair HGCalWafer::HGCalWaferUV2XY2(int32_t u, int32_t v, int double y0 = (2 * u - v - ncell_[type]) * cellY_[type]; const std::vector fcos = {0.5, 1.0, 0.5, -0.5, -1.0, -0.5}; const std::vector fsin = {sqrt3By2_, 0.0, -sqrt3By2_, -sqrt3By2_, 0.0, sqrt3By2_}; - x = x0 * fcos[placementIndex - HGCalWafer::waferPlacementExtra] - - y0 * fsin[placementIndex - HGCalWafer::waferPlacementExtra]; - y = x0 * fsin[placementIndex - HGCalWafer::waferPlacementExtra] + - y0 * fcos[placementIndex - HGCalWafer::waferPlacementExtra]; + x = x0 * fcos[placementIndex - HGCalCell::cellPlacementExtra] - + y0 * fsin[placementIndex - HGCalCell::cellPlacementExtra]; + y = x0 * fsin[placementIndex - HGCalCell::cellPlacementExtra] + + y0 * fcos[placementIndex - HGCalCell::cellPlacementExtra]; } return std::make_pair(x, y); } -std::pair HGCalWafer::HGCalWaferUV2Cell(int32_t u, int32_t v, int32_t placementIndex, int32_t type) { +std::pair HGCalCell::HGCalCellUV2Cell(int32_t u, int32_t v, int32_t placementIndex, int32_t type) { if (type != 0) type = 1; - int cell(0), cellx(0), cellt(HGCalWafer::cornerCell); - if (placementIndex >= HGCalWafer::waferPlacementExtra) { + int cell(0), cellx(0), cellt(HGCalCell::cornerCell); + if (placementIndex >= HGCalCell::cellPlacementExtra) { const std::vector itype0 = {0, 6, 7, 8, 9, 10, 11, 3, 4, 5, 3, 4, 5}; const std::vector itype1 = {0, 0, 1, 2, 3, 4, 5, 0, 1, 2, 0, 1, 2}; const std::vector itype2 = {0, 10, 11, 6, 7, 8, 9, 5, 3, 4, 5, 3, 4}; @@ -116,37 +116,37 @@ std::pair HGCalWafer::HGCalWaferUV2Cell(int32_t u, int32_t v, int32_t cellx = 5; } else if (u == 0) { cellx = 6; - cellt = HGCalWafer::truncatedCell; + cellt = HGCalCell::truncatedCell; } else if ((v - u) == (ncell_[type] - 1)) { cellx = 9; - cellt = HGCalWafer::extendedCell; + cellt = HGCalCell::extendedCell; } else if (v == (2 * ncell_[type] - 1)) { cellx = 7; - cellt = HGCalWafer::truncatedCell; + cellt = HGCalCell::truncatedCell; } else if (u == (2 * ncell_[type] - 1)) { cellx = 10; - cellt = HGCalWafer::extendedCell; + cellt = HGCalCell::extendedCell; } else if ((u - v) == ncell_[type]) { cellx = 8; - cellt = HGCalWafer::truncatedCell; + cellt = HGCalCell::truncatedCell; } else if (v == 0) { cellx = 11; - cellt = HGCalWafer::extendedCell; + cellt = HGCalCell::extendedCell; } switch (placementIndex) { - case (HGCalWafer::waferPlacementIndex6): + case (HGCalCell::cellPlacementIndex6): cell = itype0[cellx]; break; - case (HGCalWafer::waferPlacementIndex7): + case (HGCalCell::cellPlacementIndex7): cell = itype1[cellx]; break; - case (HGCalWafer::waferPlacementIndex8): + case (HGCalCell::cellPlacementIndex8): cell = itype2[cellx]; break; - case (HGCalWafer::waferPlacementIndex9): + case (HGCalCell::cellPlacementIndex9): cell = itype3[cellx]; break; - case (HGCalWafer::waferPlacementIndex10): + case (HGCalCell::cellPlacementIndex10): cell = itype4[cellx]; break; default: @@ -174,37 +174,37 @@ std::pair HGCalWafer::HGCalWaferUV2Cell(int32_t u, int32_t v, int32_t cellx = 5; } else if (v == 0) { cellx = 9; - cellt = HGCalWafer::extendedCell; + cellt = HGCalCell::extendedCell; } else if ((u - v) == ncell_[type]) { cellx = 6; - cellt = HGCalWafer::truncatedCell; + cellt = HGCalCell::truncatedCell; } else if (u == (2 * ncell_[type] - 1)) { cellx = 10; - cellt = HGCalWafer::extendedCell; + cellt = HGCalCell::extendedCell; } else if (v == (2 * ncell_[type] - 1)) { cellx = 7; - cellt = HGCalWafer::truncatedCell; + cellt = HGCalCell::truncatedCell; } else if ((v - u) == (ncell_[type] - 1)) { cellx = 11; - cellt = HGCalWafer::extendedCell; + cellt = HGCalCell::extendedCell; } else if (u == 0) { cellx = 8; - cellt = HGCalWafer::truncatedCell; + cellt = HGCalCell::truncatedCell; } switch (placementIndex) { - case (HGCalWafer::waferPlacementIndex0): + case (HGCalCell::cellPlacementIndex0): cell = itype0[cellx]; break; - case (HGCalWafer::waferPlacementIndex1): + case (HGCalCell::cellPlacementIndex1): cell = itype1[cellx]; break; - case (HGCalWafer::waferPlacementIndex2): + case (HGCalCell::cellPlacementIndex2): cell = itype2[cellx]; break; - case (HGCalWafer::waferPlacementIndex3): + case (HGCalCell::cellPlacementIndex3): cell = itype3[cellx]; break; - case (HGCalWafer::waferPlacementIndex4): + case (HGCalCell::cellPlacementIndex4): cell = itype4[cellx]; break; default: @@ -215,7 +215,7 @@ std::pair HGCalWafer::HGCalWaferUV2Cell(int32_t u, int32_t v, int32_t return std::make_pair(cell, cellt); } -int HGCalWafer::HGCalWaferPlacementIndex(int32_t iz, int32_t fwdBack, int32_t orient) { - int32_t indx = ((iz * fwdBack) > 0) ? orient : (orient + HGCalWafer::waferPlacementExtra); +int HGCalCell::HGCalCellPlacementIndex(int32_t iz, int32_t fwdBack, int32_t orient) { + int32_t indx = ((iz * fwdBack) > 0) ? orient : (orient + HGCalCell::cellPlacementExtra); return indx; } diff --git a/Geometry/HGCalCommonData/test/HGCalCellPositionTester.cc b/Geometry/HGCalCommonData/test/HGCalCellPositionTester.cc index 6618eeecbfdcb..2569bb5a57823 100644 --- a/Geometry/HGCalCommonData/test/HGCalCellPositionTester.cc +++ b/Geometry/HGCalCommonData/test/HGCalCellPositionTester.cc @@ -35,7 +35,7 @@ #include "FWCore/MessageLogger/interface/MessageLogger.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h" -#include "Geometry/HGCalCommonData/interface/HGCalWafer.h" +#include "Geometry/HGCalCommonData/interface/HGCalCell.h" class HGCalCellPositionTester : public edm::one::EDAnalyzer<> { public: @@ -56,7 +56,7 @@ class HGCalCellPositionTester : public edm::one::EDAnalyzer<> { HGCalCellPositionTester::HGCalCellPositionTester(const edm::ParameterSet& iC) : waferSize_(iC.getParameter("waferSize")), waferType_(iC.getParameter("waferType")), - placeIndex_(iC.getParameter("waferPlacementIndex")) { + placeIndex_(iC.getParameter("cellPlacementIndex")) { edm::LogVerbatim("HGCalGeom") << "Test positions for wafer of size " << waferSize_ << " Type " << waferType_ << " Placement Index " << placeIndex_; } @@ -65,7 +65,7 @@ void HGCalCellPositionTester::fillDescriptions(edm::ConfigurationDescriptions& d edm::ParameterSetDescription desc; desc.add("waferSize", 166.4408); desc.add("waferType", 0); - desc.add("waferPlacementIndex", 7); + desc.add("cellPlacementIndex", 7); descriptions.add("hgcalCellPositionTester", desc); } @@ -73,7 +73,7 @@ void HGCalCellPositionTester::fillDescriptions(edm::ConfigurationDescriptions& d void HGCalCellPositionTester::analyze(const edm::Event&, const edm::EventSetup&) { const int nFine(12), nCoarse(8); const double tol(0.00001); - HGCalWafer wafer(waferSize_, nFine, nCoarse); + HGCalCell wafer(waferSize_, nFine, nCoarse); int nCells = (waferType_ == 0) ? nFine : nCoarse; int indexMin = (placeIndex_ >= 0) ? placeIndex_ : 0; int indexMax = (placeIndex_ >= 0) ? placeIndex_ : 11; @@ -83,13 +83,13 @@ void HGCalCellPositionTester::analyze(const edm::Event&, const edm::EventSetup&) for (int iu = 0; iu < 2 * nCells; ++iu) { for (int iv = 0; iv < 2 * nCells; ++iv) { int u(iu), v(iv); - if (placeIndex < HGCalWafer::waferPlacementExtra) { + if (placeIndex < HGCalCell::cellPlacementExtra) { u = iv; v = iu; } if (((v - u) < nCells) && ((u - v) <= nCells)) { - std::pair xy1 = wafer.HGCalWaferUV2XY1(u, v, placeIndex, waferType_); - std::pair xy2 = wafer.HGCalWaferUV2XY2(u, v, placeIndex, waferType_); + std::pair xy1 = wafer.HGCalCellUV2XY1(u, v, placeIndex, waferType_); + std::pair xy2 = wafer.HGCalCellUV2XY2(u, v, placeIndex, waferType_); double dx = xy1.first - xy2.first; double dy = xy1.second - xy2.second; std::string comment = ((std::abs(dx) > tol) || (std::abs(dy) > tol)) ? " ***** ERROR *****" : ""; From 7f678e5a17cc447c2eca2bc07923ea98fffc707b Mon Sep 17 00:00:00 2001 From: Sunanda Date: Thu, 27 Jan 2022 14:15:31 +0100 Subject: [PATCH 11/11] Fixes by Pruthvi --- .../HGCalCommonData/interface/HGCalCell.h | 7 +- Geometry/HGCalCommonData/src/HGCalCell.cc | 74 +++++++++++-------- 2 files changed, 47 insertions(+), 34 deletions(-) diff --git a/Geometry/HGCalCommonData/interface/HGCalCell.h b/Geometry/HGCalCommonData/interface/HGCalCell.h index 53408be01afd7..6888d05979655 100644 --- a/Geometry/HGCalCommonData/interface/HGCalCell.h +++ b/Geometry/HGCalCommonData/interface/HGCalCell.h @@ -32,9 +32,10 @@ class HGCalCell { static constexpr int32_t cellPlacementOld = 7; static constexpr int32_t cellPlacementTotal = 12; - static constexpr int32_t cornerCell = 0; - static constexpr int32_t truncatedCell = 1; - static constexpr int32_t extendedCell = 2; + static constexpr int32_t fullCell = 0; + static constexpr int32_t cornerCell = 1; + static constexpr int32_t truncatedCell = 2; + static constexpr int32_t extendedCell = 3; std::pair HGCalCellUV2XY1(int32_t u, int32_t v, int32_t placementIndex, int32_t type); std::pair HGCalCellUV2XY2(int32_t u, int32_t v, int32_t placementIndex, int32_t type); diff --git a/Geometry/HGCalCommonData/src/HGCalCell.cc b/Geometry/HGCalCommonData/src/HGCalCell.cc index 3fb621949b599..60e82acbf0684 100644 --- a/Geometry/HGCalCommonData/src/HGCalCell.cc +++ b/Geometry/HGCalCommonData/src/HGCalCell.cc @@ -94,43 +94,49 @@ std::pair HGCalCell::HGCalCellUV2XY2(int32_t u, int32_t v, int32 std::pair HGCalCell::HGCalCellUV2Cell(int32_t u, int32_t v, int32_t placementIndex, int32_t type) { if (type != 0) type = 1; - int cell(0), cellx(0), cellt(HGCalCell::cornerCell); + int cell(0), cellx(0), cellt(HGCalCell::fullCell); if (placementIndex >= HGCalCell::cellPlacementExtra) { - const std::vector itype0 = {0, 6, 7, 8, 9, 10, 11, 3, 4, 5, 3, 4, 5}; + const std::vector itype0 = {0, 7, 8, 9, 10, 11, 6, 3, 4, 5, 4, 5, 3}; const std::vector itype1 = {0, 0, 1, 2, 3, 4, 5, 0, 1, 2, 0, 1, 2}; - const std::vector itype2 = {0, 10, 11, 6, 7, 8, 9, 5, 3, 4, 5, 3, 4}; + const std::vector itype2 = {0, 11, 6, 7, 8, 9, 10, 5, 3, 4, 3, 4, 5}; const std::vector itype3 = {0, 4, 5, 0, 1, 2, 3, 2, 0, 1, 2, 0, 1}; - const std::vector itype4 = {0, 8, 9, 10, 11, 6, 7, 4, 5, 3, 4, 5, 3}; + const std::vector itype4 = {0, 9, 10, 11, 6, 7, 8, 4, 5, 3, 5, 3, 4}; const std::vector itype5 = {0, 2, 3, 4, 5, 0, 1, 1, 2, 0, 1, 2, 0}; if (u == 0 && v == 0) { - cellx = 0; - } else if (u == 0 && (v - u) == (ncell_[type] - 1)) { cellx = 1; - } else if ((v - u) == (ncell_[type] - 1) && v == (2 * ncell_[type] - 1)) { + cellt = HGCalCell::cornerCell; + } else if (u == 0 && (v - u) == (ncell_[type] - 1)) { cellx = 2; - } else if (u == (2 * ncell_[type] - 1) && v == (2 * ncell_[type] - 1)) { + cellt = HGCalCell::cornerCell; + } else if ((v - u) == (ncell_[type] - 1) && v == (2 * ncell_[type] - 1)) { cellx = 3; - } else if (u == (2 * ncell_[type] - 1) && (u - v) == ncell_[type]) { + cellt = HGCalCell::cornerCell; + } else if (u == (2 * ncell_[type] - 1) && v == (2 * ncell_[type] - 1)) { cellx = 4; - } else if ((u - v) == ncell_[type] && v == 0) { + cellt = HGCalCell::cornerCell; + } else if (u == (2 * ncell_[type] - 1) && (u - v) == ncell_[type]) { cellx = 5; - } else if (u == 0) { + cellt = HGCalCell::cornerCell; + } else if ((u - v) == ncell_[type] && v == 0) { cellx = 6; + cellt = HGCalCell::cornerCell; + } else if (u == 0) { + cellx = 7; cellt = HGCalCell::truncatedCell; } else if ((v - u) == (ncell_[type] - 1)) { - cellx = 9; + cellx = 10; cellt = HGCalCell::extendedCell; } else if (v == (2 * ncell_[type] - 1)) { - cellx = 7; + cellx = 8; cellt = HGCalCell::truncatedCell; } else if (u == (2 * ncell_[type] - 1)) { - cellx = 10; + cellx = 11; cellt = HGCalCell::extendedCell; } else if ((u - v) == ncell_[type]) { - cellx = 8; + cellx = 9; cellt = HGCalCell::truncatedCell; } else if (v == 0) { - cellx = 11; + cellx = 12; cellt = HGCalCell::extendedCell; } switch (placementIndex) { @@ -155,40 +161,46 @@ std::pair HGCalCell::HGCalCellUV2Cell(int32_t u, int32_t v, int32_t pl } } else { const std::vector itype0 = {0, 1, 2, 3, 4, 5, 0, 1, 2, 0, 0, 1, 2}; - const std::vector itype1 = {0, 7, 8, 9, 10, 11, 6, 4, 5, 3, 3, 4, 5}; + const std::vector itype1 = {0, 8, 9, 10, 11, 6, 7, 4, 5, 3, 4, 5, 3}; const std::vector itype2 = {0, 3, 4, 5, 0, 1, 2, 2, 0, 1, 1, 2, 0}; - const std::vector itype3 = {0, 9, 10, 11, 6, 7, 8, 5, 3, 4, 4, 5, 3}; + const std::vector itype3 = {0, 10, 11, 6, 7, 8, 9, 5, 3, 4, 5, 3, 4}; const std::vector itype4 = {0, 5, 0, 1, 2, 3, 4, 0, 1, 2, 2, 0, 1}; - const std::vector itype5 = {0, 11, 6, 7, 8, 9, 10, 3, 4, 5, 3, 4, 5}; + const std::vector itype5 = {0, 6, 7, 8, 9, 10, 11, 3, 4, 5, 3, 4, 5}; if (u == 0 && v == 0) { - cellx = 0; - } else if (v == 0 && (u - v) == (ncell_[type])) { cellx = 1; - } else if ((u - v) == (ncell_[type]) && u == (2 * ncell_[type] - 1)) { + cellt = HGCalCell::cornerCell; + } else if (v == 0 && (u - v) == (ncell_[type])) { cellx = 2; - } else if (u == (2 * ncell_[type] - 1) && v == (2 * ncell_[type] - 1)) { + cellt = HGCalCell::cornerCell; + } else if ((u - v) == (ncell_[type]) && u == (2 * ncell_[type] - 1)) { cellx = 3; - } else if (v == (2 * ncell_[type] - 1) && (v - u) == (ncell_[type] - 1)) { + cellt = HGCalCell::cornerCell; + } else if (u == (2 * ncell_[type] - 1) && v == (2 * ncell_[type] - 1)) { cellx = 4; - } else if ((v - u) == (ncell_[type] - 1) && u == 0) { + cellt = HGCalCell::cornerCell; + } else if (v == (2 * ncell_[type] - 1) && (v - u) == (ncell_[type] - 1)) { cellx = 5; + cellt = HGCalCell::cornerCell; + } else if ((v - u) == (ncell_[type] - 1) && u == 0) { + cellx = 6; + cellt = HGCalCell::cornerCell; } else if (v == 0) { - cellx = 9; + cellx = 10; cellt = HGCalCell::extendedCell; } else if ((u - v) == ncell_[type]) { - cellx = 6; + cellx = 7; cellt = HGCalCell::truncatedCell; } else if (u == (2 * ncell_[type] - 1)) { - cellx = 10; + cellx = 11; cellt = HGCalCell::extendedCell; } else if (v == (2 * ncell_[type] - 1)) { - cellx = 7; + cellx = 8; cellt = HGCalCell::truncatedCell; } else if ((v - u) == (ncell_[type] - 1)) { - cellx = 11; + cellx = 12; cellt = HGCalCell::extendedCell; } else if (u == 0) { - cellx = 8; + cellx = 9; cellt = HGCalCell::truncatedCell; } switch (placementIndex) {