CMS 3D CMS Logo

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

◆ addToCommonMETData()

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

Definition at line 90 of file NoPileUpPFMEtProducer.cc.

90  {
91  metData.mex += p4.px();
92  metData.mey += p4.py();
93  metData.mez += p4.pz();
94  metData.sumet += p4.pt();
95 }

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

Referenced by NoPileUpPFMEtProducer::produce().

◆ computePFMEtSignificance()

reco::METCovMatrix computePFMEtSignificance ( const std::vector< metsig::SigInputObj > &  metSignObjects)

Definition at line 143 of file NoPileUpPFMEtProducer.cc.

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 }

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

Referenced by NoPileUpPFMEtProducer::produce().

◆ finalizeCommonMETData()

void finalizeCommonMETData ( CommonMETData metData)

Definition at line 97 of file NoPileUpPFMEtProducer.cc.

97  {
98  metData.met = sqrt(metData.mex * metData.mex + metData.mey * metData.mey);
99  metData.phi = atan2(metData.mey, metData.mex);
100 }

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

Referenced by NoPileUpPFMEtProducer::produce().

◆ findBestMatchingLepton()

int findBestMatchingLepton ( const std::vector< reco::Candidate::LorentzVector > &  leptons,
const reco::Candidate::LorentzVector p4_ref 
)

Definition at line 102 of file NoPileUpPFMEtProducer.cc.

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 }

References cms::cuda::assert(), HLTMuonOfflineAnalyzer_cfi::deltaR2, and HLT_FULL_cff::leptons.

Referenced by NoPileUpPFMEtProducer::produce().

◆ initializeCommonMETData()

void initializeCommonMETData ( CommonMETData metData)

Definition at line 81 of file NoPileUpPFMEtProducer.cc.

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 }

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

Referenced by NoPileUpPFMEtProducer::produce().

◆ printCommonMETData()

void printCommonMETData ( const std::string &  label,
const CommonMETData metData 
)

Definition at line 170 of file NoPileUpPFMEtProducer.cc.

170  {
171  std::cout << label << ": Px = " << metData.mex << ", Py = " << metData.mey << ", sumEt = " << metData.sumet
172  << std::endl;
173 }

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

◆ printMVAMEtJetInfo()

void printMVAMEtJetInfo ( const std::string &  label,
int  idx,
const reco::PUSubMETCandInfo jet 
)

Definition at line 175 of file NoPileUpPFMEtProducer.cc.

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 }

References gather_cfg::cout, heavyIonCSV_trainingSettings::idx, metsig::jet, reco::PUSubMETCandInfo::kHS, reco::PUSubMETCandInfo::kPU, and label.

◆ printMVAMEtPFCandInfo()

void printMVAMEtPFCandInfo ( const std::string &  label,
int  idx,
const reco::PUSubMETCandInfo pfCand 
)

Definition at line 186 of file NoPileUpPFMEtProducer.cc.

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 }

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

◆ printP4()

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.

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 }

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

◆ s_filler__LINE__()

static const edm::ParameterSetDescriptionFillerPluginFactory::PMaker<edm::ParameterSetDescriptionFiller< NoPileUpPFMEtProducer > > s_filler__LINE__ ( "NoPileUpPFMEtProducer"  )
static

◆ s_maker__LINE__()

static const edm::MakerPluginFactory ::PMaker< edm::WorkerMaker< NoPileUpPFMEtProducer > > s_maker__LINE__ ( "NoPileUpPFMEtProducer"  )
static

◆ scaleAndAddPFMEtSignObjects()

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.

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 }

References metsig::SigInputObj::set().

Referenced by NoPileUpPFMEtProducer::produce().

Variable Documentation

◆ defaultPFMEtResolutionX

const double defaultPFMEtResolutionX = 10.

Definition at line 11 of file NoPileUpPFMEtProducer.cc.

Referenced by computePFMEtSignificance().

◆ defaultPFMEtResolutionY

const double defaultPFMEtResolutionY = 10.

Definition at line 12 of file NoPileUpPFMEtProducer.cc.

Referenced by computePFMEtSignificance().

◆ epsilon

const double epsilon = 1.e-9

Definition at line 14 of file NoPileUpPFMEtProducer.cc.

Referenced by computePFMEtSignificance().

CommonMETData::met
double met
Definition: CommonMETData.h:14
HLT_FULL_cff.leptons
leptons
Definition: HLT_FULL_cff.py:26277
reco::Candidate::eta
virtual double eta() const =0
momentum pseudorapidity
gather_cfg.cout
cout
Definition: gather_cfg.py:144
metsig::SigInputObj::set
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
reco::Candidate::pt
virtual double pt() const =0
transverse momentum
cms::cuda::assert
assert(be >=bs)
defaultPFMEtResolutionX
const double defaultPFMEtResolutionX
Definition: NoPileUpPFMEtProducer.cc:11
defaultPFMEtResolutionY
const double defaultPFMEtResolutionY
Definition: NoPileUpPFMEtProducer.cc:12
CommonMETData::mez
double mez
Definition: CommonMETData.h:17
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
heavyIonCSV_trainingSettings.idx
idx
Definition: heavyIonCSV_trainingSettings.py:5
metsig::significanceAlgo::addObjects
const void addObjects(const std::vector< metsig::SigInputObj > &EventVec)
Definition: significanceAlgo.cc:109
reco::PUSubMETCandInfo::type
int type() const
Definition: PUSubMETData.h:33
CommonMETData::mex
double mex
Definition: CommonMETData.h:15
reco::PUSubMETCandInfo::p4
const reco::Candidate::LorentzVector & p4() const
Definition: PUSubMETData.h:30
reco::Candidate::charge
virtual int charge() const =0
electric charge
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
reco::PUSubMETCandInfo::passesLooseJetId
float passesLooseJetId() const
Definition: PUSubMETData.h:38
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
CommonMETData::sumet
double sumet
Definition: CommonMETData.h:18
CommonMETData::phi
double phi
Definition: CommonMETData.h:19
epsilon
const double epsilon
Definition: NoPileUpPFMEtProducer.cc:14
p4
double p4[4]
Definition: TauolaWrapper.h:92
reco::PUSubMETCandInfo::kPU
Definition: PUSubMETData.h:63
reco::PUSubMETCandInfo::kChPU
Definition: PUSubMETData.h:63
metsig::significanceAlgo
Definition: significanceAlgo.h:86
HLTMuonOfflineAnalyzer_cfi.deltaR2
deltaR2
Definition: HLTMuonOfflineAnalyzer_cfi.py:105
metsig::jet
Definition: SignAlgoResolutions.h:47
metsig::significanceAlgo::getSignifMatrix
reco::METCovMatrix getSignifMatrix() const
Definition: significanceAlgo.h:99
reco::PUSubMETCandInfo::kChHS
Definition: PUSubMETData.h:63
reco::PUSubMETCandInfo::isWithinJet
bool isWithinJet() const
Definition: PUSubMETData.h:37
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
reco::PUSubMETCandInfo::kHS
Definition: PUSubMETData.h:63
reco::Candidate::phi
virtual double phi() const =0
momentum azimuthal angle
CommonMETData::mey
double mey
Definition: CommonMETData.h:16
metsig::SigInputObj
Definition: SigInputObj.h:29
label
const char * label
Definition: PFTauDecayModeTools.cc:11
reco::METCovMatrix
ROOT::Math::SMatrix< double, 2 > METCovMatrix
Definition: MET.h:39
reco::PUSubMETCandInfo::kNeutral
Definition: PUSubMETData.h:63