Skip to content

Commit

Permalink
Merge pull request #38461 from michaelwassmer/CMSSW_12_3_4_patch2_MET…
Browse files Browse the repository at this point in the history
…XYCorrections_rebased

Add possibility to apply latest MET Phi corrections during MiniAOD processing
  • Loading branch information
cmsbuild authored Jul 16, 2022
2 parents 035f882 + cf9bcca commit 8ab252c
Show file tree
Hide file tree
Showing 8 changed files with 812 additions and 44 deletions.
35 changes: 19 additions & 16 deletions JetMETCorrections/Type1MET/plugins/MultShiftMETcorrInputProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,12 @@ void MultShiftMETcorrInputProducer::produce(edm::Event& evt, const edm::EventSet
if (!hpv.isValid()) {
edm::LogError("MultShiftMETcorrInputProducer::produce") << "could not find vertex collection ";
}
std::vector<reco::Vertex> goodVertices;
uint ngoodVertices = 0;
for (unsigned i = 0; i < hpv->size(); i++) {
if ((*hpv)[i].ndof() > 4 && (fabs((*hpv)[i].z()) <= 24.) && (fabs((*hpv)[i].position().rho()) <= 2.0))
goodVertices.push_back((*hpv)[i]);
ngoodVertices += 1;
}
int ngoodVertices = goodVertices.size();
uint nVertices = hpv->size();

for (unsigned i = 0; i < counts_.size(); i++)
counts_[i] = 0;
Expand All @@ -106,15 +106,18 @@ void MultShiftMETcorrInputProducer::produce(edm::Event& evt, const edm::EventSet
edm::Handle<edm::ValueMap<float>> weights;
if (!weightsToken_.isUninitialized())
evt.getByToken(weightsToken_, weights);
for (unsigned i = 0; i < particleFlow->size(); ++i) {
const reco::Candidate& c = particleFlow->at(i);
for (unsigned j = 0; j < type_.size(); j++) {
if (abs(c.pdgId()) == translateTypeToAbsPdgId(reco::PFCandidate::ParticleType(type_[j]))) {
if ((c.eta() > etaMin_[j]) and (c.eta() < etaMax_[j])) {
float weight = (!weightsToken_.isUninitialized()) ? (*weights)[particleFlow->ptrAt(i)] : 1.0;
counts_[j] += (weight > 0);
sumPt_[j] += c.pt() * weight;
continue;
if (std::find(varType_.begin(), varType_.end(), 0) != varType_.end() ||
std::find(varType_.begin(), varType_.end(), 2) != varType_.end()) {
for (unsigned i = 0; i < particleFlow->size(); ++i) {
const reco::Candidate& c = particleFlow->at(i);
for (unsigned j = 0; j < type_.size(); j++) {
if (abs(c.pdgId()) == translateTypeToAbsPdgId(reco::PFCandidate::ParticleType(type_[j]))) {
if ((c.eta() > etaMin_[j]) and (c.eta() < etaMax_[j])) {
float weight = (!weightsToken_.isUninitialized()) ? (*weights)[particleFlow->ptrAt(i)] : 1.0;
counts_[j] += (weight > 0);
sumPt_[j] += c.pt() * weight;
continue;
}
}
}
}
Expand All @@ -133,12 +136,12 @@ void MultShiftMETcorrInputProducer::produce(edm::Event& evt, const edm::EventSet
double val(0.);
if (varType_[j] == 0) {
val = counts_[j];
}
if (varType_[j] == 1) {
} else if (varType_[j] == 1) {
val = ngoodVertices;
}
if (varType_[j] == 2) {
} else if (varType_[j] == 2) {
val = sumPt_[j];
} else if (varType_[j] == 3) {
val = nVertices;
}

corx -= formula_x_[j]->Eval(val);
Expand Down
256 changes: 256 additions & 0 deletions JetMETCorrections/Type1MET/python/multPhiCorr_Puppi_Run2_ULDATA_cfi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,256 @@
import FWCore.ParameterSet.Config as cms

# ULDATA 2018A corrections
multPhiCorr_Puppi_ULDATA2018A = cms.VPSet(
cms.PSet(
name=cms.string("ULDATA2018A"),
type=cms.int32(0),
varType=cms.int32(3),
etaMin=cms.double(-9.9),
etaMax=cms.double(9.9),
fx=cms.string("((x*[0])+[1])"),
px=cms.vdouble(-0.0073377,0.0250294),
fy=cms.string("((x*[0])+[1])"),
py=cms.vdouble(-0.000406059,0.0417346),
),
)

# ULDATA 2018B corrections
multPhiCorr_Puppi_ULDATA2018B = cms.VPSet(
cms.PSet(
name=cms.string("ULDATA2018B"),
type=cms.int32(0),
varType=cms.int32(3),
etaMin=cms.double(-9.9),
etaMax=cms.double(9.9),
fx=cms.string("((x*[0])+[1])"),
px=cms.vdouble(0.00434261,0.00892927),
fy=cms.string("((x*[0])+[1])"),
py=cms.vdouble(0.00234695,0.20381),
),
)

# ULDATA 2018C corrections
multPhiCorr_Puppi_ULDATA2018C = cms.VPSet(
cms.PSet(
name=cms.string("ULDATA2018C"),
type=cms.int32(0),
varType=cms.int32(3),
etaMin=cms.double(-9.9),
etaMax=cms.double(9.9),
fx=cms.string("((x*[0])+[1])"),
px=cms.vdouble(0.00198311,0.37026),
fy=cms.string("((x*[0])+[1])"),
py=cms.vdouble(-0.016127,0.402029),
),
)

# ULDATA 2018D corrections
multPhiCorr_Puppi_ULDATA2018D = cms.VPSet(
cms.PSet(
name=cms.string("ULDATA2018D"),
type=cms.int32(0),
varType=cms.int32(3),
etaMin=cms.double(-9.9),
etaMax=cms.double(9.9),
fx=cms.string("((x*[0])+[1])"),
px=cms.vdouble(0.00220647,0.378141),
fy=cms.string("((x*[0])+[1])"),
py=cms.vdouble(-0.0160244,0.471053),
),
)

# ULDATA 2017B corrections
multPhiCorr_Puppi_ULDATA2017B = cms.VPSet(
cms.PSet(
name=cms.string("ULDATA2017B"),
type=cms.int32(0),
varType=cms.int32(3),
etaMin=cms.double(-9.9),
etaMax=cms.double(9.9),
fx=cms.string("((x*[0])+[1])"),
px=cms.vdouble(-0.00382117,-0.666228),
fy=cms.string("((x*[0])+[1])"),
py=cms.vdouble(0.0109034,0.172188),
),
)

# ULDATA 2017C corrections
multPhiCorr_Puppi_ULDATA2017C = cms.VPSet(
cms.PSet(
name=cms.string("ULDATA2017C"),
type=cms.int32(0),
varType=cms.int32(3),
etaMin=cms.double(-9.9),
etaMax=cms.double(9.9),
fx=cms.string("((x*[0])+[1])"),
px=cms.vdouble(-0.00110699,-0.747643),
fy=cms.string("((x*[0])+[1])"),
py=cms.vdouble(-0.0012184,0.303817),
),
)

# ULDATA 2017D corrections
multPhiCorr_Puppi_ULDATA2017D = cms.VPSet(
cms.PSet(
name=cms.string("ULDATA2017D"),
type=cms.int32(0),
varType=cms.int32(3),
etaMin=cms.double(-9.9),
etaMax=cms.double(9.9),
fx=cms.string("((x*[0])+[1])"),
px=cms.vdouble(-0.00141442,-0.721382),
fy=cms.string("((x*[0])+[1])"),
py=cms.vdouble(-0.0011873,0.21646),
),
)

# ULDATA 2017E corrections
multPhiCorr_Puppi_ULDATA2017E = cms.VPSet(
cms.PSet(
name=cms.string("ULDATA2017E"),
type=cms.int32(0),
varType=cms.int32(3),
etaMin=cms.double(-9.9),
etaMax=cms.double(9.9),
fx=cms.string("((x*[0])+[1])"),
px=cms.vdouble(0.00593859,-0.851999),
fy=cms.string("((x*[0])+[1])"),
py=cms.vdouble(-0.00754254,0.245956),
),
)

# ULDATA 2017F corrections
multPhiCorr_Puppi_ULDATA2017F = cms.VPSet(
cms.PSet(
name=cms.string("ULDATA2017F"),
type=cms.int32(0),
varType=cms.int32(3),
etaMin=cms.double(-9.9),
etaMax=cms.double(9.9),
fx=cms.string("((x*[0])+[1])"),
px=cms.vdouble(0.00765682,-0.945001),
fy=cms.string("((x*[0])+[1])"),
py=cms.vdouble(-0.0154974,0.804176),
),
)

# ULDATA 2016preVFPB corrections
multPhiCorr_Puppi_ULDATA2016preVFPB = cms.VPSet(
cms.PSet(
name=cms.string("ULDATA2016preVFPB"),
type=cms.int32(0),
varType=cms.int32(3),
etaMin=cms.double(-9.9),
etaMax=cms.double(9.9),
fx=cms.string("((x*[0])+[1])"),
px=cms.vdouble(-0.00109025,-0.338093),
fy=cms.string("((x*[0])+[1])"),
py=cms.vdouble(-0.00356058,0.128407),
),
)

# ULDATA 2016preVFPC corrections
multPhiCorr_Puppi_ULDATA2016preVFPC = cms.VPSet(
cms.PSet(
name=cms.string("ULDATA2016preVFPC"),
type=cms.int32(0),
varType=cms.int32(3),
etaMin=cms.double(-9.9),
etaMax=cms.double(9.9),
fx=cms.string("((x*[0])+[1])"),
px=cms.vdouble(-0.00271913,-0.342268),
fy=cms.string("((x*[0])+[1])"),
py=cms.vdouble(0.00187386,0.104),
),
)

# ULDATA 2016preVFPD corrections
multPhiCorr_Puppi_ULDATA2016preVFPD = cms.VPSet(
cms.PSet(
name=cms.string("ULDATA2016preVFPD"),
type=cms.int32(0),
varType=cms.int32(3),
etaMin=cms.double(-9.9),
etaMax=cms.double(9.9),
fx=cms.string("((x*[0])+[1])"),
px=cms.vdouble(-0.00254194,-0.305264),
fy=cms.string("((x*[0])+[1])"),
py=cms.vdouble(-0.00177408,0.164639),
),
)

# ULDATA 2016preVFPE corrections
multPhiCorr_Puppi_ULDATA2016preVFPE = cms.VPSet(
cms.PSet(
name=cms.string("ULDATA2016preVFPE"),
type=cms.int32(0),
varType=cms.int32(3),
etaMin=cms.double(-9.9),
etaMax=cms.double(9.9),
fx=cms.string("((x*[0])+[1])"),
px=cms.vdouble(-0.00358835,-0.225435),
fy=cms.string("((x*[0])+[1])"),
py=cms.vdouble(-0.000444268,0.180479),
),
)

# ULDATA 2016preVFPF corrections
multPhiCorr_Puppi_ULDATA2016preVFPF = cms.VPSet(
cms.PSet(
name=cms.string("ULDATA2016preVFPF"),
type=cms.int32(0),
varType=cms.int32(3),
etaMin=cms.double(-9.9),
etaMax=cms.double(9.9),
fx=cms.string("((x*[0])+[1])"),
px=cms.vdouble(0.0056759,-0.454101),
fy=cms.string("((x*[0])+[1])"),
py=cms.vdouble(-0.00962707,0.35731),
),
)

# ULDATA 2016ostVFPF corrections
multPhiCorr_Puppi_ULDATA2016postVFPF = cms.VPSet(
cms.PSet(
name=cms.string("ULDATA2016postVFPF"),
type=cms.int32(0),
varType=cms.int32(3),
etaMin=cms.double(-9.9),
etaMax=cms.double(9.9),
fx=cms.string("((x*[0])+[1])"),
px=cms.vdouble(0.0234421,-0.371298),
fy=cms.string("((x*[0])+[1])"),
py=cms.vdouble(-0.00997438,0.0809178),
),
)

# ULDATA 2016ostVFPG corrections
multPhiCorr_Puppi_ULDATA2016postVFPG = cms.VPSet(
cms.PSet(
name=cms.string("ULDATA2016postVFPG"),
type=cms.int32(0),
varType=cms.int32(3),
etaMin=cms.double(-9.9),
etaMax=cms.double(9.9),
fx=cms.string("((x*[0])+[1])"),
px=cms.vdouble(0.0182134,-0.335786),
fy=cms.string("((x*[0])+[1])"),
py=cms.vdouble(-0.0063338,0.093349),
),
)

# ULDATA 2016ostVFPH corrections
multPhiCorr_Puppi_ULDATA2016postVFPH = cms.VPSet(
cms.PSet(
name=cms.string("ULDATA2016postVFPH"),
type=cms.int32(0),
varType=cms.int32(3),
etaMin=cms.double(-9.9),
etaMax=cms.double(9.9),
fx=cms.string("((x*[0])+[1])"),
px=cms.vdouble(0.015702,-0.340832),
fy=cms.string("((x*[0])+[1])"),
py=cms.vdouble(-0.00544957,0.199093),
),
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import FWCore.ParameterSet.Config as cms

# UL 2018 MC corrections
multPhiCorr_Puppi_ULMC2018 = cms.VPSet(
cms.PSet(
name=cms.string("ULMC2018"),
type=cms.int32(0),
varType=cms.int32(3),
etaMin=cms.double(-9.9),
etaMax=cms.double(9.9),
fx=cms.string("((x*[0])+[1])"),
px=cms.vdouble(-0.0214557,0.969428),
fy=cms.string("((x*[0])+[1])"),
py=cms.vdouble(0.0167134,0.199296),
),
)

# UL 2017 MC corrections
multPhiCorr_Puppi_ULMC2017 = cms.VPSet(
cms.PSet(
name=cms.string("ULMC2017"),
type=cms.int32(0),
varType=cms.int32(3),
etaMin=cms.double(-9.9),
etaMax=cms.double(9.9),
fx=cms.string("((x*[0])+[1])"),
px=cms.vdouble(-0.0102265,-0.446416),
fy=cms.string("((x*[0])+[1])"),
py=cms.vdouble(0.0198663,0.243182),
),
)

# UL 2016preVFP MC corrections
multPhiCorr_Puppi_ULMC2016preVFP = cms.VPSet(
cms.PSet(
name=cms.string("ULMC2016preVFP"),
type=cms.int32(0),
varType=cms.int32(3),
etaMin=cms.double(-9.9),
etaMax=cms.double(9.9),
fx=cms.string("((x*[0])+[1])"),
px=cms.vdouble(-0.0058341,-0.395049),
fy=cms.string("((x*[0])+[1])"),
py=cms.vdouble(0.00971595,-0.101288),
),
)

# UL 2016postVFP MC corrections
multPhiCorr_Puppi_ULMC2016postVFP = cms.VPSet(
cms.PSet(
name=cms.string("ULMC2016postVFP"),
type=cms.int32(0),
varType=cms.int32(3),
etaMin=cms.double(-9.9),
etaMax=cms.double(9.9),
fx=cms.string("((x*[0])+[1])"),
px=cms.vdouble(-0.0060447,-0.4183),
fy=cms.string("((x*[0])+[1])"),
py=cms.vdouble(0.008331,-0.0990046),
),
)
Loading

0 comments on commit 8ab252c

Please sign in to comment.