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 IMOC/EventVertexGenerators #30485

Merged
merged 1 commit into from
Jul 4, 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
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ ________________________________________________________________________

#include "IOMC/EventVertexGenerators/interface/BaseEvtVtxGenerator.h"
#include "FWCore/Framework/interface/ESWatcher.h"
#include "FWCore/Utilities/interface/ESGetToken.h"
#include "CondFormats/DataRecord/interface/SimBeamSpotObjectsRcd.h"
#include "CondFormats/BeamSpotObjects/interface/SimBeamSpotObjects.h"

namespace CLHEP {
class HepRandomEngine;
Expand All @@ -31,7 +33,6 @@ class BetafuncEvtVtxGenerator : public BaseEvtVtxGenerator {
BetafuncEvtVtxGenerator(const edm::ParameterSet& p);
~BetafuncEvtVtxGenerator() override;

void beginRun(const edm::Run&, const edm::EventSetup&) override;
void beginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) override;

/// return a new event vertex
Expand Down Expand Up @@ -80,6 +81,7 @@ class BetafuncEvtVtxGenerator : public BaseEvtVtxGenerator {

void update(const edm::EventSetup& iEventSetup);
edm::ESWatcher<SimBeamSpotObjectsRcd> parameterWatcher_;
edm::ESGetToken<SimBeamSpotObjects, SimBeamSpotObjectsRcd> beamToken_;
};

#endif
8 changes: 5 additions & 3 deletions IOMC/EventVertexGenerators/src/BeamDivergenceVtxGenerator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
#include "FWCore/ServiceRegistry/interface/Service.h"
#include "FWCore/Utilities/interface/RandomNumberGenerator.h"
#include "FWCore/Utilities/interface/ESGetToken.h"

#include "SimDataFormats/GeneratorProducts/interface/HepMCProduct.h"

Expand All @@ -36,6 +37,7 @@ class BeamDivergenceVtxGenerator : public edm::stream::EDProducer<> {

private:
edm::EDGetTokenT<edm::HepMCProduct> sourceToken_;
edm::ESGetToken<CTPPSBeamParameters, CTPPSBeamParametersRcd> beamParametersToken_;
std::vector<edm::EDGetTokenT<reco::GenParticleCollection>> genParticleTokens_;

bool simulateVertex_;
Expand All @@ -57,7 +59,8 @@ class BeamDivergenceVtxGenerator : public edm::stream::EDProducer<> {
//----------------------------------------------------------------------------------------------------

BeamDivergenceVtxGenerator::BeamDivergenceVtxGenerator(const edm::ParameterSet &iConfig)
: simulateVertex_(iConfig.getParameter<bool>("simulateVertex")),
: beamParametersToken_(esConsumes<CTPPSBeamParameters, CTPPSBeamParametersRcd>()),
simulateVertex_(iConfig.getParameter<bool>("simulateVertex")),
simulateBeamDivergence_(iConfig.getParameter<bool>("simulateBeamDivergence")) {
const edm::InputTag tagSrcHepMC = iConfig.getParameter<edm::InputTag>("src");
if (!tagSrcHepMC.label().empty())
Expand Down Expand Up @@ -102,8 +105,7 @@ void BeamDivergenceVtxGenerator::produce(edm::Event &iEvent, const edm::EventSet
CLHEP::HepRandomEngine *rnd = &(rng->getEngine(iEvent.streamID()));

// get conditions
edm::ESHandle<CTPPSBeamParameters> hBeamParameters;
iSetup.get<CTPPSBeamParametersRcd>().get(hBeamParameters);
edm::ESHandle<CTPPSBeamParameters> hBeamParameters = iSetup.getHandle(beamParametersToken_);

// get HepMC input (if given)
HepMC::GenEvent *genEvt;
Expand Down
10 changes: 4 additions & 6 deletions IOMC/EventVertexGenerators/src/BetafuncEvtVtxGenerator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@ ________________________________________________________________________
//#include "CLHEP/Vector/ThreeVector.h"
#include "HepMC/SimpleVector.h"

#include "CondFormats/DataRecord/interface/SimBeamSpotObjectsRcd.h"
#include "CondFormats/BeamSpotObjects/interface/SimBeamSpotObjects.h"

#include <iostream>

BetafuncEvtVtxGenerator::BetafuncEvtVtxGenerator(const edm::ParameterSet& p) : BaseEvtVtxGenerator(p), boost_(4, 4) {
Expand All @@ -50,19 +47,20 @@ BetafuncEvtVtxGenerator::BetafuncEvtVtxGenerator(const edm::ParameterSet& p) : B
<< "Illegal resolution in Z (SigmaZ is negative)";
}
}
if (readDB_) {
beamToken_ = esConsumes<SimBeamSpotObjects, SimBeamSpotObjectsRcd, edm::Transition::BeginLuminosityBlock>();
}
}

BetafuncEvtVtxGenerator::~BetafuncEvtVtxGenerator() {}

void BetafuncEvtVtxGenerator::beginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const& iEventSetup) {
update(iEventSetup);
}
void BetafuncEvtVtxGenerator::beginRun(const edm::Run&, const edm::EventSetup& iEventSetup) { update(iEventSetup); }
Copy link
Contributor

Choose a reason for hiding this comment

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

Getting from the EventSetup in both the BeginRun and BeginLuminosityBlock is unnecessary and would have required 2 different tokens.


void BetafuncEvtVtxGenerator::update(const edm::EventSetup& iEventSetup) {
if (readDB_ && parameterWatcher_.check(iEventSetup)) {
edm::ESHandle<SimBeamSpotObjects> beamhandle;
iEventSetup.get<SimBeamSpotObjectsRcd>().get(beamhandle);
edm::ESHandle<SimBeamSpotObjects> beamhandle = iEventSetup.getHandle(beamToken_);

fX0 = beamhandle->fX0;
fY0 = beamhandle->fY0;
Expand Down