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

Moved modules in PhysicsTools/PatExamples to be thread-friendly #36399

Merged
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
10 changes: 4 additions & 6 deletions PhysicsTools/PatExamples/plugins/JetEnergyShift.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/EDProducer.h"
#include "FWCore/Framework/interface/global/EDProducer.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"

#include "DataFormats/PatCandidates/interface/Jet.h"
Expand Down Expand Up @@ -31,16 +31,14 @@
and met input collections.
*/

class JetEnergyShift : public edm::EDProducer {
class JetEnergyShift : public edm::global::EDProducer<> {
public:
/// default constructor
explicit JetEnergyShift(const edm::ParameterSet&);
/// default destructor
~JetEnergyShift() override{};

private:
/// rescale jet energy and recalculated MET
void produce(edm::Event&, const edm::EventSetup&) override;
void produce(edm::StreamID, edm::Event&, const edm::EventSetup&) const override;

private:
/// jet input collection
Expand Down Expand Up @@ -73,7 +71,7 @@ JetEnergyShift::JetEnergyShift(const edm::ParameterSet& cfg)
produces<std::vector<pat::MET>>(outputMETs_);
}

void JetEnergyShift::produce(edm::Event& event, const edm::EventSetup& setup) {
void JetEnergyShift::produce(edm::StreamID, edm::Event& event, const edm::EventSetup& setup) const {
edm::Handle<std::vector<pat::Jet>> jets;
event.getByToken(inputJetsToken_, jets);

Expand Down
5 changes: 3 additions & 2 deletions PhysicsTools/PatExamples/plugins/MuonAnalyzer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include "CommonTools/UtilAlgos/interface/TFileService.h"
#include "DataFormats/Math/interface/LorentzVector.h"
#include "DataFormats/PatCandidates/interface/Muon.h"
#include "FWCore/Framework/interface/EDAnalyzer.h"
#include "FWCore/Framework/interface/one/EDAnalyzer.h"
#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/Frameworkfwd.h"
Expand All @@ -18,7 +18,7 @@
#include "TH1F.h"
#include "TH2F.h"

class ExampleMuonAnalyzer : public edm::EDAnalyzer {
class ExampleMuonAnalyzer : public edm::one::EDAnalyzer<edm::one::SharedResources> {
public:
/// Constructor
ExampleMuonAnalyzer(const edm::ParameterSet &pset);
Expand Down Expand Up @@ -65,6 +65,7 @@ using namespace edm;
/// Constructor
ExampleMuonAnalyzer::ExampleMuonAnalyzer(const ParameterSet &pset) {
theMuonToken = consumes<pat::MuonCollection>(pset.getParameter<InputTag>("MuonCollection"));
usesResource(TFileService::kSharedResource);
}

/// Destructor
Expand Down
8 changes: 5 additions & 3 deletions PhysicsTools/PatExamples/plugins/PatBJetTagAnalyzer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/Framework/interface/EDAnalyzer.h"
#include "FWCore/Framework/interface/one/EDAnalyzer.h"
#include "FWCore/Utilities/interface/InputTag.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/ServiceRegistry/interface/Service.h"
Expand All @@ -17,7 +17,7 @@

#include "DataFormats/PatCandidates/interface/Jet.h"

class PatBJetTagAnalyzer : public edm::EDAnalyzer {
class PatBJetTagAnalyzer : public edm::one::EDAnalyzer<edm::one::SharedResources> {
public:
/// constructor and destructor
PatBJetTagAnalyzer(const edm::ParameterSet &params);
Expand Down Expand Up @@ -49,7 +49,9 @@ class PatBJetTagAnalyzer : public edm::EDAnalyzer {
PatBJetTagAnalyzer::PatBJetTagAnalyzer(const edm::ParameterSet &params)
: jetsToken_(consumes<pat::JetCollection>(params.getParameter<edm::InputTag>("jets"))),
jetPtCut_(params.getParameter<double>("jetPtCut")),
jetEtaCut_(params.getParameter<double>("jetEtaCut")) {}
jetEtaCut_(params.getParameter<double>("jetEtaCut")) {
usesResource(TFileService::kSharedResource);
}

PatBJetTagAnalyzer::~PatBJetTagAnalyzer() {}

Expand Down
8 changes: 5 additions & 3 deletions PhysicsTools/PatExamples/plugins/PatBJetTrackAnalyzer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/Framework/interface/EDAnalyzer.h"
#include "FWCore/Framework/interface/one/EDAnalyzer.h"
#include "FWCore/Utilities/interface/InputTag.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/ServiceRegistry/interface/Service.h"
Expand All @@ -27,7 +27,7 @@
#include "DataFormats/PatCandidates/interface/Jet.h"
#include "DataFormats/GeometryCommonDetAlgo/interface/Measurement1D.h"

class PatBJetTrackAnalyzer : public edm::EDAnalyzer {
class PatBJetTrackAnalyzer : public edm::one::EDAnalyzer<edm::one::SharedResources> {
public:
/// constructor and destructor
PatBJetTrackAnalyzer(const edm::ParameterSet &params);
Expand Down Expand Up @@ -80,7 +80,9 @@ PatBJetTrackAnalyzer::PatBJetTrackAnalyzer(const edm::ParameterSet &params)
minPt_(params.getParameter<double>("minPt")),
minPixelHits_(params.getParameter<unsigned int>("minPixelHits")),
minTotalHits_(params.getParameter<unsigned int>("minTotalHits")),
nThTrack_(params.getParameter<unsigned int>("nThTrack")) {}
nThTrack_(params.getParameter<unsigned int>("nThTrack")) {
usesResource(TFileService::kSharedResource);
}

PatBJetTrackAnalyzer::~PatBJetTrackAnalyzer() {}

Expand Down
8 changes: 5 additions & 3 deletions PhysicsTools/PatExamples/plugins/PatBJetVertexAnalyzer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/Framework/interface/EDAnalyzer.h"
#include "FWCore/Framework/interface/one/EDAnalyzer.h"
#include "FWCore/Utilities/interface/InputTag.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/ServiceRegistry/interface/Service.h"
Expand All @@ -30,7 +30,7 @@
#include "DataFormats/PatCandidates/interface/Jet.h"
#include "DataFormats/GeometryCommonDetAlgo/interface/Measurement1D.h"

class PatBJetVertexAnalyzer : public edm::EDAnalyzer {
class PatBJetVertexAnalyzer : public edm::one::EDAnalyzer<edm::one::SharedResources> {
public:
/// constructor and destructor
PatBJetVertexAnalyzer(const edm::ParameterSet &params);
Expand Down Expand Up @@ -65,7 +65,9 @@ class PatBJetVertexAnalyzer : public edm::EDAnalyzer {
PatBJetVertexAnalyzer::PatBJetVertexAnalyzer(const edm::ParameterSet &params)
: jetsToken_(consumes<pat::JetCollection>(params.getParameter<edm::InputTag>("jets"))),
jetPtCut_(params.getParameter<double>("jetPtCut")),
jetEtaCut_(params.getParameter<double>("jetEtaCut")) {}
jetEtaCut_(params.getParameter<double>("jetEtaCut")) {
usesResource(TFileService::kSharedResource);
}

PatBJetVertexAnalyzer::~PatBJetVertexAnalyzer() {}

Expand Down
5 changes: 3 additions & 2 deletions PhysicsTools/PatExamples/plugins/PatBTagAnalyzer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include "TGraphErrors.h"

#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/EDAnalyzer.h"
#include "FWCore/Framework/interface/one/EDAnalyzer.h"
#include "FWCore/Utilities/interface/InputTag.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/ServiceRegistry/interface/Service.h"
Expand All @@ -18,7 +18,7 @@
#include "PhysicsTools/PatExamples/interface/BTagPerformance.h"
#include "PhysicsTools/PatExamples/interface/PatBTagCommonHistos.h"

class PatBTagAnalyzer : public edm::EDAnalyzer {
class PatBTagAnalyzer : public edm::one::EDAnalyzer<edm::one::SharedResources> {
public:
explicit PatBTagAnalyzer(const edm::ParameterSet &);
~PatBTagAnalyzer() override;
Expand Down Expand Up @@ -74,6 +74,7 @@ PatBTagAnalyzer::PatBTagAnalyzer(const edm::ParameterSet &iConfig)
BTagger(iConfig.getParameter<edm::ParameterSet>("BJetOperatingPoints")),
BTagHistograms(iConfig) {
//now do what ever initialization is needed
usesResource(TFileService::kSharedResource);
}

PatBTagAnalyzer::~PatBTagAnalyzer() {
Expand Down
8 changes: 5 additions & 3 deletions PhysicsTools/PatExamples/plugins/PatBasicAnalyzer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include "TH1.h"

#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/EDAnalyzer.h"
#include "FWCore/Framework/interface/one/EDAnalyzer.h"
#include "FWCore/Utilities/interface/InputTag.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/ServiceRegistry/interface/Service.h"
Expand All @@ -17,7 +17,7 @@
#include "DataFormats/PatCandidates/interface/Jet.h"
#include "DataFormats/PatCandidates/interface/MET.h"

class PatBasicAnalyzer : public edm::EDAnalyzer {
class PatBasicAnalyzer : public edm::one::EDAnalyzer<edm::one::SharedResources> {
public:
/// default constructor
explicit PatBasicAnalyzer(const edm::ParameterSet&);
Expand Down Expand Up @@ -55,7 +55,9 @@ PatBasicAnalyzer::PatBasicAnalyzer(const edm::ParameterSet& iConfig)
muonSrcToken_(consumes<edm::View<pat::Muon>>(iConfig.getUntrackedParameter<edm::InputTag>("muonSrc"))),
tauSrcToken_(consumes<edm::View<pat::Tau>>(iConfig.getUntrackedParameter<edm::InputTag>("tauSrc"))),
jetSrcToken_(consumes<edm::View<pat::Jet>>(iConfig.getUntrackedParameter<edm::InputTag>("jetSrc"))),
metSrcToken_(consumes<edm::View<pat::MET>>(iConfig.getUntrackedParameter<edm::InputTag>("metSrc"))) {}
metSrcToken_(consumes<edm::View<pat::MET>>(iConfig.getUntrackedParameter<edm::InputTag>("metSrc"))) {
usesResource(TFileService::kSharedResource);
}

PatBasicAnalyzer::~PatBasicAnalyzer() {}

Expand Down
6 changes: 4 additions & 2 deletions PhysicsTools/PatExamples/plugins/PatElectronAnalyzer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include "TMath.h"

#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/EDAnalyzer.h"
#include "FWCore/Framework/interface/one/EDAnalyzer.h"
#include "FWCore/Utilities/interface/InputTag.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/ServiceRegistry/interface/Service.h"
Expand All @@ -12,7 +12,7 @@
#include "DataFormats/PatCandidates/interface/Electron.h"
#include "DataFormats/HepMCCandidate/interface/GenParticle.h"

class PatElectronAnalyzer : public edm::EDAnalyzer {
class PatElectronAnalyzer : public edm::one::EDAnalyzer<edm::one::SharedResources> {
public:
explicit PatElectronAnalyzer(const edm::ParameterSet &);
~PatElectronAnalyzer() override;
Expand Down Expand Up @@ -81,6 +81,8 @@ PatElectronAnalyzer::PatElectronAnalyzer(const edm::ParameterSet &cfg)
particleSrcToken_(consumes<reco::GenParticleCollection>(cfg.getParameter<edm::InputTag>("particleSrc"))),
genMatchMode_(cfg.getParameter<edm::ParameterSet>("genMatchMode")),
tagAndProbeMode_(cfg.getParameter<edm::ParameterSet>("tagAndProbeMode")) {
usesResource(TFileService::kSharedResource);

// complete the configuration of the analyzer
maxDeltaR_ = genMatchMode_.getParameter<double>("maxDeltaR");
maxDeltaM_ = tagAndProbeMode_.getParameter<double>("maxDeltaM");
Expand Down
19 changes: 4 additions & 15 deletions PhysicsTools/PatExamples/plugins/PatJPsiProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

// user include files
#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/EDProducer.h"
#include "FWCore/Framework/interface/global/EDProducer.h"

#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/MakerMacros.h"
Expand All @@ -44,15 +44,12 @@
// class decleration
//

class PatJPsiProducer : public edm::EDProducer {
class PatJPsiProducer : public edm::global::EDProducer<> {
public:
explicit PatJPsiProducer(const edm::ParameterSet&);
~PatJPsiProducer() override;

private:
void beginJob() override;
void produce(edm::Event&, const edm::EventSetup&) override;
void endJob() override;
void produce(edm::StreamID, edm::Event&, const edm::EventSetup&) const override;

// ----------member data ---------------------------

Expand All @@ -75,14 +72,12 @@ PatJPsiProducer::PatJPsiProducer(const edm::ParameterSet& iConfig)
produces<std::vector<pat::CompositeCandidate>>();
}

PatJPsiProducer::~PatJPsiProducer() {}

//
// member functions
//

// ------------ method called to produce the data ------------
void PatJPsiProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) {
void PatJPsiProducer::produce(edm::StreamID, edm::Event& iEvent, const edm::EventSetup& iSetup) const {
auto jpsiCands = std::make_unique<std::vector<pat::CompositeCandidate>>();
edm::Handle<edm::View<pat::Muon>> h_muons;
iEvent.getByToken(muonSrcToken_, h_muons);
Expand Down Expand Up @@ -122,11 +117,5 @@ void PatJPsiProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup)
iEvent.put(std::move(jpsiCands));
}

// ------------ method called once each job just before starting event loop ------------
void PatJPsiProducer::beginJob() {}

// ------------ method called once each job just after ending the event loop ------------
void PatJPsiProducer::endJob() {}

//define this as a plug-in
DEFINE_FWK_MODULE(PatJPsiProducer);
5 changes: 3 additions & 2 deletions PhysicsTools/PatExamples/plugins/PatJetAnalyzer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include "TH1.h"

#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/EDAnalyzer.h"
#include "FWCore/Framework/interface/one/EDAnalyzer.h"
#include "FWCore/Utilities/interface/InputTag.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/ServiceRegistry/interface/Service.h"
Expand Down Expand Up @@ -39,7 +39,7 @@ static const float BINS[] = {30., 40., 50., 60., 70., 80., 100., 125., 150.};
- corrLevel --> string for the pat jet correction level.
*/

class PatJetAnalyzer : public edm::EDAnalyzer {
class PatJetAnalyzer : public edm::one::EDAnalyzer<edm::one::SharedResources> {
public:
/// default contructor
explicit PatJetAnalyzer(const edm::ParameterSet& cfg);
Expand Down Expand Up @@ -72,6 +72,7 @@ class PatJetAnalyzer : public edm::EDAnalyzer {
PatJetAnalyzer::PatJetAnalyzer(const edm::ParameterSet& cfg)
: corrLevel_(cfg.getParameter<std::string>("corrLevel")),
jetsToken_(consumes<edm::View<pat::Jet> >(cfg.getParameter<edm::InputTag>("src"))) {
usesResource(TFileService::kSharedResource);
// register TFileService
edm::Service<TFileService> fs;

Expand Down
8 changes: 5 additions & 3 deletions PhysicsTools/PatExamples/plugins/PatMCMatching.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include "TH1.h"

#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/EDAnalyzer.h"
#include "FWCore/Framework/interface/one/EDAnalyzer.h"
#include "FWCore/Utilities/interface/InputTag.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/ServiceRegistry/interface/Service.h"
Expand All @@ -13,7 +13,7 @@

#include "DataFormats/PatCandidates/interface/Muon.h"

class PatMCMatching : public edm::EDAnalyzer {
class PatMCMatching : public edm::one::EDAnalyzer<edm::one::SharedResources> {
public:
/// default constructor
explicit PatMCMatching(const edm::ParameterSet&);
Expand All @@ -36,7 +36,9 @@ class PatMCMatching : public edm::EDAnalyzer {

PatMCMatching::PatMCMatching(const edm::ParameterSet& iConfig)
: histContainer_(),
muonSrcToken_(consumes<edm::View<pat::Muon> >(iConfig.getUntrackedParameter<edm::InputTag>("muonSrc"))) {}
muonSrcToken_(consumes<edm::View<pat::Muon> >(iConfig.getUntrackedParameter<edm::InputTag>("muonSrc"))) {
usesResource(TFileService::kSharedResource);
}

PatMCMatching::~PatMCMatching() {}

Expand Down
8 changes: 5 additions & 3 deletions PhysicsTools/PatExamples/plugins/PatMCMatchingExtended.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include "TH1.h"

#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/EDAnalyzer.h"
#include "FWCore/Framework/interface/one/EDAnalyzer.h"
#include "FWCore/Utilities/interface/InputTag.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/ServiceRegistry/interface/Service.h"
Expand All @@ -13,7 +13,7 @@

#include "DataFormats/PatCandidates/interface/Muon.h"

class PatMCMatchingExtended : public edm::EDAnalyzer {
class PatMCMatchingExtended : public edm::one::EDAnalyzer<edm::one::SharedResources> {
public:
/// default constructor
explicit PatMCMatchingExtended(const edm::ParameterSet&);
Expand Down Expand Up @@ -48,7 +48,9 @@ class PatMCMatchingExtended : public edm::EDAnalyzer {

PatMCMatchingExtended::PatMCMatchingExtended(const edm::ParameterSet& iConfig)
: histContainer_(),
muonSrcToken_(consumes<edm::View<pat::Muon> >(iConfig.getUntrackedParameter<edm::InputTag>("muonSrc"))) {}
muonSrcToken_(consumes<edm::View<pat::Muon> >(iConfig.getUntrackedParameter<edm::InputTag>("muonSrc"))) {
usesResource(TFileService::kSharedResource);
}

PatMCMatchingExtended::~PatMCMatchingExtended() {}

Expand Down
5 changes: 3 additions & 2 deletions PhysicsTools/PatExamples/plugins/PatTauAnalyzer.cc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "CommonTools/UtilAlgos/interface/TFileService.h"
#include "DataFormats/PatCandidates/interface/Tau.h"
#include "FWCore/Framework/interface/EDAnalyzer.h"
#include "FWCore/Framework/interface/one/EDAnalyzer.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/Framework/interface/Frameworkfwd.h"
Expand All @@ -14,7 +14,7 @@

#include <string>

class PatTauAnalyzer : public edm::EDAnalyzer {
class PatTauAnalyzer : public edm::one::EDAnalyzer<edm::one::SharedResources> {
public:
explicit PatTauAnalyzer(const edm::ParameterSet&);
~PatTauAnalyzer() override;
Expand Down Expand Up @@ -87,6 +87,7 @@ const reco::GenParticle* getGenTau(const pat::Tau& patTau) {

PatTauAnalyzer::PatTauAnalyzer(const edm::ParameterSet& cfg) {
//std::cout << "<PatTauAnalyzer::PatTauAnalyzer>:" << std::endl;
usesResource(TFileService::kSharedResource);

//--- read name of pat::Tau collection
src_ = cfg.getParameter<edm::InputTag>("src");
Expand Down
Loading