From 6fc8f831f3c8b22ce8c32689359aaf4b7047f501 Mon Sep 17 00:00:00 2001 From: Sunanda Date: Sat, 29 Oct 2022 08:02:29 +0200 Subject: [PATCH] Add protection to eta values for phase2 scenario Code check Bug fix Code check --- CondFormats/GeometryObjects/interface/HcalParameters.h | 5 +++-- Geometry/HcalCommonData/src/HcalDDDRecConstants.cc | 7 ++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/CondFormats/GeometryObjects/interface/HcalParameters.h b/CondFormats/GeometryObjects/interface/HcalParameters.h index 0695d25f6abc4..08f112be3b73f 100644 --- a/CondFormats/GeometryObjects/interface/HcalParameters.h +++ b/CondFormats/GeometryObjects/interface/HcalParameters.h @@ -5,8 +5,8 @@ class HcalParameters { public: - HcalParameters(void) {} - ~HcalParameters(void) {} + HcalParameters(void) = default; + ~HcalParameters(void) = default; struct LayerItem { unsigned int layer; @@ -63,6 +63,7 @@ class HcalParameters { std::vector layerGroupEtaSim, layerGroupEtaRec; int topologyMode; + uint32_t etaMaxHBHE() const { return static_cast(etagroup.size()); } COND_SERIALIZABLE; }; diff --git a/Geometry/HcalCommonData/src/HcalDDDRecConstants.cc b/Geometry/HcalCommonData/src/HcalDDDRecConstants.cc index 45b0e2080b938..773b325b54fce 100644 --- a/Geometry/HcalCommonData/src/HcalDDDRecConstants.cc +++ b/Geometry/HcalCommonData/src/HcalDDDRecConstants.cc @@ -160,8 +160,13 @@ std::pair HcalDDDRecConstants::getEtaPhi(const int& subdet, cons } HcalDDDRecConstants::HcalID HcalDDDRecConstants::getHCID(int subdet, int keta, int iphi, int lay, int idepth) const { - int ieta = (keta > 0) ? keta : -keta; + uint32_t ieta = (keta > 0) ? keta : -keta; int zside = (keta > 0) ? 1 : -1; + if ((ieta > hpar->etaMaxHBHE()) && + ((subdet == static_cast(HcalOuter)) || (subdet == static_cast(HcalBarrel)) || + (subdet == static_cast(HcalEndcap)))) + throw cms::Exception("HcalDDDRecConstants") + << "getHCID: receives an eta value " << ieta << " outside the limit (1:" << hpar->etaMaxHBHE() << ")"; int eta(ieta), phi(iphi), depth(idepth); if ((subdet == static_cast(HcalOuter)) || ((subdet == static_cast(HcalBarrel)) && (lay > maxLayerHB_ + 1))) {