From e663d0065628b8e245fe2f23da4c6a3f6137600e Mon Sep 17 00:00:00 2001 From: Sunanda Date: Mon, 26 Jun 2023 15:19:08 +0200 Subject: [PATCH 1/2] Try to fix the issue of Layer 0 weight in HCAL in the version 13_0_X - bacport of #42083 --- .../interface/HcalDDDRecConstants.h | 1 + .../interface/HcalHitRelabeller.h | 3 +-- .../HcalCommonData/src/HcalDDDRecConstants.cc | 19 +++++++++++++++++++ .../HcalCommonData/src/HcalHitRelabeller.cc | 2 +- 4 files changed, 22 insertions(+), 3 deletions(-) diff --git a/Geometry/HcalCommonData/interface/HcalDDDRecConstants.h b/Geometry/HcalCommonData/interface/HcalDDDRecConstants.h index 1cd7a60e3b103..070152daa23aa 100644 --- a/Geometry/HcalCommonData/interface/HcalDDDRecConstants.h +++ b/Geometry/HcalCommonData/interface/HcalDDDRecConstants.h @@ -61,6 +61,7 @@ class HcalDDDRecConstants { return gcons; } } + int findDepth(const int& det, const int& eta, const int& phi, const int& zside, const int& lay) const; std::vector getDepth(const int& det, const int& phi, const int& zside, const unsigned int& eta) const; std::vector getDepth(const unsigned int& eta, const bool& extra) const; int getDepthEta16(const int& det, const int& iphi, const int& zside) const { diff --git a/Geometry/HcalCommonData/interface/HcalHitRelabeller.h b/Geometry/HcalCommonData/interface/HcalHitRelabeller.h index f4a166dafd891..c13346197a2e2 100644 --- a/Geometry/HcalCommonData/interface/HcalHitRelabeller.h +++ b/Geometry/HcalCommonData/interface/HcalHitRelabeller.h @@ -14,10 +14,9 @@ class HcalHitRelabeller { void setGeometry(const HcalDDDRecConstants*&); DetId relabel(const uint32_t testId) const; static DetId relabel(const uint32_t testId, const HcalDDDRecConstants* theRecNumber); - -private: double energyWt(const uint32_t testId) const; +private: const HcalDDDRecConstants* theRecNumber; bool neutralDensity_; }; diff --git a/Geometry/HcalCommonData/src/HcalDDDRecConstants.cc b/Geometry/HcalCommonData/src/HcalDDDRecConstants.cc index 773b325b54fce..4ee9d2c6b0d0c 100644 --- a/Geometry/HcalCommonData/src/HcalDDDRecConstants.cc +++ b/Geometry/HcalCommonData/src/HcalDDDRecConstants.cc @@ -7,6 +7,7 @@ #include "CLHEP/Units/GlobalSystemOfUnits.h" #include #include +#include //#define EDM_ML_DEBUG using namespace geant_units::operators; @@ -27,6 +28,24 @@ HcalDDDRecConstants::~HcalDDDRecConstants() { #endif } +int HcalDDDRecConstants::findDepth( + const int& det, const int& eta, const int& phi, const int& zside, const int& lay) const { + int depth = hcons.findDepth(det, eta, phi, zside, lay); + if (depth < 0) { + std::vector depths = getDepth(eta, false); + if ((lay > 0) && (lay <= static_cast(depths.size()))) + depth = depths[lay - 1]; +#ifdef EDM_ML_DEBUG + std::ostringstream st1; + st1 << depths.size() << " depths "; + for (const auto& d : depths) + st1 << ": " << d; + edm::LogVerbatim("HCalGeom") << "HcalDDDRecConstants:: " << st1.str() << " for eta = " << eta << " Depth " << depth; +#endif + } + return depth; +} + std::vector HcalDDDRecConstants::getDepth(const unsigned int& eta, const bool& extra) const { if (!extra) { std::vector::const_iterator last = hpar->layerGroupEtaRec.begin(); diff --git a/Geometry/HcalCommonData/src/HcalHitRelabeller.cc b/Geometry/HcalCommonData/src/HcalHitRelabeller.cc index 34929db5fcaff..8c3bf1e6c7df6 100644 --- a/Geometry/HcalCommonData/src/HcalHitRelabeller.cc +++ b/Geometry/HcalCommonData/src/HcalHitRelabeller.cc @@ -89,7 +89,7 @@ double HcalHitRelabeller::energyWt(const uint32_t testId) const { int det, z, depth, eta, phi, layer; HcalTestNumbering::unpackHcalIndex(testId, det, z, depth, eta, phi, layer); int zside = (z == 0) ? (-1) : (1); - double wt = (((det == 1) || (det == 2)) && (depth == 1)) ? theRecNumber->getLayer0Wt(det, phi, zside) : 1.0; + double wt = (((det == 1) || (det == 2)) && (layer <= 1)) ? theRecNumber->getLayer0Wt(det, phi, zside) : 1.0; #ifdef EDM_ML_DEBUG edm::LogVerbatim("HcalSim") << "EnergyWT::det: " << det << " z: " << z << ":" << zside << " depth: " << depth << " ieta: " << eta << " iphi: " << phi << " layer: " << layer << " wt " << wt; From f6327794973cd18d2611c38031030868049ef475 Mon Sep 17 00:00:00 2001 From: Sunanda Date: Tue, 27 Jun 2023 07:15:59 +0200 Subject: [PATCH 2/2] A fix --- Geometry/HcalCommonData/src/HcalHitRelabeller.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Geometry/HcalCommonData/src/HcalHitRelabeller.cc b/Geometry/HcalCommonData/src/HcalHitRelabeller.cc index 8c3bf1e6c7df6..41fdc015925ed 100644 --- a/Geometry/HcalCommonData/src/HcalHitRelabeller.cc +++ b/Geometry/HcalCommonData/src/HcalHitRelabeller.cc @@ -89,7 +89,9 @@ double HcalHitRelabeller::energyWt(const uint32_t testId) const { int det, z, depth, eta, phi, layer; HcalTestNumbering::unpackHcalIndex(testId, det, z, depth, eta, phi, layer); int zside = (z == 0) ? (-1) : (1); - double wt = (((det == 1) || (det == 2)) && (layer <= 1)) ? theRecNumber->getLayer0Wt(det, phi, zside) : 1.0; + double wt = ((((det == 1) && (layer <= 1)) || ((det == 2) && (layer <= 2))) && (depth == 1)) + ? theRecNumber->getLayer0Wt(det, phi, zside) + : 1.0; #ifdef EDM_ML_DEBUG edm::LogVerbatim("HcalSim") << "EnergyWT::det: " << det << " z: " << z << ":" << zside << " depth: " << depth << " ieta: " << eta << " iphi: " << phi << " layer: " << layer << " wt " << wt;