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 Geometry from setConsumes() to type-deducing consumes() #31289

Merged
merged 1 commit into from
Sep 3, 2020
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions Geometry/CSCGeometryBuilder/plugins/CSCGeometryESModule.cc
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,11 @@ CSCGeometryESModule::CSCGeometryESModule(const edm::ParameterSet& p)
debugV_ = p.getUntrackedParameter<bool>("debugV", false);

if (fromDDD_) {
cc.setConsumes(cpvToken_).setConsumes(mdcToken_);
cpvToken_ = cc.consumes();
mdcToken_ = cc.consumes();
} else if (fromDD4hep_) {
cc.setConsumes(cpvTokendd4hep_).setConsumes(mdcToken_);
cpvTokendd4hep_ = cc.consumes();
mdcToken_ = cc.consumes();
} else {
rigToken_ = cc.consumesFrom<RecoIdealGeometry, CSCRecoGeometryRcd>(edm::ESInputTag{});
rdpToken_ = cc.consumesFrom<CSCRecoDigiParameters, CSCRecoDigiParametersRcd>(edm::ESInputTag{});
Expand Down
14 changes: 8 additions & 6 deletions Geometry/GEMGeometryBuilder/plugins/GEMGeometryESModule.cc
Original file line number Diff line number Diff line change
Expand Up @@ -71,16 +71,18 @@ GEMGeometryESModule::GEMGeometryESModule(const edm::ParameterSet& p)
alignmentsLabel_(p.getParameter<std::string>("alignmentsLabel")) {
auto cc = setWhatProduced(this);
if (fromDDD_) {
cc.setConsumes(cpvToken_).setConsumes(mdcToken_);
cpvToken_ = cc.consumes();
mdcToken_ = cc.consumes();
} else if (fromDD4hep_) {
cc.setConsumes(dd4hepcpvToken_).setConsumes(mdcToken_);
dd4hepcpvToken_ = cc.consumes();
mdcToken_ = cc.consumes();
} else {
cc.setConsumes(riggemToken_);
riggemToken_ = cc.consumes();
}
if (applyAlignment_) {
cc.setConsumes(globalPositionToken_, edm::ESInputTag{"", alignmentsLabel_})
.setConsumes(alignmentsToken_, edm::ESInputTag{"", alignmentsLabel_})
.setConsumes(alignmentErrorsToken_, edm::ESInputTag{"", alignmentsLabel_});
globalPositionToken_ = cc.consumes(edm::ESInputTag{"", alignmentsLabel_});
alignmentsToken_ = cc.consumes(edm::ESInputTag{"", alignmentsLabel_});
alignmentErrorsToken_ = cc.consumes(edm::ESInputTag{"", alignmentsLabel_});
}
}

Expand Down
8 changes: 5 additions & 3 deletions Geometry/GEMGeometryBuilder/plugins/ME0GeometryESModule.cc
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,13 @@ ME0GeometryESModule::ME0GeometryESModule(const edm::ParameterSet& p) {
fromDD4hep_ = p.getParameter<bool>("fromDD4hep");
auto cc = setWhatProduced(this);
if (fromDDD_) {
cc.setConsumes(cpvToken_).setConsumes(mdcToken_);
cpvToken_ = cc.consumes();
mdcToken_ = cc.consumes();
} else if (fromDD4hep_) {
cc.setConsumes(dd4hepcpvToken_).setConsumes(mdcToken_);
dd4hepcpvToken_ = cc.consumes();
mdcToken_ = cc.consumes();
} else {
cc.setConsumes(rigme0Token_);
rigme0Token_ = cc.consumes();
}
}

Expand Down
7 changes: 3 additions & 4 deletions Geometry/MuonNumbering/plugins/MuonNumberingInitialization.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,11 @@ class MuonNumberingInitialization : public edm::ESProducer {
ReturnType produce(const MuonNumberingRecord&);

private:
edm::ESGetToken<DDCompactView, IdealGeometryRecord> geomToken_;
const edm::ESGetToken<DDCompactView, IdealGeometryRecord> geomToken_;
};

MuonNumberingInitialization::MuonNumberingInitialization(const edm::ParameterSet&) {
setWhatProduced(this).setConsumes(geomToken_);
}
MuonNumberingInitialization::MuonNumberingInitialization(const edm::ParameterSet&)
: geomToken_{setWhatProduced(this).consumes()} {}
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe

Suggested change
: geomToken_{setWhatProduced(this).consumes()} {}
: geomToken_{setWhatProduced(this)} {}

also works. Not sure I like it or not.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually it doesn't work. I tested and it leads to compilation errors

In file included from .../src/FWCore/Framework/interface/es_impl/MayConsumeChooser.h:28,
                 from .../src/FWCore/Framework/interface/ESConsumesCollector.h:33,
                 from .../src/FWCore/Framework/interface/ESProducer.h:77,
                 from .../Geometry/MuonNumbering/plugins/MuonNumberingInitialization.cc:22:
.../FWCore/Utilities/interface/ESGetToken.h: In instantiation of 'constexpr edm::ESGetToken<ESProduct, ESRecord>::ESGetToken(ADAPTER&&) [with ADAPTER = edm::ESConsumesCollectorT<Mu
onNumberingRecord>; ESProduct = DDCompactView; ESRecord = IdealGeometryRecord]':
.../Geometry/MuonNumbering/plugins/MuonNumberingInitialization.cc:41:39:   required from here
.../FWCore/Utilities/interface/ESGetToken.h:52:117: error: no matching function for call to 'edm::ESConsumesCollectorT<MuonNumberingRecord>::consumes<DDCompactView, IdealGeometryRe
cord>()'
     constexpr explicit ESGetToken(ADAPTER&& iAdapter) : ESGetToken(iAdapter.template consumes<ESProduct, ESRecord>()) {}

In file included from .../FWCore/Framework/interface/es_impl/MayConsumeChooser.h:28,
                 from .../FWCore/Framework/interface/ESConsumesCollector.h:33,
                 from .../FWCore/Framework/interface/ESProducer.h:77,
                 from .../Geometry/MuonNumbering/plugins/MuonNumberingInitialization.cc:22:
.../FWCore/Utilities/interface/ESGetToken.h: In instantiation of 'constexpr edm::ESGetToken<ESProduct, ESRecord>::ESGetToken(ADAPTER&&) [with ADAPTER = edm::ESConsumesCollectorT<Mu
onNumberingRecord>; ESProduct = DDCompactView; ESRecord = IdealGeometryRecord]':
.../Geometry/MuonNumbering/plugins/MuonNumberingInitialization.cc:41:39:   required from here
.../FWCore/Utilities/interface/ESGetToken.h:52:117: error: no matching function for call to 'edm::ESConsumesCollectorT<MuonNumberingRecord>::consumes<DDCompactView, IdealGeometryRe
cord>()'
     constexpr explicit ESGetToken(ADAPTER&& iAdapter) : ESGetToken(iAdapter.template consumes<ESProduct, ESRecord>()) {}

I think this happens because setWhatConsumes() returns ESConsumesCollector<T>, whose consumes() takes only one template argument, while the ESGetToken constructor calls consumes() with two template arguments.

Anyway, I think the explicit call to consumes() makes the call slightly easier to understand.


MuonNumberingInitialization::ReturnType MuonNumberingInitialization::produce(const MuonNumberingRecord& iRecord) {
edm::ESTransientHandle<DDCompactView> pDD = iRecord.getTransientHandle(geomToken_);
Expand Down
8 changes: 5 additions & 3 deletions Geometry/RPCGeometryBuilder/plugins/RPCGeometryESModule.cc
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,13 @@ RPCGeometryESModule::RPCGeometryESModule(const edm::ParameterSet& p)
auto cc = setWhatProduced(this);

if (fromDDD_) {
cc.setConsumes(idealGeomToken_).setConsumes(dddConstantsToken_);
idealGeomToken_ = cc.consumes();
dddConstantsToken_ = cc.consumes();
} else if (fromDD4hep_) {
cc.setConsumes(idealDD4hepGeomToken_).setConsumes(dddConstantsToken_);
idealDD4hepGeomToken_ = cc.consumes();
dddConstantsToken_ = cc.consumes();
} else {
cc.setConsumes(recoIdealToken_);
recoIdealToken_ = cc.consumes();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,12 @@ class TrackerParametersESModule : public edm::ESProducer {
ReturnType produce(const PTrackerParametersRcd&);

private:
edm::ESGetToken<DDCompactView, IdealGeometryRecord> geomToken_;
const edm::ESGetToken<DDCompactView, IdealGeometryRecord> geomToken_;
};

TrackerParametersESModule::TrackerParametersESModule(const edm::ParameterSet&) {
TrackerParametersESModule::TrackerParametersESModule(const edm::ParameterSet&)
: geomToken_{setWhatProduced(this).consumes()} {
edm::LogInfo("TRACKER") << "TrackerParametersESModule::TrackerParametersESModule";

setWhatProduced(this).setConsumes(geomToken_);
}

TrackerParametersESModule::~TrackerParametersESModule() {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,12 @@ class TrackerParametersESProducer : public edm::ESProducer {
ReturnType produce(const PTrackerParametersRcd&);

private:
edm::ESGetToken<cms::DDCompactView, IdealGeometryRecord> geomToken_;
const edm::ESGetToken<cms::DDCompactView, IdealGeometryRecord> geomToken_;
};

TrackerParametersESProducer::TrackerParametersESProducer(const edm::ParameterSet&) {
TrackerParametersESProducer::TrackerParametersESProducer(const edm::ParameterSet&)
: geomToken_(setWhatProduced(this).consumes()) {
edm::LogInfo("TRACKER") << "TrackerParametersESProducer::TrackerParametersESProducer";

setWhatProduced(this).setConsumes(geomToken_);
}

TrackerParametersESProducer::~TrackerParametersESProducer() {}
Expand Down