24 #include "TLorentzVector.h"
42 std::ostringstream os;
47 for (
unsigned iEntry = 0; iEntry <
numEntries; ++iEntry ) {
49 if ( iEntry < (numEntries - 1) ) os <<
", ";
61 mvaMEtAlgo_isInitialized_(
false),
70 for(vInputTag::const_iterator it=srcLeptonsTags.begin();it!=srcLeptonsTags.end();it++) {
89 <<
"<PFMETProducerMVA::PFMETProducerMVA>:" << std::endl;
97 produces<reco::PFMETCollection>();
108 srcLeptons_i !=
srcLeptons_.end(); ++srcLeptons_i ) {
111 numLeptons += leptons->size();
115 <<
"<PFMETProducerMVA::produce>:" << std::endl
117 <<
" numLeptons = " << numLeptons <<
", minNumLeptons = " <<
minNumLeptons_ <<
" --> skipping !!" << std::endl;
121 pfMEtCollection->push_back(pfMEt);
122 evt.
put(pfMEtCollection);
149 const reco::Vertex* hardScatterVertex = ( vertices->size() >= 1 ) ?
150 &(vertices->front()) : 0;
155 bool lHasPhotons =
false;
156 std::vector<mvaMEtUtilities::leptonInfo> leptonInfo;
158 srcLeptons_i !=
srcLeptons_.end(); ++srcLeptons_i ) {
162 lepton1 != leptons->end(); ++lepton1 ) {
165 srcLeptons_j !=
srcLeptons_.end(); ++srcLeptons_j ) {
169 lepton2 != leptons2->end(); ++lepton2 ) {
170 if(&(*lepton1) == &(*lepton2)) {
continue; }
171 if(
deltaR2(lepton1->p4(),lepton2->p4()) <
dR2Max) { pMatch =
true; }
172 if(pMatch && !
istau(&(*lepton1)) &&
istau(&(*lepton2))) { pMatch =
false; }
173 if(pMatch && ( (
istau(&(*lepton1)) &&
istau(&(*lepton2))) || (!
istau(&(*lepton1)) && !
istau(&(*lepton2))))
174 && lepton1->pt() > lepton2->pt()) { pMatch =
false; }
175 if(pMatch && lepton1->pt() == lepton2->pt()) {
177 for(
unsigned int i0 = 0; i0 < leptonInfo.size(); i0++) {
178 if(
std::abs(lepton1->pt() - leptonInfo[i0].p4_.pt()) <
dPtMatch) { pMatch =
true;
break; }
187 pLeptonInfo.
p4_ = lepton1->p4();
189 leptonInfo.push_back(pLeptonInfo);
190 if(lepton1->isPhoton()) { lHasPhotons =
true; }
223 std::vector<mvaMEtUtilities::pfCandInfo> pfCandidateInfo =
computePFCandidateInfo(*pfCandidates, hardScatterVertex);
224 std::vector<mvaMEtUtilities::JetInfo> jetInfo =
computeJetInfo(*uncorrJets, *corrJets, *vertices, hardScatterVertex, *corrector,evt,es,leptonInfo,pfCandidateInfo);
236 <<
"<PFMETProducerMVA::produce>:" << std::endl
238 <<
" PFMET: Pt = " << pfMEtP4_original.pt() <<
", phi = " << pfMEtP4_original.phi() <<
" "
239 <<
"(Px = " << pfMEtP4_original.px() <<
", Py = " << pfMEtP4_original.py() <<
")" << std::endl
240 <<
" MVA MET: Pt = " << pfMEt.
pt() <<
" phi = " << pfMEt.
phi() <<
" (Px = " << pfMEt.
px() <<
", Py = " << pfMEt.
py() <<
")" << std::endl
241 <<
" Cov:" << std::endl
248 pfMEtCollection->push_back(pfMEt);
249 evt.
put(pfMEtCollection);
257 std::vector<mvaMEtUtilities::leptonInfo> &iLeptons,std::vector<mvaMEtUtilities::pfCandInfo> &iCands)
261 std::vector<mvaMEtUtilities::JetInfo> retVal;
262 for ( reco::PFJetCollection::const_iterator uncorrJet = uncorrJets.begin();
263 uncorrJet != uncorrJets.end(); ++uncorrJet ) {
266 for ( reco::PFJetCollection::const_iterator corrJet = corrJets.begin();
267 corrJet != corrJets.end(); ++corrJet ) {
269 if ( uncorrJet->jetArea() != corrJet->jetArea() )
continue;
270 if (
deltaR2(corrJet->p4(),uncorrJet->p4()) >
dR2Min )
continue;
279 double jetEnCorrFactor = corrJet->pt()/uncorrJet->pt();
283 jetInfo.
p4_ = corrJet->p4();
284 double lType1Corr = 0;
286 double pCorr = lCorrector->
correction(*uncorrJet,iEvent,iSetup);
287 lType1Corr = (corrJet->pt()-pCorr*uncorrJet->pt());
288 TLorentzVector pVec; pVec.SetPtEtaPhiM(lType1Corr,0,corrJet->phi(),0);
291 bool pOnLepton =
false;
292 for(
unsigned int i0 = 0; i0 < iLeptons.size(); i0++)
if(
deltaR2(iLeptons[i0].p4_,corrJet->p4()) <
dR2Max) {pOnLepton =
true;
break;}
294 if(corrJet->pt() > 10 && !pOnLepton) {
296 pfCandidateInfo.
p4_ = pType1Corr;
297 pfCandidateInfo.
dZ_ = -999;
298 iCands.push_back(pfCandidateInfo);
301 lType1Corr = (pCorr*uncorrJet->pt()-uncorrJet->pt());
302 lType1Corr /=corrJet->pt();
308 jetInfo.
neutralEnFrac_ = (uncorrJet->neutralEmEnergy() + uncorrJet->neutralHadronEnergy())/uncorrJet->energy();
310 retVal.push_back(jetInfo);
320 std::vector<mvaMEtUtilities::pfCandInfo> retVal;
321 for ( reco::PFCandidateCollection::const_iterator pfCandidate = pfCandidates.begin();
322 pfCandidate != pfCandidates.end(); ++pfCandidate ) {
325 if ( hardScatterVertex ) {
326 if ( pfCandidate->trackRef().isNonnull() ) dZ =
std::abs(pfCandidate->trackRef()->dz(hardScatterVertex->
position()));
327 else if ( pfCandidate->gsfTrackRef().isNonnull() ) dZ =
std::abs(pfCandidate->gsfTrackRef()->dz(hardScatterVertex->
position()));
330 pfCandidateInfo.
p4_ = pfCandidate->p4();
331 pfCandidateInfo.
dZ_ = dZ;
332 retVal.push_back(pfCandidateInfo);
339 std::vector<reco::Vertex::Point> retVal;
340 for ( reco::VertexCollection::const_iterator vertex = vertices.begin();
341 vertex != vertices.end(); ++vertex ) {
342 if(
std::abs(vertex->z()) > 24.)
continue;
343 if(vertex->ndof() < 4.)
continue;
344 if(vertex->position().Rho() > 2.)
continue;
345 retVal.push_back(vertex->position());
358 double lPtTot = 0;
double lPtCharged = 0;
362 for (UInt_t i0 = 0; i0 < lPFTau->
signalPFCands().size(); i0++) {
369 const pat::Tau *lPatPFTau =
nullptr;
370 lPatPFTau =
dynamic_cast<const pat::Tau*
>(iCand);
371 if(lPatPFTau !=
nullptr) {
372 for (UInt_t i0 = 0; i0 < lPatPFTau->
signalPFCands().size(); i0++) {
374 if((lPatPFTau->
signalPFCands())[i0]->charge() == 0)
continue;
379 if(lPtTot == 0) lPtTot = 1.;
380 return lPtCharged/lPtTot;
384 if(iCand->
isMuon())
return false;
390 if(iJet->
energy()== 0)
return false;
405 double iDR2Max = iDRMax*iDRMax;
407 for ( reco::PFCandidateCollection::const_iterator pfCandidate = pfCandidates.begin();
408 pfCandidate != pfCandidates.end(); ++pfCandidate ) {
409 if(
deltaR2(iCand->
p4(),pfCandidate->p4()) > iDR2Max)
continue;
412 if ( hardScatterVertex ) {
413 if ( pfCandidate->trackRef().isNonnull() ) dZ =
std::abs(pfCandidate->trackRef()->dz(hardScatterVertex->
position()));
414 else if ( pfCandidate->gsfTrackRef().isNonnull() ) dZ =
std::abs(pfCandidate->gsfTrackRef()->dz(hardScatterVertex->
position()));
417 lVis += pfCandidate->p4();
419 return lVis.pt()/iCand->
pt();
PFMETAlgorithmMVA mvaMEtAlgo_
T getParameter(std::string const &) const
EventNumber_t event() const
virtual double correction(const LorentzVector &fJet) const
apply correction using Jet information only
PFMETProducerMVA(const edm::ParameterSet &)
float chargedEmEnergy() const
chargedEmEnergy
virtual float pt() const
transverse momentum
PFSpecificAlgo pfMEtSpecificAlgo_
void produce(edm::Event &, const edm::EventSetup &)
std::string correctorLabel_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
const float & mva() const
#define DEFINE_FWK_MODULE(type)
virtual float phi() const
momentum azimuthal angle
std::vector< reco::Vertex::Point > computeVertexInfo(const reco::VertexCollection &)
PileupJetIdAlgo mvaJetIdAlgo_
void setSignificanceMatrix(const reco::METCovMatrix &matrix)
bool exists(std::string const ¶meterName) const
checks if a parameter exists
edm::LuminosityBlockNumber_t luminosityBlock() const
virtual void setP4(const LorentzVector &p4)
set 4-momentum
std::vector< Vertex > VertexCollection
collection of Vertex objects
edm::EDGetTokenT< reco::PFCandidateCollection > srcPFCandidates_
bool mvaMEtAlgo_isInitialized_
int chargedMultiplicity() const
chargedMultiplicity
const Point & position() const
position
const std::vector< reco::PFCandidatePtr > & signalPFCands() const
PFCandidates in signal region.
Jets made from PFObjects.
float neutralEmEnergy() const
neutralEmEnergy
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
std::vector< PFCandidatePtr > pfCandidates(const PFJet &jet, int particleId, bool sort=true)
virtual bool isPhoton() const =0
const std::vector< reco::PFCandidatePtr > & signalPFCands() const
virtual double energy() const
energy
reco::Candidate::LorentzVector p4_
bool istau(const reco::Candidate *iCand)
virtual float pt() const =0
transverse momentum
reco::Candidate::LorentzVector p4_
edm::EDGetTokenT< edm::View< reco::Candidate > > srcPFCandidatesView_
std::vector< mvaMEtUtilities::pfCandInfo > computePFCandidateInfo(const reco::PFCandidateCollection &, const reco::Vertex *)
reco::Candidate::LorentzVector p4_
bool passPFLooseId(const reco::PFJet *iJet)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
edm::EDGetTokenT< reco::PFJetCollection > srcCorrJets_
std::vector< edm::InputTag > vInputTag
virtual float eta() const
momentum pseudorapidity
Long64_t numEntries(TFile *hdl, std::string const &trname)
Abs< T >::type abs(const T &t)
edm::EDGetTokenT< reco::VertexCollection > srcVertices_
double deltaR2(const T1 &t1, const T2 &t2)
Structure containing data common to all types of MET.
PileupJetIdentifier computeIdVariables(const reco::Jet *jet, float jec, const reco::Vertex *, const reco::VertexCollection &, bool calculateMva=false)
MET made from Particle Flow Candidates.
Analysis-level tau class.
SpecificPFMETData run(const edm::View< reco::Candidate > &pfCands)
double chargedFrac(const reco::Candidate *iCand, const reco::PFCandidateCollection &pfCandidates, const reco::Vertex *hardScatterVertex)
std::vector< reco::PFCandidate > PFCandidateCollection
collection of PFCandidates
virtual bool isMuon() const =0
double chargedFracInCone(const reco::Candidate *iCand, const reco::PFCandidateCollection &pfCandidates, const reco::Vertex *hardScatterVertex, double iDRMax=0.2)
virtual double px() const
x coordinate of momentum vector
static const JetCorrector * getJetCorrector(const std::string &fName, const edm::EventSetup &fSetup)
retrieve corrector from the event setup. troughs exception if something is missing ...
edm::EDGetTokenT< edm::Handle< double > > srcRho_
math::XYZTLorentzVector LorentzVector
Lorentz vector.
std::vector< PFJet > PFJetCollection
collection of PFJet objects
virtual int nConstituents() const
of constituents
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
std::vector< reco::PFMET > PFMETCollection
collection of PFMET objects
float neutralHadronEnergy() const
neutralHadronEnergy
math::XYZPoint Point
point in the space
volatile std::atomic< bool > shutdown_flag false
std::vector< edm::EDGetTokenT< edm::View< reco::Candidate > > > srcLeptons_
edm::EDGetTokenT< reco::PFJetCollection > srcUncorrJets_
virtual bool isElectron() const =0
virtual const LorentzVector & p4() const
four-momentum Lorentz vector
std::vector< mvaMEtUtilities::JetInfo > computeJetInfo(const reco::PFJetCollection &, const reco::PFJetCollection &, const reco::VertexCollection &, const reco::Vertex *, const JetCorrector &iCorr, edm::Event &iEvent, const edm::EventSetup &iSetup, std::vector< mvaMEtUtilities::leptonInfo > &iLeptons, std::vector< mvaMEtUtilities::pfCandInfo > &iCands)
float chargedHadronEnergy() const
chargedHadronEnergy
virtual double py() const
y coordinate of momentum vector
virtual const LorentzVector & p4() const =0
four-momentum Lorentz vector