CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups 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 90 of file NoPileUpPFMEtProducer.cc.

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

Referenced by NoPileUpPFMEtProducer::produce().

90  {
91  metData.mex += p4.px();
92  metData.mey += p4.py();
93  metData.mez += p4.pz();
94  metData.sumet += p4.pt();
95 }
reco::METCovMatrix computePFMEtSignificance ( const std::vector< metsig::SigInputObj > &  metSignObjects)

Definition at line 143 of file NoPileUpPFMEtProducer.cc.

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

Referenced by NoPileUpPFMEtProducer::produce().

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

Definition at line 97 of file NoPileUpPFMEtProducer.cc.

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

Referenced by NoPileUpPFMEtProducer::produce().

97  {
98  metData.met = sqrt(metData.mex * metData.mex + metData.mey * metData.mey);
99  metData.phi = atan2(metData.mey, metData.mex);
100 }
T sqrt(T t)
Definition: SSEVec.h:19
int findBestMatchingLepton ( const std::vector< reco::Candidate::LorentzVector > &  leptons,
const reco::Candidate::LorentzVector p4_ref 
)

Definition at line 102 of file NoPileUpPFMEtProducer.cc.

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

Referenced by NoPileUpPFMEtProducer::produce().

103  {
104  int leptonIdx_dR2min = -1;
105  double dR2min = 1.e+3;
106  int leptonIdx = 0;
107  for (std::vector<reco::Candidate::LorentzVector>::const_iterator lepton = leptons.begin(); lepton != leptons.end();
108  ++lepton) {
109  double dR2 = deltaR2(*lepton, p4_ref);
110  if (leptonIdx_dR2min == -1 || dR2 < dR2min) {
111  leptonIdx_dR2min = leptonIdx;
112  dR2min = dR2;
113  }
114  ++leptonIdx;
115  }
116  assert(leptonIdx_dR2min >= 0 && leptonIdx_dR2min < (int)leptons.size());
117  return leptonIdx_dR2min;
118 }
assert(be >=bs)
constexpr auto deltaR2(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:16
void initializeCommonMETData ( CommonMETData metData)

Definition at line 81 of file NoPileUpPFMEtProducer.cc.

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

Referenced by NoPileUpPFMEtProducer::produce().

81  {
82  metData.met = 0.;
83  metData.mex = 0.;
84  metData.mey = 0.;
85  metData.mez = 0.;
86  metData.sumet = 0.;
87  metData.phi = 0.;
88 }
void printCommonMETData ( const std::string &  label,
const CommonMETData metData 
)

Definition at line 170 of file NoPileUpPFMEtProducer.cc.

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

170  {
171  std::cout << label << ": Px = " << metData.mex << ", Py = " << metData.mey << ", sumEt = " << metData.sumet
172  << std::endl;
173 }
char const * label
tuple cout
Definition: gather_cfg.py:144
void printMVAMEtJetInfo ( const std::string &  label,
int  idx,
const reco::PUSubMETCandInfo jet 
)

Definition at line 175 of file NoPileUpPFMEtProducer.cc.

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

175  {
176  std::cout << label << " #" << idx << " (";
177  if (jet.type() == reco::PUSubMETCandInfo::kHS)
178  std::cout << "no-PU";
179  else if (jet.type() == reco::PUSubMETCandInfo::kPU)
180  std::cout << "PU";
181  std::cout << "): Pt = " << jet.p4().pt() << ", eta = " << jet.p4().eta() << ", phi = " << jet.p4().phi();
182  std::cout << " id. flags: anti-noise = " << jet.passesLooseJetId() << std::endl;
183  std::cout << std::endl;
184 }
char const * label
tuple cout
Definition: gather_cfg.py:144
float passesLooseJetId() const
Definition: PUSubMETData.h:38
const reco::Candidate::LorentzVector & p4() const
Definition: PUSubMETData.h:30
void printMVAMEtPFCandInfo ( const std::string &  label,
int  idx,
const reco::PUSubMETCandInfo pfCand 
)

Definition at line 186 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().

186  {
187  std::cout << label << " #" << idx << " (";
188  if (pfCand.type() == reco::PUSubMETCandInfo::kChHS)
189  std::cout << "no-PU charged";
190  else if (pfCand.type() == reco::PUSubMETCandInfo::kChPU)
191  std::cout << "PU charged";
192  else if (pfCand.type() == reco::PUSubMETCandInfo::kNeutral)
193  std::cout << "neutral";
194  std::cout << "): Pt = " << pfCand.p4().pt() << ", eta = " << pfCand.p4().eta() << ", phi = " << pfCand.p4().phi();
195  std::string isWithinJet_string;
196  if (pfCand.isWithinJet())
197  isWithinJet_string = "true";
198  else
199  isWithinJet_string = "false";
200  std::cout << " (isWithinJet = " << isWithinJet_string << ")";
201  if (pfCand.isWithinJet())
202  std::cout << " Jet id. flags: anti-noise = " << pfCand.passesLooseJetId() << std::endl;
203  std::cout << std::endl;
204 }
char const * label
bool isWithinJet() const
Definition: PUSubMETData.h:37
tuple cout
Definition: gather_cfg.py:144
float passesLooseJetId() const
Definition: PUSubMETData.h:38
const reco::Candidate::LorentzVector & p4() const
Definition: PUSubMETData.h:30
void printP4 ( const std::string &  label_part1,
int  idx,
const std::string &  label_part2,
const reco::Candidate candidate 
)

Definition at line 165 of file NoPileUpPFMEtProducer.cc.

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

165  {
166  std::cout << label_part1 << " #" << idx << label_part2 << ": Pt = " << candidate.pt() << ", eta = " << candidate.eta()
167  << ", phi = " << candidate.phi() << " (charge = " << candidate.charge() << ")" << std::endl;
168 }
virtual double pt() const =0
transverse momentum
virtual int charge() const =0
electric charge
tuple cout
Definition: gather_cfg.py:144
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 120 of file NoPileUpPFMEtProducer.cc.

References metsig::SigInputObj::set().

Referenced by NoPileUpPFMEtProducer::produce().

124  {
125  double sf_value = sf;
126  if (sf_value > sfMax)
127  sf_value = sfMax;
128  if (sf_value < sfMin)
129  sf_value = sfMin;
130  for (std::vector<metsig::SigInputObj>::const_iterator metSignObject = metSignObjects.begin();
131  metSignObject != metSignObjects.end();
132  ++metSignObject) {
133  metsig::SigInputObj metSignObject_scaled;
134  metSignObject_scaled.set(metSignObject->get_type(),
135  sf_value * metSignObject->get_energy(),
136  metSignObject->get_phi(),
137  sf_value * metSignObject->get_sigma_e(),
138  metSignObject->get_sigma_tan());
139  metSignObjects_scaled.push_back(metSignObject_scaled);
140  }
141 }
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:42

Variable Documentation

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

Definition at line 14 of file NoPileUpPFMEtProducer.cc.