From 251c92a9f2afb988e0a22a881058e0297a679437 Mon Sep 17 00:00:00 2001 From: Sunanda Date: Mon, 6 Nov 2023 10:45:16 +0100 Subject: [PATCH 1/2] Update HGCSiliconDetId in view of adding a fourth type of wafer: high density but thicker --- .../ForwardDetId/interface/HGCSiliconDetId.h | 83 ++++++++++--------- .../src/HGCSiliconDetIdToModule.cc | 4 +- DataFormats/ForwardDetId/test/testHGCDetId.cc | 4 +- .../test/HGCalPartialWaferTester.cc | 2 +- .../test/HGCalValidHexTester.cc | 2 +- Geometry/HGCalGeometry/src/HGCalMouseBite.cc | 4 +- .../test/HGCalGeometryMouseBiteTester.cc | 2 +- 7 files changed, 54 insertions(+), 47 deletions(-) diff --git a/DataFormats/ForwardDetId/interface/HGCSiliconDetId.h b/DataFormats/ForwardDetId/interface/HGCSiliconDetId.h index 0ce56bd2b2b72..175dcf4d15dcd 100644 --- a/DataFormats/ForwardDetId/interface/HGCSiliconDetId.h +++ b/DataFormats/ForwardDetId/interface/HGCSiliconDetId.h @@ -17,16 +17,20 @@ [25:25] z-side (0 for +z; 1 for -z) [26:27] Type (0 fine divisions of wafer with 120 mum thick silicon 1 coarse divisions of wafer with 200 mum thick silicon - 2 coarse divisions of wafer with 300 mum thick silicon) + 2 coarse divisions of wafer with 300 mum thick silicon + 3 fine divisions of wafer with 200 mum thick silicon) [28:31] Detector type (HGCalEE or HGCalHSi) */ class HGCSiliconDetId : public DetId { public: - enum waferType { HGCalFine = 0, HGCalCoarseThin = 1, HGCalCoarseThick = 2 }; - static const int HGCalFineN = 12; - static const int HGCalCoarseN = 8; - static const int HGCalFineTrigger = 3; - static const int HGCalCoarseTrigger = 2; + enum waferType { HGCalFine = 0, HGCalCoarseThin = 1, HGCalCoarseThick = 2, HGCalFineThick = 3 }; + static constexpr int32_t HGCalHighDensityN = 12; + static constexpr int32_t HGCalLowDensityN = 8; + static constexpr int32_t HGCalFineTrigger = 3; + static constexpr int32_t HGCalCoarseTrigger = 2; + static constexpr int32_t HGCal0Depletion = 120; + static constexpr int32_t HGCal1Depletion = 200; + static constexpr int32_t HGCal2Depletion = 300; /** Create a null cellid*/ constexpr HGCSiliconDetId() : DetId() {} @@ -34,12 +38,12 @@ class HGCSiliconDetId : public DetId { constexpr HGCSiliconDetId(uint32_t rawid) : DetId(rawid) {} /** Constructor from subdetector, zplus, layer, module, cell numbers */ constexpr HGCSiliconDetId( - DetId::Detector det, int zp, int type, int layer, int waferU, int waferV, int cellU, int cellV) + DetId::Detector det, int32_t zp, int32_t type, int32_t layer, int32_t waferU, int32_t waferV, int32_t cellU, int32_t cellV) : DetId(det, ForwardEmpty) { - int waferUabs(std::abs(waferU)), waferVabs(std::abs(waferV)); - int waferUsign = (waferU >= 0) ? 0 : 1; - int waferVsign = (waferV >= 0) ? 0 : 1; - int zside = (zp < 0) ? 1 : 0; + int32_t waferUabs(std::abs(waferU)), waferVabs(std::abs(waferV)); + int32_t waferUsign = (waferU >= 0) ? 0 : 1; + int32_t waferVsign = (waferV >= 0) ? 0 : 1; + int32_t zside = (zp < 0) ? 1 : 0; id_ |= (((cellU & kHGCalCellUMask) << kHGCalCellUOffset) | ((cellV & kHGCalCellVMask) << kHGCalCellVOffset) | ((waferUabs & kHGCalWaferUMask) << kHGCalWaferUOffset) | ((waferUsign & kHGCalWaferUSignMask) << kHGCalWaferUSignOffset) | @@ -84,42 +88,45 @@ class HGCSiliconDetId : public DetId { constexpr DetId::Detector subdet() const { return det(); } /// get the type - constexpr int type() const { return (id_ >> kHGCalTypeOffset) & kHGCalTypeMask; } + constexpr int32_t type() const { return (id_ >> kHGCalTypeOffset) & kHGCalTypeMask; } + constexpr bool lowDensity() const { return ((type() == HGCalCoarseThin) || (type() == HGCalCoarseThick)); } + constexpr bool highDensity() const { return ((type() == HGCalFine) || (type() == HGCalFineThick)); } + constexpr int32_t depletion() const { return ((type() == HGCalFine) ? HGCal0Depletion : ((type() == HGCalCoarseThick) ? HGCal2Depletion : HGCal1Depletion)); } /// get the z-side of the cell (1/-1) - constexpr int zside() const { return (((id_ >> kHGCalZsideOffset) & kHGCalZsideMask) ? -1 : 1); } + constexpr int32_t zside() const { return (((id_ >> kHGCalZsideOffset) & kHGCalZsideMask) ? -1 : 1); } /// get the layer # - constexpr int layer() const { return (id_ >> kHGCalLayerOffset) & kHGCalLayerMask; } + constexpr int32_t layer() const { return (id_ >> kHGCalLayerOffset) & kHGCalLayerMask; } /// get the cell #'s in u,v or in x,y - constexpr int cellU() const { return (id_ >> kHGCalCellUOffset) & kHGCalCellUMask; } - constexpr int cellV() const { return (id_ >> kHGCalCellVOffset) & kHGCalCellVMask; } - constexpr std::pair cellUV() const { return std::pair(cellU(), cellV()); } - constexpr int cellX() const { - int N = (type() == HGCalFine) ? HGCalFineN : HGCalCoarseN; + constexpr int32_t cellU() const { return (id_ >> kHGCalCellUOffset) & kHGCalCellUMask; } + constexpr int32_t cellV() const { return (id_ >> kHGCalCellVOffset) & kHGCalCellVMask; } + constexpr std::pair cellUV() const { return std::pair(cellU(), cellV()); } + constexpr int32_t cellX() const { + int32_t N = ((type() == HGCalFine) || (type() == HGCalFineThick)) ? HGCalHighDensityN : HGCalLowDensityN; return (3 * (cellV() - N) + 2); } - constexpr int cellY() const { - int N = (type() == HGCalFine) ? HGCalFineN : HGCalCoarseN; + constexpr int32_t cellY() const { + int32_t N = ((type() == HGCalFine) || (type() == HGCalFineThick)) ? HGCalHighDensityN : HGCalLowDensityN; return (2 * cellU() - (N + cellV())); } - constexpr std::pair cellXY() const { return std::pair(cellX(), cellY()); } + constexpr std::pair cellXY() const { return std::pair(cellX(), cellY()); } /// get the wafer #'s in u,v or in x,y - constexpr int waferUAbs() const { return (id_ >> kHGCalWaferUOffset) & kHGCalWaferUMask; } - constexpr int waferVAbs() const { return (id_ >> kHGCalWaferVOffset) & kHGCalWaferVMask; } - constexpr int waferU() const { + constexpr int32_t waferUAbs() const { return (id_ >> kHGCalWaferUOffset) & kHGCalWaferUMask; } + constexpr int32_t waferVAbs() const { return (id_ >> kHGCalWaferVOffset) & kHGCalWaferVMask; } + constexpr int32_t waferU() const { return (((id_ >> kHGCalWaferUSignOffset) & kHGCalWaferUSignMask) ? -waferUAbs() : waferUAbs()); } - constexpr int waferV() const { + constexpr int32_t waferV() const { return (((id_ >> kHGCalWaferVSignOffset) & kHGCalWaferVSignMask) ? -waferVAbs() : waferVAbs()); } - constexpr std::pair waferUV() const { return std::pair(waferU(), waferV()); } - constexpr int waferX() const { return (-2 * waferU() + waferV()); } - constexpr int waferY() const { return (2 * waferV()); } - constexpr std::pair waferXY() const { return std::pair(waferX(), waferY()); } - constexpr void unpack(int& ty, int& zs, int& ly, int& wU, int& wV, int& cU, int& cV) const { + constexpr std::pair waferUV() const { return std::pair(waferU(), waferV()); } + constexpr int32_t waferX() const { return (-2 * waferU() + waferV()); } + constexpr int32_t waferY() const { return (2 * waferV()); } + constexpr std::pair waferXY() const { return std::pair(waferX(), waferY()); } + constexpr void unpack(int32_t& ty, int32_t& zs, int32_t& ly, int32_t& wU, int32_t& wV, int32_t& cU, int32_t& cV) const { ty = type(); zs = zside(); ly = layer(); @@ -130,21 +137,21 @@ class HGCSiliconDetId : public DetId { } // get trigger cell u,v - constexpr int triggerCellU() const { - int N = (type() == HGCalFine) ? HGCalFineN : HGCalCoarseN; - int NT = (type() == HGCalFine) ? HGCalFineTrigger : HGCalCoarseTrigger; + constexpr int32_t triggerCellU() const { + int32_t N = ((type() == HGCalFine) || (type() == HGCalFineThick)) ? HGCalHighDensityN : HGCalLowDensityN; + int32_t NT = ((type() == HGCalFine) || (type() == HGCalFineThick)) ? HGCalFineTrigger : HGCalCoarseTrigger; return (cellU() >= N && cellV() >= N) ? cellU() / NT : ((cellU() < N && cellU() <= cellV()) ? cellU() / NT : (1 + (cellU() - (cellV() % NT + 1)) / NT)); } - constexpr int triggerCellV() const { - int N = (type() == HGCalFine) ? HGCalFineN : HGCalCoarseN; - int NT = (type() == HGCalFine) ? HGCalFineTrigger : HGCalCoarseTrigger; + constexpr int32_t triggerCellV() const { + int32_t N = ((type() == HGCalFine) || (type() == HGCalFineThick)) ? HGCalHighDensityN : HGCalLowDensityN; + int32_t NT = ((type() == HGCalFine) || (type() == HGCalFineThick)) ? HGCalFineTrigger : HGCalCoarseTrigger; return (cellU() >= N && cellV() >= N) ? cellV() / NT : ((cellU() < N && cellU() <= cellV()) ? ((cellV() - cellU()) / NT + cellU() / NT) : cellV() / NT); } - constexpr std::pair triggerCellUV() const { return std::pair(triggerCellU(), triggerCellV()); } + constexpr std::pair triggerCellUV() const { return std::pair(triggerCellU(), triggerCellV()); } /// consistency check : no bits left => no overhead constexpr bool isEE() const { return (det() == HGCalEE); } diff --git a/DataFormats/ForwardDetId/src/HGCSiliconDetIdToModule.cc b/DataFormats/ForwardDetId/src/HGCSiliconDetIdToModule.cc index ce4362a6892a7..c41a7ae605b74 100644 --- a/DataFormats/ForwardDetId/src/HGCSiliconDetIdToModule.cc +++ b/DataFormats/ForwardDetId/src/HGCSiliconDetIdToModule.cc @@ -4,7 +4,7 @@ HGCSiliconDetIdToModule::HGCSiliconDetIdToModule() {} std::vector HGCSiliconDetIdToModule::getDetIds(HGCSiliconDetId const& id) const { std::vector ids; - int nCells = (id.type() == 0) ? HGCSiliconDetId::HGCalFineN : HGCSiliconDetId::HGCalCoarseN; + int nCells = (id.type() == 0) ? HGCSiliconDetId::HGCalHighDensityN : HGCSiliconDetId::HGCalLowDensityN; for (int u = 0; u < 2 * nCells; ++u) { for (int v = 0; v < 2 * nCells; ++v) { if (((v - u) < nCells) && (u - v) <= nCells) { @@ -18,7 +18,7 @@ std::vector HGCSiliconDetIdToModule::getDetIds(HGCSiliconDetId std::vector HGCSiliconDetIdToModule::getDetTriggerIds(HGCSiliconDetId const& id) const { std::vector ids; - int nCells = HGCSiliconDetId::HGCalFineN / HGCSiliconDetId::HGCalFineTrigger; + int nCells = HGCSiliconDetId::HGCalHighDensityN / HGCSiliconDetId::HGCalFineTrigger; int subdet = (id.det() == DetId::HGCalEE) ? HGCalEETrigger : HGCalHSiTrigger; for (int u = 0; u < 2 * nCells; ++u) { for (int v = 0; v < 2 * nCells; ++v) { diff --git a/DataFormats/ForwardDetId/test/testHGCDetId.cc b/DataFormats/ForwardDetId/test/testHGCDetId.cc index a18fabf18d388..77a0ee0f3ecac 100644 --- a/DataFormats/ForwardDetId/test/testHGCDetId.cc +++ b/DataFormats/ForwardDetId/test/testHGCDetId.cc @@ -12,7 +12,7 @@ #include void testCell(int type) { - int N = (type == 0) ? HGCSiliconDetId::HGCalFineN : HGCSiliconDetId::HGCalCoarseN; + int N = (type == 0) ? HGCSiliconDetId::HGCalHighDensityN : HGCSiliconDetId::HGCalLowDensityN; const int waferu(0), waferv(0), layer(1), zside(1); std::map, int> triggers; int ntot(0); @@ -125,7 +125,7 @@ void testScint(int layer) { } void testTriggerCell(int type) { - int N = (type == 0) ? HGCSiliconDetId::HGCalFineN : HGCSiliconDetId::HGCalCoarseN; + int N = (type == 0) ? HGCSiliconDetId::HGCalHighDensityN : HGCSiliconDetId::HGCalLowDensityN; const int waferu(0), waferv(0), layer(1); std::string error[2] = {"ERROR", "OK"}; int ntot(0), nerror(0); diff --git a/Geometry/HGCalCommonData/test/HGCalPartialWaferTester.cc b/Geometry/HGCalCommonData/test/HGCalPartialWaferTester.cc index b98b3a3a18cb9..d0088c02d1b76 100644 --- a/Geometry/HGCalCommonData/test/HGCalPartialWaferTester.cc +++ b/Geometry/HGCalCommonData/test/HGCalPartialWaferTester.cc @@ -98,7 +98,7 @@ void HGCalPartialWaferTester::analyze(const edm::Event&, const edm::EventSetup& edm::LogVerbatim("HGCalGeom") << "\n\nPartial Type " << partialType << " Orientation " << orientation << " Wafer " << waferU << ":" << waferV << " in layer " << layer << " at " << xy.first << ":" << xy.second << "\n\n"; - int nCells = (type == 0) ? HGCSiliconDetId::HGCalFineN : HGCSiliconDetId::HGCalCoarseN; + int nCells = (type == 0) ? HGCSiliconDetId::HGCalHighDensityN : HGCSiliconDetId::HGCalLowDensityN; for (int i = 0; i < nTrials_; i++) { int ui = std::floor(nCells * 0.0002 * (rand() % 10000)); int vi = std::floor(nCells * 0.0002 * (rand() % 10000)); diff --git a/Geometry/HGCalCommonData/test/HGCalValidHexTester.cc b/Geometry/HGCalCommonData/test/HGCalValidHexTester.cc index 07a073b7cbd6e..ab978272b36f1 100644 --- a/Geometry/HGCalCommonData/test/HGCalValidHexTester.cc +++ b/Geometry/HGCalCommonData/test/HGCalValidHexTester.cc @@ -91,7 +91,7 @@ void HGCalValidHexTester::analyze(const edm::Event& iEvent, const edm::EventSetu edm::LogVerbatim("HGCalGeom") << nameDetector_ << " Layers = " << hgdc.layers(true) << " Sectors = " << hgdc.sectors() << "\n"; for (unsigned int k = 0; k < layers_.size(); ++k) { - int nCells = (types_[k] == 0) ? HGCSiliconDetId::HGCalFineN : HGCSiliconDetId::HGCalCoarseN; + int nCells = (types_[k] == 0) ? HGCSiliconDetId::HGCalHighDensityN : HGCSiliconDetId::HGCalLowDensityN; int ncell(0); for (int u = 0; u < 2 * nCells; ++u) { for (int v = 0; v < 2 * nCells; ++v) { diff --git a/Geometry/HGCalGeometry/src/HGCalMouseBite.cc b/Geometry/HGCalGeometry/src/HGCalMouseBite.cc index b69957f39228a..49c508aaeaf76 100644 --- a/Geometry/HGCalGeometry/src/HGCalMouseBite.cc +++ b/Geometry/HGCalGeometry/src/HGCalMouseBite.cc @@ -22,7 +22,7 @@ HGCalMouseBite::HGCalMouseBite(const HGCalDDDConstants& hgc, const bool rot) { << projXY[k].first << ":" << projXY[k].second; #endif static const double sqrt3 = std::sqrt(3.0); - int nf(HGCSiliconDetId::HGCalFineN); + int nf(HGCSiliconDetId::HGCalHighDensityN); int nf2 = nf / 2; double delXF = wafersize / (3.0 * nf); double delYF = 0.5 * delXF * sqrt3; @@ -48,7 +48,7 @@ HGCalMouseBite::HGCalMouseBite(const HGCalDDDConstants& hgc, const bool rot) { edm::LogVerbatim("HGCalGeom") << "[" << k << "] = (" << rejectFine_[k] / 100 << ", " << rejectFine_[k] % 100 << ")"; #endif - int nc(HGCSiliconDetId::HGCalCoarseN); + int nc(HGCSiliconDetId::HGCalLowDensityN); int nc2 = nc / 2; double delXC = hgc.getParameter()->waferSize_ / (3.0 * nc); double delYC = 0.5 * delXC * sqrt3; diff --git a/Geometry/HGCalGeometry/test/HGCalGeometryMouseBiteTester.cc b/Geometry/HGCalGeometry/test/HGCalGeometryMouseBiteTester.cc index 9f280204b514a..c9a2945394f8b 100644 --- a/Geometry/HGCalGeometry/test/HGCalGeometryMouseBiteTester.cc +++ b/Geometry/HGCalGeometry/test/HGCalGeometryMouseBiteTester.cc @@ -59,7 +59,7 @@ void HGCalGeometryMouseBiteTester::analyze(const edm::Event&, const edm::EventSe int zside(1), layer(1), waferU(1), waferV(1); int types[] = {0, 1}; for (int type : types) { - int ncell = (type == 0) ? HGCSiliconDetId::HGCalFineN : HGCSiliconDetId::HGCalCoarseN; + int ncell = (type == 0) ? HGCSiliconDetId::HGCalHighDensityN : HGCSiliconDetId::HGCalLowDensityN; edm::LogVerbatim("HGCalGeomX") << "zside " << zside << " layer " << layer << " wafer " << waferU << ":" << waferV << " type " << type << " cells " << ncell; for (int u = 0; u < 2 * ncell; ++u) { From 226996bd6dc003f890f48f8fc2d74ee0ac5d7023 Mon Sep 17 00:00:00 2001 From: Sunanda Date: Mon, 6 Nov 2023 11:12:37 +0100 Subject: [PATCH 2/2] Code check --- .../ForwardDetId/interface/HGCSiliconDetId.h | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/DataFormats/ForwardDetId/interface/HGCSiliconDetId.h b/DataFormats/ForwardDetId/interface/HGCSiliconDetId.h index 175dcf4d15dcd..0894769356cd1 100644 --- a/DataFormats/ForwardDetId/interface/HGCSiliconDetId.h +++ b/DataFormats/ForwardDetId/interface/HGCSiliconDetId.h @@ -37,8 +37,14 @@ class HGCSiliconDetId : public DetId { /** Create cellid from raw id (0=invalid tower id) */ constexpr HGCSiliconDetId(uint32_t rawid) : DetId(rawid) {} /** Constructor from subdetector, zplus, layer, module, cell numbers */ - constexpr HGCSiliconDetId( - DetId::Detector det, int32_t zp, int32_t type, int32_t layer, int32_t waferU, int32_t waferV, int32_t cellU, int32_t cellV) + constexpr HGCSiliconDetId(DetId::Detector det, + int32_t zp, + int32_t type, + int32_t layer, + int32_t waferU, + int32_t waferV, + int32_t cellU, + int32_t cellV) : DetId(det, ForwardEmpty) { int32_t waferUabs(std::abs(waferU)), waferVabs(std::abs(waferV)); int32_t waferUsign = (waferU >= 0) ? 0 : 1; @@ -91,7 +97,10 @@ class HGCSiliconDetId : public DetId { constexpr int32_t type() const { return (id_ >> kHGCalTypeOffset) & kHGCalTypeMask; } constexpr bool lowDensity() const { return ((type() == HGCalCoarseThin) || (type() == HGCalCoarseThick)); } constexpr bool highDensity() const { return ((type() == HGCalFine) || (type() == HGCalFineThick)); } - constexpr int32_t depletion() const { return ((type() == HGCalFine) ? HGCal0Depletion : ((type() == HGCalCoarseThick) ? HGCal2Depletion : HGCal1Depletion)); } + constexpr int32_t depletion() const { + return ((type() == HGCalFine) ? HGCal0Depletion + : ((type() == HGCalCoarseThick) ? HGCal2Depletion : HGCal1Depletion)); + } /// get the z-side of the cell (1/-1) constexpr int32_t zside() const { return (((id_ >> kHGCalZsideOffset) & kHGCalZsideMask) ? -1 : 1); } @@ -126,7 +135,8 @@ class HGCSiliconDetId : public DetId { constexpr int32_t waferX() const { return (-2 * waferU() + waferV()); } constexpr int32_t waferY() const { return (2 * waferV()); } constexpr std::pair waferXY() const { return std::pair(waferX(), waferY()); } - constexpr void unpack(int32_t& ty, int32_t& zs, int32_t& ly, int32_t& wU, int32_t& wV, int32_t& cU, int32_t& cV) const { + constexpr void unpack( + int32_t& ty, int32_t& zs, int32_t& ly, int32_t& wU, int32_t& wV, int32_t& cU, int32_t& cV) const { ty = type(); zs = zside(); ly = layer(); @@ -151,7 +161,9 @@ class HGCSiliconDetId : public DetId { ? cellV() / NT : ((cellU() < N && cellU() <= cellV()) ? ((cellV() - cellU()) / NT + cellU() / NT) : cellV() / NT); } - constexpr std::pair triggerCellUV() const { return std::pair(triggerCellU(), triggerCellV()); } + constexpr std::pair triggerCellUV() const { + return std::pair(triggerCellU(), triggerCellV()); + } /// consistency check : no bits left => no overhead constexpr bool isEE() const { return (det() == HGCalEE); }