Skip to content

Commit

Permalink
Merge pull request #34634 from abhih1/ESConsumesFix_master
Browse files Browse the repository at this point in the history
Migrate ECAL DQM codes to ESConsumes
  • Loading branch information
cmsbuild committed Jul 28, 2021
2 parents 075121f + a6bec70 commit 6d07e66
Show file tree
Hide file tree
Showing 20 changed files with 139 additions and 81 deletions.
21 changes: 21 additions & 0 deletions DQM/EcalCommon/interface/DQWorker.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,21 @@
#include "Geometry/CaloTopology/interface/EcalTrigTowerConstituentsMap.h"
#include "Geometry/EcalMapping/interface/EcalElectronicsMapping.h"

#include "Geometry/EcalMapping/interface/EcalMappingRcd.h"
#include "Geometry/Records/interface/CaloGeometryRecord.h"
#include "Geometry/Records/interface/CaloTopologyRecord.h"
#include "Geometry/Records/interface/IdealGeometryRecord.h"

#include "FWCore/Framework/interface/ConsumesCollector.h"
#include "FWCore/Framework/interface/ESHandle.h"
namespace edm {
class Run;
class LuminosityBlock;
class Event;
class EventSetup;
class ParameterSet;
class ParameterSetDescription;
class ConsumesCollector;
} // namespace edm

namespace ecaldqm {
Expand Down Expand Up @@ -58,6 +66,7 @@ namespace ecaldqm {
virtual ~DQWorker() noexcept(false);

static void fillDescriptions(edm::ParameterSetDescription &_desc);
void setTokens(edm::ConsumesCollector &);

virtual void beginRun(edm::Run const &, edm::EventSetup const &) {}
virtual void endRun(edm::Run const &, edm::EventSetup const &) {}
Expand All @@ -82,13 +91,25 @@ namespace ecaldqm {
// which leads to poor multi-threading performance.
// Original issue here:
// https://github.com/cms-sw/cmssw/issues/28858

void setSetupObjects(edm::EventSetup const &);
void setSetupObjectsEndLumi(edm::EventSetup const &);
EcalElectronicsMapping const *GetElectronicsMap();
EcalTrigTowerConstituentsMap const *GetTrigTowerMap();
CaloGeometry const *GetGeometry();
CaloTopology const *GetTopology();
EcalDQMSetupObjects const getEcalDQMSetupObjects();

edm::ESGetToken<EcalElectronicsMapping, EcalMappingRcd> elecMapHandle;
edm::ESGetToken<EcalTrigTowerConstituentsMap, IdealGeometryRecord> ttMapHandle;
edm::ESGetToken<CaloGeometry, CaloGeometryRecord> geomHandle;
edm::ESGetToken<CaloTopology, CaloTopologyRecord> topoHandle;

edm::ESGetToken<EcalElectronicsMapping, EcalMappingRcd> elecMapHandleEndLumi;
edm::ESGetToken<EcalTrigTowerConstituentsMap, IdealGeometryRecord> ttMapHandleEndLumi;
edm::ESGetToken<CaloGeometry, CaloGeometryRecord> geomHandleEndLumi;
edm::ESGetToken<CaloTopology, CaloTopologyRecord> topoHandleEndLumi;

void setTime(time_t _t) { timestamp_.now = _t; }
void setRunNumber(edm::RunNumber_t _r) { timestamp_.iRun = _r; }
void setLumiNumber(edm::LuminosityBlockNumber_t _l) { timestamp_.iLumi = _l; }
Expand Down
4 changes: 3 additions & 1 deletion DQM/EcalCommon/plugins/EcalMEFormatter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

EcalMEFormatter::EcalMEFormatter(edm::ParameterSet const &_ps) : DQMEDHarvester(), ecaldqm::DQWorker() {
initialize("EcalMEFormatter", _ps);
edm::ConsumesCollector collector(consumesCollector());
setTokens(collector);
setME(_ps.getUntrackedParameterSet("MEs"));
verbosity_ = _ps.getUntrackedParameter<int>("verbosity", 0);
}
Expand All @@ -28,7 +30,7 @@ void EcalMEFormatter::dqmEndLuminosityBlock(DQMStore::IBooker &,
DQMStore::IGetter &_igetter,
edm::LuminosityBlock const &,
edm::EventSetup const &_es) {
setSetupObjects(_es);
setSetupObjectsEndLumi(_es);
format_(_igetter, true);
}

Expand Down
42 changes: 28 additions & 14 deletions DQM/EcalCommon/src/DQWorker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,16 @@

#include "DataFormats/Provenance/interface/EventID.h"

#include "Geometry/CaloGeometry/interface/CaloGeometry.h"
#include "Geometry/CaloTopology/interface/CaloTopology.h"
#include "Geometry/CaloTopology/interface/EcalTrigTowerConstituentsMap.h"
#include "Geometry/EcalMapping/interface/EcalElectronicsMapping.h"

#include "Geometry/EcalMapping/interface/EcalMappingRcd.h"
#include "Geometry/Records/interface/CaloGeometryRecord.h"
#include "Geometry/Records/interface/CaloTopologyRecord.h"
#include "Geometry/Records/interface/IdealGeometryRecord.h"
#include "FWCore/Framework/interface/ConsumesCollector.h"

namespace ecaldqm {
DQWorker::DQWorker()
Expand Down Expand Up @@ -44,6 +50,18 @@ namespace ecaldqm {
_desc.addUntracked("params", workerParameters);
}

void DQWorker::setTokens(edm::ConsumesCollector &_collector) {
elecMapHandle = _collector.esConsumes<edm::Transition::BeginRun>();
ttMapHandle = _collector.esConsumes<edm::Transition::BeginRun>();
geomHandle = _collector.esConsumes<edm::Transition::BeginRun>();
topoHandle = _collector.esConsumes<edm::Transition::BeginRun>();

elecMapHandleEndLumi = _collector.esConsumes<edm::Transition::EndLuminosityBlock>();
ttMapHandleEndLumi = _collector.esConsumes<edm::Transition::EndLuminosityBlock>();
geomHandleEndLumi = _collector.esConsumes<edm::Transition::EndLuminosityBlock>();
topoHandleEndLumi = _collector.esConsumes<edm::Transition::EndLuminosityBlock>();
}

void DQWorker::initialize(std::string const &_name, edm::ParameterSet const &_commonParams) {
name_ = _name;
onlineMode_ = _commonParams.getUntrackedParameter<bool>("onlineMode");
Expand Down Expand Up @@ -84,21 +102,17 @@ namespace ecaldqm {
}

void DQWorker::setSetupObjects(edm::EventSetup const &_es) {
edm::ESHandle<EcalElectronicsMapping> elecMapHandle;
_es.get<EcalMappingRcd>().get(elecMapHandle);
edso_.electronicsMap = elecMapHandle.product();

edm::ESHandle<EcalTrigTowerConstituentsMap> ttMapHandle;
_es.get<IdealGeometryRecord>().get(ttMapHandle);
edso_.trigtowerMap = ttMapHandle.product();

edm::ESHandle<CaloGeometry> geomHandle;
_es.get<CaloGeometryRecord>().get(geomHandle);
edso_.geometry = geomHandle.product();
edso_.electronicsMap = &_es.getData(elecMapHandle);
edso_.trigtowerMap = &_es.getData(ttMapHandle);
edso_.geometry = &_es.getData(geomHandle);
edso_.topology = &_es.getData(topoHandle);
}

edm::ESHandle<CaloTopology> topoHandle;
_es.get<CaloTopologyRecord>().get(topoHandle);
edso_.topology = topoHandle.product();
void DQWorker::setSetupObjectsEndLumi(edm::EventSetup const &_es) {
edso_.electronicsMap = &_es.getData(elecMapHandleEndLumi);
edso_.trigtowerMap = &_es.getData(ttMapHandleEndLumi);
edso_.geometry = &_es.getData(geomHandleEndLumi);
edso_.topology = &_es.getData(topoHandleEndLumi);
}

EcalElectronicsMapping const *DQWorker::GetElectronicsMap() {
Expand Down
2 changes: 2 additions & 0 deletions DQM/EcalCommon/src/EcalDQMonitor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
#include "Geometry/Records/interface/CaloTopologyRecord.h"
#include "Geometry/Records/interface/IdealGeometryRecord.h"

#include "FWCore/Framework/interface/ConsumesCollector.h"

#include <ctime>
#include <sstream>

Expand Down
7 changes: 7 additions & 0 deletions DQM/EcalMonitorClient/interface/DQWorkerClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@
#include <utility>

#include "DQM/EcalCommon/interface/DQWorker.h"
#include "FWCore/Framework/interface/ConsumesCollector.h"

class DetId;
namespace edm {
class ConsumesCollector;
} // namespace edm

namespace ecaldqm {
class StatusManager;
Expand All @@ -32,6 +36,9 @@ namespace ecaldqm {
virtual void resetMEs();
virtual void producePlots(ProcessType) = 0;

// mechanisms to register EDGetTokens for any additional objects used internally
virtual void setTokens(edm::ConsumesCollector&) {}

void setStatusManager(StatusManager const& _manager) { statusManager_ = &_manager; }

enum Quality { kBad = 0, kGood = 1, kUnknown = 2, kMBad = 3, kMGood = 4, kMUnknown = 5 };
Expand Down
7 changes: 6 additions & 1 deletion DQM/EcalMonitorClient/interface/EcalDQMonitorClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
#include "DQM/EcalCommon/interface/StatusManager.h"

#include "DQM/EcalMonitorClient/interface/DQWorkerClient.h"
#include "CondFormats/EcalObjects/interface/EcalDQMChannelStatus.h"
#include "CondFormats/EcalObjects/interface/EcalDQMTowerStatus.h"
#include "CondFormats/DataRecord/interface/EcalDQMChannelStatusRcd.h"
#include "CondFormats/DataRecord/interface/EcalDQMTowerStatusRcd.h"

class EcalDQMonitorClient : public DQMEDHarvester, public ecaldqm::EcalDQMonitor {
public:
Expand All @@ -27,7 +31,8 @@ class EcalDQMonitorClient : public DQMEDHarvester, public ecaldqm::EcalDQMonitor

unsigned eventCycleLength_;
unsigned iEvt_;

edm::ESGetToken<EcalDQMChannelStatus, EcalDQMChannelStatusRcd> cStHndl;
edm::ESGetToken<EcalDQMTowerStatus, EcalDQMTowerStatusRcd> tStHndl;
ecaldqm::StatusManager statusManager_;
};

Expand Down
6 changes: 4 additions & 2 deletions DQM/EcalMonitorClient/interface/IntegrityClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
#define IntegrityClient_H

#include "DQWorkerClient.h"

#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include "CondFormats/EcalObjects/interface/EcalChannelStatus.h"
#include "CondFormats/DataRecord/interface/EcalChannelStatusRcd.h"

namespace ecaldqm {
class IntegrityClient : public DQWorkerClient {
Expand All @@ -18,7 +18,9 @@ namespace ecaldqm {

private:
void setParams(edm::ParameterSet const&) override;
edm::ESHandle<EcalChannelStatus> chStatus;
edm::ESGetToken<EcalChannelStatus, EcalChannelStatusRcd> chStatusToken;
const EcalChannelStatus* chStatus;
void setTokens(edm::ConsumesCollector&) override;

float errFractionThreshold_;
};
Expand Down
7 changes: 7 additions & 0 deletions DQM/EcalMonitorClient/interface/TowerStatusTask.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
#include "DQWorkerClient.h"

#include "DQM/EcalCommon/interface/EcalDQMCommonUtils.h"
#include "CondFormats/EcalObjects/interface/EcalDAQTowerStatus.h"
#include "CondFormats/DataRecord/interface/EcalDAQTowerStatusRcd.h"
#include "CondFormats/EcalObjects/interface/EcalDCSTowerStatus.h"
#include "CondFormats/DataRecord/interface/EcalDCSTowerStatusRcd.h"

namespace ecaldqm {

Expand All @@ -19,6 +23,9 @@ namespace ecaldqm {
private:
void setParams(edm::ParameterSet const&) override;
void producePlotsTask_(float const*, std::string const&);
edm::ESGetToken<EcalDAQTowerStatus, EcalDAQTowerStatusRcd> daqHndlToken;
edm::ESGetToken<EcalDCSTowerStatus, EcalDCSTowerStatusRcd> dcsHndlToken;
void setTokens(edm::ConsumesCollector&) override;

bool doDAQInfo_;
bool doDCSInfo_;
Expand Down
26 changes: 13 additions & 13 deletions DQM/EcalMonitorClient/plugins/EcalDQMonitorClient.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,25 @@

#include "FWCore/MessageLogger/interface/MessageLogger.h"

#include "CondFormats/EcalObjects/interface/EcalDQMChannelStatus.h"
#include "CondFormats/EcalObjects/interface/EcalDQMTowerStatus.h"
#include "CondFormats/DataRecord/interface/EcalDQMChannelStatusRcd.h"
#include "CondFormats/DataRecord/interface/EcalDQMTowerStatusRcd.h"

#include <ctime>
#include <fstream>

EcalDQMonitorClient::EcalDQMonitorClient(edm::ParameterSet const& _ps)
: DQMEDHarvester(), ecaldqm::EcalDQMonitor(_ps), iEvt_(0), statusManager_() {
: DQMEDHarvester(),
ecaldqm::EcalDQMonitor(_ps),
iEvt_(0),
cStHndl(esConsumes<edm::Transition::BeginRun>()),
tStHndl(esConsumes<edm::Transition::BeginRun>()),
statusManager_() {
edm::ConsumesCollector collector(consumesCollector());
executeOnWorkers_(
[this](ecaldqm::DQWorker* worker) {
[this, &collector](ecaldqm::DQWorker* worker) {
ecaldqm::DQWorkerClient* client(dynamic_cast<ecaldqm::DQWorkerClient*>(worker));
if (!client)
throw cms::Exception("InvalidConfiguration") << "Non-client DQWorker " << worker->getName() << " passed";
client->setStatusManager(this->statusManager_);
client->setTokens(collector);
worker->setTokens(collector);
},
"initialization");

Expand Down Expand Up @@ -70,13 +73,10 @@ void EcalDQMonitorClient::beginRun(edm::Run const& _run, edm::EventSetup const&

if (_es.find(edm::eventsetup::EventSetupRecordKey::makeKey<EcalDQMChannelStatusRcd>()) &&
_es.find(edm::eventsetup::EventSetupRecordKey::makeKey<EcalDQMTowerStatusRcd>())) {
edm::ESHandle<EcalDQMChannelStatus> cStHndl;
_es.get<EcalDQMChannelStatusRcd>().get(cStHndl);

edm::ESHandle<EcalDQMTowerStatus> tStHndl;
_es.get<EcalDQMTowerStatusRcd>().get(tStHndl);
const EcalDQMChannelStatus* ChStatus = &_es.getData(cStHndl);
const EcalDQMTowerStatus* TStatus = &_es.getData(tStHndl);

statusManager_.readFromObj(*cStHndl, *tStHndl);
statusManager_.readFromObj(*ChStatus, *TStatus);
}

ecaldqmBeginRun(_run, _es);
Expand Down
7 changes: 5 additions & 2 deletions DQM/EcalMonitorClient/src/IntegrityClient.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

#include "DataFormats/EcalDetId/interface/EBDetId.h"
#include "DataFormats/EcalDetId/interface/EEDetId.h"
#include "CondFormats/DataRecord/interface/EcalChannelStatusRcd.h"

#include "DQM/EcalCommon/interface/EcalDQMCommonUtils.h"

Expand All @@ -20,10 +19,14 @@ namespace ecaldqm {
errFractionThreshold_ = _params.getUntrackedParameter<double>("errFractionThreshold");
}

void IntegrityClient::setTokens(edm::ConsumesCollector& _collector) {
chStatusToken = _collector.esConsumes<edm::Transition::EndLuminosityBlock>();
}

// Check Channel Status Record at every endLumi
// Used to fill Channel Status Map MEs
void IntegrityClient::endLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const& _es) {
_es.get<EcalChannelStatusRcd>().get(chStatus);
chStatus = &_es.getData(chStatusToken);
}

void IntegrityClient::producePlots(ProcessType) {
Expand Down
22 changes: 11 additions & 11 deletions DQM/EcalMonitorClient/src/TowerStatusTask.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"

#include "CondFormats/EcalObjects/interface/EcalDAQTowerStatus.h"
#include "CondFormats/DataRecord/interface/EcalDAQTowerStatusRcd.h"
#include "CondFormats/EcalObjects/interface/EcalDCSTowerStatus.h"
#include "CondFormats/DataRecord/interface/EcalDCSTowerStatusRcd.h"

#include "DataFormats/EcalDetId/interface/EcalTrigTowerDetId.h"
#include "DataFormats/EcalDetId/interface/EcalScDetId.h"
#include "DataFormats/EcalDetId/interface/EBDetId.h"
Expand Down Expand Up @@ -40,13 +35,18 @@ namespace ecaldqm {
throw cms::Exception("InvalidConfiguration") << "Nothing to do in TowerStatusTask";
}

void TowerStatusTask::setTokens(edm::ConsumesCollector& _collector) {
daqHndlToken = _collector.esConsumes<edm::Transition::EndLuminosityBlock>();
dcsHndlToken = _collector.esConsumes<edm::Transition::EndLuminosityBlock>();
}

void TowerStatusTask::endLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const& _es) {
if (doDAQInfo_) {
std::fill_n(daqStatus_, nDCC, 1.);

edm::ESHandle<EcalDAQTowerStatus> daqHndl;
_es.get<EcalDAQTowerStatusRcd>().get(daqHndl);
if (daqHndl.isValid()) {
const EcalDAQTowerStatus* daqHndl = &_es.getData(daqHndlToken);
auto daqhandle = _es.getHandle(daqHndlToken);
if (daqhandle.isValid()) {
for (unsigned id(0); id < EcalTrigTowerDetId::kEBTotalTowers; id++) {
if (daqHndl->barrel(id).getStatusCode() != 0) {
EcalTrigTowerDetId ttid(EcalTrigTowerDetId::detIdFromDenseIndex(id));
Expand All @@ -67,9 +67,9 @@ namespace ecaldqm {
if (doDCSInfo_) {
std::fill_n(dcsStatus_, nDCC, 1.);

edm::ESHandle<EcalDCSTowerStatus> dcsHndl;
_es.get<EcalDCSTowerStatusRcd>().get(dcsHndl);
if (dcsHndl.isValid()) {
const EcalDCSTowerStatus* dcsHndl = &_es.getData(dcsHndlToken);
auto dcshandle = _es.getHandle(dcsHndlToken);
if (dcshandle.isValid()) {
for (unsigned id(0); id < EcalTrigTowerDetId::kEBTotalTowers; id++) {
if (dcsHndl->barrel(id).getStatusCode() != 0) {
EcalTrigTowerDetId ttid(EcalTrigTowerDetId::detIdFromDenseIndex(id));
Expand Down
5 changes: 4 additions & 1 deletion DQM/EcalMonitorTasks/interface/ClusterTask.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@

#include "FWCore/Utilities/interface/InputTag.h"
#include "FWCore/Utilities/interface/EDGetToken.h"

#include "FWCore/Framework/interface/ESHandle.h"
#include "CondFormats/L1TObjects/interface/L1GtTriggerMenu.h"
#include "CondFormats/DataRecord/interface/L1GtTriggerMenuRcd.h"
#include <bitset>

namespace ecaldqm {
Expand Down Expand Up @@ -57,6 +59,7 @@ namespace ecaldqm {
edm::InputTag L1MuGMTReadoutCollectionTag_;
edm::EDGetTokenT<L1GlobalTriggerReadoutRecord> L1GlobalTriggerReadoutRecordToken_;
edm::EDGetTokenT<L1MuGMTReadoutCollection> L1MuGMTReadoutCollectionToken_;
edm::ESGetToken<L1GtTriggerMenu, L1GtTriggerMenuRcd> menuRcd;
};

inline bool ClusterTask::analyze(void const* _p, Collections _collection) {
Expand Down
3 changes: 1 addition & 2 deletions DQM/EcalMonitorTasks/interface/EcalFEDMonitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@

#include "DQM/EcalCommon/interface/EcalDQMCommonUtils.h"

#include "Geometry/EcalMapping/interface/EcalElectronicsMapping.h"

#include <iostream>

// Making the class templated temporarily, until HLT sequence can be fixed (is using EBHltTask and EEHltTask currently)
Expand Down Expand Up @@ -55,6 +53,7 @@ class EcalFEDMonitorTemp : public DQMEDAnalyzer {
edm::EDGetTokenT<EEDetIdCollection> eeGainSwitchErrorsToken_;
edm::EDGetTokenT<EcalElectronicsIdCollection> towerIdErrorsToken_;
edm::EDGetTokenT<EcalElectronicsIdCollection> blockSizeErrorsToken_;
edm::ESGetToken<EcalElectronicsMapping, EcalMappingRcd> elecMapHandle;

std::vector<MonitorElement *> MEs_;
};
Expand Down

0 comments on commit 6d07e66

Please sign in to comment.