CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
metsig::METSignificance Class Reference

#include <METSignificance.h>

Public Member Functions

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)
 
 METSignificance (const edm::ParameterSet &iConfig)
 
 ~METSignificance ()
 

Static Public Member Functions

static double getSignificance (const reco::METCovMatrix &cov, const reco::MET &met)
 

Private Member Functions

bool cleanJet (const reco::Jet &jet, const std::vector< edm::Handle< reco::CandidateView > > &leptons)
 

Private Attributes

double dR2match_
 
std::vector< double > jetEtas_
 
std::vector< double > jetParams_
 
double jetThreshold_
 
std::vector< double > pjetParams_
 

Detailed Description

Definition at line 35 of file METSignificance.h.

Constructor & Destructor Documentation

METSignificance::METSignificance ( const edm::ParameterSet iConfig)

Definition at line 21 of file METSignificance.cc.

References dR2match_, CaloRecoTauDiscriminationAgainstMuon_cfi::dRmatch, edm::ParameterSet::getParameter(), jetEtas_, jetParams_, jetThreshold_, and pjetParams_.

21  {
22 
23  edm::ParameterSet cfgParams = iConfig.getParameter<edm::ParameterSet>("parameters");
24 
25  double dRmatch = cfgParams.getParameter<double>("dRMatch");
26  dR2match_ = dRmatch*dRmatch;
27 
28  jetThreshold_ = cfgParams.getParameter<double>("jetThreshold");
29  jetEtas_ = cfgParams.getParameter<std::vector<double> >("jeta");
30  jetParams_ = cfgParams.getParameter<std::vector<double> >("jpar");
31  pjetParams_ = cfgParams.getParameter<std::vector<double> >("pjpar");
32 
33 }
T getParameter(std::string const &) const
std::vector< double > jetEtas_
std::vector< double > pjetParams_
std::vector< double > jetParams_
METSignificance::~METSignificance ( )

Definition at line 35 of file METSignificance.cc.

35  {
36 }

Member Function Documentation

bool METSignificance::cleanJet ( const reco::Jet jet,
const std::vector< edm::Handle< reco::CandidateView > > &  leptons 
)
private

Definition at line 192 of file METSignificance.cc.

References reco::deltaR2(), dR2match_, and AK4GenJetFlavourInfos_cfi::leptons.

Referenced by getCovariance().

193  {
194 
195  for ( std::vector< edm::Handle<reco::CandidateView> >::const_iterator lep_i = leptons.begin();
196  lep_i != leptons.end(); ++lep_i ) {
197  for( reco::CandidateView::const_iterator lep = (*lep_i)->begin(); lep != (*lep_i)->end(); lep++ ){
198  if ( reco::deltaR2(*lep, jet) < dR2match_ ) {
199  return false;
200  }
201  }
202  }
203  return true;
204 }
T1 deltaR2(T1 eta1, T2 phi1, T3 eta2, T4 phi2)
Definition: deltaR.h:36
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
reco::METCovMatrix METSignificance::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 
)

Definition at line 40 of file METSignificance.cc.

References funct::abs(), edm::View< T >::begin(), EnergyCorrector::c, cleanJet(), edm::View< T >::end(), JME::JetResolution::getResolution(), mps_fire::i, metsig::jet, METSignificanceParams_cfi::jeta, jetEtas_, jetParams_, jetThreshold_, AK4GenJetFlavourInfos_cfi::leptons, gen::n, slimmedMuons_cfi::pfCandidates, pjetParams_, edm::View< T >::ptrAt(), alignCSCRings::s, Scenarios_cff::scale, JME::JetParameters::setJetEta(), JME::JetParameters::setJetPt(), JME::JetParameters::setRho(), edm::View< T >::size(), and TtFullHadEvtBuilder_cfi::sumPt.

Referenced by cms::PFMETProducer::getMETCovMatrix(), pat::PATMETProducer::getMETCovMatrix(), and cms::METSignificanceProducer::produce().

47  {
48 
49  //pfcandidates
50  const edm::View<reco::Candidate>* pfCandidates=pfCandidatesH.product();
51 
52  // metsig covariance
53  double cov_xx = 0;
54  double cov_xy = 0;
55  double cov_yy = 0;
56 
57  // for lepton and jet subtraction
58  std::set<reco::CandidatePtr> footprint;
59 
60  // subtract leptons out of sumPt
61  for ( std::vector< edm::Handle<reco::CandidateView> >::const_iterator lep_i = leptons.begin();
62  lep_i != leptons.end(); ++lep_i ) {
63  for( reco::CandidateView::const_iterator lep = (*lep_i)->begin(); lep != (*lep_i)->end(); lep++ ){
64  if( lep->pt() > 10 ){
65  for( unsigned int n=0; n < lep->numberOfSourceCandidatePtrs(); n++ ){
66  if( lep->sourceCandidatePtr(n).isNonnull() and lep->sourceCandidatePtr(n).isAvailable() ){
67  footprint.insert(lep->sourceCandidatePtr(n));
68  }
69  }
70  }
71  }
72  }
73  // subtract jets out of sumPt
74  for(edm::View<reco::Jet>::const_iterator jet = jets.begin(); jet != jets.end(); ++jet) {
75 
76  // disambiguate jets and leptons
77  if(!cleanJet(*jet, leptons) ) continue;
78  for( unsigned int n=0; n < jet->numberOfSourceCandidatePtrs(); n++){
79  if( jet->sourceCandidatePtr(n).isNonnull() and jet->sourceCandidatePtr(n).isAvailable() ){
80 
81  footprint.insert(jet->sourceCandidatePtr(n));
82  }
83  }
84 
85  }
86 
87  // calculate sumPt
88  double sumPt = 0;
89  for(size_t i = 0; i< pfCandidates->size(); ++i) {
90 
91  // check if candidate exists in a lepton or jet
92  bool cleancand = true;
93  if(footprint.find( pfCandidates->ptrAt(i) )==footprint.end()) {
94 
95  //dP4 recovery
96  for( std::set<reco::CandidatePtr>::const_iterator it=footprint.begin();it!=footprint.end();it++) {
97  if( ((*it)->p4()-(*pfCandidates)[i].p4()).Et2()<0.000025 ){
98  cleancand = false;
99  break;
100  }
101  }
102  // if not, add to sumPt
103  if( cleancand ){
104  sumPt += (*pfCandidates)[i].pt();
105  }
106  }
107  }
108 
109  // add jets to metsig covariance matrix and subtract them from sumPt
110  for(edm::View<reco::Jet>::const_iterator jet = jets.begin(); jet != jets.end(); ++jet) {
111 
112  // disambiguate jets and leptons
113  if(!cleanJet(*jet, leptons) ) continue;
114 
115  double jpt = jet->pt();
116  double jeta = jet->eta();
117  double feta = std::abs(jeta);
118  double c = jet->px()/jet->pt();
119  double s = jet->py()/jet->pt();
120 
122  parameters.setJetPt(jpt).setJetEta(jeta).setRho(rho);
123 
124  // jet energy resolutions
125  double sigmapt = resPtObj.getResolution(parameters);
126  double sigmaphi = resPhiObj.getResolution(parameters);
127  // SF not needed since is already embedded in the sigma in the dataGlobalTag
128  // double sigmaSF = isRealData ? resSFObj.getScaleFactor(parameters) : 1.0;
129 
130  // split into high-pt and low-pt sector
131  if( jpt > jetThreshold_ ){
132  // high-pt jets enter into the covariance matrix via JER
133 
134  double scale = 0;
135  if(feta<jetEtas_[0]) scale = jetParams_[0];
136  else if(feta<jetEtas_[1]) scale = jetParams_[1];
137  else if(feta<jetEtas_[2]) scale = jetParams_[2];
138  else if(feta<jetEtas_[3]) scale = jetParams_[3];
139  else scale = jetParams_[4];
140 
141  // double dpt = sigmaSF*scale*jpt*sigmapt;
142  double dpt = scale*jpt*sigmapt;
143  double dph = jpt*sigmaphi;
144 
145  cov_xx += dpt*dpt*c*c + dph*dph*s*s;
146  cov_xy += (dpt*dpt-dph*dph)*c*s;
147  cov_yy += dph*dph*c*c + dpt*dpt*s*s;
148 
149  } else {
150 
151  // add the (corrected) jet to the sumPt
152  sumPt += jpt;
153 
154  }
155 
156  }
157 
158  //protection against unphysical events
159  if(sumPt<0) sumPt=0;
160 
161  // add pseudo-jet to metsig covariance matrix
162  cov_xx += pjetParams_[0]*pjetParams_[0] + pjetParams_[1]*pjetParams_[1]*sumPt;
163  cov_yy += pjetParams_[0]*pjetParams_[0] + pjetParams_[1]*pjetParams_[1]*sumPt;
164 
165  reco::METCovMatrix cov;
166  cov(0,0) = cov_xx;
167  cov(1,0) = cov_xy;
168  cov(0,1) = cov_xy;
169  cov(1,1) = cov_yy;
170 
171  return cov;
172 }
bool cleanJet(const reco::Jet &jet, const std::vector< edm::Handle< reco::CandidateView > > &leptons)
float getResolution(const JetParameters &parameters) const
JetParameters & setJetEta(float eta)
JetParameters & setRho(float rho)
Ptr< value_type > ptrAt(size_type i) const
size_type size() const
ROOT::Math::SMatrix< double, 2 > METCovMatrix
Definition: MET.h:40
std::vector< double > jetEtas_
const_iterator begin() const
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
std::vector< double > pjetParams_
std::vector< double > jetParams_
T const * product() const
Definition: Handle.h:81
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
const_iterator end() const
JetParameters & setJetPt(float pt)
double METSignificance::getSignificance ( const reco::METCovMatrix cov,
const reco::MET met 
)
static

Definition at line 175 of file METSignificance.cc.

References reco::LeafCandidate::px(), and reco::LeafCandidate::py().

Referenced by pat::PATMETProducer::produce(), cms::METSignificanceProducer::produce(), and CorrectedPATMETProducer::produce().

175  {
176 
177  // covariance matrix determinant
178  double det = cov(0,0)*cov(1,1) - cov(0,1)*cov(1,0);
179 
180  // invert matrix
181  double ncov_xx = cov(1,1) / det;
182  double ncov_xy = -cov(0,1) / det;
183  double ncov_yy = cov(0,0) / det;
184 
185  // product of met and inverse of covariance
186  double sig = met.px()*met.px()*ncov_xx + 2*met.px()*met.py()*ncov_xy + met.py()*met.py()*ncov_yy;
187 
188  return sig;
189 }
double px() const final
x coordinate of momentum vector
double py() const final
y coordinate of momentum vector

Member Data Documentation

double metsig::METSignificance::dR2match_
private

Definition at line 56 of file METSignificance.h.

Referenced by cleanJet(), and METSignificance().

std::vector<double> metsig::METSignificance::jetEtas_
private

Definition at line 57 of file METSignificance.h.

Referenced by getCovariance(), and METSignificance().

std::vector<double> metsig::METSignificance::jetParams_
private

Definition at line 58 of file METSignificance.h.

Referenced by getCovariance(), and METSignificance().

double metsig::METSignificance::jetThreshold_
private

Definition at line 55 of file METSignificance.h.

Referenced by getCovariance(), and METSignificance().

std::vector<double> metsig::METSignificance::pjetParams_
private

Definition at line 59 of file METSignificance.h.

Referenced by getCovariance(), and METSignificance().