Skip to content

Commit

Permalink
Use thread-friendly modules in Validation/RecoParticleFlow
Browse files Browse the repository at this point in the history
- changed from legacy to thread-friendly module types
- minor code improvements
  • Loading branch information
Dr15Jones committed Jun 9, 2022
1 parent 03c0e6a commit 1d9dd6b
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 59 deletions.
Expand Up @@ -10,7 +10,7 @@
#include "DataFormats/Common/interface/Handle.h"
#include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h"
#include "DataFormats/ParticleFlowCandidate/interface/PFCandidateFwd.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/MessageLogger/interface/MessageLogger.h"
Expand All @@ -29,7 +29,7 @@
#include <ostream>
#include <vector>

class GenericBenchmarkAnalyzer : public edm::EDAnalyzer, public GenericBenchmark {
class GenericBenchmarkAnalyzer : public edm::one::EDAnalyzer<>, public GenericBenchmark {
public:
explicit GenericBenchmarkAnalyzer(const edm::ParameterSet &);
~GenericBenchmarkAnalyzer() override;
Expand Down
12 changes: 6 additions & 6 deletions Validation/RecoParticleFlow/plugins/PFFilter.cc
Expand Up @@ -4,21 +4,21 @@
#include "DataFormats/Candidate/interface/Candidate.h"
#include "DataFormats/Candidate/interface/CandidateFwd.h"
#include "DataFormats/Common/interface/Handle.h"
#include "FWCore/Framework/interface/EDFilter.h"
#include "FWCore/Framework/interface/global/EDFilter.h"
#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/Utilities/interface/InputTag.h"

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

bool filter(edm::Event &, const edm::EventSetup &) override;
bool filter(edm::StreamID, edm::Event &, const edm::EventSetup &) const override;
void beginJob() override;
void endJob() override;
bool checkInput();
bool checkInput() const;

private:
std::vector<std::string> collections_;
Expand All @@ -40,7 +40,7 @@ PFFilter::PFFilter(const edm::ParameterSet &iConfig) {

PFFilter::~PFFilter() {}

bool PFFilter::checkInput() {
bool PFFilter::checkInput() const {
if (collections_.size() != min_.size()) {
std::cout << "Error: in PFFilter: collections_.size()!=min_.size()" << std::endl;
std::cout << "collections_.size() = " << collections_.size() << std::endl;
Expand Down Expand Up @@ -78,7 +78,7 @@ void PFFilter::beginJob() {
// std::cout << "FL: beginJob" << std::endl;
}

bool PFFilter::filter(edm::Event &iEvent, const edm::EventSetup &iSetup) {
bool PFFilter::filter(edm::StreamID, edm::Event &iEvent, const edm::EventSetup &iSetup) const {
// std::cout << "FL: filter" << std::endl;
// std::cout << "FL: Mins = " << min_ << std::endl;

Expand Down
27 changes: 14 additions & 13 deletions Validation/RecoParticleFlow/plugins/PFJetBenchmarkAnalyzer.cc
Expand Up @@ -21,7 +21,7 @@
#include <memory>

// user include files
#include "FWCore/Framework/interface/EDAnalyzer.h"
#include "FWCore/Framework/interface/one/EDAnalyzer.h"
#include "FWCore/Framework/interface/Frameworkfwd.h"

#include "FWCore/Framework/interface/Event.h"
Expand All @@ -46,7 +46,7 @@ using namespace std;
//
// class decleration

class PFJetBenchmarkAnalyzer : public edm::EDAnalyzer {
class PFJetBenchmarkAnalyzer : public edm::one::EDAnalyzer<> {
public:
typedef dqm::legacy::DQMStore DQMStore;
typedef dqm::legacy::MonitorElement MonitorElement;
Expand All @@ -61,20 +61,21 @@ class PFJetBenchmarkAnalyzer : public edm::EDAnalyzer {
// ----------member data ---------------------------
edm::EDGetTokenT<reco::GenJetCollection> sGenJetAlgo_tok_;
edm::EDGetTokenT<reco::PFJetCollection> sJetAlgo_tok_;

// neuhaus - comment
PFJetBenchmark PFJetBenchmark_;
string outjetfilename;
bool pfjBenchmarkDebug;
bool plotAgainstReco;
bool onlyTwoJets;
double deltaRMax = 0.1;
string benchmarkLabel_;
double recPt;
double maxEta;
dqm::legacy::DQMStore *dbe_;
};
/// PFJet Benchmark

// neuhaus - comment
PFJetBenchmark PFJetBenchmark_;
string outjetfilename;
bool pfjBenchmarkDebug;
bool plotAgainstReco;
bool onlyTwoJets;
double deltaRMax = 0.1;
string benchmarkLabel_;
double recPt;
double maxEta;
dqm::legacy::DQMStore *dbe_;
//
// constants, enums and typedefs
//
Expand Down
36 changes: 17 additions & 19 deletions Validation/RecoParticleFlow/plugins/PFJetFilter.cc
Expand Up @@ -2,7 +2,7 @@
#include "DataFormats/Candidate/interface/CandidateFwd.h"
#include "DataFormats/Common/interface/Handle.h"
#include "DataFormats/JetReco/interface/PFJet.h"
#include "FWCore/Framework/interface/EDFilter.h"
#include "FWCore/Framework/interface/global/EDFilter.h"
#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/MakerMacros.h"
Expand All @@ -11,19 +11,20 @@
#include "FWCore/ServiceRegistry/interface/Service.h"
#include "FWCore/Utilities/interface/InputTag.h"
#include "RecoParticleFlow/Benchmark/interface/PFBenchmarkAlgo.h"
#include <atomic>

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

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

double resolution(double, bool);
double response(double, bool);
double resolution(double, bool) const;
double response(double, bool) const;

double recPt_cut;
double genPt_cut;
Expand All @@ -36,10 +37,8 @@ class PFJetFilter : public edm::EDFilter {
edm::EDGetTokenT<edm::View<reco::Candidate>> inputTruthLabel_;
edm::EDGetTokenT<edm::View<reco::Candidate>> inputRecoLabel_;

unsigned int entry;
mutable std::atomic<unsigned int> entry;
bool verbose;

PFBenchmarkAlgo *algo_;
};

#include "FWCore/Framework/interface/MakerMacros.h"
Expand Down Expand Up @@ -76,7 +75,7 @@ void PFJetFilter::beginJob() {}

void PFJetFilter::endJob() {}

bool PFJetFilter::filter(edm::Event &iEvent, const edm::EventSetup &iESetup) {
bool PFJetFilter::filter(edm::StreamID, edm::Event &iEvent, const edm::EventSetup &iESetup) const {
// Typedefs to use views
typedef edm::View<reco::Candidate> candidateCollection;
typedef edm::View<reco::Candidate> candidateCollection;
Expand Down Expand Up @@ -150,7 +149,7 @@ bool PFJetFilter::filter(edm::Event &iEvent, const edm::EventSetup &iESetup) {
if (i == j)
continue;
const reco::Candidate *other = &(*reco_candidates)[j];
double deltaR = algo_->deltaR(particle, other);
double deltaR = PFBenchmarkAlgo::deltaR(particle, other);
if (deltaR < deltaRmin && other->pt() > 0.25 * particle->pt() && other->pt() > recPt_cut) {
deltaRmin = deltaR;
ptmin = other->pt();
Expand All @@ -162,14 +161,14 @@ bool PFJetFilter::filter(edm::Event &iEvent, const edm::EventSetup &iESetup) {
continue;

// Find the closest genJet.
const reco::Candidate *gen_particle = algo_->matchByDeltaR(particle, truth_candidates);
const reco::Candidate *gen_particle = PFBenchmarkAlgo::matchByDeltaR(particle, truth_candidates);

// Check there is a genJet associated to the recoJet
if (gen_particle == nullptr)
continue;

// check deltaR is small enough
double deltaR = algo_->deltaR(particle, gen_particle);
double deltaR = PFBenchmarkAlgo::deltaR(particle, gen_particle);
if (deltaR > deltaR_max)
continue;

Expand All @@ -191,10 +190,10 @@ bool PFJetFilter::filter(edm::Event &iEvent, const edm::EventSetup &iESetup) {
if (nSig > deltaEt_max || nSig < deltaEt_min) {
/* */
if (verbose)
std::cout << "Entry " << entry << " resPt = " << resPt << " sigma/avera/nSig = " << sigma << "/" << avera << "/"
<< nSig << " pT (T/R) " << true_pt << "/" << rec_pt << " Eta (T/R) " << true_eta << "/" << rec_eta
<< " Phi (T/R) " << true_phi << "/" << rec_phi << " deltaRMin/ptmin " << deltaRmin << "/" << ptmin
<< std::endl;
std::cout << "Entry " << entry++ << " resPt = " << resPt << " sigma/avera/nSig = " << sigma << "/" << avera
<< "/" << nSig << " pT (T/R) " << true_pt << "/" << rec_pt << " Eta (T/R) " << true_eta << "/"
<< rec_eta << " Phi (T/R) " << true_phi << "/" << rec_phi << " deltaRMin/ptmin " << deltaRmin << "/"
<< ptmin << std::endl;
/* */
pass = true;
}
Expand All @@ -203,11 +202,10 @@ bool PFJetFilter::filter(edm::Event &iEvent, const edm::EventSetup &iESetup) {
break;
}

entry++;
return pass;
}

double PFJetFilter::resolution(double pt, bool barrel) {
double PFJetFilter::resolution(double pt, bool barrel) const {
double p0 = barrel ? 1.19200e-02 : 8.45341e-03;
double p1 = barrel ? 1.06138e+00 : 7.96855e-01;
double p2 = barrel ? -2.05929e+00 : -3.12076e-01;
Expand All @@ -216,7 +214,7 @@ double PFJetFilter::resolution(double pt, bool barrel) {
return resp;
}

double PFJetFilter::response(double pt, bool barrel) {
double PFJetFilter::response(double pt, bool barrel) const {
double p0 = barrel ? 1.09906E-1 : 6.91939E+1;
double p1 = barrel ? -1.61443E-1 : -6.92733E+1;
double p2 = barrel ? 3.45489E+3 : 1.58207E+6;
Expand Down
19 changes: 10 additions & 9 deletions Validation/RecoParticleFlow/plugins/PFMETBenchmarkAnalyzer.cc
Expand Up @@ -21,7 +21,7 @@
#include <memory>

// user include files
#include "FWCore/Framework/interface/EDAnalyzer.h"
#include "FWCore/Framework/interface/one/EDAnalyzer.h"
#include "FWCore/Framework/interface/Frameworkfwd.h"

#include "FWCore/Framework/interface/Event.h"
Expand All @@ -48,7 +48,7 @@ using namespace std;
//
// class decleration

class PFMETBenchmarkAnalyzer : public edm::EDAnalyzer {
class PFMETBenchmarkAnalyzer : public edm::one::EDAnalyzer<> {
public:
typedef dqm::legacy::DQMStore DQMStore;
typedef dqm::legacy::MonitorElement MonitorElement;
Expand All @@ -65,16 +65,17 @@ class PFMETBenchmarkAnalyzer : public edm::EDAnalyzer {
edm::EDGetTokenT<reco::PFMETCollection> sInputRecoLabel_tok_;
edm::EDGetTokenT<reco::CaloMETCollection> sInputCaloLabel_tok_;
edm::EDGetTokenT<reco::METCollection> sInputTCLabel_tok_;

// neuhaus - comment
PFMETBenchmark PFMETBenchmark_;
string OutputFileName;
bool pfmBenchmarkDebug;
bool xplotAgainstReco;
string xbenchmarkLabel_;
dqm::legacy::DQMStore *xdbe_;
};
/// PFJet Benchmark

// neuhaus - comment
PFMETBenchmark PFMETBenchmark_;
string OutputFileName;
bool pfmBenchmarkDebug;
bool xplotAgainstReco;
string xbenchmarkLabel_;
dqm::legacy::DQMStore *xdbe_;
//
// constants, enums and typedefs
//
Expand Down
12 changes: 6 additions & 6 deletions Validation/RecoParticleFlow/plugins/PFMETFilter.cc
Expand Up @@ -5,22 +5,22 @@
#include "DataFormats/Candidate/interface/CandidateFwd.h"
#include "DataFormats/Common/interface/Handle.h"
#include "DataFormats/METReco/interface/MET.h"
#include "FWCore/Framework/interface/EDFilter.h"
#include "FWCore/Framework/interface/global/EDFilter.h"
#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/Utilities/interface/InputTag.h"

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

bool filter(edm::Event &, const edm::EventSetup &) override;
bool filter(edm::StreamID, edm::Event &, const edm::EventSetup &) const override;
void beginJob() override;
void endJob() override;
bool checkInput();
bool checkInput() const;

private:
std::vector<std::string> collections_;
Expand Down Expand Up @@ -60,7 +60,7 @@ PFMETFilter::PFMETFilter(const edm::ParameterSet &iConfig) {

PFMETFilter::~PFMETFilter() {}

bool PFMETFilter::checkInput() {
bool PFMETFilter::checkInput() const {
if (collections_.size() != min_.size()) {
std::cout << "Error: in PFMETFilter: collections_.size()!=min_.size()" << std::endl;
std::cout << "collections_.size() = " << collections_.size() << std::endl;
Expand Down Expand Up @@ -98,7 +98,7 @@ void PFMETFilter::beginJob() {
// std::cout << "FL: beginJob" << std::endl;
}

bool PFMETFilter::filter(edm::Event &iEvent, const edm::EventSetup &iSetup) {
bool PFMETFilter::filter(edm::StreamID, edm::Event &iEvent, const edm::EventSetup &iSetup) const {
// std::cout << "FL: filter" << std::endl;
// std::cout << "FL: Mins = " << min_ << std::endl;

Expand Down
Expand Up @@ -2,7 +2,7 @@
#include <memory>

// user include files
#include "FWCore/Framework/interface/EDAnalyzer.h"
#include "FWCore/Framework/interface/one/EDAnalyzer.h"
#include "FWCore/Framework/interface/Frameworkfwd.h"

#include "FWCore/Framework/interface/Event.h"
Expand All @@ -21,7 +21,7 @@ using namespace std;
//
// class declaration

class PFTauElecRejectionBenchmarkAnalyzer : public edm::EDAnalyzer {
class PFTauElecRejectionBenchmarkAnalyzer : public edm::one::EDAnalyzer<> {
public:
typedef dqm::legacy::DQMStore DQMStore;
typedef dqm::legacy::MonitorElement MonitorElement;
Expand Down
4 changes: 2 additions & 2 deletions Validation/RecoParticleFlow/plugins/PFTester.cc
Expand Up @@ -14,7 +14,7 @@
#include "DataFormats/ParticleFlowReco/interface/PFBlock.h"
#include "DataFormats/ParticleFlowReco/interface/PFBlockElement.h"
#include "DataFormats/ParticleFlowReco/interface/PFRecTrack.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/MessageLogger/interface/MessageLogger.h"
Expand All @@ -31,7 +31,7 @@
#include <string>
#include <vector>

class PFTester : public edm::EDAnalyzer {
class PFTester : public edm::one::EDAnalyzer<> {
public:
typedef dqm::legacy::DQMStore DQMStore;
typedef dqm::legacy::MonitorElement MonitorElement;
Expand Down

0 comments on commit 1d9dd6b

Please sign in to comment.