19 #include <unordered_set>
35 double dRmatch = cfgParams.
getParameter<
double>(
"dRMatch");
54 double& sumPtUnclustered,
65 std::unordered_set<reco::CandidatePtr, ptr_hash> footprint;
68 for (
const auto& lep_i :
leptons) {
69 for (
const auto& lep : lep_i->ptrs()) {
71 for (
unsigned int n = 0;
n < lep->numberOfSourceCandidatePtrs();
n++)
72 footprint.insert(lep->sourceCandidatePtr(
n));
77 std::vector<bool> cleanedJets(jets.
size(),
false);
79 return cleanJet(
jet, leptons);
82 auto iCleaned = cleanedJets.begin();
83 for (
const auto&
jet : jets) {
87 for (
unsigned int n = 0;
n <
jet.numberOfSourceCandidatePtrs();
n++) {
88 footprint.insert(
jet.sourceCandidatePtr(
n));
93 for (
size_t i = 0;
i < pfCandidates.
size(); ++
i) {
95 bool cleancand =
true;
96 if (footprint.find(pfCandidates.
ptrAt(
i)) == footprint.end()) {
97 float weight = (weights !=
nullptr) ? (*weights)[pfCandidates.
ptrAt(
i)] : 1.0;
99 for (
const auto& it : footprint) {
100 if (it.isNonnull() && it.isAvailable() && (
reco::deltaR2(*it, pfCandidates[
i]) < 0.00000025)) {
107 sumPtUnclustered += pfCandidates[
i].pt() *
weight;
113 iCleaned = cleanedJets.begin();
114 for (
const auto&
jet : jets) {
119 double jpt =
jet.pt();
122 if (jpt > jetThreshold_) {
125 double jeta =
jet.eta();
127 double c =
jet.px() / jpt;
128 double s =
jet.py() / jpt;
140 if (feta < jetEtas_[0])
141 scale = jetParams_[0];
142 else if (feta < jetEtas_[1])
143 scale = jetParams_[1];
144 else if (feta < jetEtas_[2])
145 scale = jetParams_[2];
146 else if (feta < jetEtas_[3])
147 scale = jetParams_[3];
149 scale = jetParams_[4];
152 double dpt = scale * jpt * sigmapt;
153 double dph = jpt * sigmaphi;
155 cov_xx += dpt * dpt * c * c + dph * dph * s *
s;
156 cov_xy += (dpt * dpt - dph * dph) * c * s;
157 cov_yy += dph * dph * c * c + dpt * dpt * s *
s;
161 sumPtUnclustered += jpt;
166 if (sumPtUnclustered < 0)
167 sumPtUnclustered = 0;
170 double pseudoJetCov = pjetParams_[0] * pjetParams_[0] + pjetParams_[1] * pjetParams_[1] * sumPtUnclustered;
171 cov_xx += pseudoJetCov;
172 cov_yy += pseudoJetCov;
185 double det = cov(0, 0) * cov(1, 1) - cov(0, 1) * cov(1, 0);
188 double ncov_xx = cov(1, 1) / det;
189 double ncov_xy = -cov(0, 1) / det;
190 double ncov_yy = cov(0, 0) / det;
193 double sig = met.
px() * met.
px() * ncov_xx + 2 * met.
px() * met.
py() * ncov_xy + met.
py() * met.
py() * ncov_yy;
200 for (
const auto& lep_i :
leptons) {
201 for (
const auto& lep : *lep_i) {
bool cleanJet(const reco::Jet &jet, const std::vector< edm::Handle< reco::CandidateView > > &leptons)
reco::METCovMatrix getCovariance(const edm::View< reco::Jet > &jets, const std::vector< edm::Handle< reco::CandidateView > > &leptons, const edm::Handle< edm::View< reco::Candidate > > &pfCandidates, double rho, JME::JetResolution &resPtObj, JME::JetResolution &resPhiObj, JME::JetResolutionScaleFactor &resSFObj, bool isRealData, double &sumPtUnclustered, edm::ValueMap< float > const *weights=nullptr)
float getResolution(const JetParameters ¶meters) const
const edm::EventSetup & c
JetParameters & setJetEta(float eta)
static double getSignificance(const reco::METCovMatrix &cov, const reco::MET &met)
JetParameters & setRho(float rho)
Ptr< value_type > ptrAt(size_type i) const
Base class for all types of Jets.
ROOT::Math::SMatrix< double, 2 > METCovMatrix
ProcessIndex productIndex() const
std::vector< double > jetEtas_
double px() const final
x coordinate of momentum vector
const_iterator begin() const
void const * productPtr() const
RefCore const & refCore() const
Abs< T >::type abs(const T &t)
std::vector< double > pjetParams_
double py() const final
y coordinate of momentum vector
std::vector< double > jetParams_
METSignificance(const edm::ParameterSet &iConfig)
constexpr auto deltaR2(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
T getParameter(std::string const &) const
const_iterator end() const
JetParameters & setJetPt(float pt)
ProcessIndex processIndex() const