-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
30 changed files
with
501 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#include "CommonTools/ParticleFlow/plugins/PFnoPileUp.h" | ||
|
||
#include "DataFormats/VertexReco/interface/Vertex.h" | ||
|
||
#include "FWCore/Framework/interface/ESHandle.h" | ||
|
||
// #include "FWCore/MessageLogger/interface/MessageLogger.h" | ||
#include "FWCore/Utilities/interface/Exception.h" | ||
#include "FWCore/Framework/interface/EventSetup.h" | ||
|
||
using namespace std; | ||
using namespace edm; | ||
using namespace reco; | ||
|
||
PFnoPileUp::PFnoPileUp(const edm::ParameterSet& iConfig) { | ||
tokenCandidatesView_ = consumes<CandidateView>(iConfig.getParameter<InputTag>("candidates")); | ||
vertexAssociationQuality_ = iConfig.getParameter<int>("vertexAssociationQuality"); | ||
tokenVertexAssociation_ = consumes<CandToVertex>(iConfig.getParameter<edm::InputTag>("vertexAssociation")); | ||
tokenVertexAssociationQuality_ = | ||
consumes<edm::ValueMap<int>>(iConfig.getParameter<edm::InputTag>("vertexAssociation")); | ||
produces<edm::PtrVector<reco::Candidate>>(); | ||
} | ||
|
||
PFnoPileUp::~PFnoPileUp() {} | ||
|
||
void PFnoPileUp::produce(Event& iEvent, const EventSetup& iSetup) { | ||
unique_ptr<edm::PtrVector<reco::Candidate>> pOutput(new edm::PtrVector<reco::Candidate>); | ||
Handle<CandidateView> candidateView; | ||
iEvent.getByToken(tokenCandidatesView_, candidateView); | ||
edm::Handle<edm::Association<reco::VertexCollection>> assoHandle; | ||
iEvent.getByToken(tokenVertexAssociation_, assoHandle); | ||
const edm::Association<reco::VertexCollection>* associatedPV = assoHandle.product(); | ||
edm::Handle<edm::ValueMap<int>> assoQualityHandle; | ||
iEvent.getByToken(tokenVertexAssociationQuality_, assoQualityHandle); | ||
const edm::ValueMap<int>* associationQuality = assoQualityHandle.product(); | ||
for (unsigned i = 0; i < candidateView->size(); i++) { | ||
const reco::VertexRef& PVOrig = (*associatedPV)[candidateView->ptrAt(i)]; | ||
int quality = (*associationQuality)[candidateView->ptrAt(i)]; | ||
if (!(PVOrig.isNonnull() && (PVOrig.key() > 0) && (quality >= vertexAssociationQuality_))) | ||
pOutput->push_back(candidateView->ptrAt(i)); | ||
} | ||
iEvent.put(std::move(pOutput)); | ||
} | ||
|
||
DEFINE_FWK_MODULE(PFnoPileUp); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#ifndef CommonTools_ParticleFlow_PFnoPileUp_ | ||
#define CommonTools_ParticleFlow_PFnoPileUp_ | ||
|
||
// system include files | ||
#include <memory> | ||
#include <string> | ||
|
||
// user include files | ||
#include "FWCore/Framework/interface/Frameworkfwd.h" | ||
#include "FWCore/Framework/interface/stream/EDProducer.h" | ||
#include "FWCore/ParameterSet/interface/ParameterSet.h" | ||
|
||
#include "FWCore/Framework/interface/Event.h" | ||
#include "FWCore/Framework/interface/MakerMacros.h" | ||
|
||
#include "DataFormats/Candidate/interface/Candidate.h" | ||
#include "DataFormats/VertexReco/interface/VertexFwd.h" | ||
#include "DataFormats/Common/interface/Association.h" | ||
|
||
/**\class PFnoPileUp | ||
\brief Identifies pile-up candidates from a collection of Candidates, and | ||
produces the corresponding collection of NoPileUpCandidates. | ||
\author Andreas Hinzmann | ||
\date May 2021 | ||
*/ | ||
|
||
class PFnoPileUp : public edm::stream::EDProducer<> { | ||
public: | ||
typedef edm::View<reco::Candidate> CandidateView; | ||
typedef edm::Association<reco::VertexCollection> CandToVertex; | ||
|
||
explicit PFnoPileUp(const edm::ParameterSet&); | ||
|
||
~PFnoPileUp() override; | ||
|
||
void produce(edm::Event&, const edm::EventSetup&) override; | ||
|
||
private: | ||
edm::EDGetTokenT<CandidateView> tokenCandidatesView_; | ||
edm::EDGetTokenT<reco::VertexCollection> tokenVertices_; | ||
edm::EDGetTokenT<CandToVertex> tokenVertexAssociation_; | ||
edm::EDGetTokenT<edm::ValueMap<int>> tokenVertexAssociationQuality_; | ||
int vertexAssociationQuality_; | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import FWCore.ParameterSet.Config as cms | ||
from CommonTools.ParticleFlow.pfNoPileUpJME_cff import adapt, pfPileUpJME | ||
from PhysicsTools.PatAlgos.sortedPackedPrimaryVertices_cfi import sortedPackedPrimaryVertices | ||
|
||
packedPrimaryVertexAssociationJME = sortedPackedPrimaryVertices.clone( | ||
produceSortedVertices = False, | ||
producePileUpCollection = False, | ||
produceNoPileUpCollection = False | ||
) | ||
adapt(packedPrimaryVertexAssociationJME) | ||
|
||
pfCHS = cms.EDProducer("PFnoPileUp", | ||
candidates = cms.InputTag("packedPFCandidates"), | ||
vertexAssociationQuality = pfPileUpJME.vertexAssociationQuality, | ||
vertexAssociation = cms.InputTag("packedPrimaryVertexAssociationJME","original") | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.