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_0__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.

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 }

◆ computePFMEtSignificance()

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, 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
const double epsilon
Log< level::Warning, false > LogWarning
reco::METCovMatrix getSignifMatrix() const

◆ finalizeCommonMETData()

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:23

◆ findBestMatchingLepton()

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(), HLTMuonOfflineAnalyzer_cfi::deltaR2, ALPAKA_ACCELERATOR_NAMESPACE::dR2(), and HLT_2024v13_cff::leptons.

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)
ALPAKA_FN_ACC static ALPAKA_FN_INLINE float dR2(Position4 pos1, Position4 pos2)

◆ initializeCommonMETData()

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 }

◆ printCommonMETData()

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

Definition at line 170 of file NoPileUpPFMEtProducer.cc.

References gather_cfg::cout, label, 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

◆ printMVAMEtJetInfo()

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

Definition at line 175 of file NoPileUpPFMEtProducer.cc.

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

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

◆ printMVAMEtPFCandInfo()

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

Definition at line 186 of file NoPileUpPFMEtProducer.cc.

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().

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 }
bool isWithinJet() const
Definition: PUSubMETData.h:37
char const * label
const reco::Candidate::LorentzVector & p4() const
Definition: PUSubMETData.h:30
float passesLooseJetId() const
Definition: PUSubMETData.h:38

◆ 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.

References reco::Candidate::charge(), gather_cfg::cout, reco::Candidate::eta(), heavyIonCSV_trainingSettings::idx, 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
virtual double phi() const =0
momentum azimuthal angle
virtual double eta() const =0
momentum pseudorapidity

◆ s_filler_0__LINE__()

static const edm::ParameterSetDescriptionFillerPluginFactory::PMaker<edm::ParameterSetDescriptionFiller< NoPileUpPFMEtProducer > > s_filler_0__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.

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

◆ 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().