19 #include <unordered_set> 35 double dRmatch = cfgParams.
getParameter<
double>(
"dRMatch");
36 dR2match_ = dRmatch * dRmatch;
38 jetThreshold_ = cfgParams.
getParameter<
double>(
"jetThreshold");
39 jetEtas_ = cfgParams.
getParameter<std::vector<double> >(
"jeta");
40 jetParams_ = cfgParams.
getParameter<std::vector<double> >(
"jpar");
41 pjetParams_ = cfgParams.
getParameter<std::vector<double> >(
"pjpar");
54 double& sumPtUnclustered) {
64 std::unordered_set<reco::CandidatePtr, ptr_hash> footprint;
67 for (
const auto& lep_i :
leptons) {
68 for (
const auto& lep : *lep_i) {
70 for (
unsigned int n = 0;
n < lep.numberOfSourceCandidatePtrs();
n++) {
71 if (lep.sourceCandidatePtr(
n).isNonnull() and lep.sourceCandidatePtr(
n).isAvailable()) {
72 footprint.insert(lep.sourceCandidatePtr(
n));
79 for (
const auto&
jet : jets) {
81 if (!cleanJet(
jet, leptons))
83 for (
unsigned int n = 0;
n <
jet.numberOfSourceCandidatePtrs();
n++) {
84 if (
jet.sourceCandidatePtr(
n).isNonnull() and
jet.sourceCandidatePtr(
n).isAvailable()) {
85 footprint.insert(
jet.sourceCandidatePtr(
n));
91 for (
size_t i = 0;
i < pfCandidates->
size(); ++
i) {
93 bool cleancand =
true;
94 if (footprint.find(pfCandidates->
ptrAt(
i)) == footprint.end()) {
96 for (
const auto& it : footprint) {
97 if ((it->p4() - (*pfCandidates)[
i].p4()).Et2() < 0.000025) {
104 sumPtUnclustered += (*pfCandidates)[
i].pt();
110 for (
const auto&
jet : jets) {
112 if (!cleanJet(
jet, leptons))
118 double c =
jet.px() /
jet.pt();
119 double s =
jet.py() /
jet.pt();
131 if (jpt > jetThreshold_) {
135 if (feta < jetEtas_[0])
136 scale = jetParams_[0];
137 else if (feta < jetEtas_[1])
138 scale = jetParams_[1];
139 else if (feta < jetEtas_[2])
140 scale = jetParams_[2];
141 else if (feta < jetEtas_[3])
142 scale = jetParams_[3];
144 scale = jetParams_[4];
147 double dpt = scale * jpt * sigmapt;
148 double dph = jpt * sigmaphi;
150 cov_xx += dpt * dpt * c * c + dph * dph * s *
s;
151 cov_xy += (dpt * dpt - dph * dph) * c * s;
152 cov_yy += dph * dph * c * c + dpt * dpt * s *
s;
156 sumPtUnclustered += jpt;
161 if (sumPtUnclustered < 0)
162 sumPtUnclustered = 0;
165 cov_xx += pjetParams_[0] * pjetParams_[0] + pjetParams_[1] * pjetParams_[1] * sumPtUnclustered;
166 cov_yy += pjetParams_[0] * pjetParams_[0] + pjetParams_[1] * pjetParams_[1] * sumPtUnclustered;
179 double det = cov(0, 0) * cov(1, 1) - cov(0, 1) * cov(1, 0);
182 double ncov_xx = cov(1, 1) / det;
183 double ncov_xy = -cov(0, 1) / det;
184 double ncov_yy = cov(0, 0) / det;
187 double sig = met.
px() * met.
px() * ncov_xx + 2 * met.
px() * met.
py() * ncov_xy + met.
py() * met.
py() * ncov_yy;
194 for (
const auto& lep_i :
leptons) {
195 for (
const auto& lep : *lep_i) {
T getParameter(std::string const &) const
bool cleanJet(const reco::Jet &jet, const std::vector< edm::Handle< reco::CandidateView > > &leptons)
float getResolution(const JetParameters ¶meters) const
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
double px() const final
x coordinate of momentum vector
ProcessIndex productIndex() const
void const * productPtr() const
RefCore const & refCore() const
Abs< T >::type abs(const T &t)
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)
METSignificance(const edm::ParameterSet &iConfig)
constexpr auto deltaR2(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
double py() const final
y coordinate of momentum vector
JetParameters & setJetPt(float pt)
ProcessIndex processIndex() const