91 fUseVertexAssociation = iConfig.
getParameter<
bool>(
"useVertexAssociation");
92 vertexAssociationQuality_ = iConfig.
getParameter<
int>(
"vertexAssociationQuality");
93 if (fUseVertexAssociation) {
95 tokenVertexAssociationQuality_ =
98 fNumOfPUVtxsForCharged_ = iConfig.
getParameter<
unsigned int>(
"NumOfPUVtxsForCharged");
99 fDzCutForChargedFromPUVtxs_ = iConfig.
getParameter<
double>(
"DzCutForChargedFromPUVtxs");
105 checkClosestZVertex_ = iConfig.
getParameter<
bool>(
"checkClosestZVertex");
108 pileUpAlgo_.setVerbose(verbose_);
109 pileUpAlgo_.setCheckClosestZVertex(checkClosestZVertex_);
110 pileUpAlgo_.setNumOfPUVtxsForCharged(fNumOfPUVtxsForCharged_);
111 pileUpAlgo_.setDzCutForChargedFromPUVtxs(fDzCutForChargedFromPUVtxs_);
114 produces<PFCollection>();
150 bool getFromView =
iEvent.getByToken(tokenPFCandidatesView_, pfView);
153 "PFPileUp is misconfigured. This needs to be either vector<FwdPtr<PFCandidate> >, or View<PFCandidate>");
156 viewEnd = pfView->end(),
160 usedIfNoFwdPtrs.push_back(
163 pfCandidatesRef = &usedIfNoFwdPtrs;
166 if (pfCandidatesRef ==
nullptr) {
168 "Something went dreadfully wrong with PFPileUp. pfCandidatesRef should never be zero, so this is a logic " 172 if (fUseVertexAssociation) {
176 for (
auto&
p : (*pfCandidatesRef)) {
178 int quality = associationQuality[
p];
180 pfCandidatesFromPU.push_back(
p);
182 pOutput->insert(pOutput->end(), pfCandidatesFromPU.begin(), pfCandidatesFromPU.end());
184 pileUpAlgo_.process(*pfCandidatesRef, *
vertices);
186 pOutput->end(), pileUpAlgo_.getPFCandidatesFromPU().begin(), pileUpAlgo_.getPFCandidatesFromPU().end());
204 desc.add<
bool>(
"enable",
true);
205 desc.addUntracked<
bool>(
"verbose",
false);
206 desc.add<
bool>(
"checkClosestZVertex",
true);
207 desc.add<
bool>(
"useVertexAssociation",
false);
208 desc.add<
int>(
"vertexAssociationQuality", 0);
210 desc.add<
unsigned int>(
"NumOfPUVtxsForCharged", 0);
211 desc.add<
double>(
"DzCutForChargedFromPUVtxs", .2);
212 descriptions.
add(
"pfPileUp",
desc);
int vertexAssociationQuality_
T getParameter(std::string const &) const
Identifies pile-up candidates from a collection of PFCandidates, and produces the corresponding colle...
edm::Association< reco::VertexCollection > CandToVertex
edm::EDGetTokenT< reco::VertexCollection > tokenVertices_
vertices
edm::EDGetTokenT< PFView > tokenPFCandidatesView_
fall-back token
#define DEFINE_FWK_MODULE(type)
bool isNonnull() const
Checks for non-null.
unsigned int fNumOfPUVtxsForCharged_
key_type key() const
Accessor for product key.
T getUntrackedParameter(std::string const &, T const &) const
void produce(edm::Event &, const edm::EventSetup &) override
std::vector< reco::PFCandidate > PFCollectionByValue
edm::EDGetTokenT< PFCollection > tokenPFCandidates_
PFCandidates to be analyzed.
std::vector< edm::FwdPtr< reco::PFCandidate > > PFCollection
edm::EDGetTokenT< CandToVertex > tokenVertexAssociation_
bool enable_
enable PFPileUp selection
double fDzCutForChargedFromPUVtxs_
bool fUseVertexAssociation
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
edm::EDGetTokenT< edm::ValueMap< int > > tokenVertexAssociationQuality_
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
bool checkClosestZVertex_
use the closest z vertex if a track is not in a vertex
PFPileUp(const edm::ParameterSet &)
edm::View< reco::PFCandidate > PFView