46 ptokenValues_ = produces<edm::ValueMap<reco::CandidatePtr>>();
77 const reco::VertexCollection::const_iterator vtxEnd = pvCol->end();
78 for (reco::VertexCollection::const_iterator vtxIter = pvCol->begin(); vtxEnd != vtxIter; ++vtxIter) {
83 std::vector<double> lWeights;
88 for (
auto const& aPF : *pfCol) {
91 pReco.
eta = aPF.eta();
92 pReco.
phi = aPF.phi();
95 pReco.
charge = aPF.charge();
96 pReco.
pdgId = aPF.pdgId();
104 if (lPack ==
nullptr) {
107 int closestVtxForUnassociateds = -9999;
109 for (
auto const& aV : *pvCol) {
112 pDZ = aTrackRef->dz(aV.position());
113 pD0 = aTrackRef->d0();
127 double tmpdz = 99999;
129 tmpdz = aTrackRef->dz(aV.position());
134 closestVtxForUnassociateds = pVtxId;
141 if (closestVtx !=
nullptr && pVtxId > 0)
143 if (closestVtx !=
nullptr && pVtxId == 0)
145 if (closestVtx ==
nullptr && closestVtxForUnassociateds == 0)
147 if (closestVtx ==
nullptr && closestVtxForUnassociateds != 0)
158 else if (tmpFromPV == 0) {
161 else if (tmpFromPV == 3) {
163 }
else if (tmpFromPV == 1 || tmpFromPV == 2) {
190 else if (lPack->
fromPV() == 0) {
223 for (
auto const& aPF : *pfCol) {
225 float curpupweight = -1.;
226 if (lPack ==
nullptr) {
229 "PuppiProducer: cannot get weights since inputs are not PackedCandidates");
241 lWeights.push_back(curpupweight);
249 lPupFiller.
insert(hPFProduct, lWeights.begin(), lWeights.end());
266 std::vector<reco::CandidatePtr>
values(hPFProduct->
size());
269 for (
auto const& aCand : *hPFProduct) {
271 std::unique_ptr<pat::PackedCandidate> pCand;
272 std::unique_ptr<reco::PFCandidate> pfCand;
288 pCand->setPuppiWeight(pCand->puppiWeight(), lWeights[iCand]);
290 pCand->setPuppiWeight(lWeights[iCand], pCand->puppiWeightNoLep());
293 puppiP4s.emplace_back(lWeights[iCand] * aCand.px(),
294 lWeights[iCand] * aCand.py(),
295 lWeights[iCand] * aCand.pz(),
296 lWeights[iCand] * aCand.energy());
302 pCand->setP4(puppiP4s.back());
303 pCand->setSourceCandidatePtr(aCand.sourceCandidatePtr(0));
304 fPackedPuppiCandidates.push_back(*pCand);
306 pfCand->setP4(puppiP4s.back());
307 pfCand->setSourceCandidatePtr(aCand.sourceCandidatePtr(0));
308 fPuppiCandidates.push_back(*pfCand);
314 p4PupFiller.
insert(hPFProduct, puppiP4s.begin(), puppiP4s.end());
322 for (
unsigned int ic = 0, nc = oh->size(); ic < nc; ++ic) {
328 for (
unsigned int ic = 0, nc = oh->size(); ic < nc; ++ic) {
364 desc.
add<
bool>(
"puppiDiagnostics",
false);
365 desc.
add<
bool>(
"puppiNoLep",
false);
366 desc.
add<
bool>(
"UseFromPVLooseTight",
false);
367 desc.
add<
bool>(
"UseDeltaZCut",
true);
368 desc.
add<
double>(
"DeltaZCut", 0.3);
369 desc.
add<
double>(
"EtaMinUseDeltaZ", 0.);
370 desc.
add<
double>(
"PtMaxCharged", -1.);
371 desc.
add<
double>(
"EtaMaxCharged", 99999.);
372 desc.
add<
double>(
"PtMaxPhotons", -1.);
373 desc.
add<
double>(
"EtaMaxPhotons", 2.5);
374 desc.
add<
double>(
"PtMaxNeutrals", 200.);
375 desc.
add<
double>(
"PtMaxNeutralsStartSlope", 0.);
376 desc.
add<
bool>(
"useExistingWeights",
false);
377 desc.
add<
bool>(
"clonePackedCands",
false);
378 desc.
add<
int>(
"vtxNdofCut", 4);
379 desc.
add<
double>(
"vtxZCut", 24);
382 desc.
add<
bool>(
"applyCHS",
true);
383 desc.
add<
bool>(
"invertPuppi",
false);
384 desc.
add<
bool>(
"useExp",
false);
385 desc.
add<
double>(
"MinPuppiWeight", .01);
389 descriptions.
add(
"PuppiProducer", desc);