diff --git a/Geometry/GEMGeometryBuilder/interface/GEMGeometryParsFromDD.h b/Geometry/GEMGeometryBuilder/interface/GEMGeometryParsFromDD.h index e4bd217ec17f1..b88a8ea70a47d 100644 --- a/Geometry/GEMGeometryBuilder/interface/GEMGeometryParsFromDD.h +++ b/Geometry/GEMGeometryBuilder/interface/GEMGeometryParsFromDD.h @@ -38,7 +38,10 @@ class GEMGeometryParsFromDD { private: // DD - void buildGeometry(DDFilteredView& fview, const MuonGeometryConstants& muonConstants, RecoIdealGeometry& rgeo); + void buildGeometry(DDFilteredView& fview, + DDFilteredView& fview2, + const MuonGeometryConstants& muonConstants, + RecoIdealGeometry& rgeo); void buildSuperChamber(DDFilteredView& fv, GEMDetId detId, RecoIdealGeometry& rgeo); void buildChamber(DDFilteredView& fv, GEMDetId detId, RecoIdealGeometry& rgeo); void buildEtaPartition(DDFilteredView& fv, GEMDetId detId, RecoIdealGeometry& rgeo); diff --git a/Geometry/GEMGeometryBuilder/src/GEMGeometryParsFromDD.cc b/Geometry/GEMGeometryBuilder/src/GEMGeometryParsFromDD.cc index 17ef0b5492486..4d8712b6420a2 100644 --- a/Geometry/GEMGeometryBuilder/src/GEMGeometryParsFromDD.cc +++ b/Geometry/GEMGeometryBuilder/src/GEMGeometryParsFromDD.cc @@ -43,11 +43,13 @@ void GEMGeometryParsFromDD::build(const DDCompactView* cview, // Asking only for the MuonGEM's DDSpecificsMatchesValueFilter filter{DDValue(attribute, value, 0.0)}; DDFilteredView fv(*cview, filter); + DDFilteredView fv2(*cview, filter); - this->buildGeometry(fv, muonConstants, rgeo); + this->buildGeometry(fv, fv2, muonConstants, rgeo); } void GEMGeometryParsFromDD::buildGeometry(DDFilteredView& fv, + DDFilteredView& fvGE2, const MuonGeometryConstants& muonConstants, RecoIdealGeometry& rgeo) { LogDebug("GEMGeometryParsFromDD") << "Building the geometry service"; @@ -58,46 +60,83 @@ void GEMGeometryParsFromDD::buildGeometry(DDFilteredView& fv, MuonGeometryNumbering muonDDDNumbering(muonConstants); GEMNumberingScheme gemNumbering(muonConstants); - bool doSuper = fv.firstChild(); + // Check for the demonstrator geometry (only 1 chamber of GE2/1) + int nGE21 = 0; + bool doSuper = fvGE2.firstChild(); + while (doSuper) { + // getting chamber id from eta partitions + fvGE2.firstChild(); + doSuper = fvGE2.firstChild(); + if (doSuper) { + int rawidCh = gemNumbering.baseNumberToUnitNumber(muonDDDNumbering.geoHistoryToBaseNumber(fvGE2.geoHistory())); + GEMDetId detIdCh = GEMDetId(rawidCh); + if (detIdCh.station() == 2) + nGE21++; + + // back to chambers + fvGE2.parent(); + fvGE2.parent(); + doSuper = (nGE21 < 2 && fvGE2.nextSibling()); + } else { + edm::LogError("GEMGeometryParsFromDD") << "Failed to find next child volume. Cannot determine presence of GE 2/1"; + } + } + bool demonstratorGeometry = nGE21 == 1; + +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("Geometry") << "Found " << nGE21 << " GE2/1 chambers. Demonstrator geometry on? " + << demonstratorGeometry; +#endif + + doSuper = fv.firstChild(); LogDebug("GEMGeometryParsFromDD") << "doSuperChamber = " << doSuper; // loop over superchambers while (doSuper) { // getting chamber id from eta partitions fv.firstChild(); - fv.firstChild(); - GEMDetId detIdCh = - GEMDetId(gemNumbering.baseNumberToUnitNumber(muonDDDNumbering.geoHistoryToBaseNumber(fv.geoHistory()))); - // back to chambers - fv.parent(); - fv.parent(); - - // currently there is no superchamber in the geometry - // only 2 chambers are present separated by a gap. - // making superchamber out of the first chamber layer including the gap between chambers - if (detIdCh.layer() == 1) { // only make superChambers when doing layer 1 - buildSuperChamber(fv, detIdCh, rgeo); - } - buildChamber(fv, detIdCh, rgeo); - - // loop over chambers - // only 1 chamber - bool doChambers = fv.firstChild(); - while (doChambers) { - // loop over GEMEtaPartitions - bool doEtaPart = fv.firstChild(); - while (doEtaPart) { - GEMDetId detId = - GEMDetId(gemNumbering.baseNumberToUnitNumber(muonDDDNumbering.geoHistoryToBaseNumber(fv.geoHistory()))); - buildEtaPartition(fv, detId, rgeo); + doSuper = fv.firstChild(); + if (doSuper) { + GEMDetId detIdCh = + GEMDetId(gemNumbering.baseNumberToUnitNumber(muonDDDNumbering.geoHistoryToBaseNumber(fv.geoHistory()))); + // back to chambers + fv.parent(); + fv.parent(); + + // currently there is no superchamber in the geometry + // only 2 chambers are present separated by a gap. + // making superchamber out of the first chamber layer including the gap between chambers - doEtaPart = fv.nextSibling(); + // In Run 3 we also have a single GE2/1 chamber at layer 2. We + // make sure the superchamber gets built but also we build on the + // first layer for the other stations so the superchamber is in + // the right position there. + if ((detIdCh.layer() == 1) || (detIdCh.layer() == 2 and detIdCh.station() == 2 and demonstratorGeometry)) { + buildSuperChamber(fv, detIdCh, rgeo); + } + buildChamber(fv, detIdCh, rgeo); + + // loop over chambers + // only 1 chamber + bool doChambers = fv.firstChild(); + while (doChambers) { + // loop over GEMEtaPartitions + bool doEtaPart = fv.firstChild(); + while (doEtaPart) { + GEMDetId detId = + GEMDetId(gemNumbering.baseNumberToUnitNumber(muonDDDNumbering.geoHistoryToBaseNumber(fv.geoHistory()))); + buildEtaPartition(fv, detId, rgeo); + + doEtaPart = fv.nextSibling(); + } + fv.parent(); + doChambers = fv.nextSibling(); } fv.parent(); - doChambers = fv.nextSibling(); + doSuper = fv.nextSibling(); + } else { + edm::LogError("GEMGeometryParsFromDD") << "Failed to find next child volume. Cannot build GEM chambers."; } - fv.parent(); - doSuper = fv.nextSibling(); } } @@ -246,6 +285,24 @@ void GEMGeometryParsFromDD::buildGeometry(cms::DDFilteredView& fv, int theRingLevel = muonConstants.getValue("mg_ring") / theLevelPart; int theSectorLevel = muonConstants.getValue("mg_sector") / theLevelPart; + // Check for the demonstrator geometry (only 1 chamber of GE2/1) + auto start = fv.copyNos(); + int nGE21 = 0; + while (nGE21 < 2 && fv.firstChild()) { + const auto& history = fv.history(); + MuonBaseNumber num(mdddnum.geoHistoryToBaseNumber(history)); + GEMDetId detId(gemNum.baseNumberToUnitNumber(num)); + if (fv.level() == levelChamb && detId.station() == 2) { + nGE21++; + } + } + bool demonstratorGeometry = nGE21 == 1; +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("Geometry") << "Found " << nGE21 << " GE2/1 chambers. Demonstrator geometry on? " + << demonstratorGeometry; +#endif + + fv.goTo(start); while (fv.firstChild()) { const auto& history = fv.history(); MuonBaseNumber num(mdddnum.geoHistoryToBaseNumber(history)); @@ -267,7 +324,7 @@ void GEMGeometryParsFromDD::buildGeometry(cms::DDFilteredView& fv, } } else { if (fv.level() == levelChamb) { - if (detId.layer() == 1) { + if ((detId.layer() == 1) || (detId.layer() == 2 and detId.station() == 2 and demonstratorGeometry)) { buildSuperChamber(fv, detId, rgeo); } buildChamber(fv, detId, rgeo);