Skip to content

Commit

Permalink
Merge pull request #38694 from francescobrivio/alca-activateGEMalignm…
Browse files Browse the repository at this point in the history
…ent_12_4_X

[12_4_X] Run3 GEMGeometryBuilder Run3 modifier and fix DQM GEM chambers
  • Loading branch information
cmsbuild authored Aug 22, 2022
2 parents f3a9a2f + a7d1a5c commit b46958c
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 27 deletions.
3 changes: 2 additions & 1 deletion DQM/GEM/interface/GEMDQMBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,8 @@ class GEMDQMBase : public DQMEDAnalyzer {
const GEMGeometry *GEMGeometry_;
edm::ESGetToken<GEMGeometry, MuonGeometryRecord> geomToken_;

std::vector<GEMChamber> gemChambers_;
std::vector<GEMDetId> listChamberId_;
std::map<GEMDetId, std::vector<const GEMEtaPartition *>> mapEtaPartition_;

std::map<ME2IdsKey, bool> MEMap2Check_;
std::map<ME3IdsKey, bool> MEMap2WithEtaCheck_;
Expand Down
5 changes: 2 additions & 3 deletions DQM/GEM/plugins/GEMDigiSource.cc
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,7 @@ void GEMDigiSource::analyze(edm::Event const& event, edm::EventSetup const& even

std::map<ME3IdsKey, Int_t> total_digi_layer;
std::map<ME3IdsKey, Int_t> total_digi_eta;
for (const auto& ch : gemChambers_) {
GEMDetId gid = ch.id();
for (auto gid : listChamberId_) {
ME2IdsKey key2{gid.region(), gid.station()};
ME3IdsKey key3{gid.region(), gid.station(), gid.layer()};
ME4IdsKey key4Ch{gid.region(), gid.station(), gid.layer(), gid.chamber()};
Expand All @@ -168,7 +167,7 @@ void GEMDigiSource::analyze(edm::Event const& event, edm::EventSetup const& even
const BoundPlane& surface = GEMGeometry_->idToDet(gid)->surface();
if (total_digi_layer.find(key3) == total_digi_layer.end())
total_digi_layer[key3] = 0;
for (auto iEta : ch.etaPartitions()) {
for (auto iEta : mapEtaPartition_[gid]) {
GEMDetId eId = iEta->id();
ME3IdsKey key3IEta{gid.region(), gid.station(), eId.ieta()};
if (total_digi_eta.find(key3IEta) == total_digi_eta.end())
Expand Down
5 changes: 2 additions & 3 deletions DQM/GEM/plugins/GEMRecHitSource.cc
Original file line number Diff line number Diff line change
Expand Up @@ -187,13 +187,12 @@ void GEMRecHitSource::analyze(edm::Event const& event, edm::EventSetup const& ev
std::map<ME3IdsKey, Int_t> total_rechit_iEta;
std::map<ME4IdsKey, std::map<Int_t, Bool_t>> mapCLSOver5;

for (const auto& ch : gemChambers_) {
GEMDetId gid = ch.id();
for (auto gid : listChamberId_) {
auto chamber = gid.chamber();
ME3IdsKey key3{gid.region(), gid.station(), gid.layer()};
ME4IdsKey key4Ch{gid.region(), gid.station(), gid.layer(), gid.chamber()};
MEStationInfo& stationInfo = mapStationInfo_[key3];
for (auto iEta : ch.etaPartitions()) {
for (auto iEta : mapEtaPartition_[gid]) {
GEMDetId eId = iEta->id();
ME3IdsKey key3IEta{gid.region(), gid.station(), eId.ieta()};
ME3IdsKey key3AbsReIEta{std::abs(gid.region()), gid.station(), eId.ieta()};
Expand Down
36 changes: 16 additions & 20 deletions DQM/GEM/src/GEMDQMBase.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,9 @@ GEMDQMBase::GEMDQMBase(const edm::ParameterSet& cfg) : geomToken_(esConsumes<edm

int GEMDQMBase::initGeometry(edm::EventSetup const& iSetup) {
GEMGeometry_ = nullptr;
try {
//edm::ESHandle<GEMGeometry> hGeom;
//iSetup.get<MuonGeometryRecord>().get(hGeom);
GEMGeometry_ = &iSetup.getData(geomToken_);
} catch (edm::eventsetup::NoProxyException<GEMGeometry>& e) {
if (auto handle = iSetup.getHandle(geomToken_)) {
GEMGeometry_ = handle.product();
} else {
edm::LogError(log_category_) << "+++ Error : GEM geometry is unavailable on event loop. +++\n";
return -1;
}
Expand Down Expand Up @@ -58,20 +56,19 @@ int GEMDQMBase::getNumEtaPartitions(const GEMStation* station) {
int GEMDQMBase::loadChambers() {
if (GEMGeometry_ == nullptr)
return -1;
gemChambers_.clear();
const std::vector<const GEMSuperChamber*>& superChambers_ = GEMGeometry_->superChambers();
for (auto sch : superChambers_) { // FIXME: This loop can be merged into the below loop
for (auto pch : sch->chambers()) {
Bool_t bExist = false;
for (const auto& ch : gemChambers_) {
if (pch->id() == ch.id()) {
bExist = true;
break;
listChamberId_.clear();
mapEtaPartition_.clear();
for (const GEMRegion* region : GEMGeometry_->regions()) {
for (const GEMStation* station : region->stations()) {
for (auto sch : station->superChambers()) {
for (auto pchamber : sch->chambers()) {
GEMDetId gid = pchamber->id();
listChamberId_.push_back(pchamber->id());
for (auto iEta : pchamber->etaPartitions()) {
mapEtaPartition_[gid].push_back(iEta);
}
}
}
if (bExist)
continue;
gemChambers_.push_back(*pch);
}
}

Expand Down Expand Up @@ -178,8 +175,7 @@ int GEMDQMBase::GenerateMEPerChamber(DQMStore::IBooker& ibooker) {
MEMap3Check_.clear();
MEMap3WithChCheck_.clear();
MEMap4Check_.clear();
for (const auto& ch : gemChambers_) {
GEMDetId gid = ch.id();
for (auto gid : listChamberId_) {
ME2IdsKey key2{gid.region(), gid.station()};
ME3IdsKey key3{gid.region(), gid.station(), gid.layer()};
ME4IdsKey key3WithChamber{gid.region(), gid.station(), gid.layer(), gid.chamber()};
Expand Down Expand Up @@ -207,7 +203,7 @@ int GEMDQMBase::GenerateMEPerChamber(DQMStore::IBooker& ibooker) {
ProcessWithMEMap3WithChamber(bh3Ch, key3WithChamber);
MEMap3WithChCheck_[key3WithChamber] = true;
}
for (auto iEta : ch.etaPartitions()) {
for (auto iEta : mapEtaPartition_[gid]) {
GEMDetId eId = iEta->id();
ME4IdsKey key4{gid.region(), gid.station(), gid.layer(), eId.ieta()};
ME3IdsKey key2WithEta{gid.region(), gid.station(), eId.ieta()};
Expand Down
6 changes: 6 additions & 0 deletions Geometry/GEMGeometryBuilder/python/gemGeometryDB_cfi.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,9 @@
alignmentsLabel = cms.string(''),
applyAlignment = cms.bool(False)
)

from Configuration.Eras.Modifier_run3_GEM_cff import run3_GEM
from Configuration.Eras.Modifier_phase2_GEM_cff import phase2_GEM

run3_GEM.toModify(GEMGeometryESModule, applyAlignment = True)
phase2_GEM.toModify(GEMGeometryESModule, applyAlignment = False)
6 changes: 6 additions & 0 deletions Geometry/GEMGeometryBuilder/python/gemGeometry_cff.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,10 @@

from Configuration.ProcessModifiers.dd4hep_cff import dd4hep

from Configuration.Eras.Modifier_run3_GEM_cff import run3_GEM
from Configuration.Eras.Modifier_phase2_GEM_cff import phase2_GEM

dd4hep.toModify(gemGeometry, fromDDD = False, fromDD4hep = True)

run3_GEM.toModify(gemGeometry, applyAlignment = True)
phase2_GEM.toModify(gemGeometry, applyAlignment = False)

0 comments on commit b46958c

Please sign in to comment.