6 const double dR2Min = 0.01 * 0.01;
11 : mvaMEtAlgo_(cfg, consumesCollector()), mvaMEtAlgo_isInitialized_(
false) {
18 for (vInputTag::const_iterator it = srcLeptonsTags.begin(); it != srcLeptonsTags.end(); it++) {
19 srcLeptons_.push_back(consumes<reco::CandidateView>(*it));
31 produces<reco::PFMETCollection>();
45 numLeptons += leptons->size();
48 LogDebug(
"produce") <<
"<PFMETProducerMVA::produce>:" << std::endl
50 <<
", Event: " << evt.
id().
event() << std::endl
51 <<
" numLeptons = " << numLeptons <<
", minNumLeptons = " <<
minNumLeptons_
52 <<
" --> skipping !!" << std::endl;
55 auto pfMEtCollection = std::make_unique<reco::PFMETCollection>();
56 pfMEtCollection->push_back(pfMEt);
86 const reco::Vertex* hardScatterVertex = (!vertices->empty()) ? &(vertices->front()) :
nullptr;
91 bool lHasPhotons =
false;
92 std::vector<reco::PUSubMETCandInfo> leptonInfo =
112 std::vector<reco::PUSubMETCandInfo> pfCandidateInfo =
computePFCandidateInfo(*pfCandidates_view, hardScatterVertex);
114 *uncorrJets, corrJets, *jetIds, *vertices, hardScatterVertex, *corrector, evt, es, leptonInfo, pfCandidateInfo);
124 <<
", Event: " << evt.
id().
event() << std::endl
125 <<
" PFMET: Pt = " << pfMEtP4_original.pt() <<
", phi = " << pfMEtP4_original.phi() <<
" "
126 <<
"(Px = " << pfMEtP4_original.px() <<
", Py = " << pfMEtP4_original.py() <<
")" << std::endl
127 <<
" MVA MET: Pt = " << pfMEt.
pt() <<
" phi = " << pfMEt.
phi() <<
" (Px = " << pfMEt.
px()
128 <<
", Py = " << pfMEt.
py() <<
")" << std::endl
129 <<
" Cov:" << std::endl
135 auto pfMEtCollection = std::make_unique<reco::PFMETCollection>();
136 pfMEtCollection->push_back(pfMEt);
147 std::vector<reco::PUSubMETCandInfo> leptonInfo;
162 if (&(*lepton1) == &(*lepton2)) {
168 if (pMatch && !
istau(&(*lepton1)) &&
istau(&(*lepton2))) {
171 if (pMatch && ((
istau(&(*lepton1)) &&
istau(&(*lepton2))) || (!
istau(&(*lepton1)) && !
istau(&(*lepton2)))) &&
172 lepton1->pt() > lepton2->pt()) {
175 if (pMatch && lepton1->pt() == lepton2->pt()) {
177 for (
unsigned int i0 = 0; i0 < leptonInfo.size(); i0++) {
193 pLeptonInfo.
setP4(lepton1->p4());
195 leptonInfo.push_back(pLeptonInfo);
196 if (lepton1->isPhoton()) {
214 std::vector<reco::PUSubMETCandInfo>& iLeptons,
215 std::vector<reco::PUSubMETCandInfo>& iCands) {
216 std::vector<reco::PUSubMETCandInfo> retVal;
217 for (reco::PFJetCollection::const_iterator uncorrJet = uncorrJets.begin(); uncorrJet != uncorrJets.end();
221 auto corrJet = corrJets->begin();
222 for (
size_t cjIdx = 0; cjIdx < corrJets->size(); ++cjIdx, ++corrJet) {
226 if (uncorrJet->jetArea() != corrJet->jetArea())
241 jetInfo.
setP4(corrJet->p4());
242 double lType1Corr = 0;
244 double pCorr = iCorrector.
correction(*uncorrJet);
245 lType1Corr =
std::abs(corrJet->pt() - pCorr * uncorrJet->pt());
247 pVec.SetPtEtaPhiM(lType1Corr, 0, corrJet->phi(), 0);
249 pType1Corr.SetCoordinates(pVec.Px(), pVec.Py(), pVec.Pz(), pVec.E());
251 bool pOnLepton =
false;
252 for (
unsigned int i0 = 0; i0 < iLeptons.size(); i0++) {
259 if (corrJet->pt() > 10 && !pOnLepton) {
261 pfCandidateInfo.
setP4(pType1Corr);
262 pfCandidateInfo.
setDZ(-999);
263 iCands.push_back(pfCandidateInfo);
266 lType1Corr = (pCorr * uncorrJet->pt() - uncorrJet->pt());
267 lType1Corr /= corrJet->pt();
275 float chEnF = (uncorrJet->chargedEmEnergy() + uncorrJet->chargedHadronEnergy() + uncorrJet->chargedMuEnergy()) /
280 retVal.push_back(jetInfo);
286 std::sort(retVal.begin(), retVal.end());
293 std::vector<reco::PUSubMETCandInfo> retVal;
298 if (hardScatterVertex) {
300 if (pfc !=
nullptr) {
315 pfCandidateInfo.
setP4(pfCandidate->p4());
316 pfCandidateInfo.
setDZ(dZ);
317 retVal.push_back(pfCandidateInfo);
323 std::vector<reco::Vertex::Point> retVal;
324 for (reco::VertexCollection::const_iterator vertex = vertices.begin(); vertex != vertices.end(); ++vertex) {
327 if (vertex->ndof() < 4.)
329 if (vertex->position().Rho() > 2.)
331 retVal.push_back(vertex->position());
348 double lPtCharged = 0;
351 if (lPFTau !=
nullptr) {
352 for (UInt_t i0 = 0; i0 < lPFTau->
signalCands().size(); i0++) {
359 const pat::Tau* lPatPFTau =
nullptr;
360 lPatPFTau =
dynamic_cast<const pat::Tau*
>(iCand);
361 if (lPatPFTau !=
nullptr) {
372 return lPtCharged / lPtTot;
406 double iDR2Max = iDRMax * iDRMax;
410 if (
deltaR2(iCand->
p4(), pfCandidate->p4()) > iDR2Max)
414 if (hardScatterVertex) {
416 if (pfc !=
nullptr) {
428 lVis += pfCandidate->p4();
430 return lVis.pt() / iCand->
pt();
virtual float dz(size_t ipv=0) const
dz with respect to the PV[ipv]
PFMETAlgorithmMVA mvaMEtAlgo_
EventNumber_t event() const
SpecificPFMETData run(const edm::View< reco::Candidate > &pfCands, edm::ValueMap< float > const *weights=nullptr)
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
std::vector< edm::EDGetTokenT< reco::CandidateView > > srcLeptons_
bool isNonnull() const
Checks for non-null.
size_type size() const
Size of the RefVector.
PFMETProducerMVA(const edm::ParameterSet &)
void produce(edm::Event &, const edm::EventSetup &) override
float chargedEmEnergy() const
chargedEmEnergy
double pt() const final
transverse momentum
PFSpecificAlgo pfMEtSpecificAlgo_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
virtual double pt() const =0
transverse momentum
#define DEFINE_FWK_MODULE(type)
std::vector< reco::Vertex::Point > computeVertexInfo(const reco::VertexCollection &)
void setSignificanceMatrix(const reco::METCovMatrix &matrix)
void setP4(const reco::Candidate::LorentzVector p4)
bool exists(std::string const ¶meterName) const
checks if a parameter exists
edm::LuminosityBlockNumber_t luminosityBlock() const
void setMvaVal(float mva)
std::vector< Vertex > VertexCollection
collection of Vertex objects
double correction(const LorentzVector &fJet) const
get correction using Jet information only
reco::CandidatePtrVector signalCands() const
bool mvaMEtAlgo_isInitialized_
int chargedMultiplicity() const
chargedMultiplicity
const Point & position() const
position
Jets made from PFObjects.
double chargedFracInCone(const reco::Candidate *iCand, const reco::CandidateView &pfCandidates, const reco::Vertex *hardScatterVertex, double iDRMax=0.2)
float neutralEmEnergy() const
neutralEmEnergy
edm::EDGetTokenT< edm::ValueMap< float > > srcJetIds_
reco::TrackRef trackRef() const
virtual bool isPhoton() const =0
double px() const final
x coordinate of momentum vector
bool istau(const reco::Candidate *iCand)
const_iterator begin() const
edm::EDGetTokenT< edm::View< reco::Candidate > > srcPFCandidatesView_
bool passPFLooseId(const reco::PFJet *iJet)
edm::EDGetTokenT< reco::PFJetCollection > srcCorrJets_
std::vector< edm::InputTag > vInputTag
Abs< T >::type abs(const T &t)
edm::EDGetTokenT< reco::VertexCollection > srcVertices_
std::vector< reco::PUSubMETCandInfo > computeLeptonInfo(const std::vector< edm::EDGetTokenT< reco::CandidateView > > &srcLeptons_, const reco::CandidateView &pfCandidates, const reco::Vertex *hardScatterVertex, int &lId, bool &lHasPhotons, edm::Event &iEvent)
Structure containing data common to all types of MET.
double py() const final
y coordinate of momentum vector
MET made from Particle Flow Candidates.
Analysis-level tau class.
constexpr auto deltaR2(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
void setChargedEnFrac(float chEnF)
virtual bool isMuon() const =0
edm::EDGetTokenT< reco::JetCorrector > mJetCorrector_
std::vector< reco::PUSubMETCandInfo > computeJetInfo(const reco::PFJetCollection &, const edm::Handle< reco::PFJetCollection > &, const edm::ValueMap< float > &, const reco::VertexCollection &, const reco::Vertex *, const reco::JetCorrector &iCorr, edm::Event &iEvent, const edm::EventSetup &iSetup, std::vector< reco::PUSubMETCandInfo > &iLeptons, std::vector< reco::PUSubMETCandInfo > &iCands)
T getParameter(std::string const &) const
math::XYZTLorentzVector LorentzVector
Lorentz vector.
std::vector< PFJet > PFJetCollection
collection of PFJet objects
Particle reconstructed by the particle flow algorithm.
virtual int nConstituents() const
of constituents
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
reco::GsfTrackRef gsfTrackRef() const
float chargedEnFrac() const
~PFMETProducerMVA() override
double chargedEnFrac(const reco::Candidate *iCand, const reco::CandidateView &pfCandidates, const reco::Vertex *hardScatterVertex)
float neutralHadronEnergy() const
neutralHadronEnergy
math::XYZPoint Point
point in the space
const_iterator end() const
edm::EDGetTokenT< reco::PFJetCollection > srcUncorrJets_
const std::vector< reco::CandidatePtr > & signalCands() const
Candidates in signal region.
virtual bool isElectron() const =0
double phi() const final
momentum azimuthal angle
void setP4(const LorentzVector &p4) final
set 4-momentum
float chargedHadronEnergy() const
chargedHadronEnergy
const reco::Candidate::LorentzVector & p4() const
std::vector< reco::PUSubMETCandInfo > computePFCandidateInfo(const reco::CandidateView &, const reco::Vertex *)
virtual const LorentzVector & p4() const =0
four-momentum Lorentz vector
double energy() const final
energy
double eta() const final
momentum pseudorapidity