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 <math.h>
#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::MVAMEtJetInfo &jet)
 
void printMVAMEtPFCandInfo (const std::string &label, int idx, const reco::MVAMEtPFCandInfo &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 96 of file NoPileUpPFMEtProducer.cc.

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

Referenced by NoPileUpPFMEtProducer::produce().

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

Definition at line 157 of file NoPileUpPFMEtProducer.cc.

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

Referenced by NoPileUpPFMEtProducer::produce().

158 {
159  reco::METCovMatrix pfMEtCov;
160  if ( metSignObjects.size() >= 2 ) {
161  metsig::significanceAlgo pfMEtSignAlgorithm;
162  pfMEtSignAlgorithm.addObjects(metSignObjects);
163  pfMEtCov = pfMEtSignAlgorithm.getSignifMatrix();
164  }
165 
166  double det = 0;
167  pfMEtCov.Det(det);
168  if ( std::abs(det) < epsilon ) {
169  edm::LogWarning("computePFMEtSignificance")
170  << "Inversion of PFMEt covariance matrix failed, det = " << det
171  << " --> replacing covariance matrix by resolution defaults !!";
173  pfMEtCov(0,1) = 0.;
174  pfMEtCov(1,0) = 0.;
176  }
177 
178  return pfMEtCov;
179 }
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 104 of file NoPileUpPFMEtProducer.cc.

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

Referenced by NoPileUpPFMEtProducer::produce().

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

Definition at line 110 of file NoPileUpPFMEtProducer.cc.

References reco::deltaR2().

Referenced by NoPileUpPFMEtProducer::produce().

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

Definition at line 86 of file NoPileUpPFMEtProducer.cc.

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

Referenced by NoPileUpPFMEtProducer::produce().

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

Definition at line 187 of file NoPileUpPFMEtProducer.cc.

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

188 {
189  std::cout << label << ": Px = " << metData.mex << ", Py = " << metData.mey << ", sumEt = " << metData.sumet << std::endl;
190 }
tuple cout
Definition: gather_cfg.py:121
void printMVAMEtJetInfo ( const std::string &  label,
int  idx,
const reco::MVAMEtJetInfo jet 
)

Definition at line 192 of file NoPileUpPFMEtProducer.cc.

References gather_cfg::cout, reco::MVAMEtJetInfo::kNoPileUp, reco::MVAMEtJetInfo::kPileUp, reco::MVAMEtJetInfo::p4_, reco::MVAMEtJetInfo::passesLooseJetId_, and reco::MVAMEtJetInfo::type_.

193 {
194  std::cout << label << " #" << idx << " (";
195  if ( jet.type_ == reco::MVAMEtJetInfo::kNoPileUp ) std::cout << "no-PU";
196  else if ( jet.type_ == reco::MVAMEtJetInfo::kPileUp ) std::cout << "PU";
197  std::cout << "): Pt = " << jet.p4_.pt() << ", eta = " << jet.p4_.eta() << ", phi = " << jet.p4_.phi();
198  std::cout << " id. flags: anti-noise = " << jet.passesLooseJetId_ << std::endl;
199  std::cout << std::endl;
200 }
double passesLooseJetId_
Definition: MVAMEtData.h:33
reco::Candidate::LorentzVector p4_
Definition: MVAMEtData.h:29
tuple idx
DEBUGGING if hasattr(process,&quot;trackMonIterativeTracking2012&quot;): print &quot;trackMonIterativeTracking2012 D...
tuple cout
Definition: gather_cfg.py:121
void printMVAMEtPFCandInfo ( const std::string &  label,
int  idx,
const reco::MVAMEtPFCandInfo pfCand 
)

Definition at line 202 of file NoPileUpPFMEtProducer.cc.

References gather_cfg::cout, reco::MVAMEtPFCandInfo::isWithinJet_, reco::MVAMEtPFCandInfo::kNeutral, reco::MVAMEtPFCandInfo::kNoPileUpCharged, reco::MVAMEtPFCandInfo::kPileUpCharged, reco::MVAMEtPFCandInfo::p4_, reco::MVAMEtPFCandInfo::passesLooseJetId_, AlCaHLTBitMon_QueryRunRegistry::string, and reco::MVAMEtPFCandInfo::type_.

203 {
204  std::cout << label << " #" << idx << " (";
205  if ( pfCand.type_ == reco::MVAMEtPFCandInfo::kNoPileUpCharged ) std::cout << "no-PU charged";
206  else if ( pfCand.type_ == reco::MVAMEtPFCandInfo::kPileUpCharged ) std::cout << "PU charged";
207  else if ( pfCand.type_ == reco::MVAMEtPFCandInfo::kNeutral ) std::cout << "neutral";
208  std::cout << "): Pt = " << pfCand.p4_.pt() << ", eta = " << pfCand.p4_.eta() << ", phi = " << pfCand.p4_.phi();
209  std::string isWithinJet_string;
210  if ( pfCand.isWithinJet_ ) isWithinJet_string = "true";
211  else isWithinJet_string = "false";
212  std::cout << " (isWithinJet = " << isWithinJet_string << ")";
213  if ( pfCand.isWithinJet_ ) std::cout << " Jet id. flags: anti-noise = " << pfCand.passesLooseJetId_ << std::endl;
214  std::cout << std::endl;
215 }
reco::Candidate::LorentzVector p4_
Definition: MVAMEtData.h:51
tuple idx
DEBUGGING if hasattr(process,&quot;trackMonIterativeTracking2012&quot;): print &quot;trackMonIterativeTracking2012 D...
tuple cout
Definition: gather_cfg.py:121
void printP4 ( const std::string &  label_part1,
int  idx,
const std::string &  label_part2,
const reco::Candidate candidate 
)

Definition at line 181 of file NoPileUpPFMEtProducer.cc.

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

182 {
183  std::cout << label_part1 << " #" << idx << label_part2 << ": Pt = " << candidate.pt() << ", eta = " << candidate.eta() << ", phi = " << candidate.phi()
184  << " (charge = " << candidate.charge() << ")" << std::endl;
185 }
virtual float eta() const =0
momentum pseudorapidity
virtual float phi() const =0
momentum azimuthal angle
virtual float 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:121
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 128 of file NoPileUpPFMEtProducer.cc.

References metsig::SigInputObj::set().

Referenced by NoPileUpPFMEtProducer::produce().

130 {
131  double sf_value = sf;
132  if ( sf_value > sfMax ) sf_value = sfMax;
133  if ( sf_value < sfMin ) sf_value = sfMin;
134  for ( std::vector<metsig::SigInputObj>::const_iterator metSignObject = metSignObjects.begin();
135  metSignObject != metSignObjects.end(); ++metSignObject ) {
136  metsig::SigInputObj metSignObject_scaled;
137  metSignObject_scaled.set(
138  metSignObject->get_type(),
139  sf_value*metSignObject->get_energy(),
140  metSignObject->get_phi(),
141  sf_value*metSignObject->get_sigma_e(),
142  metSignObject->get_sigma_tan());
143  metSignObjects_scaled.push_back(metSignObject_scaled);
144  }
145 }
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 16 of file NoPileUpPFMEtProducer.cc.