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

added esConsumes to modules in RecoVertex/BeamSpotProducer #30554

Merged
merged 3 commits into from
Jul 7, 2020
Merged
Show file tree
Hide file tree
Changes from 2 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
5 changes: 5 additions & 0 deletions RecoVertex/BeamSpotProducer/interface/BeamSpotFromDB.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ ________________________________________________________________**/
#include "FWCore/Framework/interface/EDAnalyzer.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/Utilities/interface/ESGetToken.h"

#include "CondFormats/DataRecord/interface/BeamSpotObjectsRcd.h"
#include "CondFormats/BeamSpotObjects/interface/BeamSpotObjects.h"

class BeamSpotFromDB : public edm::EDAnalyzer {
public:
Expand All @@ -29,6 +33,7 @@ class BeamSpotFromDB : public edm::EDAnalyzer {
void beginJob() override;
void analyze(const edm::Event&, const edm::EventSetup&) override;
void endJob() override;
edm::ESGetToken<BeamSpotObjects, BeamSpotObjectsRcd> m_beamToken;
};

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ ________________________________________________________________**/
#include "DataFormats/Common/interface/Handle.h"
#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/Utilities/interface/ESGetToken.h"

#include "CondFormats/DataRecord/interface/BeamSpotObjectsRcd.h"
Copy link
Contributor

Choose a reason for hiding this comment

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

These two includes can be removed from the implementation file, then

#include "CondFormats/BeamSpotObjects/interface/BeamSpotObjects.h"
#include "DataFormats/Scalers/interface/BeamSpotOnline.h"
#include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerEvmReadoutRecord.h"

Expand All @@ -38,6 +42,7 @@ class BeamSpotOnlineProducer : public edm::stream::EDProducer<> {
double theMaxR2;
const edm::EDGetTokenT<BeamSpotOnlineCollection> scalerToken_;
const edm::EDGetTokenT<L1GlobalTriggerEvmReadoutRecord> l1GtEvmReadoutRecordToken_;
const edm::ESGetToken<BeamSpotObjects, BeamSpotObjectsRcd> beamToken_;

const unsigned int theBeamShoutMode;
};
Expand Down
5 changes: 5 additions & 0 deletions RecoVertex/BeamSpotProducer/interface/BeamSpotProducer.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ ________________________________________________________________**/
#include "DataFormats/Common/interface/Handle.h"
#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/Utilities/interface/ESGetToken.h"

#include "CondFormats/DataRecord/interface/BeamSpotObjectsRcd.h"
#include "CondFormats/BeamSpotObjects/interface/BeamSpotObjects.h"

class BeamSpotProducer : public edm::stream::EDProducer<> {
public:
Expand All @@ -31,6 +35,7 @@ class BeamSpotProducer : public edm::stream::EDProducer<> {
void produce(edm::Event& iEvent, const edm::EventSetup& iSetup) override;

private:
edm::ESGetToken<BeamSpotObjects, BeamSpotObjectsRcd> m_beamToken;
};

#endif
8 changes: 3 additions & 5 deletions RecoVertex/BeamSpotProducer/plugins/BeamSpotFromDB.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,14 @@ ________________________________________________________________**/
#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/Framework/interface/IOVSyncValue.h"
#include "CondFormats/DataRecord/interface/BeamSpotObjectsRcd.h"
#include "CondFormats/BeamSpotObjects/interface/BeamSpotObjects.h"

BeamSpotFromDB::BeamSpotFromDB(const edm::ParameterSet& iConfig) {}
BeamSpotFromDB::BeamSpotFromDB(const edm::ParameterSet& iConfig)
: m_beamToken(esConsumes<BeamSpotObjects, BeamSpotObjectsRcd>()) {}

BeamSpotFromDB::~BeamSpotFromDB() {}

void BeamSpotFromDB::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
edm::ESHandle<BeamSpotObjects> beamhandle;
iSetup.get<BeamSpotObjectsRcd>().get(beamhandle);
edm::ESHandle<BeamSpotObjects> beamhandle = iSetup.getHandle(m_beamToken);
const BeamSpotObjects* mybeamspot = beamhandle.product();

std::cout << " for runs: " << iEvent.id().run() << " - " << iEvent.id().run() << std::endl;
Expand Down
4 changes: 2 additions & 2 deletions RecoVertex/BeamSpotProducer/plugins/BeamSpotOnlineProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ BeamSpotOnlineProducer::BeamSpotOnlineProducer(const ParameterSet& iconf)
theSetSigmaZ(iconf.getParameter<double>("setSigmaZ")),
scalerToken_(consumes<BeamSpotOnlineCollection>(iconf.getParameter<InputTag>("src"))),
l1GtEvmReadoutRecordToken_(consumes<L1GlobalTriggerEvmReadoutRecord>(iconf.getParameter<InputTag>("gtEvmLabel"))),
beamToken_(esConsumes<BeamSpotObjects, BeamSpotObjectsRcd>()),
theBeamShoutMode(iconf.getUntrackedParameter<unsigned int>("beamMode", 11)) {
theMaxR2 = iconf.getParameter<double>("maxRadius");
theMaxR2 *= theMaxR2;
Expand Down Expand Up @@ -106,8 +107,7 @@ void BeamSpotOnlineProducer::produce(Event& iEvent, const EventSetup& iSetup) {
}

if (fallBackToDB) {
edm::ESHandle<BeamSpotObjects> beamhandle;
iSetup.get<BeamSpotObjectsRcd>().get(beamhandle);
edm::ESHandle<BeamSpotObjects> beamhandle = iSetup.getHandle(beamToken_);
const BeamSpotObjects* spotDB = beamhandle.product();

// translate from BeamSpotObjects to reco::BeamSpot
Expand Down
6 changes: 2 additions & 4 deletions RecoVertex/BeamSpotProducer/plugins/BeamSpotProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/Framework/interface/IOVSyncValue.h"
#include "CondFormats/DataRecord/interface/BeamSpotObjectsRcd.h"
#include "CondFormats/BeamSpotObjects/interface/BeamSpotObjects.h"

#include "DataFormats/Math/interface/Error.h"
#include "DataFormats/Math/interface/Point3D.h"
Expand All @@ -21,6 +19,7 @@ BeamSpotProducer::BeamSpotProducer(const edm::ParameterSet& iConf) {
<< "\n";

//fVerbose=conf.getUntrackedParameter<bool>("verbose", false);
m_beamToken = esConsumes<BeamSpotObjects, BeamSpotObjectsRcd>();

produces<reco::BeamSpot>();
}
Expand All @@ -46,8 +45,7 @@ void BeamSpotProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup
//try {
edm::LogInfo("RecoVertex/BeamSpotProducer") << "Reconstructing event number: " << iEvent.id() << "\n";

edm::ESHandle<BeamSpotObjects> beamhandle;
iSetup.get<BeamSpotObjectsRcd>().get(beamhandle);
edm::ESHandle<BeamSpotObjects> beamhandle = iSetup.getHandle(m_beamToken);
const BeamSpotObjects* spotDB = beamhandle.product();

// translate from BeamSpotObjects to reco::BeamSpot
Expand Down