136 ptokenValues_ = produces<edm::ValueMap<reco::CandidatePtr>>();
147 ptokenAlphas_ = produces<std::vector<double>>(
"PuppiAlphas");
173 double puProxyValue = 0.;
177 for (
auto const&
vtx : *pvCol) {
183 std::vector<double> lWeights;
189 for (
auto const& aPF : *pfCol) {
192 pReco.
eta = aPF.eta();
193 pReco.
phi = aPF.phi();
194 pReco.
m = aPF.mass();
196 pReco.
charge = aPF.charge();
197 pReco.
pdgId = aPF.pdgId();
209 closestVtx = PVOrig.
get();
210 pVtxId = PVOrig.
key();
216 else if (closestVtx !=
nullptr && pVtxId == 0)
218 else if (closestVtx !=
nullptr && pVtxId > 0)
222 }
else if (lPack ==
nullptr) {
225 int closestVtxForUnassociateds = -9999;
228 for (
auto const& aV : *pvCol) {
231 pDZ = aTrackRef->dz(aV.position());
232 pD0 = aTrackRef->d0();
246 double tmpdz = 99999;
248 tmpdz = aTrackRef->dz(aV.position());
253 closestVtxForUnassociateds = pVtxId;
260 if (closestVtx !=
nullptr && pVtxId > 0)
262 if (closestVtx !=
nullptr && pVtxId == 0)
264 if (closestVtx ==
nullptr && closestVtxForUnassociateds == 0)
266 if (closestVtx ==
nullptr && closestVtxForUnassociateds != 0)
277 else if (tmpFromPV == 0) {
282 }
else if (tmpFromPV == 3)
284 else if (tmpFromPV == 1 || tmpFromPV == 2) {
315 }
else if (lPack->
fromPV() == 0) {
320 if (lPack->
fromPV(puVtx_idx) >= 2) {
361 lWeights.reserve(pfCol->
size());
362 for (
auto const& aPF : *pfCol) {
364 float curpupweight = -1.;
365 if (lPack ==
nullptr) {
368 "PuppiProducer: cannot get weights since inputs are not PackedCandidates");
380 lWeights.push_back(curpupweight);
387 lPupFiller.
insert(hPFProduct, lWeights.begin(), lWeights.end());
404 std::vector<reco::CandidatePtr>
values(hPFProduct->
size());
407 puppiP4s.reserve(hPFProduct->
size());
409 fPackedPuppiCandidates.reserve(hPFProduct->
size());
411 fPuppiCandidates.reserve(hPFProduct->
size());
412 for (
auto const& aCand : *hPFProduct) {
414 std::unique_ptr<pat::PackedCandidate> pCand;
415 std::unique_ptr<reco::PFCandidate> pfCand;
421 pCand = std::make_unique<pat::PackedCandidate>(*cand);
431 pCand->setPuppiWeight(pCand->puppiWeight(), lWeights[iCand]);
433 pCand->setPuppiWeight(lWeights[iCand], pCand->puppiWeightNoLep());
436 puppiP4s.emplace_back(lWeights[iCand] * aCand.px(),
437 lWeights[iCand] * aCand.py(),
438 lWeights[iCand] * aCand.pz(),
439 lWeights[iCand] * aCand.energy());
445 pCand->setP4(puppiP4s.back());
446 pCand->setSourceCandidatePtr(aCand.sourceCandidatePtr(0));
447 fPackedPuppiCandidates.push_back(*pCand);
449 pfCand->setP4(puppiP4s.back());
450 pfCand->setSourceCandidatePtr(aCand.sourceCandidatePtr(0));
451 fPuppiCandidates.push_back(*pfCand);
457 p4PupFiller.
insert(hPFProduct, puppiP4s.begin(), puppiP4s.end());
465 for (
unsigned int ic = 0, nc = oh->size(); ic < nc; ++ic) {
471 for (
unsigned int ic = 0, nc = oh->size(); ic < nc; ++ic) {
507 desc.add<
bool>(
"puppiDiagnostics",
false);
508 desc.add<
bool>(
"puppiNoLep",
false);
509 desc.add<
bool>(
"UseFromPVLooseTight",
false);
510 desc.add<
bool>(
"UseFromPV2Recovery",
false);
511 desc.add<
bool>(
"UseDeltaZCut",
true);
512 desc.add<
bool>(
"UseDeltaZCutForPileup",
true);
513 desc.add<
double>(
"DeltaZCut", 0.3);
514 desc.add<
double>(
"EtaMinUseDeltaZ", 0.);
515 desc.add<
double>(
"PtMaxCharged", -1.);
516 desc.add<
double>(
"EtaMaxCharged", 99999.);
517 desc.add<
double>(
"PtMaxPhotons", -1.);
518 desc.add<
double>(
"EtaMaxPhotons", 2.5);
519 desc.add<
double>(
"PtMaxNeutrals", 200.);
520 desc.add<
double>(
"PtMaxNeutralsStartSlope", 0.);
521 desc.add<
double>(
"PtMinForFromPV2Recovery", 0.);
522 desc.add<
uint>(
"NumOfPUVtxsForCharged", 0);
523 desc.add<
double>(
"DeltaZCutForChargedFromPUVtxs", 0.2);
524 desc.add<
bool>(
"useExistingWeights",
false);
525 desc.add<
bool>(
"applyPhotonProtectionForExistingWeights",
false);
526 desc.add<
bool>(
"clonePackedCands",
false);
527 desc.add<
int>(
"vtxNdofCut", 4);
528 desc.add<
double>(
"vtxZCut", 24);
531 desc.add<
bool>(
"useVertexAssociation",
false);
532 desc.add<
int>(
"vertexAssociationQuality", 0);
534 desc.add<
bool>(
"applyCHS",
true);
535 desc.add<
bool>(
"invertPuppi",
false);
536 desc.add<
bool>(
"useExp",
false);
537 desc.add<
double>(
"MinPuppiWeight", .01);
538 desc.add<
bool>(
"usePUProxyValue",
false);
543 descriptions.
add(
"PuppiProducer",
desc);
float puppiWeight() const
std::vector< reco::PFCandidate > PFInputCollection
reco::GsfTrackRef gsfTrackRef() const
bool fUseFromPVLooseTight
float puppiWeightNoLep() const
Weight from full PUPPI.
T getParameter(std::string const &) const
edm::EDPutTokenT< pat::PackedCandidateCollection > ptokenPackedPuppiCandidates_
edm::EDPutTokenT< std::vector< double > > ptokenAlphasMed_
edm::EDGetTokenT< PuppiContainer > tokenPuppiContainer_
double fDZCutForChargedFromPUVtxs
static void fillDescriptionsPuppiAlgo(edm::ParameterSetDescription &desc)
T const * product() const
bool fUseVertexAssociation
void insert(const H &h, I begin, I end)
std::vector< RecoObj > fRecoObjCollection
bool isNonnull() const
Checks for non-null.
std::vector< Vertex > VertexCollection
collection of Vertex objects
std::vector< LorentzVector > LorentzVectorCollection
bool isLepton(const Candidate &part)
const PVAssoc fromPV(size_t ipv=0) const
edm::EDGetTokenT< CandToVertex > tokenVertexAssociation_
edm::EDPutTokenT< reco::PFCandidateCollection > ptokenPuppiCandidates_
edm::EDPutTokenT< double > ptokenNalgos_
int pdgId() const override
PDG identifier.
math::XYZTLorentzVector LorentzVector
const reco::VertexRef vertexRef() const
std::unique_ptr< PuppiContainer > fPuppiContainer
key_type key() const
Accessor for product key.
edm::EDGetTokenT< PFOutputCollection > tokenPuppiCandidates_
edm::EDPutTokenT< edm::ValueMap< reco::CandidatePtr > > ptokenValues_
int vertexAssociationQuality_
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
reco::VertexCollection VertexCollection
edm::EDGetTokenT< double > puProxyValueToken_
double eta() const override
momentum pseudorapidity
std::vector< reco::PFCandidate > PFOutputCollection
edm::EDGetTokenT< edm::ValueMap< int > > tokenVertexAssociationQuality_
Abs< T >::type abs(const T &t)
#define DEFINE_FWK_MODULE(type)
edm::View< reco::Candidate > CandidateView
void produce(edm::Event &, const edm::EventSetup &) override
std::vector< pat::PackedCandidate > PackedOutputCollection
PuppiProducer(const edm::ParameterSet &)
edm::EDGetTokenT< VertexCollection > tokenVertices_
edm::EDPutTokenT< edm::ValueMap< float > > ptokenPupOut_
edm::EDPutTokenT< std::vector< double > > ptokenAlphas_
edm::EDPutTokenT< std::vector< double > > ptokenRawAlphas_
edm::EDGetTokenT< CandidateView > tokenPFCandidates_
double fPtMinForFromPV2Recovery
edm::Association< reco::VertexCollection > CandToVertex
edm::Ptr< Candidate > CandidatePtr
persistent reference to an object in a collection of Candidate objects
double pt() const override
transverse momentum
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
bool fApplyPhotonProtectionForExistingWeights
uint fNumOfPUVtxsForCharged
edm::EDPutTokenT< edm::ValueMap< LorentzVector > > ptokenP4PupOut_
Particle reconstructed by the particle flow algorithm.
ParticleType translatePdgIdToType(int pdgid) const
edm::View< reco::PFCandidate > PFView
T const * get() const
Returns C++ pointer to the item.
reco::TrackRef trackRef() const
virtual float dxy() const
dxy with respect to the PV ref
edm::EDPutTokenT< std::vector< double > > ptokenAlphasRms_
edm::EDGetTokenT< PackedOutputCollection > tokenPackedPuppiCandidates_
virtual float dz(size_t ipv=0) const
dz with respect to the PV[ipv]
~PuppiProducer() override
if(threadIdxLocalY==0 &&threadIdxLocalX==0)