From 7d73be1d47ff7913a2e42d9f21ffa848a837ca3f Mon Sep 17 00:00:00 2001 From: Sunanda Date: Thu, 29 Jun 2023 13:25:57 +0200 Subject: [PATCH] Fix the remaining issue of ieta=18 and ieta=15 towers in layer=2 of HCAL - backport of #42130to CMSSW version 13_1_X --- .../HcalCommonData/src/HcalHitRelabeller.cc | 57 +++++++++++-------- 1 file changed, 32 insertions(+), 25 deletions(-) diff --git a/Geometry/HcalCommonData/src/HcalHitRelabeller.cc b/Geometry/HcalCommonData/src/HcalHitRelabeller.cc index 41fdc015925ed..b1ff33cb843fa 100644 --- a/Geometry/HcalCommonData/src/HcalHitRelabeller.cc +++ b/Geometry/HcalCommonData/src/HcalHitRelabeller.cc @@ -23,19 +23,26 @@ void HcalHitRelabeller::process(std::vector& hcalHits) { edm::LogVerbatim("HcalSim") << "Hit[" << ii << "] " << std::hex << hcalHit.id() << std::dec << " Neutral density " << neutralDensity_; #endif - double energy = (hcalHit.energy()); - if (neutralDensity_) { - energy *= (energyWt(hcalHit.id())); - hcalHit.setEnergy(energy); - } - DetId newid = relabel(hcalHit.id()); + uint32_t hid; + int det, z, depth, eta, phi, layer; + HcalTestNumbering::unpackHcalIndex(hcalHit.id(), det, z, depth, eta, phi, layer); + if ((det == 2) && (layer == 2) && (eta == 18)) + depth = 2; + hid = HcalTestNumbering::packHcalIndex(det, z, depth, eta, phi, layer); + double wt = (neutralDensity_) ? (energyWt(hid)) : 1.0; + double energy = wt * (hcalHit.energy()); + hcalHit.setEnergy(energy); + uint32_t newid = relabel(hid).rawId(); #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HcalSim") << "Hit " << ii << " out of " << hcalHits.size() << " " << std::hex << newid.rawId() - << std::dec << " E " << energy; + edm::LogVerbatim("HcalSim") << "Hit " << ii << " out of " << hcalHits.size() << " " << std::hex << newid + << std::dec << " E " << energy << " wt " << wt; #endif - hcalHit.setID(newid.rawId()); + hcalHit.setID(newid); #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HcalSim") << "Modified Hit " << HcalDetId(hcalHit.id()); + edm::LogVerbatim("HcalSim") << "Final Setting::subdet: " << HcalDetId(newid).subdet() + << " z: " << HcalDetId(newid).zside() << " depth: " << HcalDetId(newid).depth() + << " ieta: " << HcalDetId(newid).ietaAbs() << " iphi: " << HcalDetId(newid).iphi() + << " wt " << wt; ++ii; #endif } @@ -57,30 +64,30 @@ DetId HcalHitRelabeller::relabel(const uint32_t testId, const HcalDDDRecConstant HcalDetId hid; int det, z, depth, eta, phi, layer, sign; HcalTestNumbering::unpackHcalIndex(testId, det, z, depth, eta, phi, layer); -#ifdef EDM_ML_DEBUG - edm::LogVerbatim("HcalSim") << "det: " << det << " " - << "z: " << z << " " - << "depth: " << depth << " " - << "ieta: " << eta << " " - << "iphi: " << phi << " " - << "layer: " << layer; -#endif + sign = (z == 0) ? (-1) : (1); HcalDDDRecConstants::HcalID id = theRecNumber->getHCID(det, sign * eta, phi, layer, depth); + int depth0 = ((det == 1) && (layer == 2) && (eta == 15)) ? depth : id.depth; if (id.subdet == int(HcalBarrel)) { - hid = HcalDetId(HcalBarrel, sign * id.eta, id.phi, id.depth); + hid = HcalDetId(HcalBarrel, sign * id.eta, id.phi, depth0); } else if (id.subdet == int(HcalEndcap)) { - hid = HcalDetId(HcalEndcap, sign * id.eta, id.phi, id.depth); + hid = HcalDetId(HcalEndcap, sign * id.eta, id.phi, depth0); } else if (id.subdet == int(HcalOuter)) { - hid = HcalDetId(HcalOuter, sign * id.eta, id.phi, id.depth); + hid = HcalDetId(HcalOuter, sign * id.eta, id.phi, depth0); } else if (id.subdet == int(HcalForward)) { - hid = HcalDetId(HcalForward, sign * id.eta, id.phi, id.depth); + hid = HcalDetId(HcalForward, sign * id.eta, id.phi, depth0); } #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HcalSim") << " new HcalDetId -> hex.RawID = " << std::hex << hid.rawId() << std::dec - << " det, z, depth, eta, phi = " << det << " " << z << " " << id.depth << " " << id.eta - << " " << id.phi << " ---> " << hid; + edm::LogVerbatim("HcalSim") << "Initial indices:" + << "subdet: " << det << " " + << "z: " << z << " " + << "depth: " << depth << " " + << "ieta: " << eta << " " + << "iphi: " << phi << " " + << "layer: " << layer << " new HcalDetId -> hex.RawID = " << std::hex << hid.rawId() + << std::dec << " subdet, z, depth, eta, phi = " << det << " " << z << " " << id.depth + << " " << id.eta << " " << id.phi << " ---> " << hid; #endif return hid; }