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

Migrate ED modules to use esConsumes #33786

Merged
merged 13 commits into from May 24, 2021
4 changes: 4 additions & 0 deletions DQMOffline/Muon/interface/CSCOfflineMonitor.h
Expand Up @@ -91,6 +91,10 @@ class CSCOfflineMonitor : public DQMEDAnalyzer {
edm::EDGetTokenT<CSCRecHit2DCollection> rh_token;
edm::EDGetTokenT<CSCSegmentCollection> se_token;

const edm::ESGetToken<CSCGeometry, MuonGeometryRecord> cscGeomToken_;

const edm::ESGetToken<CSCCrateMap, CSCCrateMapRcd> hcrateToken_;

// modules
void doOccupancies(edm::Handle<CSCStripDigiCollection> strips,
edm::Handle<CSCWireDigiCollection> wires,
Expand Down
2 changes: 2 additions & 0 deletions DQMOffline/Muon/interface/DTSegmentsTask.h
Expand Up @@ -41,6 +41,8 @@ class DTSegmentsTask : public DQMEDAnalyzer {
bool checkNoisyChannels;
edm::ParameterSet parameters;

const edm::ESGetToken<DTStatusFlag, DTStatusFlagRcd> statusMapToken_;

// the histos
std::vector<MonitorElement *> phiHistos;
std::vector<MonitorElement *> thetaHistos;
Expand Down
11 changes: 11 additions & 0 deletions DQMOffline/Muon/interface/GEMEfficiencyAnalyzer.h
Expand Up @@ -18,6 +18,12 @@
#include "DataFormats/MuonReco/interface/MuonSelectors.h"
#include "RecoMuon/TrackingTools/interface/MuonServiceProxy.h"
#include "TrackingTools/TransientTrack/interface/TransientTrack.h"
#include "TrackingTools/TransientTrack/interface/TransientTrackBuilder.h"
#include "TrackingTools/Records/interface/TransientTrackRecord.h"
#include "Geometry/CommonTopologies/interface/GlobalTrackingGeometry.h"
#include "Geometry/Records/interface/GlobalTrackingGeometryRecord.h"
#include "Geometry/GEMGeometry/interface/GEMGeometry.h"
#include "Geometry/Records/interface/MuonGeometryRecord.h"

class GEMEfficiencyAnalyzer : public GEMOfflineDQMBase {
public:
Expand All @@ -39,6 +45,11 @@ class GEMEfficiencyAnalyzer : public GEMOfflineDQMBase {
int region, station, layer;
};

const edm::ESGetToken<GEMGeometry, MuonGeometryRecord> gemToken1_;
const edm::ESGetToken<GEMGeometry, MuonGeometryRecord> gemToken2_;
const edm::ESGetToken<GlobalTrackingGeometry, GlobalTrackingGeometryRecord> globalGeomToken_;
const edm::ESGetToken<TransientTrackBuilder, TransientTrackRecord> trasientTrackToken_;

MonitorElement *bookNumerator1D(DQMStore::IBooker &, MonitorElement *);
MonitorElement *bookNumerator2D(DQMStore::IBooker &, MonitorElement *);

Expand Down
3 changes: 3 additions & 0 deletions DQMOffline/Muon/interface/GEMOfflineMonitor.h
Expand Up @@ -8,6 +8,7 @@
#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
#include "DataFormats/GEMDigi/interface/GEMDigiCollection.h"
#include "DataFormats/GEMRecHit/interface/GEMRecHitCollection.h"
#include "Geometry/Records/interface/MuonGeometryRecord.h"

class GEMOfflineMonitor : public GEMOfflineDQMBase {
public:
Expand All @@ -29,6 +30,8 @@ class GEMOfflineMonitor : public GEMOfflineDQMBase {
edm::EDGetTokenT<GEMDigiCollection> digi_token_;
edm::EDGetTokenT<GEMRecHitCollection> rechit_token_;

const edm::ESGetToken<GEMGeometry, MuonGeometryRecord> gemToken_;

bool do_digi_occupancy_;
bool do_hit_occupancy_;

Expand Down
7 changes: 7 additions & 0 deletions DQMOffline/Muon/interface/MuonEnergyDepositAnalyzer.h
Expand Up @@ -25,6 +25,9 @@
#include "DataFormats/MuonReco/interface/MuonFwd.h"
#include "DataFormats/MuonReco/interface/MuonEnergy.h"

#include "TrackingTools/TransientTrack/interface/TransientTrackBuilder.h"
#include "TrackingTools/Records/interface/TransientTrackRecord.h"

class MuonEnergyDepositAnalyzer : public DQMEDAnalyzer {
public:
/// Constructor
Expand All @@ -42,6 +45,10 @@ class MuonEnergyDepositAnalyzer : public DQMEDAnalyzer {
edm::ParameterSet parameters;
edm::EDGetTokenT<reco::MuonCollection> theMuonCollectionLabel_;

edm::ESHandle<TransientTrackBuilder> theB;

edm::ESGetToken<TransientTrackBuilder, TransientTrackRecord> trasientTrackToken_;

// Switch for verbosity
std::string metname;
std::string AlgoName;
Expand Down
2 changes: 2 additions & 0 deletions DQMOffline/Muon/interface/MuonIdDQM.h
Expand Up @@ -73,6 +73,8 @@ class MuonIdDQM : public DQMEDAnalyzer {
edm::Handle<CSCSegmentCollection> cscSegmentCollectionH_;
edm::ESHandle<GlobalTrackingGeometry> geometry_;

const edm::ESGetToken<GlobalTrackingGeometry, GlobalTrackingGeometryRecord> trackingGeomToken_;

// trackerMuon == 0; globalMuon == 1
MonitorElement* hNumChambers[4];
MonitorElement* hNumMatches[4];
Expand Down
11 changes: 8 additions & 3 deletions DQMOffline/Muon/src/CSCOfflineMonitor.cc
Expand Up @@ -10,7 +10,9 @@ using namespace std;
///////////////////
// CONSTRUCTOR //
///////////////////
CSCOfflineMonitor::CSCOfflineMonitor(const edm::ParameterSet& pset) {
CSCOfflineMonitor::CSCOfflineMonitor(const edm::ParameterSet& pset)
: cscGeomToken_(esConsumes<CSCGeometry, MuonGeometryRecord>()),
hcrateToken_(esConsumes<CSCCrateMap, CSCCrateMapRcd>()) {
rd_token = consumes<FEDRawDataCollection>(pset.getParameter<edm::InputTag>("FEDRawDataCollectionTag"));
sd_token = consumes<CSCStripDigiCollection>(pset.getParameter<edm::InputTag>("stripDigiTag"));
wd_token = consumes<CSCWireDigiCollection>(pset.getParameter<edm::InputTag>("wireDigiTag"));
Expand Down Expand Up @@ -817,7 +819,8 @@ void CSCOfflineMonitor::analyze(const edm::Event& event, const edm::EventSetup&

// Get the CSC Geometry :
edm::ESHandle<CSCGeometry> cscGeom;
eventSetup.get<MuonGeometryRecord>().get(cscGeom);

cscGeom = eventSetup.getHandle(cscGeomToken_);

// Get the RecHits collection :
edm::Handle<CSCRecHit2DCollection> recHits;
Expand Down Expand Up @@ -1802,7 +1805,9 @@ void CSCOfflineMonitor::doBXMonitor(edm::Handle<CSCALCTDigiCollection> alcts,
// Loop over raw data to get TMBHeader information
// Taking code from EventFilter/CSCRawToDigis/CSCDCCUnpacker.cc
edm::ESHandle<CSCCrateMap> hcrate;
eventSetup.get<CSCCrateMapRcd>().get(hcrate);

hcrate = eventSetup.getHandle(hcrateToken_);

const CSCCrateMap* pcrate = hcrate.product();

// Try to get raw data
Expand Down
5 changes: 3 additions & 2 deletions DQMOffline/Muon/src/DTSegmentsTask.cc
Expand Up @@ -24,7 +24,8 @@
using namespace edm;
using namespace std;

DTSegmentsTask::DTSegmentsTask(const edm::ParameterSet& pset) {
DTSegmentsTask::DTSegmentsTask(const edm::ParameterSet& pset)
: statusMapToken_(esConsumes<DTStatusFlag, DTStatusFlagRcd>()) {
debug = pset.getUntrackedParameter<bool>("debug", false);
parameters = pset;

Expand Down Expand Up @@ -112,7 +113,7 @@ void DTSegmentsTask::analyze(const edm::Event& event, const edm::EventSetup& set
// bool checkNoisyChannels = parameters.getUntrackedParameter<bool>("checkNoisyChannels",false);
ESHandle<DTStatusFlag> statusMap;
if (checkNoisyChannels) {
setup.get<DTStatusFlagRcd>().get(statusMap);
statusMap = setup.getHandle(statusMapToken_);
}

// Get the 4D segment collection from the event
Expand Down
23 changes: 16 additions & 7 deletions DQMOffline/Muon/src/GEMEfficiencyAnalyzer.cc
Expand Up @@ -6,13 +6,17 @@
#include "DataFormats/Math/interface/deltaPhi.h"
#include "DataFormats/GeometryCommonDetAlgo/interface/ErrorFrameTransformer.h"
#include "DataFormats/GeometrySurface/interface/SimpleDiskBounds.h"
#include "Geometry/CommonTopologies/interface/GlobalTrackingGeometry.h"
#include "Geometry/Records/interface/GlobalTrackingGeometryRecord.h"
#include "Geometry/CommonTopologies/interface/StripTopology.h"
#include "Validation/MuonHits/interface/MuonHitHelper.h"
#include "Validation/MuonGEMHits/interface/GEMValidationUtils.h"

GEMEfficiencyAnalyzer::GEMEfficiencyAnalyzer(const edm::ParameterSet& pset) : GEMOfflineDQMBase(pset) {
GEMEfficiencyAnalyzer::GEMEfficiencyAnalyzer(const edm::ParameterSet& pset)
: GEMOfflineDQMBase(pset),
gemToken1_(esConsumes<edm::Transition::BeginRun>()),
gemToken2_(esConsumes<GEMGeometry, MuonGeometryRecord>()),
globalGeomToken_(esConsumes<GlobalTrackingGeometry, GlobalTrackingGeometryRecord>()),
trasientTrackToken_(
esConsumes<TransientTrackBuilder, TransientTrackRecord>(edm::ESInputTag("", "TransientTrackBuilder"))) {
name_ = pset.getUntrackedParameter<std::string>("name");
folder_ = pset.getUntrackedParameter<std::string>("folder");

Expand Down Expand Up @@ -107,7 +111,8 @@ void GEMEfficiencyAnalyzer::bookHistograms(DQMStore::IBooker& ibooker,
edm::Run const& run,
edm::EventSetup const& isetup) {
edm::ESHandle<GEMGeometry> gem;
isetup.get<MuonGeometryRecord>().get(gem);
gem = isetup.getHandle(gemToken1_);

if (not gem.isValid()) {
edm::LogError(kLogCategory_) << "GEMGeometry is invalid" << std::endl;
return;
Expand Down Expand Up @@ -320,21 +325,25 @@ void GEMEfficiencyAnalyzer::analyze(const edm::Event& event, const edm::EventSet
}

edm::ESHandle<GEMGeometry> gem;
setup.get<MuonGeometryRecord>().get(gem);
gem = setup.getHandle(gemToken2_);

if (not gem.isValid()) {
edm::LogError(kLogCategory_) << "GEMGeometry is invalid" << std::endl;
return;
}

edm::ESHandle<GlobalTrackingGeometry> global_tracking_geometry;
setup.get<GlobalTrackingGeometryRecord>().get(global_tracking_geometry);

global_tracking_geometry = setup.getHandle(globalGeomToken_);

if (not global_tracking_geometry.isValid()) {
edm::LogError(kLogCategory_) << "GlobalTrackingGeometry is invalid" << std::endl;
return;
}

edm::ESHandle<TransientTrackBuilder> transient_track_builder;
setup.get<TransientTrackRecord>().get("TransientTrackBuilder", transient_track_builder);
transient_track_builder = setup.getHandle(trasientTrackToken_);

if (not transient_track_builder.isValid()) {
edm::LogError(kLogCategory_) << "TransientTrackRecord is invalid" << std::endl;
return;
Expand Down
9 changes: 6 additions & 3 deletions DQMOffline/Muon/src/GEMOfflineMonitor.cc
Expand Up @@ -4,7 +4,8 @@
#include "Geometry/Records/interface/MuonGeometryRecord.h"
#include "Validation/MuonGEMHits/interface/GEMValidationUtils.h"

GEMOfflineMonitor::GEMOfflineMonitor(const edm::ParameterSet& pset) : GEMOfflineDQMBase(pset) {
GEMOfflineMonitor::GEMOfflineMonitor(const edm::ParameterSet& pset)
: GEMOfflineDQMBase(pset), gemToken_(esConsumes<GEMGeometry, MuonGeometryRecord>()) {
digi_token_ = consumes<GEMDigiCollection>(pset.getParameter<edm::InputTag>("digiTag"));
rechit_token_ = consumes<GEMRecHitCollection>(pset.getParameter<edm::InputTag>("recHitTag"));
do_digi_occupancy_ = pset.getUntrackedParameter<bool>("doDigiOccupancy");
Expand All @@ -26,7 +27,8 @@ void GEMOfflineMonitor::fillDescriptions(edm::ConfigurationDescriptions& descrip

void GEMOfflineMonitor::bookHistograms(DQMStore::IBooker& ibooker, edm::Run const& run, edm::EventSetup const& setup) {
edm::ESHandle<GEMGeometry> gem;
setup.get<MuonGeometryRecord>().get(gem);
gem = setup.getHandle(gemToken_);

if (not gem.isValid()) {
edm::LogError(log_category_) << "GEMGeometry is invalid" << std::endl;
return;
Expand Down Expand Up @@ -132,7 +134,8 @@ void GEMOfflineMonitor::analyze(const edm::Event& event, const edm::EventSetup&
}

edm::ESHandle<GEMGeometry> gem;
setup.get<MuonGeometryRecord>().get(gem);
gem = setup.getHandle(gemToken_);

if (not gem.isValid()) {
edm::LogError(log_category_) << "GEMGeometry is invalid" << std::endl;
return;
Expand Down
9 changes: 6 additions & 3 deletions DQMOffline/Muon/src/MuonEnergyDepositAnalyzer.cc
Expand Up @@ -21,7 +21,9 @@
using namespace std;
using namespace edm;

MuonEnergyDepositAnalyzer::MuonEnergyDepositAnalyzer(const edm::ParameterSet& pSet) {
MuonEnergyDepositAnalyzer::MuonEnergyDepositAnalyzer(const edm::ParameterSet& pSet)
: trasientTrackToken_(
esConsumes<TransientTrackBuilder, TransientTrackRecord>(edm::ESInputTag("", "TransientTrackBuilder"))) {
parameters = pSet;

theMuonCollectionLabel_ = consumes<reco::MuonCollection>(parameters.getParameter<InputTag>("MuonCollection"));
Expand Down Expand Up @@ -208,8 +210,9 @@ void MuonEnergyDepositAnalyzer::analyze(const edm::Event& iEvent, const edm::Eve
hoS9DepEnergy->Fill(muEnergy.hoS9);

// plot for energy tests
edm::ESHandle<TransientTrackBuilder> theB;
iSetup.get<TransientTrackRecord>().get("TransientTrackBuilder", theB);

theB = iSetup.getHandle(trasientTrackToken_);

reco::TransientTrack TransTrack;

if (recoMu->isGlobalMuon())
Expand Down
6 changes: 4 additions & 2 deletions DQMOffline/Muon/src/MuonIdDQM.cc
@@ -1,6 +1,7 @@
#include "DQMOffline/Muon/interface/MuonIdDQM.h"

MuonIdDQM::MuonIdDQM(const edm::ParameterSet& iConfig) {
MuonIdDQM::MuonIdDQM(const edm::ParameterSet& iConfig)
: trackingGeomToken_(esConsumes<GlobalTrackingGeometry, GlobalTrackingGeometryRecord>()) {
inputMuonCollection_ = consumes<reco::MuonCollection>(iConfig.getParameter<edm::InputTag>("inputMuonCollection"));
inputDTRecSegment4DCollection_ =
consumes<DTRecSegment4DCollection>(iConfig.getParameter<edm::InputTag>("inputDTRecSegment4DCollection"));
Expand Down Expand Up @@ -130,7 +131,8 @@ void MuonIdDQM::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
iEvent.getByToken(inputMuonCollection_, muonCollectionH_);
iEvent.getByToken(inputDTRecSegment4DCollection_, dtSegmentCollectionH_);
iEvent.getByToken(inputCSCSegmentCollection_, cscSegmentCollectionH_);
iSetup.get<GlobalTrackingGeometryRecord>().get(geometry_);

geometry_ = iSetup.getHandle(trackingGeomToken_);

for (MuonCollection::const_iterator muon = muonCollectionH_->begin(); muon != muonCollectionH_->end(); ++muon) {
// trackerMuon == 0; globalMuon == 1; trackerMuon && !globalMuon == 2; globalMuon && !trackerMuon == 3
Expand Down