19 #include <unordered_set> 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");
42 useDeltaRforFootprint_ = cfgParams.
getParameter<
bool>(
"useDeltaRforFootprint");
66 std::unordered_set<reco::CandidatePtr,ptr_hash> footprint;
69 for (
const auto& lep_i :
leptons ) {
70 for (
const auto& lep : lep_i->ptrs()) {
72 for (
unsigned int n = 0;
n < lep->numberOfSourceCandidatePtrs();
n++)
73 footprint.insert(lep->sourceCandidatePtr(
n));
78 std::vector<bool> cleanedJets(jets.
size(),
false);
80 return cleanJet(
jet, leptons);
83 auto iCleaned = cleanedJets.begin();
84 for (
const auto&
jet : jets) {
88 for (
unsigned int n = 0;
n <
jet.numberOfSourceCandidatePtrs();
n++) {
89 footprint.insert(
jet.sourceCandidatePtr(
n));
95 for(
size_t i = 0;
i< pfCandidates.
size(); ++
i) {
98 bool cleancand =
true;
99 if(footprint.find( pfCandidates.
ptrAt(
i) )==footprint.end()) {
102 for(
const auto& it : footprint) {
105 if((it.isNonnull()) && (it.isAvailable()) &&
106 (((!useDeltaRforFootprint_) && ((it->p4()-pfCandidates[
i].p4()).Et2()<0.000025)) ||
107 (( useDeltaRforFootprint_) && (
reco::deltaR2(*it, pfCandidates[
i])<0.00000025)))){
114 sumPtUnclustered += pfCandidates[
i].pt();
120 iCleaned = cleanedJets.
begin();
121 for(
const auto&
jet : jets) {
124 if(!(*iCleaned++) )
continue;
142 if( jpt > jetThreshold_ ){
146 if(feta<jetEtas_[0]) scale = jetParams_[0];
147 else if(feta<jetEtas_[1]) scale = jetParams_[1];
148 else if(feta<jetEtas_[2]) scale = jetParams_[2];
149 else if(feta<jetEtas_[3]) scale = jetParams_[3];
150 else scale = jetParams_[4];
153 double dpt = scale*jpt*sigmapt;
154 double dph = jpt*sigmaphi;
156 cov_xx += dpt*dpt*c*c + dph*dph*s*
s;
157 cov_xy += (dpt*dpt-dph*dph)*c*s;
158 cov_yy += dph*dph*c*c + dpt*dpt*s*
s;
163 sumPtUnclustered += jpt;
170 if(sumPtUnclustered<0) sumPtUnclustered=0;
173 cov_xx += pjetParams_[0]*pjetParams_[0] + pjetParams_[1]*pjetParams_[1]*
sumPtUnclustered;
174 cov_yy += pjetParams_[0]*pjetParams_[0] + pjetParams_[1]*pjetParams_[1]*
sumPtUnclustered;
189 double det = cov(0,0)*cov(1,1) - cov(0,1)*cov(1,0);
192 double ncov_xx = cov(1,1) / det;
193 double ncov_xy = -cov(0,1) / det;
194 double ncov_yy = cov(0,0) / det;
197 double sig = met.
px()*met.
px()*ncov_xx + 2*met.
px()*met.
py()*ncov_xy + met.
py()*met.
py()*ncov_yy;
206 for (
const auto& lep_i :
leptons ) {
207 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.
double px() const final
x coordinate of momentum vector
ProcessIndex productIndex() const
ROOT::Math::SMatrix< double, 2 > METCovMatrix
const_iterator begin() 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
const_iterator end() const
JetParameters & setJetPt(float pt)
ProcessIndex processIndex() const