Skip to content

Commit

Permalink
Merge pull request #38908 from quark2/GEM-onlineDQMBetterLoadGeo-12_5_X
Browse files Browse the repository at this point in the history
Fixed codes which causes memory issue by GEM onlineDQM
  • Loading branch information
cmsbuild authored Aug 3, 2022
2 parents 30f8806 + 73b4e7a commit 0929e52
Show file tree
Hide file tree
Showing 4 changed files with 22 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 @@ -579,7 +579,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 @@ -183,8 +180,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 @@ -212,7 +208,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

0 comments on commit 0929e52

Please sign in to comment.