11 mvaMEtAlgo_isInitialized_(
false)
19 for(vInputTag::const_iterator it=srcLeptonsTags.begin();it!=srcLeptonsTags.end();it++) {
20 srcLeptons_.push_back( consumes<reco::CandidateView >( *it ) );
33 produces<reco::PFMETCollection>();
44 srcLeptons_i !=
srcLeptons_.end(); ++srcLeptons_i ) {
47 numLeptons += leptons->
size();
51 <<
"<PFMETProducerMVA::produce>:" << std::endl
53 <<
" numLeptons = " << numLeptons <<
", minNumLeptons = " <<
minNumLeptons_ <<
" --> skipping !!" << std::endl;
56 auto pfMEtCollection = std::make_unique<reco::PFMETCollection>();
57 pfMEtCollection->push_back(pfMEt);
88 const reco::Vertex* hardScatterVertex = ( !vertices->empty() ) ?
89 &(vertices->front()) :
nullptr;
94 bool lHasPhotons =
false;
115 std::vector<reco::PUSubMETCandInfo> pfCandidateInfo =
computePFCandidateInfo(*pfCandidates_view, hardScatterVertex);
116 std::vector<reco::PUSubMETCandInfo> jetInfo =
computeJetInfo(*uncorrJets, corrJets, *jetIds, *vertices, hardScatterVertex, *corrector,evt,es,leptonInfo,pfCandidateInfo);
127 <<
" PFMET: Pt = " << pfMEtP4_original.pt() <<
", phi = " << pfMEtP4_original.phi() <<
" " 128 <<
"(Px = " << pfMEtP4_original.px() <<
", Py = " << pfMEtP4_original.py() <<
")" << std::endl
129 <<
" MVA MET: Pt = " << pfMEt.
pt() <<
" phi = " << pfMEt.
phi() <<
" (Px = " << pfMEt.
px() <<
", Py = " << pfMEt.
py() <<
")" << std::endl
130 <<
" Cov:" << std::endl
135 auto pfMEtCollection = std::make_unique<reco::PFMETCollection>();
136 pfMEtCollection->push_back(pfMEt);
140 std::vector<reco::PUSubMETCandInfo>
144 int& lId,
bool& lHasPhotons,
edm::Event& evt ) {
146 std::vector<reco::PUSubMETCandInfo>
leptonInfo;
149 srcLeptons_i !=
srcLeptons_.end(); ++srcLeptons_i ) {
153 lepton1 != leptons->
end(); ++lepton1 ) {
156 srcLeptons_j !=
srcLeptons_.end(); ++srcLeptons_j ) {
160 lepton2 != leptons2->
end(); ++lepton2 ) {
161 if(&(*lepton1) == &(*lepton2)) {
continue; }
162 if(
deltaR2(lepton1->p4(),lepton2->p4()) <
dR2Max) { pMatch =
true; }
163 if(pMatch && !
istau(&(*lepton1)) &&
istau(&(*lepton2))) { pMatch =
false; }
164 if(pMatch && ( (
istau(&(*lepton1)) &&
istau(&(*lepton2))) || (!
istau(&(*lepton1)) && !
istau(&(*lepton2))))
165 && lepton1->pt() > lepton2->pt()) { pMatch =
false; }
166 if(pMatch && lepton1->pt() == lepton2->pt()) {
168 for(
unsigned int i0 = 0; i0 < leptonInfo.size(); i0++) {
169 if(
std::abs(lepton1->pt() - leptonInfo[i0].p4().pt()) <
dPtMatch) { pMatch =
true;
break; }
178 pLeptonInfo.
setP4( lepton1->p4() );
180 leptonInfo.push_back(pLeptonInfo);
181 if(lepton1->isPhoton()) { lHasPhotons =
true; }
190 std::vector<reco::PUSubMETCandInfo>
197 std::vector<reco::PUSubMETCandInfo> &iLeptons,std::vector<reco::PUSubMETCandInfo> &iCands)
199 std::vector<reco::PUSubMETCandInfo> retVal;
200 for ( reco::PFJetCollection::const_iterator uncorrJet = uncorrJets.begin();
201 uncorrJet != uncorrJets.end(); ++uncorrJet ) {
204 auto corrJet = corrJets->begin();
205 for(
size_t cjIdx=0;cjIdx<corrJets->size();++cjIdx, ++corrJet) {
209 if ( uncorrJet->jetArea() != corrJet->jetArea() )
continue;
210 if (
deltaR2(corrJet->p4(),uncorrJet->p4()) >
dR2Min )
continue;
221 jetInfo.
setP4( corrJet->p4() );
222 double lType1Corr = 0;
224 double pCorr = iCorrector.
correction(*uncorrJet);
225 lType1Corr =
std::abs(corrJet->pt()-pCorr*uncorrJet->pt());
226 TLorentzVector pVec; pVec.SetPtEtaPhiM(lType1Corr,0,corrJet->phi(),0);
229 bool pOnLepton =
false;
230 for(
unsigned int i0 = 0; i0 < iLeptons.size(); i0++) {
231 if(
deltaR2(iLeptons[i0].
p4(),corrJet->p4()) <
dR2Max) {pOnLepton =
true;
break;}
234 if(corrJet->pt() > 10 && !pOnLepton) {
236 pfCandidateInfo.
setP4( pType1Corr );
237 pfCandidateInfo.
setDZ( -999 );
238 iCands.push_back(pfCandidateInfo);
241 lType1Corr = (pCorr*uncorrJet->pt()-uncorrJet->pt());
242 lType1Corr /=corrJet->pt();
249 jetInfo.
setMvaVal( jetIds[ corrJetRef ] );
250 float chEnF = (uncorrJet->chargedEmEnergy() + uncorrJet->chargedHadronEnergy() + uncorrJet->chargedMuEnergy() )/uncorrJet->energy();
253 retVal.push_back(jetInfo);
259 std::sort( retVal.begin(), retVal.end() );
267 std::vector<reco::PUSubMETCandInfo> retVal;
269 pfCandidate != pfCandidates.
end(); ++pfCandidate ) {
272 if ( hardScatterVertex ) {
274 if( pfc !=
nullptr ) {
286 pfCandidateInfo.
setP4( pfCandidate->p4() );
287 pfCandidateInfo.
setDZ( dZ );
288 retVal.push_back(pfCandidateInfo);
295 std::vector<reco::Vertex::Point> retVal;
296 for ( reco::VertexCollection::const_iterator vertex = vertices.begin();
297 vertex != vertices.end(); ++vertex ) {
298 if(
std::abs(vertex->z()) > 24.)
continue;
299 if(vertex->ndof() < 4.)
continue;
300 if(vertex->position().Rho() > 2.)
continue;
301 retVal.push_back(vertex->position());
314 double lPtTot = 0;
double lPtCharged = 0;
317 if(lPFTau !=
nullptr) {
318 for (UInt_t i0 = 0; i0 < lPFTau->
signalCands().size(); i0++) {
325 const pat::Tau *lPatPFTau =
nullptr;
326 lPatPFTau =
dynamic_cast<const pat::Tau*
>(iCand);
327 if(lPatPFTau !=
nullptr) {
335 if(lPtTot == 0) lPtTot = 1.;
336 return lPtCharged/lPtTot;
340 if(iCand->
isMuon())
return false;
346 if(iJet->
energy()== 0)
return false;
360 double iDR2Max = iDRMax*iDRMax;
363 pfCandidate != pfCandidates.
end(); ++pfCandidate ) {
364 if(
deltaR2(iCand->
p4(),pfCandidate->p4()) > iDR2Max)
continue;
367 if ( hardScatterVertex ) {
369 if( pfc !=
nullptr ) {
379 lVis += pfCandidate->p4();
381 return lVis.pt()/iCand->
pt();
virtual float dz(size_t ipv=0) const
dz with respect to the PV[ipv]
PFMETAlgorithmMVA mvaMEtAlgo_
T getParameter(std::string const &) const
EventNumber_t event() const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
bool isNonnull() const
Checks for non-null.
size_type size() const
Size of the RefVector.
double eta() const final
momentum pseudorapidity
PFMETProducerMVA(const edm::ParameterSet &)
void produce(edm::Event &, const edm::EventSetup &) override
float chargedEmEnergy() const
chargedEmEnergy
std::vector< edm::EDGetTokenT< reco::CandidateView > > srcLeptons_
PFSpecificAlgo pfMEtSpecificAlgo_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
virtual bool isMuon() const =0
std::vector< reco::Vertex::Point > computeVertexInfo(const reco::VertexCollection &)
virtual bool isPhoton() const =0
double px() const final
x coordinate of momentum vector
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)
double pt() const final
transverse momentum
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
bool istau(const reco::Candidate *iCand)
#define DEFINE_FWK_MODULE(type)
const_iterator begin() const
edm::EDGetTokenT< edm::View< reco::Candidate > > srcPFCandidatesView_
bool passPFLooseId(const reco::PFJet *iJet)
virtual const LorentzVector & p4() const =0
four-momentum Lorentz vector
edm::EDGetTokenT< reco::PFJetCollection > srcCorrJets_
std::vector< edm::InputTag > vInputTag
double energy() const final
energy
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)
const LorentzVector & p4() const final
four-momentum Lorentz vector
Structure containing data common to all types of MET.
virtual bool isElectron() const =0
MET made from Particle Flow Candidates.
Analysis-level tau class.
SpecificPFMETData run(const edm::View< reco::Candidate > &pfCands)
constexpr auto deltaR2(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
void setChargedEnFrac(float chEnF)
edm::EDGetTokenT< reco::JetCorrector > mJetCorrector_
virtual double pt() const =0
transverse momentum
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)
double py() const final
y coordinate of momentum vector
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.
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 *)