169 double puProxyValue = 0.;
173 for (
auto const& vtx : *pvCol) {
179 std::vector<double> lWeights;
185 for (
auto const& aPF : *pfCol) {
188 pReco.
eta = aPF.eta();
189 pReco.
phi = aPF.phi();
190 pReco.
m = aPF.mass();
192 pReco.
charge = aPF.charge();
193 pReco.
pdgId = aPF.pdgId();
205 closestVtx = PVOrig.
get();
206 pVtxId = PVOrig.
key();
212 else if (closestVtx !=
nullptr && pVtxId == 0)
214 else if (closestVtx !=
nullptr && pVtxId > 0)
218 }
else if (lPack ==
nullptr) {
221 int closestVtxForUnassociateds = -9999;
224 for (
auto const& aV : *pvCol) {
227 pDZ = aTrackRef->dz(aV.position());
228 pD0 = aTrackRef->d0();
242 double tmpdz = 99999;
244 tmpdz = aTrackRef->dz(aV.position());
249 closestVtxForUnassociateds = pVtxId;
256 if (closestVtx !=
nullptr && pVtxId > 0)
258 if (closestVtx !=
nullptr && pVtxId == 0)
260 if (closestVtx ==
nullptr && closestVtxForUnassociateds == 0)
262 if (closestVtx ==
nullptr && closestVtxForUnassociateds != 0)
273 else if (tmpFromPV == 0) {
278 }
else if (tmpFromPV == 3)
280 else if (tmpFromPV == 1 || tmpFromPV == 2) {
309 }
else if (lPack->
fromPV() == 0) {
314 if (lPack->
fromPV(puVtx_idx) >= 2) {
353 for (
auto const& aPF : *pfCol) {
355 float curpupweight = -1.;
356 if (lPack ==
nullptr) {
359 "PuppiProducer: cannot get weights since inputs are not PackedCandidates");
371 lWeights.push_back(curpupweight);
379 lPupFiller.insert(hPFProduct, lWeights.begin(), lWeights.end());
396 std::vector<reco::CandidatePtr>
values(hPFProduct->size());
399 for (
auto const& aCand : *hPFProduct) {
401 std::unique_ptr<pat::PackedCandidate> pCand;
402 std::unique_ptr<reco::PFCandidate> pfCand;
408 pCand = std::make_unique<pat::PackedCandidate>(*cand);
412 pfCand = std::make_unique<reco::PFCandidate>(cand ? *cand :
reco::PFCandidate(aCand.charge(), aCand.p4(),
id));
418 pCand->setPuppiWeight(pCand->puppiWeight(), lWeights[iCand]);
420 pCand->setPuppiWeight(lWeights[iCand], pCand->puppiWeightNoLep());
423 puppiP4s.emplace_back(lWeights[iCand] * aCand.px(),
424 lWeights[iCand] * aCand.py(),
425 lWeights[iCand] * aCand.pz(),
426 lWeights[iCand] * aCand.energy());
432 pCand->setP4(puppiP4s.back());
433 pCand->setSourceCandidatePtr(aCand.sourceCandidatePtr(0));
434 fPackedPuppiCandidates.push_back(*pCand);
436 pfCand->setP4(puppiP4s.back());
437 pfCand->setSourceCandidatePtr(aCand.sourceCandidatePtr(0));
438 fPuppiCandidates.push_back(*pfCand);
444 p4PupFiller.insert(hPFProduct, puppiP4s.begin(), puppiP4s.end());
452 for (
unsigned int ic = 0, nc = oh->size(); ic < nc; ++ic) {
458 for (
unsigned int ic = 0, nc = oh->size(); ic < nc; ++ic) {
465 filler.insert(hPFProduct,
values.begin(),
values.end());
float puppiWeight() const
virtual float dz(size_t ipv=0) const
dz with respect to the PV[ipv]
bool fUseFromPVLooseTight
edm::EDPutTokenT< pat::PackedCandidateCollection > ptokenPackedPuppiCandidates_
edm::EDPutTokenT< std::vector< double > > ptokenAlphasMed_
bool isNonnull() const
Checks for non-null.
float puppiWeightNoLep() const
Weight from full PUPPI.
uint16_t *__restrict__ id
double fDZCutForChargedFromPUVtxs
bool getByToken(EDGetToken token, Handle< PROD > &result) const
bool fUseVertexAssociation
std::vector< RecoObj > fRecoObjCollection
std::vector< Vertex > VertexCollection
collection of Vertex objects
bool isLepton(const Candidate &part)
edm::EDGetTokenT< CandToVertex > tokenVertexAssociation_
key_type key() const
Accessor for product key.
edm::EDPutTokenT< reco::PFCandidateCollection > ptokenPuppiCandidates_
edm::EDPutTokenT< double > ptokenNalgos_
int pdgId() const override
PDG identifier.
const reco::VertexRef vertexRef() const
std::unique_ptr< PuppiContainer > fPuppiContainer
edm::EDPutTokenT< edm::ValueMap< reco::CandidatePtr > > ptokenValues_
reco::TrackRef trackRef() const
int vertexAssociationQuality_
edm::EDGetTokenT< double > puProxyValueToken_
double eta() const override
momentum pseudorapidity
std::vector< reco::PFCandidate > PFOutputCollection
const PVAssoc fromPV(size_t ipv=0) const
if(conf_.getParameter< bool >("UseStripCablingDB"))
edm::EDGetTokenT< edm::ValueMap< int > > tokenVertexAssociationQuality_
Abs< T >::type abs(const T &t)
bool get(ProductID const &oid, Handle< PROD > &result) const
edm::View< reco::Candidate > CandidateView
std::vector< pat::PackedCandidate > PackedOutputCollection
T const * get() const
Returns C++ pointer to the item.
edm::EDGetTokenT< VertexCollection > tokenVertices_
edm::EDPutTokenT< edm::ValueMap< float > > ptokenPupOut_
std::vector< LorentzVector > LorentzVectorCollection
edm::EDPutTokenT< std::vector< double > > ptokenAlphas_
edm::EDPutTokenT< std::vector< double > > ptokenRawAlphas_
edm::EDGetTokenT< CandidateView > tokenPFCandidates_
edm::Ptr< Candidate > CandidatePtr
persistent reference to an object in a collection of Candidate objects
double pt() const override
transverse momentum
T const * product() const
OrphanHandle< PROD > emplace(EDPutTokenT< PROD > token, Args &&...args)
puts a new product
ParticleType translatePdgIdToType(int pdgid) const
uint fNumOfPUVtxsForCharged
edm::EDPutTokenT< edm::ValueMap< LorentzVector > > ptokenP4PupOut_
Particle reconstructed by the particle flow algorithm.
reco::GsfTrackRef gsfTrackRef() const
edm::EDPutTokenT< std::vector< double > > ptokenAlphasRms_
virtual float dxy() const
dxy with respect to the PV ref