Skip to content

Commit 7d99d30

Browse files
authored
Merge pull request cms-sw#43194 from bsunanda/Phase2-hgx348B
Phase2-hgx348B Take care of handling both HGCal and HFNose access to Geometry and Topology classes
2 parents dd8547a + 22b5a7b commit 7d99d30

File tree

3 files changed

+47
-21
lines changed

3 files changed

+47
-21
lines changed

Geometry/CaloTopology/src/HGCalTopology.cc

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#include "DataFormats/ForwardDetId/interface/ForwardSubdetector.h"
12
#include "DataFormats/ForwardDetId/interface/HFNoseDetId.h"
23
#include "DataFormats/ForwardDetId/interface/HGCalDetId.h"
34
#include "DataFormats/ForwardDetId/interface/HGCSiliconDetId.h"
@@ -25,7 +26,7 @@ HGCalTopology::HGCalTopology(const HGCalDDDConstants& hdcons, int det) : hdcons_
2526
subdet_ = (ForwardSubdetector)(det);
2627
kHGeomHalf_ = sectors_ * layers_;
2728
types_ = 2;
28-
} else if (det == (int)(DetId::Forward)) {
29+
} else if (det == static_cast<int>(DetId::Forward)) {
2930
det_ = DetId::Forward;
3031
subdet_ = HFNose;
3132
kHGeomHalf_ = sectors_ * layers_;
@@ -389,8 +390,8 @@ uint32_t HGCalTopology::detId2denseId(const DetId& idin) const {
389390
DetId HGCalTopology::denseId2detId(uint32_t hi) const {
390391
HGCalTopology::DecodedDetId id;
391392
if (validHashIndex(hi)) {
392-
id.zSide = ((int)(hi) < kHGhalfType_ ? -1 : 1);
393-
int di = ((int)(hi) % kHGhalfType_);
393+
id.zSide = (static_cast<int>(hi) < kHGhalfType_ ? -1 : 1);
394+
int di = (static_cast<int>(hi) % kHGhalfType_);
394395
if (waferHexagon6()) {
395396
int type = (di % types_);
396397
id.iType = (type == 0 ? -1 : 1);
@@ -466,8 +467,8 @@ bool HGCalTopology::valid(const DetId& idin) const {
466467
HGCalTopology::DecodedDetId id = decode(idin);
467468
bool flag;
468469
if (waferHexagon6()) {
469-
flag = (idin.det() == det_ && idin.subdetId() == (int)(subdet_) && id.iCell1 >= 0 && id.iCell1 < cells_ &&
470-
id.iLay > 0 && id.iLay <= layers_ && id.iSec1 >= 0 && id.iSec1 <= sectors_);
470+
flag = (idin.det() == det_ && idin.subdetId() == static_cast<int>(subdet_) && id.iCell1 >= 0 &&
471+
id.iCell1 < cells_ && id.iLay > 0 && id.iLay <= layers_ && id.iSec1 >= 0 && id.iSec1 <= sectors_);
471472
if (flag)
472473
flag = hdcons_.isValidHex(id.iLay, id.iSec1, id.iCell1, true);
473474
} else if (tileTrapezoid()) {
@@ -503,7 +504,7 @@ bool HGCalTopology::validModule(const DetId& idin, int cornerMin) const {
503504
}
504505

505506
DetId HGCalTopology::offsetBy(const DetId startId, int nrStepsX, int nrStepsY) const {
506-
if (startId.det() == DetId::Forward && startId.subdetId() == (int)(subdet_)) {
507+
if (startId.det() == DetId::Forward && startId.subdetId() == static_cast<int>(subdet_)) {
507508
DetId id = changeXY(startId, nrStepsX, nrStepsY);
508509
if (valid(id))
509510
return id;
@@ -524,8 +525,8 @@ DetId HGCalTopology::switchZSide(const DetId startId) const {
524525
HGCalTopology::DecodedDetId HGCalTopology::geomDenseId2decId(const uint32_t& hi) const {
525526
HGCalTopology::DecodedDetId id;
526527
if (hi < totalGeomModules()) {
527-
id.zSide = ((int)(hi) < kHGeomHalf_ ? -1 : 1);
528-
int di = ((int)(hi) % kHGeomHalf_);
528+
id.zSide = (static_cast<int>(hi) < kHGeomHalf_ ? -1 : 1);
529+
int di = (static_cast<int>(hi) % kHGeomHalf_);
529530
if (waferHexagon6()) {
530531
id.iSec1 = (di % sectors_);
531532
di = (di - id.iSec1) / sectors_;
@@ -582,8 +583,13 @@ void HGCalTopology::addHGCSiliconId(
582583
<< hdcons_.isValidHex8(lay, waferU, waferV, cellU, cellV, false);
583584
#endif
584585
if (hdcons_.isValidHex8(lay, waferU, waferV, cellU, cellV, false)) {
585-
HGCSiliconDetId id((DetId::Detector)(det), zside, type, lay, waferU, waferV, cellU, cellV);
586-
ids.emplace_back(DetId(id));
586+
if (det == static_cast<int>(ForwardSubdetector::HFNose)) {
587+
HFNoseDetId id(DetId::Forward, zside, type, lay, waferU, waferV, cellU, cellV);
588+
ids.emplace_back(DetId(id));
589+
} else {
590+
HGCSiliconDetId id((DetId::Detector)(det), zside, type, lay, waferU, waferV, cellU, cellV);
591+
ids.emplace_back(DetId(id));
592+
}
587593
}
588594
}
589595

@@ -608,7 +614,7 @@ HGCalTopology::DecodedDetId HGCalTopology::decode(const DetId& startId) const {
608614
idx.iSec2 = 0;
609615
idx.iType = id.type();
610616
idx.zSide = id.zside();
611-
idx.det = (int)(id.subdet());
617+
idx.det = static_cast<int>(id.subdet());
612618
} else if (det_ == DetId::Forward && subdet_ == ForwardSubdetector::HFNose) {
613619
HFNoseDetId id(startId);
614620
idx.iCell1 = id.cellU();
@@ -618,7 +624,7 @@ HGCalTopology::DecodedDetId HGCalTopology::decode(const DetId& startId) const {
618624
idx.iSec2 = id.waferV();
619625
idx.iType = id.type();
620626
idx.zSide = id.zside();
621-
idx.det = (int)(id.subdet());
627+
idx.det = static_cast<int>(id.subdet());
622628
} else {
623629
HGCSiliconDetId id(startId);
624630
idx.iCell1 = id.cellU();
@@ -628,7 +634,7 @@ HGCalTopology::DecodedDetId HGCalTopology::decode(const DetId& startId) const {
628634
idx.iSec2 = id.waferV();
629635
idx.iType = id.type();
630636
idx.zSide = id.zside();
631-
idx.det = (int)(id.subdet());
637+
idx.det = static_cast<int>(id.subdet());
632638
}
633639
return idx;
634640
}

Geometry/CaloTopology/test/HGCalTopologyTester.cc

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "Geometry/Records/interface/IdealGeometryRecord.h"
1616
#include "Geometry/HGCalCommonData/interface/HGCalDDDConstants.h"
1717
#include "Geometry/CaloTopology/interface/HGCalTopology.h"
18+
#include "DataFormats/ForwardDetId/interface/HFNoseDetId.h"
1819
#include "DataFormats/ForwardDetId/interface/HGCScintillatorDetId.h"
1920
#include "DataFormats/ForwardDetId/interface/HGCSiliconDetId.h"
2021

@@ -73,7 +74,9 @@ void HGCalTopologyTester::doTest(const HGCalTopology& topology) {
7374
if (topology.waferHexagon8() || topology.tileTrapezoid()) {
7475
for (unsigned int i = 0; i < type_.size(); ++i) {
7576
DetId id;
76-
if (detectorName_ == "HGCalEESensitive") {
77+
if (topology.isHFNose()) {
78+
id = HFNoseDetId(1, type_[i], layer_[i], sec1_[i], sec2_[i], cell1_[i], cell2_[i]);
79+
} else if (detectorName_ == "HGCalEESensitive") {
7780
id = HGCSiliconDetId(DetId::HGCalEE, 1, type_[i], layer_[i], sec1_[i], sec2_[i], cell1_[i], cell2_[i]);
7881
} else if (detectorName_ == "HGCalHESiliconSensitive") {
7982
id = HGCSiliconDetId(DetId::HGCalHSi, 1, type_[i], layer_[i], sec1_[i], sec2_[i], cell1_[i], cell2_[i]);
@@ -84,7 +87,13 @@ void HGCalTopologyTester::doTest(const HGCalTopology& topology) {
8487
}
8588
std::vector<DetId> ids = topology.neighbors(id);
8689
unsigned int k(0);
87-
if (id.det() == DetId::HGCalEE || id.det() == DetId::HGCalHSi) {
90+
if (topology.isHFNose()) {
91+
edm::LogVerbatim("HGCalGeom") << (HFNoseDetId)(id) << " has " << ids.size() << " neighbours:";
92+
for (const auto& idn : ids) {
93+
edm::LogVerbatim("HGCalGeom") << "[" << k << "] " << (HFNoseDetId)(idn);
94+
++k;
95+
}
96+
} else if (id.det() == DetId::HGCalEE || id.det() == DetId::HGCalHSi) {
8897
edm::LogVerbatim("HGCalGeom") << (HGCSiliconDetId)(id) << " has " << ids.size() << " neighbours:";
8998
for (const auto& idn : ids) {
9099
edm::LogVerbatim("HGCalGeom") << "[" << k << "] " << (HGCSiliconDetId)(idn);

Geometry/HGCalGeometry/src/HGCalGeometry.cc

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,10 @@ void HGCalGeometry::newCell(
7373
} else {
7474
cells = m_topology.dddConstants().numberCellsHexagon(id.iLay, id.iSec1, id.iSec2, false);
7575
#ifdef EDM_ML_DEBUG
76-
edm::LogVerbatim("HGCalGeom") << "NewCell " << HGCSiliconDetId(detId) << " GEOM " << HGCSiliconDetId(geomId);
76+
if (detId.det() == DetId::Forward)
77+
edm::LogVerbatim("HGCalGeom") << "NewCell " << HFNoseDetId(detId) << " GEOM " << HFNoseDetId(geomId);
78+
else
79+
edm::LogVerbatim("HGCalGeom") << "NewCell " << HGCSiliconDetId(detId) << " GEOM " << HGCSiliconDetId(geomId);
7780
#endif
7881
}
7982
const uint32_t cellIndex(m_topology.detId2denseGeomId(geomId));
@@ -136,7 +139,10 @@ void HGCalGeometry::newCell(
136139
m_validIds.emplace_back(idc);
137140
#ifdef EDM_ML_DEBUG
138141
++cellSelect;
139-
edm::LogVerbatim("HGCalGeom") << "Valid Id [" << u << ", " << v << "] " << HGCSiliconDetId(idc);
142+
if (idc.det() == DetId::Forward)
143+
edm::LogVerbatim("HGCalGeom") << "Valid Id [" << u << ", " << v << "] " << HFNoseDetId(idc);
144+
else
145+
edm::LogVerbatim("HGCalGeom") << "Valid Id [" << u << ", " << v << "] " << HGCSiliconDetId(idc);
140146
#endif
141147
}
142148
}
@@ -217,10 +223,15 @@ GlobalPoint HGCalGeometry::getPosition(const DetId& detid, bool debug) const {
217223
<< lcoord.y() << " ID " << id.iLay << ":" << id.iSec1 << ":" << id.iCell1
218224
<< " Global " << glob;
219225
} else {
220-
if (debug)
221-
edm::LogVerbatim("HGCalGeom") << "getPosition for " << HGCSiliconDetId(detid) << " Layer " << id.iLay
222-
<< " Wafer " << id.iSec1 << ":" << id.iSec2 << " Cell " << id.iCell1 << ":"
223-
<< id.iCell2;
226+
if (debug) {
227+
if (detid.det() == DetId::Forward)
228+
edm::LogVerbatim("HGCalGeom") << "getPosition for " << HFNoseDetId(detid) << " Layer " << id.iLay << " Wafer "
229+
<< id.iSec1 << ":" << id.iSec2 << " Cell " << id.iCell1 << ":" << id.iCell2;
230+
else
231+
edm::LogVerbatim("HGCalGeom") << "getPosition for " << HGCSiliconDetId(detid) << " Layer " << id.iLay
232+
<< " Wafer " << id.iSec1 << ":" << id.iSec2 << " Cell " << id.iCell1 << ":"
233+
<< id.iCell2;
234+
}
224235
xy = m_topology.dddConstants().locateCell(
225236
id.zSide, id.iLay, id.iSec1, id.iSec2, id.iCell1, id.iCell2, true, true, false, debug);
226237
double xx = id.zSide * xy.first;

0 commit comments

Comments
 (0)