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

Update to fix late validation plots from PR 15562 #15669

Merged
merged 2 commits into from Sep 12, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
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
20 changes: 13 additions & 7 deletions CommonTools/PileupAlgos/plugins/PuppiPhoton.cc
Expand Up @@ -74,12 +74,12 @@ void PuppiPhoton::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) {
if(itPho->isPhoton() && usePhotonId_) passObject = (*photonId) [phoCol->ptrAt(iC)];
if(itPho->pt() < pt_) continue;
if(!passObject && usePhotonId_) continue;
if(!usePFRef_ && fabs(itPho->eta()) < eta_) phoCands.push_back(&(*itPho));
if(!usePFRef_) continue;
//if(!usePFRef_ && fabs(itPho->eta()) < eta_) phoCands.push_back(&(*itPho)); ===> should add a flag useAODRef_ in place of usePFRef_
//if(!usePFRef_) continue;
const pat::Photon *pPho = dynamic_cast<const pat::Photon*>(&(*itPho));
if(pPho != 0) {
for( const edm::Ref<pat::PackedCandidateCollection> & ref : pPho->associatedPackedPFCandidates() ) {
if(matchPFCandidate(&(*(pfCol->ptrAt(ref.key()))),&(*itPho)) && fabs(pfCol->ptrAt(ref.key())->eta()) < eta_ ) {
if(fabs(pfCol->ptrAt(ref.key())->eta()) < eta_ ) {
phoIndx.push_back(ref.key());
phoCands.push_back(&(*(pfCol->ptrAt(ref.key()))));
}
Expand All @@ -89,7 +89,7 @@ void PuppiPhoton::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) {
const pat::Electron *pElectron = dynamic_cast<const pat::Electron*>(&(*itPho));
if(pElectron != 0) {
for( const edm::Ref<pat::PackedCandidateCollection> & ref : pElectron->associatedPackedPFCandidates() )
if(matchPFCandidate(&(*(pfCol->ptrAt(ref.key()))),&(*itPho)) && fabs(pfCol->ptrAt(ref.key())->eta()) < eta_ ) {
if(fabs(pfCol->ptrAt(ref.key())->eta()) < eta_ ) {
phoIndx.push_back(ref.key());
phoCands.push_back(&(*(pfCol->ptrAt(ref.key()))));
}
Expand All @@ -114,8 +114,14 @@ void PuppiPhoton::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) {
float pWeight = 1.;
if(useValueMap_) pWeight = (*pupWeights)[pupCol->ptrAt(iPF)];
if(!usePFRef_) {
int iPho = -1;
for(std::vector<const reco::Candidate*>::iterator itPho = phoCands.begin(); itPho!=phoCands.end(); itPho++) {
if(matchPFCandidate(&(*itPF),*itPho)) pWeight = weight_;
iPho++;
if(!matchPFCandidate(&(*itPF),*itPho)) continue;
pWeight = weight_;
if(!useValueMap_ && itPF->pt() != 0) pWeight = pWeight*(phoCands[iPho]->pt()/itPF->pt());
if(!useValueMap_ && itPF->pt() == 0) pVec.SetPxPyPzE(phoCands[iPho]->px()*pWeight,phoCands[iPho]->py()*pWeight,phoCands[iPho]->pz()*pWeight,phoCands[iPho]->energy()*pWeight);
foundPhoIndex.push_back(iPho);
}
} else {
int iPho = -1;
Expand All @@ -125,9 +131,9 @@ void PuppiPhoton::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) {
pWeight = weight_;
if(!useValueMap_ && itPF->pt() != 0) pWeight = pWeight*(phoCands[iPho]->pt()/itPF->pt());
if(!useValueMap_ && itPF->pt() == 0) pVec.SetPxPyPzE(phoCands[iPho]->px()*pWeight,phoCands[iPho]->py()*pWeight,phoCands[iPho]->pz()*pWeight,phoCands[iPho]->energy()*pWeight);
foundPhoIndex.push_back(iPho); }
foundPhoIndex.push_back(iPho);
}
}

if(itPF->pt() != 0) pVec.SetPxPyPzE(itPF->px()*pWeight,itPF->py()*pWeight,itPF->pz()*pWeight,itPF->energy()*pWeight);

lWeights.push_back(pWeight);
Expand Down
9 changes: 8 additions & 1 deletion CommonTools/PileupAlgos/python/PhotonPuppi_cff.py
Expand Up @@ -9,7 +9,7 @@
pt = cms.double(10),
eta = cms.double(2.5),
useRefs = cms.bool(True),
dRMatch = cms.vdouble(10,10,10,10),
dRMatch = cms.vdouble(0.005,0.005,0.005,0.005),
pdgids = cms.vint32 (22,11,211,130),
weight = cms.double(1.),
useValueMap = cms.bool(False),
Expand All @@ -18,6 +18,13 @@


def setupPuppiPhoton(process):
my_id_modules = ['RecoEgamma.PhotonIdentification.Identification.cutBasedPhotonID_Spring15_25ns_V1_cff']
switchOnVIDPhotonIdProducer(process, DataFormat.AOD)
for idmod in my_id_modules:
setupAllVIDIdsInModule(process,idmod,setupVIDPhotonSelection)


def setupPuppiPhotonMiniAOD(process):
my_id_modules = ['RecoEgamma.PhotonIdentification.Identification.cutBasedPhotonID_Spring15_25ns_V1_cff']
switchOnVIDPhotonIdProducer(process, DataFormat.MiniAOD)
for idmod in my_id_modules:
Expand Down
19 changes: 11 additions & 8 deletions PhysicsTools/PatAlgos/python/slimming/puppiForMET_cff.py
@@ -1,12 +1,12 @@
import FWCore.ParameterSet.Config as cms

from CommonTools.PileupAlgos.Puppi_cff import *
from CommonTools.PileupAlgos.PhotonPuppi_cff import setupPuppiPhoton
from CommonTools.PileupAlgos.PhotonPuppi_cff import setupPuppiPhoton,setupPuppiPhotonMiniAOD

def makePuppies( process ):

process.load('CommonTools.PileupAlgos.Puppi_cff')

process.pfNoLepPUPPI = cms.EDFilter("PdgIdCandViewSelector",
src = cms.InputTag("particleFlow"),
pdgId = cms.vint32( 1,2,22,111,130,310,2112,211,-211,321,-321,999211,2212,-2212 )
Expand All @@ -15,16 +15,18 @@ def makePuppies( process ):
src = cms.InputTag("particleFlow"),
pdgId = cms.vint32(-11,11,-13,13),
)

process.puppiNoLep = process.puppi.clone()
process.puppiNoLep.candName = cms.InputTag('pfNoLepPUPPI')

process.puppiMerged = cms.EDProducer("CandViewMerger",src = cms.VInputTag( 'puppiNoLep','pfLeptonsPUPPET'))
process.load('CommonTools.PileupAlgos.PhotonPuppi_cff')
process.puppiForMET = process.puppiPhoton.clone()
#Line below replaces reference linking wiht delta R matching this is because the reference key in packed candidates differs to PF candidates (must be done when reading Reco)
process.puppiForMET.useRefs = False
#Line below points puppi MET to puppi no lepton which increases the response
process.puppiForMET.puppiCandName = 'puppiMerged'



def makePuppiesFromMiniAOD( process ):
process.load('CommonTools.PileupAlgos.Puppi_cff')
process.puppi.candName = cms.InputTag('packedPFCandidates')
Expand All @@ -37,7 +39,8 @@ def makePuppiesFromMiniAOD( process ):
process.puppiMerged = cms.EDProducer("CandViewMerger",src = cms.VInputTag( 'puppiNoLep','pfLeptonsPUPPET'))
process.load('CommonTools.PileupAlgos.PhotonPuppi_cff')
process.puppiForMET = process.puppiPhoton.clone()
setupPuppiPhoton(process)
#Line below doesn't work because of an issue with references in MiniAOD
setupPuppiPhotonMiniAOD(process)
#Line below doesn't work because of an issue with references in MiniAOD without setting useRefs=>False and using delta R
#process.puppiForMET.puppiCandName = 'puppiMerged'

#process.puppiForMET.useRefs = False