From 4ad8da141ca3b569392916a53ef8d57f29f7971f Mon Sep 17 00:00:00 2001 From: Sunanda Date: Sun, 1 May 2022 12:27:27 +0200 Subject: [PATCH 1/2] Add in line documentation to some service methods in Geometry/HGCalCommonData --- .../HGCalCommonData/interface/HGCalCell.h | 4 ++ .../interface/HGCalTileIndex.h | 10 ++++ .../interface/HGCalWaferIndex.h | 8 ++- .../interface/HGCalWaferMask.h | 14 ++++- .../HGCalCommonData/src/HGCalWaferMask.cc | 52 +++++++++++++++++++ 5 files changed, 85 insertions(+), 3 deletions(-) diff --git a/Geometry/HGCalCommonData/interface/HGCalCell.h b/Geometry/HGCalCommonData/interface/HGCalCell.h index dbbb40ea2b199..f1507b889f7b1 100644 --- a/Geometry/HGCalCommonData/interface/HGCalCell.h +++ b/Geometry/HGCalCommonData/interface/HGCalCell.h @@ -47,9 +47,13 @@ class HGCalCell { std::pair cellUV2XY1(int32_t u, int32_t v, int32_t placementIndex, int32_t type); std::pair cellUV2XY2(int32_t u, int32_t v, int32_t placementIndex, int32_t type); + // Get cell type and orientation index std::pair cellUV2Cell(int32_t u, int32_t v, int32_t placementIndex, int32_t type); + // Get the placement index from zside, forward-backward tag, orientation flag static int32_t cellPlacementIndex(int32_t iz, int32_t fwdBack, int32_t orient); + // Get the orientation flag and forward-backward tag from placement index static std::pair cellOrient(int32_t placementIndex); + // Get cell type and position in the list static std::pair cellType(int32_t u, int32_t v, int32_t ncell, int32_t placementIndex); private: diff --git a/Geometry/HGCalCommonData/interface/HGCalTileIndex.h b/Geometry/HGCalCommonData/interface/HGCalTileIndex.h index 5c2cf6fe6edbe..3390c183dc8e8 100644 --- a/Geometry/HGCalCommonData/interface/HGCalTileIndex.h +++ b/Geometry/HGCalCommonData/interface/HGCalTileIndex.h @@ -6,15 +6,25 @@ #include namespace HGCalTileIndex { + // Packs layer, ring, phi indices into a single word (useful for XML files) int32_t tileIndex(int32_t layer, int32_t ring, int32_t phi); + // Unpacks Layer number from the packed index int32_t tileLayer(int32_t index); + // Unpacks Ring number from the packed index int32_t tileRing(int32_t index); + // Unpacks Phi number from the packed index int32_t tilePhi(int32_t index); + // Packs tile type and SiPM size into a single word (useful for XML files) int32_t tileProperty(int32_t, int32_t); + // Unpacks tile type from the packed word int32_t tileType(int32_t); + // Unpacks SiPM size from the packed word int32_t tileSiPM(int32_t); + // Packs 3 information for usage in xml file int32_t tilePack(int32_t ly, int32_t k1, int32_t k2); + // Unpacks thos three information from the packed word std::tuple tileUnpack(int32_t index); + // Sees if the tile exists or not depending the HEX information in flat file bool tileExist(const int32_t* hex, int32_t zside, int32_t phi); }; // namespace HGCalTileIndex diff --git a/Geometry/HGCalCommonData/interface/HGCalWaferIndex.h b/Geometry/HGCalCommonData/interface/HGCalWaferIndex.h index 6cc45320b4682..28a1b17279557 100644 --- a/Geometry/HGCalCommonData/interface/HGCalWaferIndex.h +++ b/Geometry/HGCalCommonData/interface/HGCalWaferIndex.h @@ -5,11 +5,17 @@ #include namespace HGCalWaferIndex { + // Packs layer, u, v indices into a single word (useful for xml definition) int32_t waferIndex(int32_t layer, int32_t waferU, int32_t waferV, bool old = false); + // Unpacks the layer number from the packed index int32_t waferLayer(const int32_t index); - int32_t waferU(const int32_t index); + // Unpacks wafer U from the packed index + int32_t waferU(const int32_t index); + // Unpacks wafer V from the packed index int32_t waferV(const int32_t index); + // Gets the used part of the index (Layer:u:v) int32_t waferCopy(const int32_t index); + // Finds the index format (old:false or new:true) bool waferFormat(const int32_t index); }; // namespace HGCalWaferIndex diff --git a/Geometry/HGCalCommonData/interface/HGCalWaferMask.h b/Geometry/HGCalCommonData/interface/HGCalWaferMask.h index 38d605bad846e..4f69b31f98686 100644 --- a/Geometry/HGCalCommonData/interface/HGCalWaferMask.h +++ b/Geometry/HGCalCommonData/interface/HGCalWaferMask.h @@ -17,9 +17,14 @@ class HGCalWaferMask { public: HGCalWaferMask() = default; + // Decides if the cell is present or not from # oc corners (for V14) static bool maskCell(int u, int v, int N, int ncor, int fcor, int corners); + // Decides if the cell is present or not from # oc corners (for V15, V16) static bool goodCell(int u, int v, int N, int type, int rotn); + // Converts rotation index (as otained from flat file) depending on + // zside and type (for V15, V16) static int getRotation(int zside, int type, int rotn); + // Get partial wafer type and orientation (for V15, V16) static std::pair getTypeMode(const double& xpos, const double& ypos, const double& delX, @@ -28,11 +33,16 @@ class HGCalWaferMask { const double& rout, const int& waferType, const int& mode, - bool deug = false); + bool debug = false); + // Checks partial wafer type and orientation (for V15, V16) static bool goodTypeMode( - double xpos, double ypos, double delX, double delY, double rin, double rout, int part, int rotn, bool debug); + double xpos, double ypos, double delX, double delY, double rin, double rout, int part, int rotn, bool debug = false); + // Gets the corners of the partial wafers from its type, orientation, zside + // (Good for V15, V16 geometries) static std::vector > waferXY( int part, int orient, int zside, double delX, double delY, double xpos, double ypos); + // Gets the corners of the partial wafers from its type, placement index + // (Good for V17 geometry) static std::vector > waferXY( int part, int placement, double delX, double delY, double xpos, double ypos); diff --git a/Geometry/HGCalCommonData/src/HGCalWaferMask.cc b/Geometry/HGCalCommonData/src/HGCalWaferMask.cc index 5947c9ec4829a..ae073765fe1cb 100644 --- a/Geometry/HGCalCommonData/src/HGCalWaferMask.cc +++ b/Geometry/HGCalCommonData/src/HGCalWaferMask.cc @@ -106,6 +106,7 @@ The argument 'corners' controls the types of wafers the user wants: for instance } bool HGCalWaferMask::goodCell(int u, int v, int n, int type, int rotn) { + // Needs extension for V17 bool good(false); int n2 = n / 2; int n4 = n / 4; @@ -395,6 +396,7 @@ bool HGCalWaferMask::goodCell(int u, int v, int n, int type, int rotn) { } int HGCalWaferMask::getRotation(int zside, int type, int rotn) { + // Needs extension for V17 if (rotn >= HGCalTypes::WaferCornerMax) rotn = HGCalTypes::WaferCorner0; int newrotn(rotn); @@ -441,6 +443,7 @@ std::pair HGCalWaferMask::getTypeMode(const double& xpos, const int& wType, const int& mode, bool debug) { + // No need to extend this for V17 -- use flat file information only int ncor(0), iok(0); int type(HGCalTypes::WaferFull), rotn(HGCalTypes::WaferCorner0); @@ -680,6 +683,7 @@ std::pair HGCalWaferMask::getTypeMode(const double& xpos, bool HGCalWaferMask::goodTypeMode( double xpos, double ypos, double delX, double delY, double rin, double rout, int part, int rotn, bool debug) { + // Needs extension for V17 if (part < 0 || part > HGCalTypes::WaferSizeMax) return false; if (rotn < 0 || rotn > HGCalTypes::WaferCornerMax) @@ -1002,11 +1006,35 @@ bool HGCalWaferMask::goodTypeMode( std::vector > HGCalWaferMask::waferXY( int part, int ori, int zside, double delX, double delY, double xpos, double ypos) { + // Good for V15 and V16 versions std::vector > xy; int orient = getRotation(-zside, part, ori); #ifdef EDM_ML_DEBUG edm::LogVerbatim("HGCalGeom") << "Part " << part << " zSide " << zside << " Orient " << ori << ":" << orient; #endif + /* + The exact contour of partial wafers are obtained by joining points on + the circumference of a full wafer. + Numbering the points along the edges of a hexagonal wafer, starting from + the bottom corner: + + 3 + 15 18 + 9 8 + 19 14 + 4 2 + 16 23 + 10 7 + 20 13 + 5 1 + 17 22 + 11 6 + 21 12 + 0 + + Depending on the wafer type and orientation index, the corners + are chosen in the variable *np* + */ double dx[24] = {HGCalTypes::c00 * delX, HGCalTypes::c10 * delX, HGCalTypes::c10 * delX, HGCalTypes::c00 * delX, -HGCalTypes::c10 * delX, -HGCalTypes::c10 * delX, HGCalTypes::c50 * delX, HGCalTypes::c10 * delX, HGCalTypes::c50 * delX, -HGCalTypes::c50 * delX, -HGCalTypes::c10 * delX, -HGCalTypes::c50 * delX, @@ -1155,9 +1183,33 @@ std::vector > HGCalWaferMask::waferXY( std::vector > HGCalWaferMask::waferXY( int part, int place, double delX, double delY, double xpos, double ypos) { std::vector > xy; + // Good for V17 version and uses partial wafer type & placement index #ifdef EDM_ML_DEBUG edm::LogVerbatim("HGCalGeom") << "Part " << part << " Placement Index " << place; #endif + /* + The exact contour of partial wafers are obtained by joining points on + the circumference of a full wafer. + Numbering the points along the edges of a hexagonal wafer, starting from + the bottom corner: + + 3 + 15 18 + 9 8 + 19 14 + 4 2 + 16 23 + 10 7 + 20 13 + 5 1 + 17 22 + 11 6 + 21 12 + 0 + + Depending on the wafer type and placement index, the corners + are chosen in the variable *np* + */ double dx[24] = {HGCalTypes::c00 * delX, HGCalTypes::c10 * delX, HGCalTypes::c10 * delX, HGCalTypes::c00 * delX, -HGCalTypes::c10 * delX, -HGCalTypes::c10 * delX, HGCalTypes::c50 * delX, HGCalTypes::c10 * delX, HGCalTypes::c50 * delX, -HGCalTypes::c50 * delX, -HGCalTypes::c10 * delX, -HGCalTypes::c50 * delX, From 9bf85bec20b8fc0f11a2f8d36e533fb48ffd139d Mon Sep 17 00:00:00 2001 From: Sunanda Date: Sun, 1 May 2022 12:43:23 +0200 Subject: [PATCH 2/2] Code check --- Geometry/HGCalCommonData/interface/HGCalWaferIndex.h | 2 +- Geometry/HGCalCommonData/interface/HGCalWaferMask.h | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/Geometry/HGCalCommonData/interface/HGCalWaferIndex.h b/Geometry/HGCalCommonData/interface/HGCalWaferIndex.h index 28a1b17279557..d4c0be90dda8f 100644 --- a/Geometry/HGCalCommonData/interface/HGCalWaferIndex.h +++ b/Geometry/HGCalCommonData/interface/HGCalWaferIndex.h @@ -10,7 +10,7 @@ namespace HGCalWaferIndex { // Unpacks the layer number from the packed index int32_t waferLayer(const int32_t index); // Unpacks wafer U from the packed index - int32_t waferU(const int32_t index); + int32_t waferU(const int32_t index); // Unpacks wafer V from the packed index int32_t waferV(const int32_t index); // Gets the used part of the index (Layer:u:v) diff --git a/Geometry/HGCalCommonData/interface/HGCalWaferMask.h b/Geometry/HGCalCommonData/interface/HGCalWaferMask.h index 4f69b31f98686..1021227b95c35 100644 --- a/Geometry/HGCalCommonData/interface/HGCalWaferMask.h +++ b/Geometry/HGCalCommonData/interface/HGCalWaferMask.h @@ -35,8 +35,15 @@ class HGCalWaferMask { const int& mode, bool debug = false); // Checks partial wafer type and orientation (for V15, V16) - static bool goodTypeMode( - double xpos, double ypos, double delX, double delY, double rin, double rout, int part, int rotn, bool debug = false); + static bool goodTypeMode(double xpos, + double ypos, + double delX, + double delY, + double rin, + double rout, + int part, + int rotn, + bool debug = false); // Gets the corners of the partial wafers from its type, orientation, zside // (Good for V15, V16 geometries) static std::vector > waferXY(