Skip to content

Commit

Permalink
Merge pull request #20976 from bsunanda/Run2-hcx159
Browse files Browse the repository at this point in the history
Run2-hcx159 Correct bug affecting several special cases for getPosition and getClosestCell
  • Loading branch information
cmsbuild committed Oct 26, 2017
2 parents 3759f24 + 6c7804a commit 81abab0
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 28 deletions.
21 changes: 14 additions & 7 deletions Geometry/CaloTopology/src/HcalTopology.cc
Expand Up @@ -713,15 +713,17 @@ void HcalTopology::depthBinInformation(HcalSubdetector subdet, int etaRing,
bool HcalTopology::incrementDepth(HcalDetId & detId) const {

HcalSubdetector subdet = detId.subdet();
int ieta = detId.ieta();
int ieta = detId.ieta();
int etaRing = detId.ietaAbs();
int depth = detId.depth();
int depth = detId.depth();
int iphi = detId.iphi();
int zside = detId.zside();
int nDepthBins, startingBin;
depthBinInformation(subdet, etaRing, detId.iphi(), detId.zside(), nDepthBins, startingBin);
depthBinInformation(subdet, etaRing, iphi, zside, nDepthBins, startingBin);

// see if the new depth bin exists
++depth;
if (depth > nDepthBins) {
if (depth >= (startingBin+nDepthBins)) {
// handle on a case-by-case basis
if (subdet == HcalBarrel && etaRing < lastHORing()) {
// HO
Expand All @@ -730,6 +732,8 @@ bool HcalTopology::incrementDepth(HcalDetId & detId) const {
} else if (subdet == HcalBarrel && etaRing == lastHBRing()) {
// overlap
subdet = HcalEndcap;
if (mode_==HcalTopologyMode::SLHC || mode_==HcalTopologyMode::H2HE)
depth = hcons_->getDepthEta16(2,iphi,zside);
} else if (subdet == HcalEndcap && etaRing == lastHERing()-1 &&
mode_ != HcalTopologyMode::SLHC) {
// guard ring HF29 is behind HE 28
Expand All @@ -746,7 +750,7 @@ bool HcalTopology::incrementDepth(HcalDetId & detId) const {
return false;
}
}
detId = HcalDetId(subdet, ieta, detId.iphi(), depth);
detId = HcalDetId(subdet, ieta, iphi, depth);
return validRaw(detId);
}

Expand All @@ -755,8 +759,10 @@ bool HcalTopology::decrementDepth(HcalDetId & detId) const {
int ieta = detId.ieta();
int etaRing = detId.ietaAbs();
int depth = detId.depth();
int iphi = detId.iphi();
int zside = detId.zside();
int nDepthBins, startingBin;
depthBinInformation(subdet, etaRing, detId.iphi(), detId.zside(), nDepthBins, startingBin);
depthBinInformation(subdet, etaRing, iphi, zside, nDepthBins, startingBin);

// see if the new depth bin exists
--depth;
Expand All @@ -769,7 +775,8 @@ bool HcalTopology::decrementDepth(HcalDetId & detId) const {
break;
}
}
} else if (subdet == HcalEndcap && etaRing == lastHERing() && depth == 2 &&
} else if (subdet == HcalEndcap && etaRing == lastHERing() &&
depth == hcons_->getDepthEta29(iphi,zside,0) &&
mode_ != HcalTopologyMode::SLHC) {
(ieta > 0) ? --ieta : ++ieta;
} else if (depth <= 0) {
Expand Down
2 changes: 2 additions & 0 deletions Geometry/HcalCommonData/interface/HcalDDDRecConstants.h
Expand Up @@ -68,6 +68,8 @@ class HcalDDDRecConstants {
std::vector<int> getDepth(const unsigned int& eta, const bool& extra) const;
int getDepthEta16(const int& det, const int& iphi,
const int& zside) const {return hcons.getDepthEta16(det,iphi,zside);}
int getDepthEta29(const int& iphi, const int& zside,
const int& type) const {return hcons.getDepthEta29(iphi,zside,type);}
std::vector<HcalEtaBin> getEtaBins(const int& itype) const;
std::pair<double,double> getEtaPhi(const int& subdet, const int& ieta, const int& iphi) const;
std::pair<int,int> getEtaRange(const int& i) const
Expand Down
39 changes: 21 additions & 18 deletions Geometry/HcalTowerAlgo/src/HcalFlexiHardcodeGeometryLoader.cc
Expand Up @@ -79,12 +79,12 @@ std::vector<HcalFlexiHardcodeGeometryLoader::HBHOCellParameters> HcalFlexiHardco
double rmax = gconsHB[layl].first+gconsHB[layl].second;
for (unsigned int j=0; j<etabin.phis.size(); ++j) {
#ifdef EDM_ML_DEBUG
std::cout << "HBRing " << iring << " eta " << etabins[i].etaMin << ":"
<< etabins[i].etaMax << " depth " << depth << " R " << rmin
<< ":" << rmax << " Phi " << etabins[i].phis[j].first << ":"
<< etabins[i].phis[j].second << ":" << dphi << " layer[" << k
<< "]: " << etabins[i].layer[k].first-1 << ":"
<< etabins[i].layer[k].second << std::endl;
std::cout << "HBRing " << iring << " eta " << etabin.etaMin << ":"
<< etabin.etaMax << " depth " << depth << " R " << rmin
<< ":" << rmax << " Phi " << etabin.phis[j].first << ":"
<< etabin.phis[j].second << ":" << dphi << " layer[" << k
<< "]: " << etabin.layer[k].first-1 << ":"
<< etabin.layer[k].second << std::endl;
#endif
result.emplace_back (HcalFlexiHardcodeGeometryLoader::HBHOCellParameters(iring, depth, etabin.phis[j].first, etabin.phis[j].second, dphi, rmin, rmax, etabin.etaMin, etabin.etaMax));
}
Expand Down Expand Up @@ -191,10 +191,13 @@ std::vector<HcalFlexiHardcodeGeometryLoader::HECellParameters> HcalFlexiHardcode
(etabin.phis[1].second-etabin.phis[0].second) :
((2.0*M_PI)/MAX_HCAL_PHI);
#ifdef EDM_ML_DEBUG
std::cout << "FlexiGeometryLoader::Ring " << iring << " nphi " << nphi
<< " dstart " << depth << " dphi " << dphi << " units "
<< units << " fioff " << fioff << " layers "
<< etabins[i].layer.size() << std::endl;
std::cout << "FlexiGeometryLoader::Ring " << iring << " nphi "
<< etabin.phis.size() << " dstart " << depth << " dphi "
<< dphi << " layers "<< etabin.layer.size() << std::endl;
for (unsigned int j=0; j<etabin.phis.size(); ++j)
std::cout << " [" << j << "] " << etabin.phis[j].first << ":"
<< etabin.phis[j].second;
std::cout << std::endl;
#endif
for (unsigned int k=0; k<etabin.layer.size(); ++k) {
int layf = etabin.layer[k].first-1;
Expand All @@ -212,12 +215,12 @@ std::vector<HcalFlexiHardcodeGeometryLoader::HECellParameters> HcalFlexiHardcode
if (zmin >= zmax) zmax = zmin+10.;
for (unsigned int j=0; j<etabin.phis.size(); ++j) {
#ifdef EDM_ML_DEBUG
std::cout << "HERing " << iring << " eta " << etabins[i].etaMin << ":"
<< etabins[i].etaMax << " depth " << depth << " Z " << zmin
<< ":" << zmax << " Phi :" << etabins[i].phis[j].first
<< ":" << etabins[i].phis[j].second << ":" << dphi
<< " layer[" << k << "]: " << etabins[i].layer[k].first-1
<< ":" << etabins[i].layer[k].second-1 << std::endl;
std::cout << "HERing " << iring << " eta " << etabin.etaMin << ":"
<< etabin.etaMax << " depth " << depth << " Z " << zmin
<< ":" << zmax << " Phi :" << etabin.phis[j].first
<< ":" << etabin.phis[j].second << ":" << dphi
<< " layer[" << k << "]: " << etabin.layer[k].first-1
<< ":" << etabin.layer[k].second-1 << std::endl;
#endif
result.emplace_back(HcalFlexiHardcodeGeometryLoader::HECellParameters(iring, depth, etabin.phis[j].first, etabin.phis[j].second, dphi, zmin, zmax, etabin.etaMin, etabin.etaMax));
}
Expand Down Expand Up @@ -296,10 +299,10 @@ void HcalFlexiHardcodeGeometryLoader::fillHE (HcalGeometry* fGeometry, const std
float phiCenter = param.phi; // middle of the cell
float etaCenter = 0.5 * (param.etaMin + param.etaMax);
int iside = (param.ieta >= 0) ? 1 : -1;
float perp = param.zMin / sinh (etaCenter);
float z = (isBH_) ? (iside*0.5*(param.zMin+param.zMax)) : (iside*param.zMin);
float perp = std::abs(z) / sinh (etaCenter);
float x = perp * cos (phiCenter);
float y = perp * sin (phiCenter);
float z = (isBH_) ? (iside*0.5*(param.zMin+param.zMax)) : (iside*param.zMin);
// make cell geometry
GlobalPoint refPoint (x,y,z); // center of the cell's face
std::vector<CCGFloat> cellParams;
Expand Down
13 changes: 10 additions & 3 deletions Geometry/HcalTowerAlgo/test/HcalGeometryTester.cc
Expand Up @@ -71,6 +71,7 @@ void HcalGeometryTester::analyze(const edm::Event& /*iEvent*/,
testTriggerGeometry(topology);

testClosestCells(geom, topology);

std::cout << "HcalGeometryTester::Test SLHC Hcal Geometry" << std::endl;
std::vector<int> dins;

Expand All @@ -80,6 +81,7 @@ void HcalGeometryTester::analyze(const edm::Event& /*iEvent*/,
testFlexiValidDetIds(geom, topology, DetId::Hcal, HcalForward," FORWARD ", dins );

testFlexiGeomHF(geom);

}

void HcalGeometryTester::testValidDetIds(CaloSubdetectorGeometry* caloGeom,
Expand Down Expand Up @@ -108,7 +110,7 @@ void HcalGeometryTester::testValidDetIds(CaloSubdetectorGeometry* caloGeom,
void HcalGeometryTester::testClosestCells(CaloSubdetectorGeometry* g,
const HcalTopology& topology ) {

// make sure each cel is its own closest cell
// make sure each cell is its own closest cell
HcalDetId barrelDet1(HcalBarrel, 1, 1, 1);
HcalDetId barrelDet2(HcalBarrel, 16, 50, 1);
HcalDetId endcapDet1(HcalEndcap, -17, 72, 1);
Expand All @@ -123,8 +125,13 @@ void HcalGeometryTester::testClosestCells(CaloSubdetectorGeometry* g,
if (topology.valid(forwardDet1)) testClosestCell(forwardDet1, g);
if (topology.valid(forwardDet3)) testClosestCell(forwardDet3, g);

const std::vector<DetId>& ids=g->getValidDetIds(DetId::Hcal,HcalBarrel);
for (auto id : ids) {
const std::vector<DetId>& idsb=g->getValidDetIds(DetId::Hcal,HcalBarrel);
for (auto id : idsb) {
testClosestCell(HcalDetId(id), g);
}

const std::vector<DetId>& idse=g->getValidDetIds(DetId::Hcal,HcalEndcap);
for (auto id : idse) {
testClosestCell(HcalDetId(id), g);
}
}
Expand Down
3 changes: 3 additions & 0 deletions Geometry/HcalTowerAlgo/test/runHcalGeometryTester_cfg.py
Expand Up @@ -2,6 +2,7 @@

process = cms.Process("HcalGeometryTest")

#process.load("Geometry.HcalCommonData.testGeometry17bXML_cfi")
process.load("Geometry.HcalCommonData.testPhase2GeometryFineXML_cfi")
process.load("Geometry.HcalCommonData.hcalDDConstants_cff")
process.load("Geometry.HcalEventSetup.hcalTopologyIdeal_cfi")
Expand All @@ -18,3 +19,5 @@
process.SimpleMemoryCheck = cms.Service("SimpleMemoryCheck")

process.p1 = cms.Path(process.hga)

process.hcalTopologyIdeal.MergePosition = False

0 comments on commit 81abab0

Please sign in to comment.