53 ptokenValues_ = produces<edm::ValueMap<reco::CandidatePtr>>();
83 double puProxyValue = 0.;
87 for (
auto const&
vtx : *pvCol) {
93 std::vector<double> lWeights;
98 for (
auto const& aPF : *pfCol) {
101 pReco.
eta = aPF.eta();
102 pReco.
phi = aPF.phi();
103 pReco.
m = aPF.mass();
105 pReco.
charge = aPF.charge();
106 pReco.
pdgId = aPF.pdgId();
113 if (lPack ==
nullptr) {
116 int closestVtxForUnassociateds = -9999;
119 for (
auto const& aV : *pvCol) {
122 pDZ = aTrackRef->dz(aV.position());
123 pD0 = aTrackRef->d0();
137 double tmpdz = 99999;
139 tmpdz = aTrackRef->dz(aV.position());
144 closestVtxForUnassociateds = pVtxId;
151 if (closestVtx !=
nullptr && pVtxId > 0)
153 if (closestVtx !=
nullptr && pVtxId == 0)
155 if (closestVtx ==
nullptr && closestVtxForUnassociateds == 0)
157 if (closestVtx ==
nullptr && closestVtxForUnassociateds != 0)
168 else if (tmpFromPV == 0) {
173 }
else if (tmpFromPV == 3)
175 else if (tmpFromPV == 1 || tmpFromPV == 2) {
202 }
else if (lPack->
fromPV() == 0) {
207 if (lPack->
fromPV(puVtx_idx) >= 2) {
243 for (
auto const& aPF : *pfCol) {
245 float curpupweight = -1.;
246 if (lPack ==
nullptr) {
249 "PuppiProducer: cannot get weights since inputs are not PackedCandidates");
261 lWeights.push_back(curpupweight);
269 lPupFiller.
insert(hPFProduct, lWeights.begin(), lWeights.end());
286 std::vector<reco::CandidatePtr>
values(hPFProduct->
size());
289 for (
auto const& aCand : *hPFProduct) {
291 std::unique_ptr<pat::PackedCandidate> pCand;
292 std::unique_ptr<reco::PFCandidate> pfCand;
298 pCand = std::make_unique<pat::PackedCandidate>(*
cand);
308 pCand->setPuppiWeight(pCand->puppiWeight(), lWeights[iCand]);
310 pCand->setPuppiWeight(lWeights[iCand], pCand->puppiWeightNoLep());
313 puppiP4s.emplace_back(lWeights[iCand] * aCand.px(),
314 lWeights[iCand] * aCand.py(),
315 lWeights[iCand] * aCand.pz(),
316 lWeights[iCand] * aCand.energy());
322 pCand->setP4(puppiP4s.back());
323 pCand->setSourceCandidatePtr(aCand.sourceCandidatePtr(0));
324 fPackedPuppiCandidates.push_back(*pCand);
326 pfCand->setP4(puppiP4s.back());
327 pfCand->setSourceCandidatePtr(aCand.sourceCandidatePtr(0));
328 fPuppiCandidates.push_back(*pfCand);
334 p4PupFiller.
insert(hPFProduct, puppiP4s.begin(), puppiP4s.end());
342 for (
unsigned int ic = 0, nc = oh->size(); ic < nc; ++ic) {
348 for (
unsigned int ic = 0, nc = oh->size(); ic < nc; ++ic) {
384 desc.add<
bool>(
"puppiDiagnostics",
false);
385 desc.add<
bool>(
"puppiNoLep",
false);
386 desc.add<
bool>(
"UseFromPVLooseTight",
false);
387 desc.add<
bool>(
"UseDeltaZCut",
true);
388 desc.add<
double>(
"DeltaZCut", 0.3);
389 desc.add<
double>(
"EtaMinUseDeltaZ", 0.);
390 desc.add<
double>(
"PtMaxCharged", -1.);
391 desc.add<
double>(
"EtaMaxCharged", 99999.);
392 desc.add<
double>(
"PtMaxPhotons", -1.);
393 desc.add<
double>(
"EtaMaxPhotons", 2.5);
394 desc.add<
double>(
"PtMaxNeutrals", 200.);
395 desc.add<
double>(
"PtMaxNeutralsStartSlope", 0.);
396 desc.add<
uint>(
"NumOfPUVtxsForCharged", 0);
397 desc.add<
double>(
"DeltaZCutForChargedFromPUVtxs", 0.2);
398 desc.add<
bool>(
"useExistingWeights",
false);
399 desc.add<
bool>(
"clonePackedCands",
false);
400 desc.add<
int>(
"vtxNdofCut", 4);
401 desc.add<
double>(
"vtxZCut", 24);
404 desc.add<
bool>(
"applyCHS",
true);
405 desc.add<
bool>(
"invertPuppi",
false);
406 desc.add<
bool>(
"useExp",
false);
407 desc.add<
double>(
"MinPuppiWeight", .01);
408 desc.add<
bool>(
"usePUProxyValue",
false);
413 descriptions.
add(
"PuppiProducer",
desc);