Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adapt track-vertex association in PUPPI (v15) [10_6_X] #31214

Merged
merged 2 commits into from Aug 26, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
30 changes: 24 additions & 6 deletions CommonTools/PileupAlgos/plugins/PuppiProducer.cc
Expand Up @@ -31,6 +31,8 @@ PuppiProducer::PuppiProducer(const edm::ParameterSet& iConfig) {
fEtaMinUseDZ = iConfig.getParameter<double>("EtaMinUseDeltaZ");
fPtMaxCharged = iConfig.getParameter<double>("PtMaxCharged");
fEtaMaxCharged = iConfig.getParameter<double>("EtaMaxCharged");
fNumOfPUVtxsForCharged = iConfig.getParameter<uint>("NumOfPUVtxsForCharged");
fDZCutForChargedFromPUVtxs = iConfig.getParameter<double>("DeltaZCutForChargedFromPUVtxs");
fUseExistingWeights = iConfig.getParameter<bool>("useExistingWeights");
fUseWeightsNoLep = iConfig.getParameter<bool>("useWeightsNoLep");
fClonePackedCands = iConfig.getParameter<bool>("clonePackedCands");
Expand Down Expand Up @@ -98,15 +100,15 @@ void PuppiProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) {
const reco::Vertex *closestVtx = nullptr;
double pDZ = -9999;
double pD0 = -9999;
int pVtxId = -9999;
bool lFirst = true;
uint pVtxId = 0;
const pat::PackedCandidate *lPack = dynamic_cast<const pat::PackedCandidate*>(&aPF);
if(lPack == nullptr ) {

const reco::PFCandidate *pPF = dynamic_cast<const reco::PFCandidate*>(&aPF);
double curdz = 9999;
int closestVtxForUnassociateds = -9999;
const reco::TrackRef aTrackRef = pPF->trackRef();
bool lFirst = true;
for(auto const& aV : *pvCol) {
if(lFirst) {
if ( aTrackRef.isNonnull()) {
Expand Down Expand Up @@ -147,8 +149,12 @@ void PuppiProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) {
pReco.id = 0;
if (std::abs(pReco.charge) == 0){ pReco.id = 0; }
else{
if (tmpFromPV == 0){ pReco.id = 2; } // 0 is associated to PU vertex
else if (tmpFromPV == 3){ pReco.id = 1; }
if (tmpFromPV == 0) {
pReco.id = 2;
if (fNumOfPUVtxsForCharged > 0 and (pVtxId <= fNumOfPUVtxsForCharged) and
(std::abs(pDZ) < fDZCutForChargedFromPUVtxs))
pReco.id = 1;
} else if (tmpFromPV == 3){ pReco.id = 1; }
else if (tmpFromPV == 1 || tmpFromPV == 2){
pReco.id = 0;
if ((fPtMaxCharged > 0) and (pReco.pt > fPtMaxCharged))
Expand All @@ -173,8 +179,18 @@ void PuppiProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) {
pReco.id = 0;
if (std::abs(pReco.charge) == 0){ pReco.id = 0; }
if (std::abs(pReco.charge) > 0){
if (lPack->fromPV() == 0){ pReco.id = 2; } // 0 is associated to PU vertex
else if (lPack->fromPV() == (pat::PackedCandidate::PVUsedInFit)){ pReco.id = 1; }
if (lPack->fromPV() == 0){
pReco.id = 2;
if ((fNumOfPUVtxsForCharged > 0) and (std::abs(pDZ) < fDZCutForChargedFromPUVtxs)) {
for (size_t puVtx_idx = 1; puVtx_idx <= fNumOfPUVtxsForCharged && puVtx_idx < pvCol->size();
++puVtx_idx) {
if (lPack->fromPV(puVtx_idx) >= 2) {
pReco.id = 1;
break;
}
}
}
} else if (lPack->fromPV() == (pat::PackedCandidate::PVUsedInFit)){ pReco.id = 1; }
else if (lPack->fromPV() == (pat::PackedCandidate::PVTight) || lPack->fromPV() == (pat::PackedCandidate::PVLoose)){
pReco.id = 0;
if ((fPtMaxCharged > 0) and (pReco.pt > fPtMaxCharged))
Expand Down Expand Up @@ -361,6 +377,8 @@ void PuppiProducer::fillDescriptions(edm::ConfigurationDescriptions& description
desc.add<double>("EtaMaxCharged", 99999.);
desc.add<double>("PtMaxNeutrals", 200.);
desc.add<double>("PtMaxNeutralsStartSlope", 0.);
desc.add<uint>("NumOfPUVtxsForCharged", 0);
desc.add<double>("DeltaZCutForChargedFromPUVtxs", 0.2);
desc.add<bool>("useExistingWeights", false);
desc.add<bool>("useWeightsNoLep", false);
desc.add<bool>("clonePackedCands", false);
Expand Down
2 changes: 2 additions & 0 deletions CommonTools/PileupAlgos/plugins/PuppiProducer.h
Expand Up @@ -54,6 +54,8 @@ class PuppiProducer : public edm::stream::EDProducer<> {
double fEtaMinUseDZ;
double fPtMaxCharged;
double fEtaMaxCharged;
uint fNumOfPUVtxsForCharged;
double fDZCutForChargedFromPUVtxs;
bool fUseExistingWeights;
bool fUseWeightsNoLep;
bool fClonePackedCands;
Expand Down
29 changes: 28 additions & 1 deletion CommonTools/PileupAlgos/python/Puppi_cff.py
Expand Up @@ -31,6 +31,8 @@
UseDeltaZCut = cms.bool(True),
EtaMinUseDeltaZ = cms.double(0.),
DeltaZCut = cms.double(0.3),
NumOfPUVtxsForCharged = cms.uint32(0),
DeltaZCutForChargedFromPUVtxs = cms.double(0.2),
PtMaxCharged = cms.double(0.),
EtaMaxCharged = cms.double(99999.),
PtMaxNeutrals = cms.double(200.),
Expand Down Expand Up @@ -121,5 +123,30 @@
puppi,
EtaMinUseDeltaZ = 2.4,
PtMaxCharged = 20.,
PtMaxNeutralsStartSlope = 20.
PtMaxNeutralsStartSlope = 20.,
NumOfPUVtxsForCharged = 2,
algos = cms.VPSet(
cms.PSet(
etaMin = cms.vdouble(-0.01), # include particles with eta==0 (proper fix is in #31174)
etaMax = cms.vdouble(2.5),
ptMin = cms.vdouble(0.),
MinNeutralPt = cms.vdouble(0.2),
MinNeutralPtSlope = cms.vdouble(0.015),
RMSEtaSF = cms.vdouble(1.0),
MedEtaSF = cms.vdouble(1.0),
EtaMaxExtrap = cms.double(2.0),
puppiAlgos = puppiCentral
),
cms.PSet(
etaMin = cms.vdouble( 2.5, 3.0),
etaMax = cms.vdouble( 3.0, 10.0),
ptMin = cms.vdouble( 0.0, 0.0),
MinNeutralPt = cms.vdouble( 1.7, 2.0),
MinNeutralPtSlope = cms.vdouble(0.08, 0.08),
RMSEtaSF = cms.vdouble(1.20, 0.95),
MedEtaSF = cms.vdouble(0.90, 0.75),
EtaMaxExtrap = cms.double( 2.0),
puppiAlgos = puppiForward
)
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIUC, only etaMin needs a change

Suggested change
algos = cms.VPSet(
cms.PSet(
etaMin = cms.vdouble(-0.01), # include particles with eta==0 (proper fix is in #31174)
etaMax = cms.vdouble(2.5),
ptMin = cms.vdouble(0.),
MinNeutralPt = cms.vdouble(0.2),
MinNeutralPtSlope = cms.vdouble(0.015),
RMSEtaSF = cms.vdouble(1.0),
MedEtaSF = cms.vdouble(1.0),
EtaMaxExtrap = cms.double(2.0),
puppiAlgos = puppiCentral
),
cms.PSet(
etaMin = cms.vdouble( 2.5, 3.0),
etaMax = cms.vdouble( 3.0, 10.0),
ptMin = cms.vdouble( 0.0, 0.0),
MinNeutralPt = cms.vdouble( 1.7, 2.0),
MinNeutralPtSlope = cms.vdouble(0.08, 0.08),
RMSEtaSF = cms.vdouble(1.20, 0.95),
MedEtaSF = cms.vdouble(0.90, 0.75),
EtaMaxExtrap = cms.double( 2.0),
puppiAlgos = puppiForward
)
)
algos = { 0 : dict(etaMin = {-0.01}) } # include particles with eta==0 (proper fix is in #31174)

)
20 changes: 12 additions & 8 deletions CommonTools/PileupAlgos/python/customizePuppiTune_cff.py
@@ -1,18 +1,18 @@
import FWCore.ParameterSet.Config as cms

def UpdatePuppiTuneV14(process, runOnMC=True):
def UpdatePuppiTuneV15(process, runOnMC=True):
#
# Adapt for re-running PUPPI
#
print("customizePuppiTune_cff::UpdatePuppiTuneV14: Recomputing PUPPI with Tune v14, slimmedJetsPuppi and slimmedMETsPuppi")
print("customizePuppiTune_cff::UpdatePuppiTuneV15: Recomputing PUPPI with Tune v15, slimmedJetsPuppi and slimmedMETsPuppi")
from PhysicsTools.PatAlgos.tools.helpers import getPatAlgosToolsTask, addToProcessAndTask
task = getPatAlgosToolsTask(process)
from PhysicsTools.PatAlgos.slimming.puppiForMET_cff import makePuppiesFromMiniAOD
makePuppiesFromMiniAOD(process,True)
process.puppi.useExistingWeights = False
process.puppiNoLep.useExistingWeights = False
from PhysicsTools.PatUtils.tools.runMETCorrectionsAndUncertainties import runMetCorAndUncFromMiniAOD
runMetCorAndUncFromMiniAOD(process,isData=(not runOnMC),metType="Puppi",postfix="Puppi",jetFlavor="AK4PFPuppi",recoMetFromPFCs=True,pfCandColl=cms.InputTag("puppiForMET"))
runMetCorAndUncFromMiniAOD(process,isData=(not runOnMC),metType="Puppi",postfix="Puppi",jetFlavor="AK4PFPuppi",recoMetFromPFCs=True)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this change intended?
it looks unrelated to the change from v14 to v15.

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 All @@ -26,17 +26,21 @@ def UpdatePuppiTuneV14(process, runOnMC=True):
del process.updatedPatJetsPuppiJetSpecific
process.puppiSequence = cms.Sequence(process.puppiMETSequence+process.fullPatMetSequencePuppi+process.patPuppiJetSpecificProducer+process.slimmedJetsPuppi)
#
# Adapt for PUPPI tune V14
# Adapt for PUPPI tune V15
#
process.puppi.PtMaxCharged = 20.
process.puppi.EtaMinUseDeltaZ = 2.4
process.puppi.PtMaxNeutralsStartSlope = 20.
process.puppi.NumOfPUVtxsForCharged = 2
process.puppi.algos[0].etaMin = [-0.01]
process.puppiNoLep.PtMaxCharged = 20.
process.puppiNoLep.EtaMinUseDeltaZ = 2.4
process.puppiNoLep.PtMaxNeutralsStartSlope = 20.
process.puppiNoLep.NumOfPUVtxsForCharged = 2
process.puppiNoLep.algos[0].etaMin = [-0.01]

def UpdatePuppiTuneV14_MC(process):
UpdatePuppiTuneV14(process,runOnMC=True)
def UpdatePuppiTuneV15_MC(process):
UpdatePuppiTuneV15(process,runOnMC=True)

def UpdatePuppiTuneV14_Data(process):
UpdatePuppiTuneV14(process,runOnMC=False)
def UpdatePuppiTuneV15_Data(process):
UpdatePuppiTuneV15(process,runOnMC=False)