CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Functions | Variables
NoPileUpPFMEtProducer.cc File Reference
#include "RecoMET/METPUSubtraction/plugins/NoPileUpPFMEtProducer.h"
#include "FWCore/Utilities/interface/Exception.h"
#include "RecoMET/METAlgorithms/interface/significanceAlgo.h"
#include "DataFormats/METReco/interface/SigInputObj.h"
#include <cmath>
#include "FWCore/Framework/interface/MakerMacros.h"

Go to the source code of this file.

Functions

void addToCommonMETData (CommonMETData &metData, const reco::Candidate::LorentzVector &p4)
 
reco::METCovMatrix computePFMEtSignificance (const std::vector< metsig::SigInputObj > &metSignObjects)
 
void finalizeCommonMETData (CommonMETData &metData)
 
int findBestMatchingLepton (const std::vector< reco::Candidate::LorentzVector > &leptons, const reco::Candidate::LorentzVector &p4_ref)
 
void initializeCommonMETData (CommonMETData &metData)
 
void printCommonMETData (const std::string &label, const CommonMETData &metData)
 
void printMVAMEtJetInfo (const std::string &label, int idx, const reco::PUSubMETCandInfo &jet)
 
void printMVAMEtPFCandInfo (const std::string &label, int idx, const reco::PUSubMETCandInfo &pfCand)
 
void printP4 (const std::string &label_part1, int idx, const std::string &label_part2, const reco::Candidate &candidate)
 
static const
edm::ParameterSetDescriptionFillerPluginFactory::PMaker
< edm::ParameterSetDescriptionFiller
< NoPileUpPFMEtProducer > > 
s_filler__LINE__ ("NoPileUpPFMEtProducer")
 
static const
edm::MakerPluginFactory::PMaker
< edm::WorkerMaker
< NoPileUpPFMEtProducer > > 
s_maker__LINE__ ("NoPileUpPFMEtProducer")
 
void scaleAndAddPFMEtSignObjects (std::vector< metsig::SigInputObj > &metSignObjects_scaled, const std::vector< metsig::SigInputObj > &metSignObjects, double sf, double sfMin, double sfMax)
 

Variables

const double defaultPFMEtResolutionX = 10.
 
const double defaultPFMEtResolutionY = 10.
 
const double epsilon = 1.e-9
 

Function Documentation

void addToCommonMETData ( CommonMETData metData,
const reco::Candidate::LorentzVector p4 
)

Definition at line 94 of file NoPileUpPFMEtProducer.cc.

References CommonMETData::mex, CommonMETData::mey, CommonMETData::mez, and CommonMETData::sumet.

Referenced by NoPileUpPFMEtProducer::produce().

95 {
96  metData.mex += p4.px();
97  metData.mey += p4.py();
98  metData.mez += p4.pz();
99  metData.sumet += p4.pt();
100 }
double p4[4]
Definition: TauolaWrapper.h:92
reco::METCovMatrix computePFMEtSignificance ( const std::vector< metsig::SigInputObj > &  metSignObjects)

Definition at line 145 of file NoPileUpPFMEtProducer.cc.

References funct::abs(), metsig::significanceAlgo::addObjects(), defaultPFMEtResolutionX, defaultPFMEtResolutionY, geometryDiff::epsilon, and metsig::significanceAlgo::getSignifMatrix().

Referenced by NoPileUpPFMEtProducer::produce().

146 {
147  reco::METCovMatrix pfMEtCov;
148  if ( metSignObjects.size() >= 2 ) {
149  metsig::significanceAlgo pfMEtSignAlgorithm;
150  pfMEtSignAlgorithm.addObjects(metSignObjects);
151  pfMEtCov = pfMEtSignAlgorithm.getSignifMatrix();
152  }
153 
154  double det = 0;
155  pfMEtCov.Det(det);
156  if ( std::abs(det) < epsilon ) {
157  edm::LogWarning("computePFMEtSignificance")
158  << "Inversion of PFMEt covariance matrix failed, det = " << det
159  << " --> replacing covariance matrix by resolution defaults !!";
161  pfMEtCov(0,1) = 0.;
162  pfMEtCov(1,0) = 0.;
164  }
165 
166  return pfMEtCov;
167 }
const double defaultPFMEtResolutionY
const void addObjects(const std::vector< metsig::SigInputObj > &EventVec)
ROOT::Math::SMatrix< double, 2 > METCovMatrix
Definition: MET.h:40
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
const double defaultPFMEtResolutionX
reco::METCovMatrix getSignifMatrix() const
void finalizeCommonMETData ( CommonMETData metData)

Definition at line 102 of file NoPileUpPFMEtProducer.cc.

References CommonMETData::met, CommonMETData::mex, CommonMETData::mey, CommonMETData::phi, and mathSSE::sqrt().

Referenced by NoPileUpPFMEtProducer::produce().

103 {
104  metData.met = sqrt(metData.mex*metData.mex + metData.mey*metData.mey);
105  metData.phi = atan2(metData.mey, metData.mex);
106 }
T sqrt(T t)
Definition: SSEVec.h:18
int findBestMatchingLepton ( const std::vector< reco::Candidate::LorentzVector > &  leptons,
const reco::Candidate::LorentzVector p4_ref 
)

Definition at line 108 of file NoPileUpPFMEtProducer.cc.

References assert(), and reco::deltaR2().

Referenced by NoPileUpPFMEtProducer::produce().

109 {
110  int leptonIdx_dR2min = -1;
111  double dR2min = 1.e+3;
112  int leptonIdx = 0;
113  for ( std::vector<reco::Candidate::LorentzVector>::const_iterator lepton = leptons.begin();
114  lepton != leptons.end(); ++lepton ) {
115  double dR2 = deltaR2(*lepton, p4_ref);
116  if ( leptonIdx_dR2min == -1 || dR2 < dR2min ) {
117  leptonIdx_dR2min = leptonIdx;
118  dR2min = dR2;
119  }
120  ++leptonIdx;
121  }
122  assert(leptonIdx_dR2min >= 0 && leptonIdx_dR2min < (int)leptons.size());
123  return leptonIdx_dR2min;
124 }
assert(m_qm.get())
T1 deltaR2(T1 eta1, T2 phi1, T3 eta2, T4 phi2)
Definition: deltaR.h:36
void initializeCommonMETData ( CommonMETData metData)

Definition at line 84 of file NoPileUpPFMEtProducer.cc.

References CommonMETData::met, CommonMETData::mex, CommonMETData::mey, CommonMETData::mez, CommonMETData::phi, and CommonMETData::sumet.

Referenced by NoPileUpPFMEtProducer::produce().

85 {
86  metData.met = 0.;
87  metData.mex = 0.;
88  metData.mey = 0.;
89  metData.mez = 0.;
90  metData.sumet = 0.;
91  metData.phi = 0.;
92 }
void printCommonMETData ( const std::string &  label,
const CommonMETData metData 
)

Definition at line 175 of file NoPileUpPFMEtProducer.cc.

References gather_cfg::cout, CommonMETData::mex, CommonMETData::mey, and CommonMETData::sumet.

176 {
177  std::cout << label << ": Px = " << metData.mex << ", Py = " << metData.mey << ", sumEt = " << metData.sumet << std::endl;
178 }
tuple cout
Definition: gather_cfg.py:145
void printMVAMEtJetInfo ( const std::string &  label,
int  idx,
const reco::PUSubMETCandInfo jet 
)

Definition at line 180 of file NoPileUpPFMEtProducer.cc.

References gather_cfg::cout, reco::PUSubMETCandInfo::kHS, reco::PUSubMETCandInfo::kPU, reco::PUSubMETCandInfo::p4(), reco::PUSubMETCandInfo::passesLooseJetId(), and reco::PUSubMETCandInfo::type().

181 {
182  std::cout << label << " #" << idx << " (";
183  if ( jet.type() == reco::PUSubMETCandInfo::kHS ) std::cout << "no-PU";
184  else if ( jet.type() == reco::PUSubMETCandInfo::kPU ) std::cout << "PU";
185  std::cout << "): Pt = " << jet.p4().pt() << ", eta = " << jet.p4().eta() << ", phi = " << jet.p4().phi();
186  std::cout << " id. flags: anti-noise = " << jet.passesLooseJetId() << std::endl;
187  std::cout << std::endl;
188 }
tuple idx
DEBUGGING if hasattr(process,&quot;trackMonIterativeTracking2012&quot;): print &quot;trackMonIterativeTracking2012 D...
tuple cout
Definition: gather_cfg.py:145
float passesLooseJetId() const
Definition: PUSubMETData.h:42
const reco::Candidate::LorentzVector & p4() const
Definition: PUSubMETData.h:34
void printMVAMEtPFCandInfo ( const std::string &  label,
int  idx,
const reco::PUSubMETCandInfo pfCand 
)

Definition at line 190 of file NoPileUpPFMEtProducer.cc.

References gather_cfg::cout, reco::PUSubMETCandInfo::isWithinJet(), reco::PUSubMETCandInfo::kChHS, reco::PUSubMETCandInfo::kChPU, reco::PUSubMETCandInfo::kNeutral, reco::PUSubMETCandInfo::p4(), reco::PUSubMETCandInfo::passesLooseJetId(), AlCaHLTBitMon_QueryRunRegistry::string, and reco::PUSubMETCandInfo::type().

191 {
192  std::cout << label << " #" << idx << " (";
193  if ( pfCand.type() == reco::PUSubMETCandInfo::kChHS ) std::cout << "no-PU charged";
194  else if ( pfCand.type() == reco::PUSubMETCandInfo::kChPU ) std::cout << "PU charged";
195  else if ( pfCand.type() == reco::PUSubMETCandInfo::kNeutral ) std::cout << "neutral";
196  std::cout << "): Pt = " << pfCand.p4().pt() << ", eta = " << pfCand.p4().eta() << ", phi = " << pfCand.p4().phi();
197  std::string isWithinJet_string;
198  if ( pfCand.isWithinJet() ) isWithinJet_string = "true";
199  else isWithinJet_string = "false";
200  std::cout << " (isWithinJet = " << isWithinJet_string << ")";
201  if ( pfCand.isWithinJet() ) std::cout << " Jet id. flags: anti-noise = " << pfCand.passesLooseJetId() << std::endl;
202  std::cout << std::endl;
203 }
bool isWithinJet() const
Definition: PUSubMETData.h:41
tuple idx
DEBUGGING if hasattr(process,&quot;trackMonIterativeTracking2012&quot;): print &quot;trackMonIterativeTracking2012 D...
tuple cout
Definition: gather_cfg.py:145
float passesLooseJetId() const
Definition: PUSubMETData.h:42
const reco::Candidate::LorentzVector & p4() const
Definition: PUSubMETData.h:34
void printP4 ( const std::string &  label_part1,
int  idx,
const std::string &  label_part2,
const reco::Candidate candidate 
)

Definition at line 169 of file NoPileUpPFMEtProducer.cc.

References reco::Candidate::charge(), gather_cfg::cout, reco::Candidate::eta(), reco::Candidate::phi(), and reco::Candidate::pt().

170 {
171  std::cout << label_part1 << " #" << idx << label_part2 << ": Pt = " << candidate.pt() << ", eta = " << candidate.eta() << ", phi = " << candidate.phi()
172  << " (charge = " << candidate.charge() << ")" << std::endl;
173 }
virtual double pt() const =0
transverse momentum
virtual int charge() const =0
electric charge
tuple idx
DEBUGGING if hasattr(process,&quot;trackMonIterativeTracking2012&quot;): print &quot;trackMonIterativeTracking2012 D...
tuple cout
Definition: gather_cfg.py:145
virtual double phi() const =0
momentum azimuthal angle
virtual double eta() const =0
momentum pseudorapidity
static const edm::ParameterSetDescriptionFillerPluginFactory::PMaker<edm::ParameterSetDescriptionFiller< NoPileUpPFMEtProducer > > s_filler__LINE__ ( "NoPileUpPFMEtProducer"  )
static
static const edm::MakerPluginFactory ::PMaker< edm::WorkerMaker< NoPileUpPFMEtProducer > > s_maker__LINE__ ( "NoPileUpPFMEtProducer"  )
static
void scaleAndAddPFMEtSignObjects ( std::vector< metsig::SigInputObj > &  metSignObjects_scaled,
const std::vector< metsig::SigInputObj > &  metSignObjects,
double  sf,
double  sfMin,
double  sfMax 
)

Definition at line 126 of file NoPileUpPFMEtProducer.cc.

References metsig::SigInputObj::set().

Referenced by NoPileUpPFMEtProducer::produce().

128 {
129  double sf_value = sf;
130  if ( sf_value > sfMax ) sf_value = sfMax;
131  if ( sf_value < sfMin ) sf_value = sfMin;
132  for ( std::vector<metsig::SigInputObj>::const_iterator metSignObject = metSignObjects.begin();
133  metSignObject != metSignObjects.end(); ++metSignObject ) {
134  metsig::SigInputObj metSignObject_scaled;
135  metSignObject_scaled.set(
136  metSignObject->get_type(),
137  sf_value*metSignObject->get_energy(),
138  metSignObject->get_phi(),
139  sf_value*metSignObject->get_sigma_e(),
140  metSignObject->get_sigma_tan());
141  metSignObjects_scaled.push_back(metSignObject_scaled);
142  }
143 }
void set(const std::string &m_type, const double &m_energy, const double &m_phi, const double &m_sigma_e, const double &m_sigma_tan)
Definition: SigInputObj.h:48

Variable Documentation

const double defaultPFMEtResolutionX = 10.
const double defaultPFMEtResolutionY = 10.
const double epsilon = 1.e-9

Definition at line 14 of file NoPileUpPFMEtProducer.cc.