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 #36869

Merged
merged 1 commit into from Feb 3, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
101 changes: 55 additions & 46 deletions Geometry/GEMGeometryBuilder/src/GEMGeometryParsFromDD.cc
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 @@ -59,22 +61,25 @@ void GEMGeometryParsFromDD::buildGeometry(DDFilteredView& fv,
GEMNumberingScheme gemNumbering(muonConstants);

// Check for the demonstrator geometry (only 1 chamber of GE2/1)
DDFilteredView fvGE2{fv};
int nGE21 = 0;
bool doSuper = fvGE2.firstChild();
while (doSuper) {
// getting chamber id from eta partitions
fvGE2.firstChild();
fvGE2.firstChild();
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());
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;

Expand All @@ -90,44 +95,48 @@ void GEMGeometryParsFromDD::buildGeometry(DDFilteredView& fv,
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

// 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);
doSuper = fv.firstChild();
if (doSuper) {
GEMDetId detIdCh =
GEMDetId(gemNumbering.baseNumberToUnitNumber(muonDDDNumbering.geoHistoryToBaseNumber(fv.geoHistory())));
Copy link
Contributor

@srimanob srimanob Feb 3, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a minor comment on the code style. On new GE2/1, we define rawidCh first, then use it once. In this part, we don't define new parameter, we directly get detIdCh.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I prefer the two-step process of getting the rawidCh first and then constructing the GEMDetId, but either style is OK.
This piece of code is for building the GEM reco geometry DB payload with DDD. I hope that we never have to do this again. Eventually, all DDD-related code is slated for deletion.

// 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