Skip to content

Commit

Permalink
Merge pull request cms-sw#29748 from cms-sw/revert-29254-puppiNoLep_w…
Browse files Browse the repository at this point in the history
…eight_in_aod

Revert "PUPPI MET in RECO"
  • Loading branch information
cmsbuild authored May 6, 2020
2 parents b8caa0a + 0c912b0 commit 8c0e2bf
Show file tree
Hide file tree
Showing 65 changed files with 326 additions and 510 deletions.
2 changes: 1 addition & 1 deletion CommonTools/ParticleFlow/plugins/Type1PFMET.cc
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ void Type1PFMET::run(const METCollection& uncorMET,
std::vector<CorrMETData> corrections = u->mEtCorr();
corrections.push_back(delta);
//----------------- Push onto MET Collection
MET result = MET(u->sumEt() + delta.sumet, corrections, correctedMET4vector, u->vertex(), u->isWeighted());
MET result = MET(u->sumEt() + delta.sumet, corrections, correctedMET4vector, u->vertex());
corMET->push_back(result);

return;
Expand Down
2 changes: 1 addition & 1 deletion CommonTools/ParticleFlow/python/EITopPAG_cff.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@


#### MET ####
pfMetEI = pfMET.clone(srcJets=cms.InputTag("pfJetsEI"))
pfMetEI = pfMET.clone(jets=cms.InputTag("pfJetsEI"))

#EITopPAG = cms.Sequence(
EIsequence = cms.Sequence(
Expand Down
2 changes: 1 addition & 1 deletion CommonTools/ParticleFlow/python/PFBRECO_cff.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
from CommonTools.ParticleFlow.pfTaus_cff import *

from CommonTools.ParticleFlow.pfMET_cfi import *
pfMETPFBRECO = pfMET.clone( srcJets = 'pfJetsPFBRECO' )
pfMETPFBRECO = pfMET.clone( jets = 'pfJetsPFBRECO' )

##delta beta weighting
#from CommonTools.ParticleFlow.deltaBetaWeights_cfi import *
Expand Down
4 changes: 2 additions & 2 deletions CommonTools/ParticleFlow/python/pfMET_cfi.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import FWCore.ParameterSet.Config as cms

# Clone pfMET producer from RecoMET
from RecoMET.METProducers.pfMet_cfi import *
from RecoMET.METProducers.PFMET_cfi import *

# Should the name be changed se it is similar to pfMet from reco ??
pfMET = pfMet.clone(alias="pfMET")

# Use PF2PAT cleaned jet collection (pfJets) for MET significance
# instead of standard collection (ak4PFJets)?
# It requires that MET is produced at the end.
pfMET.srcJets = cms.InputTag("pfJets")
pfMET.jets = cms.InputTag("pfJets")

# print 'PF2PAT: Jet collection used for pfMET significance: ', pfMET.jets
19 changes: 8 additions & 11 deletions CommonTools/PileupAlgos/plugins/PuppiProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
// ------------------------------------------------------------------------------------------
PuppiProducer::PuppiProducer(const edm::ParameterSet& iConfig) {
fPuppiDiagnostics = iConfig.getParameter<bool>("puppiDiagnostics");
fPuppiNoLep = iConfig.getParameter<bool>("puppiNoLep");
fPuppiForLeptons = iConfig.getParameter<bool>("puppiForLeptons");
fUseFromPVLooseTight = iConfig.getParameter<bool>("UseFromPVLooseTight");
fUseDZ = iConfig.getParameter<bool>("UseDeltaZCut");
fDZCut = iConfig.getParameter<double>("DeltaZCut");
Expand All @@ -32,6 +32,7 @@ PuppiProducer::PuppiProducer(const edm::ParameterSet& iConfig) {
fPtMaxPhotons = iConfig.getParameter<double>("PtMaxPhotons");
fEtaMaxPhotons = iConfig.getParameter<double>("EtaMaxPhotons");
fUseExistingWeights = iConfig.getParameter<bool>("useExistingWeights");
fUseWeightsNoLep = iConfig.getParameter<bool>("useWeightsNoLep");
fClonePackedCands = iConfig.getParameter<bool>("clonePackedCands");
fVtxNdofCut = iConfig.getParameter<int>("vtxNdofCut");
fVtxZCut = iConfig.getParameter<double>("vtxZCut");
Expand Down Expand Up @@ -98,7 +99,6 @@ void PuppiProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) {
double pD0 = -9999;
int pVtxId = -9999;
bool lFirst = true;
bool isLepton = ((std::abs(pReco.pdgId) == 11) || (std::abs(pReco.pdgId) == 13));
const pat::PackedCandidate* lPack = dynamic_cast<const pat::PackedCandidate*>(&aPF);
if (lPack == nullptr) {
const reco::PFCandidate* pPF = dynamic_cast<const reco::PFCandidate*>(&aPF);
Expand Down Expand Up @@ -152,9 +152,7 @@ void PuppiProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) {
if (std::abs(pReco.charge) == 0) {
pReco.id = 0;
} else {
if (fPuppiNoLep && isLepton)
pReco.id = 3;
else if (tmpFromPV == 0) {
if (tmpFromPV == 0) {
pReco.id = 2;
} // 0 is associated to PU vertex
else if (tmpFromPV == 3) {
Expand Down Expand Up @@ -184,9 +182,7 @@ void PuppiProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) {
pReco.id = 0;
}
if (std::abs(pReco.charge) > 0) {
if (fPuppiNoLep && isLepton)
pReco.id = 3;
else if (lPack->fromPV() == 0) {
if (lPack->fromPV() == 0) {
pReco.id = 2;
} // 0 is associated to PU vertex
else if (lPack->fromPV() == (pat::PackedCandidate::PVUsedInFit)) {
Expand Down Expand Up @@ -227,7 +223,7 @@ void PuppiProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) {
throw edm::Exception(edm::errors::LogicError,
"PuppiProducer: cannot get weights since inputs are not PackedCandidates");
} else {
if (fPuppiNoLep) {
if (fUseWeightsNoLep) {
curpupweight = lPack->puppiWeightNoLep();
} else {
curpupweight = lPack->puppiWeight();
Expand Down Expand Up @@ -283,7 +279,7 @@ void PuppiProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) {

// Here, we are using new weights computed and putting them in the packed candidates.
if (fClonePackedCands && (!fUseExistingWeights)) {
if (fPuppiNoLep)
if (fPuppiForLeptons)
pCand->setPuppiWeight(pCand->puppiWeight(), lWeights[iCand]);
else
pCand->setPuppiWeight(lWeights[iCand], pCand->puppiWeightNoLep());
Expand Down Expand Up @@ -361,7 +357,7 @@ void PuppiProducer::endJob() {}
void PuppiProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
edm::ParameterSetDescription desc;
desc.add<bool>("puppiDiagnostics", false);
desc.add<bool>("puppiNoLep", false);
desc.add<bool>("puppiForLeptons", false);
desc.add<bool>("UseFromPVLooseTight", false);
desc.add<bool>("UseDeltaZCut", true);
desc.add<double>("DeltaZCut", 0.3);
Expand All @@ -372,6 +368,7 @@ void PuppiProducer::fillDescriptions(edm::ConfigurationDescriptions& description
desc.add<double>("PtMaxNeutrals", 200.);
desc.add<double>("PtMaxNeutralsStartSlope", 0.);
desc.add<bool>("useExistingWeights", false);
desc.add<bool>("useWeightsNoLep", false);
desc.add<bool>("clonePackedCands", false);
desc.add<int>("vtxNdofCut", 4);
desc.add<double>("vtxZCut", 24);
Expand Down
3 changes: 2 additions & 1 deletion CommonTools/PileupAlgos/plugins/PuppiProducer.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class PuppiProducer : public edm::stream::EDProducer<> {
std::string fPFName;
std::string fPVName;
bool fPuppiDiagnostics;
bool fPuppiNoLep;
bool fPuppiForLeptons;
bool fUseFromPVLooseTight;
bool fUseDZ;
float fDZCut;
Expand All @@ -68,6 +68,7 @@ class PuppiProducer : public edm::stream::EDProducer<> {
double fPtMaxPhotons;
double fEtaMaxPhotons;
bool fUseExistingWeights;
bool fUseWeightsNoLep;
bool fClonePackedCands;
int fVtxNdofCut;
double fVtxZCut;
Expand Down
10 changes: 3 additions & 7 deletions CommonTools/PileupAlgos/python/Puppi_cff.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

puppi = cms.EDProducer("PuppiProducer",#cms.PSet(#"PuppiProducer",
puppiDiagnostics = cms.bool(False),
puppiNoLep = cms.bool(False),
puppiForLeptons = cms.bool(False),
UseFromPVLooseTight = cms.bool(False),
UseDeltaZCut = cms.bool(True),
DeltaZCut = cms.double(0.3),
Expand All @@ -45,6 +45,7 @@
useExp = cms.bool (False),
MinPuppiWeight = cms.double(0.01),
useExistingWeights = cms.bool(False),
useWeightsNoLep = cms.bool(False),
clonePackedCands = cms.bool(False), # should only be set to True for MiniAOD
vtxNdofCut = cms.int32(4),
vtxZCut = cms.double(24),
Expand Down Expand Up @@ -86,7 +87,7 @@
# )
)
)

from Configuration.Eras.Modifier_phase2_common_cff import phase2_common
phase2_common.toModify(
puppi,
Expand Down Expand Up @@ -115,8 +116,3 @@
)
)
)

puppiNoLep = puppi.clone(
puppiNoLep = True,
PtMaxPhotons = 20.
)
2 changes: 1 addition & 1 deletion CommonTools/PileupAlgos/python/customizePuppiTune_cff.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def UpdatePuppiTuneV13(process):
process.puppi.useExistingWeights = False
process.puppiNoLep.useExistingWeights = False
from PhysicsTools.PatUtils.tools.runMETCorrectionsAndUncertainties import runMetCorAndUncFromMiniAOD
runMetCorAndUncFromMiniAOD(process,isData=False,metType="Puppi",postfix="Puppi",jetFlavor="AK4PFPuppi",recoMetFromPFCs=True)
runMetCorAndUncFromMiniAOD(process,isData=False,metType="Puppi",postfix="Puppi",jetFlavor="AK4PFPuppi",recoMetFromPFCs=True,pfCandColl=cms.InputTag("puppiForMET"))
from PhysicsTools.PatAlgos.patPuppiJetSpecificProducer_cfi import patPuppiJetSpecificProducer
addToProcessAndTask('patPuppiJetSpecificProducer', patPuppiJetSpecificProducer.clone(src=cms.InputTag("patJetsPuppi")), process, task)
from PhysicsTools.PatAlgos.tools.jetTools import updateJetCollection
Expand Down
5 changes: 0 additions & 5 deletions CommonTools/PileupAlgos/src/PuppiContainer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,6 @@ double PuppiContainer::var_within_R(int iId,
near_pts.reserve(std::min(50UL, particles.size()));
const double r2 = R * R;
for (auto const &part : particles) {
if (part.puppi_register() == 3)
continue;
//squared_distance is in (y,phi) coords: rap() has faster access -> check it first
if (std::abs(part.rap() - centre.rap()) < R && part.squared_distance(centre) < r2) {
near_dR2s.push_back(reco::deltaR2(part, centre));
Expand Down Expand Up @@ -298,9 +296,6 @@ std::vector<double> const &PuppiContainer::puppiWeights() {
pWeight = 1;
if (rParticle.id == 2 && fApplyCHS)
pWeight = 0;
//Apply weight of 1 for leptons if puppiNoLep
if (rParticle.id == 3)
pWeight = 1;
//Basic Weight Checks
if (!edm::isFinite(pWeight)) {
pWeight = 0.0;
Expand Down
14 changes: 11 additions & 3 deletions CommonTools/PileupAlgos/test/testPUMods.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:run2_mc', '')

process.load('CommonTools/PileupAlgos/Puppi_cff')
process.load('CommonTools/PileupAlgos/PhotonPuppi_cff')
from CommonTools.PileupAlgos.PhotonPuppi_cff import setupPuppiPhoton
from PhysicsTools.PatAlgos.slimming.puppiForMET_cff import makePuppiesFromMiniAOD

process.load('CommonTools/PileupAlgos/softKiller_cfi')
Expand All @@ -35,10 +37,16 @@


makePuppiesFromMiniAOD(process)

process.load('RecoMET.METProducers.pfMetPuppi_cfi')
#setupPuppiPhoton(process)
#process.packedPFCandidatesNoLep = cms.EDFilter("CandPtrSelector", src = cms.InputTag("packedPFCandidates"), cut = cms.string("abs(pdgId) != 13 && abs(pdgId) != 11"))
#process.puppiNoLep = process.puppi.clone()
#process.puppiNoLep.candName = cms.InputTag('packedPFCandidatesNoLep')
#process.puppiNoLep.vertexName = cms.InputTag('offlineSlimmedPrimaryVertices')

process.load('RecoMET.METProducers.PFMET_cfi')
process.pfMet.src = cms.InputTag('puppiForMET')
#process.puppiNoLep.useExistingWeights = True
process.puSequence = cms.Sequence(process.puppi*process.puppiNoLep*process.pfMetPuppi)
process.puSequence = cms.Sequence(process.pfNoLepPUPPI*process.puppi*process.puppiNoLep*process.egmPhotonIDSequence*process.puppiForMET*process.pfMet)
process.p = cms.Path(process.puSequence)
process.output = cms.OutputModule("PoolOutputModule",
outputCommands = cms.untracked.vstring('keep *'),
Expand Down
16 changes: 3 additions & 13 deletions DataFormats/METReco/interface/MET.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,9 @@ namespace reco {
class MET : public RecoCandidate {
public:
MET();
MET(const LorentzVector& p4_, const Point& vtx_, bool isWeighted = false);
MET(double sumet_, const LorentzVector& p4_, const Point& vtx_, bool isWeighted = false);
MET(double sumet_,
const std::vector<CorrMETData>& corr_,
const LorentzVector& p4_,
const Point& vtx_,
bool isWeighted = false);
MET(const LorentzVector& p4_, const Point& vtx_);
MET(double sumet_, const LorentzVector& p4_, const Point& vtx_);
MET(double sumet_, const std::vector<CorrMETData>& corr_, const LorentzVector& p4_, const Point& vtx_);

MET* clone() const override;

Expand All @@ -73,11 +69,6 @@ namespace reco {
void setSignificanceMatrix(const reco::METCovMatrix& matrix);
reco::METCovMatrix getSignificanceMatrix(void) const;

/// Set boolean if weights were applied by algorithm (e.g. PUPPI weights)
void setIsWeighted(bool isWeighted) { mIsWeighted = isWeighted; }
/// boolean if weights were applied by algorithm (e.g. PUPPI weights)
int isWeighted() const { return mIsWeighted; }

private:
bool overlap(const Candidate&) const override;
double sumet;
Expand All @@ -88,7 +79,6 @@ namespace reco {
double signif_dyx;
double signif_dxy;
std::vector<CorrMETData> corr;
bool mIsWeighted;
};
} // namespace reco

Expand Down
8 changes: 2 additions & 6 deletions DataFormats/METReco/interface/PFMET.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,8 @@ namespace reco {
class PFMET : public MET {
public:
PFMET();
PFMET(const SpecificPFMETData& pf_data_,
double sumet_,
const LorentzVector& fP4,
const Point& fVertex,
bool isWeighted = false)
: MET(sumet_, fP4, fVertex, isWeighted), pf_data(pf_data_) {}
PFMET(const SpecificPFMETData& pf_data_, double sumet_, const LorentzVector& fP4, const Point& fVertex)
: MET(sumet_, fP4, fVertex), pf_data(pf_data_) {}

~PFMET() override {}

Expand Down
11 changes: 3 additions & 8 deletions DataFormats/METReco/src/MET.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,42 +20,37 @@ MET::MET() {
sumet = 0.0;
elongit = 0.0;
signif_dxx = signif_dyy = signif_dyx = signif_dxy = 0.;
mIsWeighted = false;
}

// Constructer for the case when only p4_ = (mEx, mEy, 0, mEt) is known.
// The vertex information is currently not used (but may be in the future)
// and is required by the RecoCandidate constructer.
//____________________________________________________________________________||
MET::MET(const LorentzVector& p4_, const Point& vtx_, bool isWeighted) : RecoCandidate(0, p4_, vtx_) {
MET::MET(const LorentzVector& p4_, const Point& vtx_) : RecoCandidate(0, p4_, vtx_) {
sumet = 0.0;
elongit = 0.0;
signif_dxx = signif_dyy = signif_dyx = signif_dxy = 0.;
mIsWeighted = isWeighted;
}

// Constructer for the case when the SumET is known in addition to
// p4_ = (mEx, mEy, 0, mEt). The vertex information is currently not used
// (but see above).
//____________________________________________________________________________||
MET::MET(double sumet_, const LorentzVector& p4_, const Point& vtx_, bool isWeighted) : RecoCandidate(0, p4_, vtx_) {
MET::MET(double sumet_, const LorentzVector& p4_, const Point& vtx_) : RecoCandidate(0, p4_, vtx_) {
sumet = sumet_;
elongit = 0.0;
signif_dxx = signif_dyy = signif_dyx = signif_dxy = 0.;
mIsWeighted = isWeighted;
}

// Constructor for the case when the SumET, the corrections which
// were applied to the MET, as well the MET itself p4_ = (mEx, mEy, 0, mEt)
// are all known. See above concerning the vertex information.
//____________________________________________________________________________||
MET::MET(
double sumet_, const std::vector<CorrMETData>& corr_, const LorentzVector& p4_, const Point& vtx_, bool isWeighted)
MET::MET(double sumet_, const std::vector<CorrMETData>& corr_, const LorentzVector& p4_, const Point& vtx_)
: RecoCandidate(0, p4_, vtx_) {
sumet = sumet_;
elongit = 0.0;
signif_dxx = signif_dyy = signif_dyx = signif_dxy = 0.;
mIsWeighted = isWeighted;
//-----------------------------------
// Fill the vector containing the corrections (corr) with vector of
// known corrections (corr_) passed in via the constructor.
Expand Down
15 changes: 5 additions & 10 deletions DataFormats/METReco/src/classes_def.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@
<version ClassVersion="11" checksum="2260055190"/>
</class>

<class name="reco::MET" ClassVersion="13">
<version ClassVersion="13" checksum="3178745935"/>
<class name="reco::MET" ClassVersion="12">
<version ClassVersion="12" checksum="2052216433"/>
<version ClassVersion="11" checksum="1997832393"/>
<version ClassVersion="10" checksum="3898304931"/>
Expand All @@ -59,8 +58,7 @@
<class name="std::vector<edm::Ref<std::vector<reco::CaloMET>,reco::CaloMET,edm::refhelper::FindUsingAdvance<std::vector<reco::CaloMET>,reco::CaloMET> > >"/>
<class name="std::vector<edm::Ref<std::vector<reco::MET>,reco::MET,edm::refhelper::FindUsingAdvance<std::vector<reco::MET>,reco::MET> > >"/>

<class name="reco::CaloMET" ClassVersion="13">
<version ClassVersion="13" checksum="2658524417"/>
<class name="reco::CaloMET" ClassVersion="12">
<version ClassVersion="12" checksum="3921700739"/>
<version ClassVersion="11" checksum="159132251"/>
<version ClassVersion="10" checksum="3207121440"/>
Expand All @@ -69,8 +67,7 @@
<class name="edm::Wrapper<std::vector<reco::CaloMET> >"/>
<class name="std::vector<reco::CaloMET>"/>

<class name="reco::PFMET" ClassVersion="13">
<version ClassVersion="13" checksum="1267179224"/>
<class name="reco::PFMET" ClassVersion="12">
<version ClassVersion="12" checksum="3350721210"/>
<version ClassVersion="11" checksum="3463342610"/>
<version ClassVersion="10" checksum="3708270533"/>
Expand All @@ -80,8 +77,7 @@
<class name="std::vector<reco::PFMET>"/>
<class name="std::vector<edm::Ref<std::vector<reco::PFMET> > >"/>

<class name="reco::PFClusterMET" ClassVersion="13">
<version ClassVersion="13" checksum="520383985"/>
<class name="reco::PFClusterMET" ClassVersion="12">
<version ClassVersion="12" checksum="3688821779"/>
<version ClassVersion="11" checksum="3634437739"/>
<version ClassVersion="10" checksum="3408846646"/>
Expand All @@ -91,8 +87,7 @@
<class name="std::vector<reco::PFClusterMET>"/>


<class name="reco::GenMET" ClassVersion="13">
<version ClassVersion="13" checksum="2800901046"/>
<class name="reco::GenMET" ClassVersion="12">
<version ClassVersion="12" checksum="77942440"/>
<version ClassVersion="11" checksum="1091535040"/>
<version ClassVersion="10" checksum="595237107"/>
Expand Down
3 changes: 1 addition & 2 deletions DataFormats/PatCandidates/src/classes_def_objects.xml
Original file line number Diff line number Diff line change
Expand Up @@ -273,8 +273,7 @@
<ioread sourceClass = "pat::Jet" version="[1-]" targetClass="pat::Jet" source="" target="daughtersTemp_">
<![CDATA[daughtersTemp_.reset();]]>
</ioread>
<class name="pat::MET" ClassVersion="17">
<version ClassVersion="17" checksum="1526897576"/>
<class name="pat::MET" ClassVersion="16">
<version ClassVersion="16" checksum="2416242778"/>
<field name="corMap_" transient="true"/>
<version ClassVersion="15" checksum="428901429"/>
Expand Down
Loading

0 comments on commit 8c0e2bf

Please sign in to comment.