Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Phase2-hgx256 Try to provide V14 geometry for HGCal #30862

Merged
merged 4 commits into from Jul 27, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 11 additions & 0 deletions Geometry/CaloTopology/interface/HGCalTopology.h
Expand Up @@ -121,6 +121,17 @@ class HGCalTopology : public CaloSubdetectorTopology {
return (((det_ == DetId::Forward) && (subdet_ == ForwardSubdetector::HFNose)) ? true : false);
}

bool tileTrapezoid() const {
return ((mode_ == HGCalGeometryMode::Trapezoid) || (mode_ == HGCalGeometryMode::TrapezoidFile));
}
bool waferHexagon6() const {
return ((mode_ == HGCalGeometryMode::Hexagon) || (mode_ == HGCalGeometryMode::HexagonFull));
}
bool waferHexagon8() const {
return ((mode_ == HGCalGeometryMode::Hexagon8) || (mode_ == HGCalGeometryMode::Hexagon8Full) ||
(mode_ == HGCalGeometryMode::Hexagon8File));
}

private:
/// add DetId of Scintillator and Silicon type if valid
void addHGCSCintillatorId(std::vector<DetId>& ids, int zside, int type, int lay, int iradius, int iphi) const;
Expand Down
41 changes: 20 additions & 21 deletions Geometry/CaloTopology/src/HGCalTopology.cc
Expand Up @@ -19,7 +19,7 @@ HGCalTopology::HGCalTopology(const HGCalDDDConstants& hdcons, int det) : hdcons_
waferMax_ = 2 * waferOff_ + 1;
kHGhalf_ = sectors_ * layers_ * cells_;
firstLay_ = hdcons_.firstLayer();
if ((mode_ == HGCalGeometryMode::Hexagon) || (mode_ == HGCalGeometryMode::HexagonFull)) {
if (waferHexagon6()) {
det_ = DetId::Forward;
subdet_ = (ForwardSubdetector)(det);
kHGeomHalf_ = sectors_ * layers_;
Expand All @@ -29,7 +29,7 @@ HGCalTopology::HGCalTopology(const HGCalDDDConstants& hdcons, int det) : hdcons_
subdet_ = HFNose;
kHGeomHalf_ = sectors_ * layers_;
types_ = 3;
} else if (mode_ == HGCalGeometryMode::Trapezoid) {
} else if (tileTrapezoid()) {
det_ = (DetId::Detector)(det);
subdet_ = ForwardEmpty;
kHGeomHalf_ = sectors_ * layers_ * cellMax_;
Expand All @@ -50,14 +50,13 @@ HGCalTopology::HGCalTopology(const HGCalDDDConstants& hdcons, int det) : hdcons_
}

unsigned int HGCalTopology::allGeomModules() const {
return ((mode_ == HGCalGeometryMode::Trapezoid) ? (unsigned int)(2 * hdcons_.numberCells(true))
: (unsigned int)(2 * hdcons_.wafers()));
return (tileTrapezoid() ? (unsigned int)(2 * hdcons_.numberCells(true)) : (unsigned int)(2 * hdcons_.wafers()));
}

std::vector<DetId> HGCalTopology::neighbors(const DetId& idin) const {
std::vector<DetId> ids;
HGCalTopology::DecodedDetId id = decode(idin);
if ((mode_ == HGCalGeometryMode::Hexagon8) || (mode_ == HGCalGeometryMode::Hexagon8Full)) {
if (waferHexagon8()) {
HGCalTypes::CellType celltype = hdcons_.cellType(id.iType, id.iCell1, id.iCell2);
#ifdef EDM_ML_DEBUG
edm::LogVerbatim("HGCalGeom") << "Type:WaferU:WaferV " << id.iType << ":" << id.iCell1 << ":" << id.iCell2
Expand Down Expand Up @@ -331,7 +330,7 @@ std::vector<DetId> HGCalTopology::neighbors(const DetId& idin) const {
<< ":" << (id.iCell2 > 2 * N - 1) << ":" << (id.iCell2 >= (id.iCell1 + N)) << ":"
<< (id.iCell1 > (id.iCell2 + N)) << " ERROR";
}
} else if (mode_ == HGCalGeometryMode::Trapezoid) {
} else if (tileTrapezoid()) {
int iphi1 = (id.iCell1 > 1) ? id.iCell1 - 1 : hdcons_.getUVMax(id.iType);
int iphi2 = (id.iCell1 < hdcons_.getUVMax(id.iType)) ? id.iCell1 + 1 : 1;
addHGCSCintillatorId(ids, id.zSide, id.iType, id.iLay, id.iSec1 - 1, id.iCell1);
Expand All @@ -349,7 +348,7 @@ std::vector<DetId> HGCalTopology::neighbors(const DetId& idin) const {
uint32_t HGCalTopology::detId2denseId(const DetId& idin) const {
HGCalTopology::DecodedDetId id = decode(idin);
uint32_t idx;
if ((mode_ == HGCalGeometryMode::Hexagon) || (mode_ == HGCalGeometryMode::HexagonFull)) {
if (waferHexagon6()) {
int type = (id.iType > 0) ? 1 : 0;
idx = (uint32_t)(((id.zSide > 0) ? kHGhalf_ : 0) +
((((id.iCell1 - 1) * layers_ + id.iLay - 1) * sectors_ + id.iSec1) * types_ + type));
Expand All @@ -358,7 +357,7 @@ uint32_t HGCalTopology::detId2denseId(const DetId& idin) const {
<< ":" << id.iType << " Constants " << kHGeomHalf_ << ":" << layers_ << ":"
<< sectors_ << ":" << types_ << " o/p " << idx;
#endif
} else if (mode_ == HGCalGeometryMode::Trapezoid) {
} else if (tileTrapezoid()) {
idx =
(uint32_t)(((id.zSide > 0) ? kHGhalf_ : 0) +
((((id.iCell1 - 1) * layers_ + id.iLay - firstLay_) * sectors_ + id.iSec1 - 1) * types_ + id.iType));
Expand Down Expand Up @@ -390,7 +389,7 @@ DetId HGCalTopology::denseId2detId(uint32_t hi) const {
if (validHashIndex(hi)) {
id.zSide = ((int)(hi) < kHGhalf_ ? -1 : 1);
int di = ((int)(hi) % kHGhalf_);
if ((mode_ == HGCalGeometryMode::Hexagon) || (mode_ == HGCalGeometryMode::HexagonFull)) {
if (waferHexagon6()) {
int type = (di % types_);
id.iType = (type == 0 ? -1 : 1);
id.iSec1 = (((di - type) / types_) % sectors_);
Expand All @@ -400,7 +399,7 @@ DetId HGCalTopology::denseId2detId(uint32_t hi) const {
edm::LogVerbatim("HGCalGeom") << "Input Hex " << hi << " o/p " << id.zSide << ":" << id.iLay << ":" << id.iType
<< ":" << id.iSec1 << ":" << id.iCell1;
#endif
} else if (mode_ == HGCalGeometryMode::Trapezoid) {
} else if (tileTrapezoid()) {
int type = (di % types_);
id.iType = type;
id.iSec1 = (((di - type) / types_) % sectors_) + 1;
Expand Down Expand Up @@ -434,14 +433,14 @@ DetId HGCalTopology::denseId2detId(uint32_t hi) const {
uint32_t HGCalTopology::detId2denseGeomId(const DetId& idin) const {
HGCalTopology::DecodedDetId id = decode(idin);
uint32_t idx;
if ((mode_ == HGCalGeometryMode::Hexagon) || (mode_ == HGCalGeometryMode::HexagonFull)) {
if (waferHexagon6()) {
idx = (uint32_t)(((id.zSide > 0) ? kHGeomHalf_ : 0) + (id.iLay - 1) * sectors_ + id.iSec1);
#ifdef EDM_ML_DEBUG
edm::LogVerbatim("HGCalGeom") << "Geom Hex I/P " << id.zSide << ":" << id.iLay << ":" << id.iSec1 << ":" << id.iType
<< " Constants " << kHGeomHalf_ << ":" << layers_ << ":" << sectors_ << " o/p "
<< idx;
#endif
} else if (mode_ == HGCalGeometryMode::Trapezoid) {
} else if (tileTrapezoid()) {
idx = (uint32_t)(((id.zSide > 0) ? kHGeomHalf_ : 0) +
(((id.iLay - firstLay_) * sectors_ + id.iSec1 - 1) * cellMax_ + id.iCell1 - 1));
#ifdef EDM_ML_DEBUG
Expand All @@ -464,12 +463,12 @@ uint32_t HGCalTopology::detId2denseGeomId(const DetId& idin) const {
bool HGCalTopology::valid(const DetId& idin) const {
HGCalTopology::DecodedDetId id = decode(idin);
bool flag;
if ((mode_ == HGCalGeometryMode::Hexagon) || (mode_ == HGCalGeometryMode::HexagonFull)) {
if (waferHexagon6()) {
flag = (idin.det() == det_ && idin.subdetId() == (int)(subdet_) && id.iCell1 >= 0 && id.iCell1 < cells_ &&
id.iLay > 0 && id.iLay <= layers_ && id.iSec1 >= 0 && id.iSec1 <= sectors_);
if (flag)
flag = hdcons_.isValidHex(id.iLay, id.iSec1, id.iCell1, true);
} else if (mode_ == HGCalGeometryMode::Trapezoid) {
} else if (tileTrapezoid()) {
flag = ((idin.det() == det_) && hdcons_.isValidTrap(id.iLay, id.iSec1, id.iCell1));
} else {
flag = ((idin.det() == det_) && hdcons_.isValidHex8(id.iLay, id.iSec1, id.iSec2, id.iCell1, id.iCell2));
Expand All @@ -478,7 +477,7 @@ bool HGCalTopology::valid(const DetId& idin) const {
}

bool HGCalTopology::valid(const DetId& idin, int cornerMin) const {
if ((mode_ == HGCalGeometryMode::Hexagon8) || (mode_ == HGCalGeometryMode::Hexagon8Full)) {
if (waferHexagon8()) {
HGCalTopology::DecodedDetId id = decode(idin);
bool mask = (cornerMin < HGCalTypes::WaferCornerMin) ? false : hdcons_.maskCell(idin, cornerMin);
bool flag = ((idin.det() == det_) &&
Expand Down Expand Up @@ -525,7 +524,7 @@ HGCalTopology::DecodedDetId HGCalTopology::geomDenseId2decId(const uint32_t& hi)
if (hi < totalGeomModules()) {
id.zSide = ((int)(hi) < kHGeomHalf_ ? -1 : 1);
int di = ((int)(hi) % kHGeomHalf_);
if ((mode_ == HGCalGeometryMode::Hexagon) || (mode_ == HGCalGeometryMode::HexagonFull)) {
if (waferHexagon6()) {
id.iSec1 = (di % sectors_);
di = (di - id.iSec1) / sectors_;
id.iLay = (di % layers_) + 1;
Expand All @@ -534,7 +533,7 @@ HGCalTopology::DecodedDetId HGCalTopology::geomDenseId2decId(const uint32_t& hi)
edm::LogVerbatim("HGCalGeom") << "Geom Hex I/P " << hi << " O/P " << id.zSide << ":" << id.iType << ":" << id.iLay
<< ":" << id.iSec1;
#endif
} else if (mode_ == HGCalGeometryMode::Trapezoid) {
} else if (tileTrapezoid()) {
id.iCell1 = (di % cellMax_) + 1;
di = (di - id.iCell1 + 1) / cellMax_;
id.iSec1 = (di % sectors_) + 1;
Expand Down Expand Up @@ -588,7 +587,7 @@ void HGCalTopology::addHGCSiliconId(

HGCalTopology::DecodedDetId HGCalTopology::decode(const DetId& startId) const {
HGCalTopology::DecodedDetId idx;
if ((mode_ == HGCalGeometryMode::Hexagon) || (mode_ == HGCalGeometryMode::HexagonFull)) {
if (waferHexagon6()) {
HGCalDetId id(startId);
idx.iCell1 = id.cell();
idx.iCell2 = 0;
Expand All @@ -598,7 +597,7 @@ HGCalTopology::DecodedDetId HGCalTopology::decode(const DetId& startId) const {
idx.iType = id.waferType();
idx.zSide = id.zside();
idx.det = id.subdetId();
} else if (mode_ == HGCalGeometryMode::Trapezoid) {
} else if (tileTrapezoid()) {
HGCScintillatorDetId id(startId);
idx.iCell1 = id.iphi();
idx.iCell2 = 0;
Expand Down Expand Up @@ -634,11 +633,11 @@ HGCalTopology::DecodedDetId HGCalTopology::decode(const DetId& startId) const {

DetId HGCalTopology::encode(const HGCalTopology::DecodedDetId& idx) const {
DetId id;
if ((mode_ == HGCalGeometryMode::Hexagon) || (mode_ == HGCalGeometryMode::HexagonFull)) {
if (waferHexagon6()) {
id =
HGCalDetId((ForwardSubdetector)(idx.det), idx.zSide, idx.iLay, ((idx.iType > 0) ? 1 : 0), idx.iSec1, idx.iCell1)
.rawId();
} else if (mode_ == HGCalGeometryMode::Trapezoid) {
} else if (tileTrapezoid()) {
id = HGCScintillatorDetId(idx.iType, idx.iLay, idx.zSide * idx.iSec1, idx.iCell1).rawId();
} else if (det_ == DetId::Forward && subdet_ == ForwardSubdetector::HFNose) {
id = HFNoseDetId(idx.zSide, idx.iType, idx.iLay, idx.iSec1, idx.iSec2, idx.iCell1, idx.iCell2).rawId();
Expand Down
4 changes: 1 addition & 3 deletions Geometry/CaloTopology/test/HGCalTopologyTester.cc
Expand Up @@ -74,9 +74,7 @@ void HGCalTopologyTester::analyze(edm::Event const&, edm::EventSetup const& iSet
}

void HGCalTopologyTester::doTest(const HGCalTopology& topology) {
if ((topology.geomMode() == HGCalGeometryMode::Hexagon8) ||
(topology.geomMode() == HGCalGeometryMode::Hexagon8Full) ||
(topology.geomMode() == HGCalGeometryMode::Trapezoid)) {
if (topology.waferHexagon8() || topology.tileTrapezoid()) {
for (unsigned int i = 0; i < type_.size(); ++i) {
DetId id;
if (detectorName_ == "HGCalEESensitive") {
Expand Down
6 changes: 3 additions & 3 deletions Geometry/HGCalCommonData/data/hgcalCons/v14/hgcalCons.xml
Expand Up @@ -23,7 +23,7 @@
<SpecPar name="HGCalEESensitive">
<PartSelector path="//HGCalEESensitive.*"/>
<Parameter name="Volume" value="HGCalEESensitive" eval="false"/>
<Parameter name="GeometryMode" value="HGCalGeometryMode::Hexagon8Full" eval="false"/>
<Parameter name="GeometryMode" value="HGCalGeometryMode::Hexagon8File" eval="false"/>
<Parameter name="LevelZSide" value="3"/>
<Parameter name="LevelTop" value="9"/>
<Parameter name="LevelTop" value="9"/>
Expand Down Expand Up @@ -76,7 +76,7 @@
<SpecPar name="HGCalHESiliconSensitive">
<PartSelector path="//HGCalHESiliconSensitive.*"/>
<Parameter name="Volume" value="HGCalHESiliconSensitive" eval="false"/>
<Parameter name="GeometryMode" value="HGCalGeometryMode::Hexagon8Full" eval="false"/>
<Parameter name="GeometryMode" value="HGCalGeometryMode::Hexagon8File" eval="false"/>
<Parameter name="LevelZSide" value="3"/>
<Parameter name="LevelTop" value="9"/>
<Parameter name="LevelTop" value="11"/>
Expand Down Expand Up @@ -129,7 +129,7 @@
<SpecPar name="HGCalHEScintillatorSensitive">
<PartSelector path="//HGCalHEScintillatorSensitive.*"/>
<Parameter name="Volume" value="HGCalHEScintillatorSensitive" eval="false"/>
<Parameter name="GeometryMode" value="HGCalGeometryMode::Trapezoid" eval="false"/>
<Parameter name="GeometryMode" value="HGCalGeometryMode::TrapezoidFile" eval="false"/>
<Parameter name="LevelZSide" value="3"/>
<Parameter name="LevelTop" value="11"/>
<Parameter name="LevelTop" value="11"/>
Expand Down
17 changes: 13 additions & 4 deletions Geometry/HGCalCommonData/interface/HGCalDDDConstants.h
Expand Up @@ -58,7 +58,7 @@ class HGCalDDDConstants {
int getPhiBins(int lay) const;
std::pair<int, int> getREtaRange(int lay) const;
const std::vector<double>& getRadiusLayer(int layer) const {
int type = ((mode_ == HGCalGeometryMode::Trapezoid) ? hgpar_->scintType(layer) : 0);
int type = (tileTrapezoid() ? hgpar_->scintType(layer) : 0);
return hgpar_->radiusLayer_[type];
}
HGCalParameters::hgtrform getTrForm(unsigned int k) const { return hgpar_->getTrForm(k); }
Expand All @@ -84,9 +84,7 @@ class HGCalDDDConstants {
std::pair<float, float> locateCellTrap(int lay, int ieta, int iphi, bool reco) const;
int levelTop(int ind = 0) const { return hgpar_->levelT_[ind]; }
bool maskCell(const DetId& id, int corners) const;
int maxCellUV() const {
return ((mode_ == HGCalGeometryMode::Trapezoid) ? hgpar_->nCellsFine_ : 2 * hgpar_->nCellsFine_);
}
int maxCellUV() const { return (tileTrapezoid() ? hgpar_->nCellsFine_ : 2 * hgpar_->nCellsFine_); }
int maxCells(bool reco) const;
int maxCells(int lay, bool reco) const;
int maxModules() const { return modHalf_; }
Expand All @@ -107,6 +105,9 @@ class HGCalDDDConstants {
std::pair<int, int> rowColumnWafer(const int wafer) const;
int sectors() const { return hgpar_->nSectors_; }
std::pair<int, int> simToReco(int cell, int layer, int mod, bool half) const;
bool tileTrapezoid() const {
return ((mode_ == HGCalGeometryMode::Trapezoid) || (mode_ == HGCalGeometryMode::TrapezoidFile));
}
unsigned int volumes() const { return hgpar_->moduleLayR_.size(); }
int waferFromCopy(int copy) const;
void waferFromPosition(const double x, const double y, int& wafer, int& icell, int& celltyp) const;
Expand All @@ -120,6 +121,13 @@ class HGCalDDDConstants {
int& celltype,
double& wt,
bool debug = false) const;
bool waferHexagon6() const {
return ((mode_ == HGCalGeometryMode::Hexagon) || (mode_ == HGCalGeometryMode::HexagonFull));
}
bool waferHexagon8() const {
return ((mode_ == HGCalGeometryMode::Hexagon8) || (mode_ == HGCalGeometryMode::Hexagon8Full) ||
(mode_ == HGCalGeometryMode::Hexagon8File));
}
bool waferInLayer(int wafer, int lay, bool reco) const;
bool waferFullInLayer(int wafer, int lay, bool reco) const;
int waferCount(const int type) const { return ((type == 0) ? waferMax_[2] : waferMax_[3]); }
Expand Down Expand Up @@ -205,6 +213,7 @@ class HGCalDDDConstants {
const double sqrt3_;
double rmax_, hexside_;
HGCalGeometryMode::GeometryMode mode_;
bool fullAndPart_;
int32_t tot_wafers_, modHalf_;
std::array<uint32_t, 2> tot_layers_;
Simrecovecs max_modules_layer_;
Expand Down
3 changes: 2 additions & 1 deletion Geometry/HGCalCommonData/interface/HGCalGeometryMode.h
Expand Up @@ -29,7 +29,8 @@ namespace HGCalGeometryMode {
Hexagon8 = 3,
Hexagon8Full = 4,
Trapezoid = 5,
HexagonFullPart = 6
Hexagon8File = 6,
TrapezoidFile = 7
};
enum WaferMode { Polyhedra = 0, ExtrudedPolygon = 1 };
} // namespace HGCalGeometryMode
Expand Down
18 changes: 9 additions & 9 deletions Geometry/HGCalCommonData/python/testHGCalV12XML_cfi.py
Expand Up @@ -4,20 +4,20 @@
geomXMLFiles = cms.vstring(
'Geometry/CMSCommonData/data/materials/2021/v1/materials.xml',
'Geometry/CMSCommonData/data/rotations.xml',
'Geometry/CMSCommonData/data/extend/cmsextent.xml',
'Geometry/CMSCommonData/data/cms/2026/v4/cms.xml',
'Geometry/CMSCommonData/data/eta3/etaMax.xml',
'Geometry/CMSCommonData/data/extend/v2/cmsextent.xml',
'Geometry/CMSCommonData/data/cmsMother.xml',
'Geometry/CMSCommonData/data/caloBase/2026/v3/caloBase.xml',
'Geometry/CMSCommonData/data/eta3/etaMax.xml',
'Geometry/CMSCommonData/data/cmsCalo.xml',
'Geometry/CMSCommonData/data/beampipe/2026/v1/beampipe.xml',
'Geometry/CMSCommonData/data/cmsBeam/2026/v1/cmsBeam.xml',
'Geometry/CMSCommonData/data/cavernData/2021/v1/cavernData.xml',
'Geometry/CMSCommonData/data/muonBase/2026/v4/muonBase.xml',
'Geometry/CMSCommonData/data/cmsMuon.xml',
'Geometry/CMSCommonData/data/mgnt.xml',
'Geometry/CMSCommonData/data/beampipe/2026/v2/beampipe.xml',
'Geometry/CMSCommonData/data/cmsBeam/2026/v1/cmsBeam.xml',
'Geometry/CMSCommonData/data/muonMB.xml',
'Geometry/CMSCommonData/data/muonMagnet.xml',
'Geometry/CMSCommonData/data/cavernData/2021/v1/cavernData.xml',
'Geometry/CMSCommonData/data/cms/2026/v4/cms.xml',
'Geometry/CMSCommonData/data/caloBase/2026/v3/caloBase.xml',
'Geometry/CMSCommonData/data/muonBase/2026/v4/muonBase.xml',
'Geometry/EcalCommonData/data/eregalgo/2026/v2/eregalgo.xml',
'Geometry/EcalCommonData/data/ectkcable/2026/v1/ectkcable.xml',
'Geometry/EcalCommonData/data/ectkcablemat/2026/v1/ectkcablemat.xml',
Expand All @@ -41,7 +41,7 @@
'Geometry/HGCalCommonData/data/hgcalHEsil/v12/hgcalHEsil.xml',
'Geometry/HGCalCommonData/data/hgcalHEmix/v12/hgcalHEmix.xml',
'Geometry/HGCalCommonData/data/hgcalCons/v12/hgcalCons.xml',
'Geometry/ForwardCommonData/data/forwardshield/2017/v1/forwardshield.xml',
'Geometry/ForwardCommonData/data/forwardshield/2026/v2/forwardshield.xml',
'Geometry/ForwardCommonData/data/brmrotations.xml',
'Geometry/ForwardCommonData/data/PostLS2/brm.xml',
'Geometry/MuonCommonData/data/mbCommon/2021/v1/mbCommon.xml',
Expand Down
4 changes: 2 additions & 2 deletions Geometry/HGCalCommonData/python/testHGCalV13XML_cfi.py
Expand Up @@ -42,9 +42,9 @@
'Geometry/HGCalCommonData/data/hgcalHEmix/v12/hgcalHEmix.xml',
'Geometry/HGCalCommonData/data/hgcalCons/v13/hgcalCons.xml',
'Geometry/HGCalCommonData/data/hgcalConsData/v13/hgcalConsData.xml',
'Geometry/ForwardCommonData/data/forwardshield/2026/v2/forwardshield.xml',
'Geometry/ForwardCommonData/data/forwardshield/2026/v4/forwardshield.xml',
'Geometry/ForwardCommonData/data/brmrotations.xml',
'Geometry/ForwardCommonData/data/PostLS2/brm.xml',
'Geometry/ForwardCommonData/data/brm/2026/v1/brm.xml',
'Geometry/MuonCommonData/data/mbCommon/2021/v1/mbCommon.xml',
'Geometry/MuonCommonData/data/mb1/2015/v2/mb1.xml',
'Geometry/MuonCommonData/data/mb2/2015/v2/mb2.xml',
Expand Down