47 ptokenValues_ = produces<edm::ValueMap<reco::CandidatePtr>>();
78 const reco::VertexCollection::const_iterator vtxEnd = pvCol->end();
79 for (reco::VertexCollection::const_iterator vtxIter = pvCol->begin(); vtxEnd != vtxIter; ++vtxIter) {
84 std::vector<double> lWeights;
89 for (
auto const& aPF : *pfCol) {
92 pReco.
eta = aPF.eta();
93 pReco.
phi = aPF.phi();
96 pReco.
charge = aPF.charge();
97 pReco.
pdgId = aPF.pdgId();
104 if (lPack ==
nullptr) {
107 int closestVtxForUnassociateds = -9999;
110 for (
auto const& aV : *pvCol) {
113 pDZ = aTrackRef->dz(aV.position());
114 pD0 = aTrackRef->d0();
128 double tmpdz = 99999;
130 tmpdz = aTrackRef->dz(aV.position());
135 closestVtxForUnassociateds = pVtxId;
142 if (closestVtx !=
nullptr && pVtxId > 0)
144 if (closestVtx !=
nullptr && pVtxId == 0)
146 if (closestVtx ==
nullptr && closestVtxForUnassociateds == 0)
148 if (closestVtx ==
nullptr && closestVtxForUnassociateds != 0)
159 else if (tmpFromPV == 0) {
164 }
else if (tmpFromPV == 3)
166 else if (tmpFromPV == 1 || tmpFromPV == 2) {
193 }
else if (lPack->
fromPV() == 0) {
198 if (lPack->
fromPV(puVtx_idx) >= 2) {
234 for (
auto const& aPF : *pfCol) {
236 float curpupweight = -1.;
237 if (lPack ==
nullptr) {
240 "PuppiProducer: cannot get weights since inputs are not PackedCandidates");
252 lWeights.push_back(curpupweight);
260 lPupFiller.
insert(hPFProduct, lWeights.begin(), lWeights.end());
277 std::vector<reco::CandidatePtr>
values(hPFProduct->
size());
280 for (
auto const& aCand : *hPFProduct) {
282 std::unique_ptr<pat::PackedCandidate> pCand;
283 std::unique_ptr<reco::PFCandidate> pfCand;
289 pCand = std::make_unique<pat::PackedCandidate>(*
cand);
299 pCand->setPuppiWeight(pCand->puppiWeight(), lWeights[iCand]);
301 pCand->setPuppiWeight(lWeights[iCand], pCand->puppiWeightNoLep());
304 puppiP4s.emplace_back(lWeights[iCand] * aCand.px(),
305 lWeights[iCand] * aCand.py(),
306 lWeights[iCand] * aCand.pz(),
307 lWeights[iCand] * aCand.energy());
313 pCand->setP4(puppiP4s.back());
314 pCand->setSourceCandidatePtr(aCand.sourceCandidatePtr(0));
315 fPackedPuppiCandidates.push_back(*pCand);
317 pfCand->setP4(puppiP4s.back());
318 pfCand->setSourceCandidatePtr(aCand.sourceCandidatePtr(0));
319 fPuppiCandidates.push_back(*pfCand);
325 p4PupFiller.
insert(hPFProduct, puppiP4s.begin(), puppiP4s.end());
333 for (
unsigned int ic = 0, nc = oh->size(); ic < nc; ++ic) {
339 for (
unsigned int ic = 0, nc = oh->size(); ic < nc; ++ic) {
375 desc.add<
bool>(
"puppiDiagnostics",
false);
376 desc.add<
bool>(
"puppiNoLep",
false);
377 desc.add<
bool>(
"UseFromPVLooseTight",
false);
378 desc.add<
bool>(
"UseDeltaZCut",
true);
379 desc.add<
double>(
"DeltaZCut", 0.3);
380 desc.add<
double>(
"EtaMinUseDeltaZ", 0.);
381 desc.add<
double>(
"PtMaxCharged", -1.);
382 desc.add<
double>(
"EtaMaxCharged", 99999.);
383 desc.add<
double>(
"PtMaxPhotons", -1.);
384 desc.add<
double>(
"EtaMaxPhotons", 2.5);
385 desc.add<
double>(
"PtMaxNeutrals", 200.);
386 desc.add<
double>(
"PtMaxNeutralsStartSlope", 0.);
387 desc.add<
uint>(
"NumOfPUVtxsForCharged", 0);
388 desc.add<
double>(
"DeltaZCutForChargedFromPUVtxs", 0.2);
389 desc.add<
bool>(
"useExistingWeights",
false);
390 desc.add<
bool>(
"clonePackedCands",
false);
391 desc.add<
int>(
"vtxNdofCut", 4);
392 desc.add<
double>(
"vtxZCut", 24);
395 desc.add<
bool>(
"applyCHS",
true);
396 desc.add<
bool>(
"invertPuppi",
false);
397 desc.add<
bool>(
"useExp",
false);
398 desc.add<
double>(
"MinPuppiWeight", .01);
402 descriptions.
add(
"PuppiProducer",
desc);