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>();
139 bool getFromFwdPtr = iEvent.
getByToken(tokenPFCandidates_, pfCandidates);
141 pfCandidatesRef = pfCandidates.
product();
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];
179 if (PVOrig.
isNonnull() && (PVOrig.
key() > 0) && (quality >= vertexAssociationQuality_))
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);
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);
T getUntrackedParameter(std::string const &, T const &) const
int vertexAssociationQuality_
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
bool isNonnull() const
Checks for non-null.
Identifies pile-up candidates from a collection of PFCandidates, and produces the corresponding colle...
edm::Association< reco::VertexCollection > CandToVertex
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
edm::EDGetTokenT< reco::VertexCollection > tokenVertices_
vertices
edm::EDGetTokenT< PFView > tokenPFCandidatesView_
fall-back token
bool getByToken(EDGetToken token, Handle< PROD > &result) const
#define DEFINE_FWK_MODULE(type)
key_type key() const
Accessor for product key.
unsigned int fNumOfPUVtxsForCharged_
void produce(edm::Event &, const edm::EventSetup &) override
std::vector< reco::PFCandidate > PFCollectionByValue
bool get(ProductID const &oid, Handle< PROD > &result) const
edm::EDGetTokenT< PFCollection > tokenPFCandidates_
PFCandidates to be analyzed.
std::vector< edm::FwdPtr< reco::PFCandidate > > PFCollection
edm::EDGetTokenT< CandToVertex > tokenVertexAssociation_
bool enable_
enable PFPileUp selection
ParameterDescriptionBase * add(U const &iLabel, T const &value)
double fDzCutForChargedFromPUVtxs_
bool fUseVertexAssociation
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
edm::EDGetTokenT< edm::ValueMap< int > > tokenVertexAssociationQuality_
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
T const * product() const
T getParameter(std::string const &) const
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