Skip to content

Commit a3a77e4

Browse files
committed
made requested formatting changes
1 parent fa5e6eb commit a3a77e4

File tree

3 files changed

+32
-34
lines changed

3 files changed

+32
-34
lines changed

PhysicsTools/NanoAOD/plugins/JetSorter.cc

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
1-
#include "FWCore/Framework/interface/stream/EDProducer.h"
1+
#include "FWCore/Framework/interface/global/EDProducer.h"
22
#include "FWCore/Framework/interface/Event.h"
33
#include "FWCore/Framework/interface/MakerMacros.h"
44
#include "FWCore/ParameterSet/interface/ParameterSet.h"
55

66
#include "DataFormats/Common/interface/View.h"
77
#include "DataFormats/PatCandidates/interface/Jet.h"
88

9-
class JetSorter : public edm::stream::EDProducer<> {
9+
#include <algorithm>
10+
#include <string>
11+
#include <memory>
12+
13+
class JetSorter : public edm::global::EDProducer<> {
1014
public:
1115
explicit JetSorter(const edm::ParameterSet &iConfig)
1216
: srcToken_(consumes<edm::View<pat::Jet>>(iConfig.getParameter<edm::InputTag>("src"))),
@@ -17,7 +21,7 @@ class JetSorter : public edm::stream::EDProducer<> {
1721

1822
~JetSorter() override = default;
1923

20-
void produce(edm::Event &iEvent, const edm::EventSetup &) override {
24+
void produce(edm::StreamID, edm::Event &iEvent, const edm::EventSetup &) const override {
2125
edm::Handle<edm::View<pat::Jet>> hSrc;
2226
iEvent.getByToken(srcToken_, hSrc);
2327

@@ -28,14 +32,14 @@ class JetSorter : public edm::stream::EDProducer<> {
2832
out->push_back(jIn);
2933
}
3034

31-
auto key = [&](pat::Jet const &j) -> float {
35+
auto key = [this](pat::Jet const &j) -> float {
3236
if (j.hasUserFloat(userFloatSorter_)) {
3337
return j.userFloat(userFloatSorter_);
3438
}
3539
return static_cast<float>(j.pt());
3640
};
3741

38-
std::stable_sort(out->begin(), out->end(), [&](pat::Jet const &a, pat::Jet const &b) {
42+
std::stable_sort(out->begin(), out->end(), [this, &key](pat::Jet const &a, pat::Jet const &b) {
3943
float pa = key(a);
4044
float pb = key(b);
4145
return descending_ ? (pa > pb) : (pa < pb);

PhysicsTools/NanoAOD/plugins/ProcessRefinedJets.cc

Lines changed: 21 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
1-
#include "FWCore/Framework/interface/stream/EDProducer.h"
1+
#include "FWCore/Framework/interface/global/EDProducer.h"
22
#include "FWCore/Framework/interface/Event.h"
33
#include "FWCore/Framework/interface/MakerMacros.h"
44
#include "FWCore/ParameterSet/interface/ParameterSet.h"
55

66
#include "DataFormats/Common/interface/View.h"
77
#include "DataFormats/PatCandidates/interface/Jet.h"
88
#include "DataFormats/PatCandidates/interface/MET.h"
9-
#include "TLorentzVector.h"
109

1110
#include <cmath>
11+
#include <memory>
12+
#include <string>
1213

13-
//This producer was written to embed the final refined FastSim jet pT values
14+
//This producer embeds the final refined FastSim jet pT values
1415
//so that they can be used as input to the pT-based sorting routine, as well
1516
//as to implement the Type-1 MET correction based on the refined jets.
16-
class ProcessRefinedJets : public edm::stream::EDProducer<> {
17+
class ProcessRefinedJets : public edm::global::EDProducer<> {
1718
public:
1819
explicit ProcessRefinedJets(const edm::ParameterSet &iConfig)
1920
: jetsToken_(consumes<edm::View<pat::Jet>>(iConfig.getParameter<edm::InputTag>("jets"))),
@@ -39,7 +40,7 @@ class ProcessRefinedJets : public edm::stream::EDProducer<> {
3940

4041
~ProcessRefinedJets() override = default;
4142

42-
void produce(edm::Event &iEvent, const edm::EventSetup &) override {
43+
void produce(edm::StreamID, edm::Event &iEvent, const edm::EventSetup &) const override {
4344
edm::Handle<edm::View<pat::Jet>> hJets;
4445
iEvent.getByToken(jetsToken_, hJets);
4546

@@ -54,13 +55,15 @@ class ProcessRefinedJets : public edm::stream::EDProducer<> {
5455
pat::Jet j(jIn);
5556

5657
const double pt_orig = j.pt();
57-
const double phi = j.phi();
58+
const double phi = j.phi();
5859

5960
// mask: BvsAll > 0
6061
const float bvsAll = j.bDiscriminator(maskBtagName_);
61-
const bool refine = (bvsAll > 0.f);
62+
const bool refine = (bvsAll > 0.f);
6263

63-
const double pt_ref = j.hasUserFloat(refinedPtName_) ? static_cast<double>(j.userFloat(refinedPtName_)) : pt_orig;
64+
const double pt_ref = j.hasUserFloat(refinedPtName_)
65+
? static_cast<double>(j.userFloat(refinedPtName_))
66+
: pt_orig;
6467

6568
const double pt_final = refine ? pt_ref : pt_orig;
6669

@@ -94,35 +97,25 @@ class ProcessRefinedJets : public edm::stream::EDProducer<> {
9497
for (auto const &mIn : *hMET) {
9598
pat::MET m(mIn);
9699

97-
// --- original MET as TLorentzVector ---
98100
const double pxOrig = m.px();
99101
const double pyOrig = m.py();
100-
const double ptOrig = std::sqrt(pxOrig * pxOrig + pyOrig * pyOrig);
101-
const double phiOrig = std::atan2(pyOrig, pxOrig);
102+
const double ptOrig = m.pt();
103+
const double phiOrig = m.phi();
102104

103-
TLorentzVector metOrig;
104-
metOrig.SetPxPyPzE(pxOrig, pyOrig, 0.0, ptOrig); // pz=0, E ~ pt (E not really used for MET)
105+
const double pxFinal = pxOrig + sumDeltaPx;
106+
const double pyFinal = pyOrig + sumDeltaPy;
107+
const double ptFinal = std::sqrt(pxFinal * pxFinal + pyFinal * pyFinal);
108+
const double phiFinal = std::atan2(pyFinal, pxFinal);
105109

106-
// Type-1 MET correction for PUPPI MET with refined jets:
107-
TLorentzVector delta;
108-
const double ptDelta = std::sqrt(sumDeltaPx * sumDeltaPx + sumDeltaPy * sumDeltaPy);
109-
delta.SetPxPyPzE(sumDeltaPx, sumDeltaPy, 0.0, ptDelta);
110-
111-
TLorentzVector metFinal = metOrig + delta;
112-
113-
const double ptFinal = metFinal.Pt();
114-
const double phiFinal = metFinal.Phi();
115-
116-
// stash unrefined values
117-
m.addUserFloat("pt_unrefined", static_cast<float>(ptOrig));
110+
m.addUserFloat("pt_unrefined", static_cast<float>(ptOrig));
118111
m.addUserFloat("phi_unrefined", static_cast<float>(phiOrig));
119112

120113
// stash final values, needed for sorting.
121-
m.addUserFloat("pt_final", static_cast<float>(ptFinal));
114+
m.addUserFloat("pt_final", static_cast<float>(ptFinal));
122115
m.addUserFloat("phi_final", static_cast<float>(phiFinal));
123116

124117
// push back into pat::MET with reco::Candidate::LorentzVector ---
125-
reco::Candidate::LorentzVector p4(metFinal.Px(), metFinal.Py(), 0.0, ptFinal);
118+
reco::Candidate::LorentzVector p4(pxFinal, pyFinal, 0.0, ptFinal);
126119
m.setP4(p4);
127120

128121
outMET->push_back(std::move(m));
@@ -134,7 +127,7 @@ class ProcessRefinedJets : public edm::stream::EDProducer<> {
134127
private:
135128
edm::EDGetTokenT<edm::View<pat::Jet>> jetsToken_;
136129
edm::EDGetTokenT<edm::View<pat::MET>> metToken_;
137-
bool doMET_;
130+
bool doMET_ = false;
138131

139132
std::string refinedPtName_;
140133
std::string maskBtagName_;

PhysicsTools/NanoAOD/python/jetsAK4_Puppi_cff.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,8 @@ def nanoAOD_refineFastSim_puppiJet(process):
289289
btagUParTAK4Brefined = cms.InputTag("puppiJetRefineNN","btagUParTAK4Brefined"),
290290
btagUParTAK4CvBrefined = cms.InputTag("puppiJetRefineNN","btagUParTAK4CvBrefined"),
291291
btagUParTAK4CvLrefined = cms.InputTag("puppiJetRefineNN","btagUParTAK4CvLrefined"),
292-
btagUParTAK4QvGrefined = cms.InputTag("puppiJetRefineNN","btagUParTAK4QvGrefined"),)
292+
btagUParTAK4QvGrefined = cms.InputTag("puppiJetRefineNN","btagUParTAK4QvGrefined"),
293+
)
293294
)
294295
fastSim.toModify(process.jetPuppiTablesTask, process.jetPuppiTablesTask.add(process.finalJetsPuppiWithRefined))
295296

0 commit comments

Comments
 (0)