Skip to content

Commit

Permalink
Merge pull request #36797 from michaelwassmer/CMSSW_12_0_0_SmearMETFi…
Browse files Browse the repository at this point in the history
…x_short_rebased

Fix for smeared MET calculation and its uncertainties.
  • Loading branch information
cmsbuild authored Feb 6, 2022
2 parents 8e4da88 + ff49d87 commit 340f6ea
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 3 deletions.
4 changes: 2 additions & 2 deletions DataFormats/PatCandidates/src/MET.cc
Original file line number Diff line number Diff line change
Expand Up @@ -342,9 +342,9 @@ void MET::setUncShift(double px, double py, double sumEt, METUncertainty shift,
//changing reference to only get the uncertainty shift and not the smeared one
// which is performed independently
shift = (MET::METUncertainty)(METUncertainty::METUncertaintySize + shift + 1);
const PackedMETUncertainty &ref = uncertainties_[METUncertainty::NoShift];
const PackedMETUncertainty &ref = corrections_[METCorrectionType::Smear];
uncertainties_[shift].set(
px + ref.dpx() - this->px(), py + ref.dpy() - this->py(), sumEt + ref.dsumEt() - this->sumEt());
px - ref.dpx() - this->px(), py - ref.dpy() - this->py(), sumEt - ref.dsumEt() - this->sumEt());
} else
uncertainties_[shift].set(px - this->px(), py - this->py(), sumEt - this->sumEt());
}
Expand Down
13 changes: 13 additions & 0 deletions JetMETCorrections/Type1MET/interface/PFJetMETcorrInputProducerT.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,16 @@ namespace PFJetMETcorrInputProducer_namespace {
reco::Candidate::LorentzVector operator()(const T& jet) const { return jet.p4(); }
};

// functor to retrieve additional scales of jets
// general template just returns 1 because only pat::Jet keeps track of the scales
// specialized template for pat::Jet returns combined factor of additional scales
template <typename T>
class AdditionalScalesT {
public:
AdditionalScalesT() {}
float operator()(const T& jet) const { return 1.0; }
};

} // namespace PFJetMETcorrInputProducer_namespace

template <typename T, typename Textractor>
Expand Down Expand Up @@ -196,6 +206,9 @@ class PFJetMETcorrInputProducerT : public edm::stream::EDProducer<> {
corrJetP4 = jetCorrExtractor_(jet, jetCorrLabel_.label(), jetCorrEtaMax_, &rawJetP4);
else
corrJetP4 = jetCorrExtractor_(jet, jetCorr.product(), jetCorrEtaMax_, &rawJetP4);
// retrieve additional jet energy scales in case of pat::Jets (done via specialized template defined for pat::Jets) and apply them
const static PFJetMETcorrInputProducer_namespace::AdditionalScalesT<T> additionalScales{};
corrJetP4 *= additionalScales(jet);

if (corrJetP4.pt() > type1JetPtThreshold_) {
reco::Candidate::LorentzVector rawJetP4offsetCorr = rawJetP4;
Expand Down
17 changes: 16 additions & 1 deletion PhysicsTools/PatUtils/plugins/PATPFJetMETcorrInputProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,26 @@ namespace PFJetMETcorrInputProducer_namespace {
RawJetExtractorT() {}
reco::Candidate::LorentzVector operator()(const pat::Jet& jet) const {
if (jet.jecSetsAvailable())
return jet.correctedP4("Uncorrected");
return jet.correctedP4(0);
else
return jet.p4();
}
};

// template specialization for pat::Jets
// retrieve combined factor of additional scales applied to the jets
// otherwise just return 1
template <>
class AdditionalScalesT<pat::Jet> {
public:
AdditionalScalesT() {}
float operator()(const pat::Jet& jet) const {
if (jet.jecSetsAvailable()) {
return jet.jecFactor("Uncorrected") / jet.jecFactor(0);
} else
return 1.0;
}
};
} // namespace PFJetMETcorrInputProducer_namespace

typedef PFJetMETcorrInputProducerT<pat::Jet, PATJetCorrExtractor> PATPFJetMETcorrInputProducer;
Expand Down

0 comments on commit 340f6ea

Please sign in to comment.