-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Associated PF for Egamma in 2018 PbPb miniAOD #37262
Changes from 4 commits
be8d658
68ac690
9246910
f9b4aef
a9fc49b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -104,3 +104,14 @@ | |||||||||
hiPhotonIsolationMapInput = "photonIsolationHIProducerppGED", | ||||||||||
hiPhotonIsolationMapOutput = "photonIsolationHIProducerppGED" | ||||||||||
) | ||||||||||
|
||||||||||
from RecoHI.HiJetAlgos.HiBadParticleCleaner_cfi import cleanedParticleFlow | ||||||||||
from CommonTools.ParticleFlow.pfEGammaToCandidateRemapper_cfi import pfEGammaToCandidateRemapper as pfEGammaToCandidateRemapperCleaned | ||||||||||
pfEGammaToCandidateRemapperCleaned.pf2pf = cms.InputTag("cleanedParticleFlow") | ||||||||||
|
||||||||||
from Configuration.ProcessModifiers.run2_miniAOD_pp_on_AA_103X_cff import run2_miniAOD_pp_on_AA_103X | ||||||||||
run2_miniAOD_pp_on_AA_103X.toModify( | ||||||||||
reducedEgamma, | ||||||||||
photonsPFValMap = cms.InputTag("pfEGammaToCandidateRemapperCleaned:photons"), | ||||||||||
gsfElectronsPFValMap = cms.InputTag("pfEGammaToCandidateRemapperCleaned:electrons") | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,7 +32,7 @@ class HiBadParticleCleaner : public edm::global::EDProducer<> { | |
void produce(edm::StreamID, edm::Event&, const edm::EventSetup&) const override; | ||
// ----------member data --------------------------- | ||
|
||
edm::EDGetTokenT<edm::View<reco::PFCandidate> > tokenPFCandidates_; | ||
edm::EDGetTokenT<edm::View<reco::PFCandidate>> tokenPFCandidates_; | ||
edm::EDGetTokenT<reco::VertexCollection> tokenPV_; | ||
|
||
const double minMuonPt_; | ||
|
@@ -51,7 +51,7 @@ class HiBadParticleCleaner : public edm::global::EDProducer<> { | |
// constructors and destructor | ||
// | ||
HiBadParticleCleaner::HiBadParticleCleaner(const edm::ParameterSet& iConfig) | ||
: tokenPFCandidates_(consumes<edm::View<reco::PFCandidate> >(iConfig.getParameter<edm::InputTag>("PFCandidates"))), | ||
: tokenPFCandidates_(consumes<edm::View<reco::PFCandidate>>(iConfig.getParameter<edm::InputTag>("PFCandidates"))), | ||
tokenPV_(consumes<reco::VertexCollection>(iConfig.getParameter<edm::InputTag>("offlinePV"))), | ||
minMuonPt_(iConfig.getParameter<double>("minMuonPt")), | ||
minChargedHadronPt_(iConfig.getParameter<double>("minChargedHadronPt")), | ||
|
@@ -66,6 +66,7 @@ HiBadParticleCleaner::HiBadParticleCleaner(const edm::ParameterSet& iConfig) | |
produces<bool>(); | ||
produces<reco::PFCandidateCollection>(); | ||
produces<reco::PFCandidateCollection>("removed"); | ||
produces<edm::ValueMap<reco::PFCandidateRef>>(); | ||
} | ||
|
||
// | ||
|
@@ -91,7 +92,11 @@ void HiBadParticleCleaner::produce(edm::StreamID, edm::Event& iEvent, const edm: | |
|
||
bool foundBadCandidate = false; | ||
|
||
size_t n = pfCandidates->size(); | ||
std::vector<int> oldToNew(n); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This
? Or as definitive fix? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was intended as definitive fix for that module. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's temporary in the sense that it's only needed for reMiniAOD of the existing 2018 PbPb AOD. If we were to re-reconstruct the 2018 data, we wouldn't need this. We will also not need it for Run 3 (assuming we don't screw up the track quality selections again). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If this has to be a definitive fix I am convinced that a more meaningfull name than |
||
size_t iPF = -1; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
for (const reco::PFCandidate& pfCandidate : *pfCandidates) { | ||
iPF++; | ||
if (pfCandidate.particleId() == reco::PFCandidate::ParticleType::mu) // muon cleaning | ||
{ | ||
if (pfCandidate.pt() > minMuonPt_) { | ||
|
@@ -128,19 +133,22 @@ void HiBadParticleCleaner::produce(edm::StreamID, edm::Event& iEvent, const edm: | |
|
||
if (sig3d > maxSigLoose_) { | ||
pBadCandidateCollection->push_back(pfCandidate); | ||
oldToNew[iPF] = -1 * (pBadCandidateCollection->size()); | ||
foundBadCandidate = true; | ||
continue; | ||
} | ||
|
||
if (track->pt() < pfCandidate.pt() / 1.5 || track->pt() > pfCandidate.pt() * 1.5) { | ||
foundBadCandidate = true; | ||
pBadCandidateCollection->push_back(pfCandidate); | ||
oldToNew[iPF] = -1 * (pBadCandidateCollection->size()); | ||
continue; | ||
} | ||
if (track->originalAlgo() == reco::TrackBase::muonSeededStepOutIn && | ||
track->hitPattern().trackerLayersWithMeasurement() < minTrackerLayersForMuonTight_) { | ||
foundBadCandidate = true; | ||
pBadCandidateCollection->push_back(pfCandidate); | ||
oldToNew[iPF] = -1 * (pBadCandidateCollection->size()); | ||
continue; | ||
} | ||
} | ||
|
@@ -156,6 +164,7 @@ void HiBadParticleCleaner::produce(edm::StreamID, edm::Event& iEvent, const edm: | |
if ((nHits < minTrackNHits_ && nPixelHits < minPixelNHits_) || nHits == 3) { | ||
foundBadCandidate = true; | ||
pBadCandidateCollection->push_back(pfCandidate); | ||
oldToNew[iPF] = -1 * (pBadCandidateCollection->size()); | ||
continue; | ||
} | ||
|
||
|
@@ -176,12 +185,14 @@ void HiBadParticleCleaner::produce(edm::StreamID, edm::Event& iEvent, const edm: | |
if (sig3d > maxSigLoose_) { | ||
foundBadCandidate = true; | ||
pBadCandidateCollection->push_back(pfCandidate); | ||
oldToNew[iPF] = -1 * (pBadCandidateCollection->size()); | ||
continue; | ||
} | ||
|
||
if (sig3d > maxSigTight_ && nHits < minTrackNHits_) { | ||
foundBadCandidate = true; | ||
pBadCandidateCollection->push_back(pfCandidate); | ||
oldToNew[iPF] = -1 * (pBadCandidateCollection->size()); | ||
continue; | ||
} | ||
|
||
|
@@ -192,12 +203,14 @@ void HiBadParticleCleaner::produce(edm::StreamID, edm::Event& iEvent, const edm: | |
if (sig3d > maxSigLoose_) { | ||
foundBadCandidate = true; | ||
pBadCandidateCollection->push_back(pfCandidate); | ||
oldToNew[iPF] = -1 * (pBadCandidateCollection->size()); | ||
continue; | ||
} | ||
|
||
if (nHits < minTrackNHits_) { | ||
foundBadCandidate = true; | ||
pBadCandidateCollection->push_back(pfCandidate); | ||
oldToNew[iPF] = -1 * (pBadCandidateCollection->size()); | ||
continue; | ||
} | ||
} | ||
|
@@ -208,34 +221,56 @@ void HiBadParticleCleaner::produce(edm::StreamID, edm::Event& iEvent, const edm: | |
if (sig3d > maxSigTight_) { | ||
foundBadCandidate = true; | ||
pBadCandidateCollection->push_back(pfCandidate); | ||
oldToNew[iPF] = -1 * (pBadCandidateCollection->size()); | ||
continue; | ||
} | ||
|
||
if (nHits < minTrackNHits_) { | ||
foundBadCandidate = true; | ||
pBadCandidateCollection->push_back(pfCandidate); | ||
oldToNew[iPF] = -1 * (pBadCandidateCollection->size()); | ||
continue; | ||
} | ||
|
||
if (nPixelHits < minPixelNHits_) { | ||
foundBadCandidate = true; | ||
pBadCandidateCollection->push_back(pfCandidate); | ||
oldToNew[iPF] = -1 * (pBadCandidateCollection->size()); | ||
continue; | ||
} | ||
} | ||
} | ||
} | ||
|
||
pOutputCandidateCollection->push_back(pfCandidate); | ||
|
||
oldToNew[iPF] = (pOutputCandidateCollection->size()); | ||
} // end loop over pf candidates | ||
|
||
bool pass = !foundBadCandidate; | ||
|
||
iEvent.put(std::move(pOutputCandidateCollection)); | ||
iEvent.put(std::move(pBadCandidateCollection), "removed"); | ||
edm::OrphanHandle<std::vector<reco::PFCandidate>> newpf = iEvent.put(std::move(pOutputCandidateCollection)); | ||
edm::OrphanHandle<std::vector<reco::PFCandidate>> badpf = iEvent.put(std::move(pBadCandidateCollection), "removed"); | ||
|
||
iEvent.put(std::make_unique<bool>(pass)); | ||
|
||
std::unique_ptr<edm::ValueMap<reco::PFCandidateRef>> pf2pf(new edm::ValueMap<reco::PFCandidateRef>()); | ||
edm::ValueMap<reco::PFCandidateRef>::Filler filler(*pf2pf); | ||
|
||
std::vector<reco::PFCandidateRef> refs; | ||
refs.reserve(n); | ||
|
||
// old to new | ||
for (iPF = 0; iPF < n; ++iPF) { | ||
if (oldToNew[iPF] > 0) { | ||
refs.push_back(reco::PFCandidateRef(newpf, oldToNew[iPF] - 1)); | ||
} else { | ||
refs.push_back(reco::PFCandidateRef(badpf, -oldToNew[iPF] - 1)); | ||
} | ||
} | ||
filler.insert(pfCandidates, refs.begin(), refs.end()); | ||
|
||
filler.fill(); | ||
iEvent.put(std::move(pf2pf)); | ||
} | ||
|
||
//define this as a plug-in | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please clone
pfEGammaToCandidateRemapperCleaned
frompfEGammaToCandidateRemapper
inside the pfEGammaToCandidateRemapper_cfi.py: modules should be modified in the very same configuration file in which they are defined, not in random places elsewhere in cmssw.(You can follow as example how the
primaryVertexAssociationCleaned
is cloned and modifiel inside primaryVertexAssociation_cfi.py)