CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | 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::View< reco::Candidate > &pfCandidates)
 
double getSignificance (const reco::METCovMatrix &cov, const reco::MET &met) const
 
 METSignificance (const edm::ParameterSet &iConfig)
 
 ~METSignificance ()
 

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_
 
JetResolutionphiRes_
 
std::vector< double > pjetParams_
 
JetResolutionptRes_
 

Detailed Description

Definition at line 33 of file METSignificance.h.

Constructor & Destructor Documentation

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

Definition at line 20 of file METSignificance.cc.

References dR2match_, edm::FileInPath::fullPath(), edm::ParameterSet::getParameter(), jetEtas_, jetParams_, jetThreshold_, phiRes_, pjetParams_, ptRes_, and AlCaHLTBitMon_QueryRunRegistry::string.

20  {
21 
22  edm::ParameterSet cfgParams = iConfig.getParameter<edm::ParameterSet>("parameters");
23 
24 
25  std::string ptResFileName = cfgParams.getParameter<std::string>("ptResFile");
26  std::string phiResFileName = cfgParams.getParameter<std::string>("phiResFile");
27 
28  double dRmatch = cfgParams.getParameter<double>("dRMatch");
29  dR2match_ = dRmatch*dRmatch;
30 
31  jetThreshold_ = cfgParams.getParameter<double>("jetThreshold");
32  jetEtas_ = cfgParams.getParameter<std::vector<double> >("jeta");
33  jetParams_ = cfgParams.getParameter<std::vector<double> >("jpar");
34  pjetParams_ = cfgParams.getParameter<std::vector<double> >("pjpar");
35 
36 
37  edm::FileInPath fpt("CondFormats/JetMETObjects/data/"+ptResFileName);
38  edm::FileInPath fphi("CondFormats/JetMETObjects/data/"+phiResFileName);
39 
40  ptRes_ = new JetResolution(fpt.fullPath().c_str(),false);
41  phiRes_ = new JetResolution(fphi.fullPath().c_str(),false);
42 
43 }
T getParameter(std::string const &) const
std::vector< double > jetEtas_
std::vector< double > pjetParams_
JetResolution * phiRes_
std::vector< double > jetParams_
JetResolution * ptRes_
METSignificance::~METSignificance ( )

Definition at line 45 of file METSignificance.cc.

45  {
46  delete ptRes_;
47  delete phiRes_;
48 }
JetResolution * phiRes_
JetResolution * ptRes_

Member Function Documentation

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

Definition at line 189 of file METSignificance.cc.

References reco::deltaR2(), and HLT_25ns14e33_v1_cff::leptons.

190  {
191 
192  for ( std::vector< edm::Handle<reco::CandidateView> >::const_iterator lep_i = leptons.begin();
193  lep_i != leptons.end(); ++lep_i ) {
194  for( reco::CandidateView::const_iterator lep = (*lep_i)->begin(); lep != (*lep_i)->end(); lep++ ){
195  if ( reco::deltaR2(*lep, jet) < dR2match_ ) {
196  return false;
197  }
198  }
199  }
200  return true;
201 }
double deltaR2(const T1 &t1, const T2 &t2)
Definition: deltaR.h:36
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:85
reco::METCovMatrix METSignificance::getCovariance ( const edm::View< reco::Jet > &  jets,
const std::vector< edm::Handle< reco::CandidateView > > &  leptons,
const edm::View< reco::Candidate > &  pfCandidates 
)

Definition at line 52 of file METSignificance.cc.

References funct::abs(), edm::View< T >::begin(), EnergyCorrector::c, edm::View< T >::end(), i, metsig::jet, HLT_25ns14e33_v1_cff::leptons, gen::n, p4, alignCSCRings::s, and pileupReCalc_HLTpaths::scale.

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

54  {
55 
56  // metsig covariance
57  double cov_xx = 0;
58  double cov_xy = 0;
59  double cov_yy = 0;
60 
61  // for lepton and jet subtraction
62  std::vector<reco::CandidatePtr> footprint;
63 
64  // subtract leptons out of sumPt
65  for ( std::vector< edm::Handle<reco::CandidateView> >::const_iterator lep_i = leptons.begin();
66  lep_i != leptons.end(); ++lep_i ) {
67  for( reco::CandidateView::const_iterator lep = (*lep_i)->begin(); lep != (*lep_i)->end(); lep++ ){
68  if( lep->pt() > 10 ){
69  for( unsigned int n=0; n < lep->numberOfSourceCandidatePtrs(); n++ ){
70  if( lep->sourceCandidatePtr(n).isNonnull() and lep->sourceCandidatePtr(n).isAvailable() ){
71  footprint.push_back(lep->sourceCandidatePtr(n));
72  }
73  }
74  }
75  }
76  }
77  // subtract jets out of sumPt
78  for(edm::View<reco::Jet>::const_iterator jet = jets.begin(); jet != jets.end(); ++jet) {
79 
80  // disambiguate jets and leptons
81  if(!cleanJet(*jet, leptons) ) continue;
82 
83  for( unsigned int n=0; n < jet->numberOfSourceCandidatePtrs(); n++){
84  if( jet->sourceCandidatePtr(n).isNonnull() and jet->sourceCandidatePtr(n).isAvailable() ){
85  footprint.push_back(jet->sourceCandidatePtr(n));
86  }
87  }
88 
89  }
90 
91  // calculate sumPt
92  double sumPt = 0;
93  for( edm::View<reco::Candidate>::const_iterator cand = pfCandidates.begin();
94  cand != pfCandidates.end(); ++cand){
95 
96  // check if candidate exists in a lepton or jet
97  bool cleancand = true;
98  for(unsigned int i=0; i < footprint.size(); i++){
99  if( footprint[i]->p4() == cand->p4() ){
100  cleancand = false;
101  }
102  }
103  // if not, add to sumPt
104  if( cleancand ){
105  sumPt += cand->pt();
106  }
107 
108  }
109 
110  // add jets to metsig covariance matrix and subtract them from sumPt
111  for(edm::View<reco::Jet>::const_iterator jet = jets.begin(); jet != jets.end(); ++jet) {
112 
113  // disambiguate jets and leptons
114  if(!cleanJet(*jet, leptons) ) continue;
115 
116  double jpt = jet->pt();
117  double jeta = jet->eta();
118  double feta = std::abs(jeta);
119  double c = jet->px()/jet->pt();
120  double s = jet->py()/jet->pt();
121 
122  // jet energy resolutions
123  double jeta_res = (std::abs(jeta) < 9.9) ? jeta : 9.89; // JetResolutions defined for |eta|<9.9
124  double sigmapt = ptRes_->parameterEtaEval("sigma",jeta_res,jpt);
125  double sigmaphi = phiRes_->parameterEtaEval("sigma",jeta_res,jpt);
126 
127  // split into high-pt and low-pt sector
128  if( jpt > jetThreshold_ ){
129  // high-pt jets enter into the covariance matrix via JER
130 
131  double scale = 0;
132  if(feta<jetEtas_[0]) scale = jetParams_[0];
133  else if(feta<jetEtas_[1]) scale = jetParams_[1];
134  else if(feta<jetEtas_[2]) scale = jetParams_[2];
135  else if(feta<jetEtas_[3]) scale = jetParams_[3];
136  else scale = jetParams_[4];
137 
138  double dpt = scale*jpt*sigmapt;
139  double dph = jpt*sigmaphi;
140 
141  cov_xx += dpt*dpt*c*c + dph*dph*s*s;
142  cov_xy += (dpt*dpt-dph*dph)*c*s;
143  cov_yy += dph*dph*c*c + dpt*dpt*s*s;
144 
145  } else {
146 
147  // add the (corrected) jet to the sumPt
148  sumPt += jpt;
149 
150  }
151 
152  }
153 
154 
155  //protection against unphysical events
156  if(sumPt<0) sumPt=0;
157 
158  // add pseudo-jet to metsig covariance matrix
159  cov_xx += pjetParams_[0]*pjetParams_[0] + pjetParams_[1]*pjetParams_[1]*sumPt;
160  cov_yy += pjetParams_[0]*pjetParams_[0] + pjetParams_[1]*pjetParams_[1]*sumPt;
161 
162  reco::METCovMatrix cov;
163  cov(0,0) = cov_xx;
164  cov(1,0) = cov_xy;
165  cov(0,1) = cov_xy;
166  cov(1,1) = cov_yy;
167 
168  return cov;
169 }
int i
Definition: DBlmapReader.cc:9
bool cleanJet(const reco::Jet &jet, const std::vector< edm::Handle< reco::CandidateView > > &leptons)
ROOT::Math::SMatrix< double, 2 > METCovMatrix
Definition: MET.h:40
double parameterEtaEval(const std::string &parameterName, float eta, float pt)
std::vector< double > jetEtas_
const_iterator begin() const
double p4[4]
Definition: TauolaWrapper.h:92
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
std::vector< double > pjetParams_
JetResolution * phiRes_
std::vector< double > jetParams_
JetResolution * ptRes_
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:85
const_iterator end() const
double METSignificance::getSignificance ( const reco::METCovMatrix cov,
const reco::MET met 
) const

Definition at line 172 of file METSignificance.cc.

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

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

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

Member Data Documentation

double metsig::METSignificance::dR2match_
private

Definition at line 48 of file METSignificance.h.

Referenced by METSignificance().

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

Definition at line 49 of file METSignificance.h.

Referenced by METSignificance().

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

Definition at line 50 of file METSignificance.h.

Referenced by METSignificance().

double metsig::METSignificance::jetThreshold_
private

Definition at line 47 of file METSignificance.h.

Referenced by METSignificance().

JetResolution* metsig::METSignificance::phiRes_
private

Definition at line 54 of file METSignificance.h.

Referenced by METSignificance().

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

Definition at line 51 of file METSignificance.h.

Referenced by METSignificance().

JetResolution* metsig::METSignificance::ptRes_
private

Definition at line 53 of file METSignificance.h.

Referenced by METSignificance().