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

[DDD] Fix building of DDD GEM reco geometry DB payload, backport of #36869 #36870

Merged
merged 1 commit into from
Feb 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
121 changes: 89 additions & 32 deletions Geometry/GEMGeometryBuilder/src/GEMGeometryParsFromDD.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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();
}
}

Expand Down Expand Up @@ -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));
Expand All @@ -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);
Expand Down