167 double puProxyValue = 0.;
171 for (
auto const&
vtx : *pvCol) {
177 std::vector<double> lWeights;
183 for (
auto const& aPF : *pfCol) {
186 pReco.
eta = aPF.eta();
187 pReco.
phi = aPF.phi();
188 pReco.
m = aPF.mass();
190 pReco.
charge = aPF.charge();
191 pReco.
pdgId = aPF.pdgId();
203 closestVtx = PVOrig.
get();
204 pVtxId = PVOrig.
key();
210 else if (closestVtx !=
nullptr && pVtxId == 0)
212 else if (closestVtx !=
nullptr && pVtxId > 0)
216 }
else if (lPack ==
nullptr) {
219 int closestVtxForUnassociateds = -9999;
222 for (
auto const& aV : *pvCol) {
225 pDZ = aTrackRef->dz(aV.position());
226 pD0 = aTrackRef->d0();
240 double tmpdz = 99999;
242 tmpdz = aTrackRef->dz(aV.position());
247 closestVtxForUnassociateds = pVtxId;
254 if (closestVtx !=
nullptr && pVtxId > 0)
256 if (closestVtx !=
nullptr && pVtxId == 0)
258 if (closestVtx ==
nullptr && closestVtxForUnassociateds == 0)
260 if (closestVtx ==
nullptr && closestVtxForUnassociateds != 0)
271 else if (tmpFromPV == 0) {
276 }
else if (tmpFromPV == 3)
278 else if (tmpFromPV == 1 || tmpFromPV == 2) {
307 }
else if (lPack->
fromPV() == 0) {
312 if (lPack->
fromPV(puVtx_idx) >= 2) {
351 lWeights.reserve(pfCol->size());
352 for (
auto const& aPF : *pfCol) {
354 float curpupweight = -1.;
355 if (lPack ==
nullptr) {
358 "PuppiProducer: cannot get weights since inputs are not PackedCandidates");
370 lWeights.push_back(curpupweight);
378 lPupFiller.insert(hPFProduct, lWeights.begin(), lWeights.end());
395 std::vector<reco::CandidatePtr>
values(hPFProduct->
size());
398 puppiP4s.reserve(hPFProduct->
size());
400 fPackedPuppiCandidates.reserve(hPFProduct->
size());
402 fPuppiCandidates.reserve(hPFProduct->
size());
403 for (
auto const& aCand : *hPFProduct) {
405 std::unique_ptr<pat::PackedCandidate> pCand;
406 std::unique_ptr<reco::PFCandidate> pfCand;
412 pCand = std::make_unique<pat::PackedCandidate>(*cand);
422 pCand->setPuppiWeight(pCand->puppiWeight(), lWeights[iCand]);
424 pCand->setPuppiWeight(lWeights[iCand], pCand->puppiWeightNoLep());
427 puppiP4s.emplace_back(lWeights[iCand] * aCand.px(),
428 lWeights[iCand] * aCand.py(),
429 lWeights[iCand] * aCand.pz(),
430 lWeights[iCand] * aCand.energy());
436 pCand->setP4(puppiP4s.back());
437 pCand->setSourceCandidatePtr(aCand.sourceCandidatePtr(0));
438 fPackedPuppiCandidates.push_back(*pCand);
440 pfCand->setP4(puppiP4s.back());
441 pfCand->setSourceCandidatePtr(aCand.sourceCandidatePtr(0));
442 fPuppiCandidates.push_back(*pfCand);
448 p4PupFiller.insert(hPFProduct, puppiP4s.begin(), puppiP4s.end());
456 for (
unsigned int ic = 0, nc = oh->size(); ic < nc; ++ic) {
462 for (
unsigned int ic = 0, nc = oh->size(); ic < nc; ++ic) {
float puppiWeight() const
reco::GsfTrackRef gsfTrackRef() const
bool fUseFromPVLooseTight
float puppiWeightNoLep() const
Weight from full PUPPI.
edm::EDPutTokenT< pat::PackedCandidateCollection > ptokenPackedPuppiCandidates_
edm::EDPutTokenT< std::vector< double > > ptokenAlphasMed_
double fDZCutForChargedFromPUVtxs
T const * product() const
bool fUseVertexAssociation
std::vector< RecoObj > fRecoObjCollection
bool isNonnull() const
Checks for non-null.
std::vector< Vertex > VertexCollection
collection of Vertex objects
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.
const reco::VertexRef vertexRef() const
std::unique_ptr< PuppiContainer > fPuppiContainer
key_type key() const
Accessor for product key.
edm::EDPutTokenT< edm::ValueMap< reco::CandidatePtr > > ptokenValues_
int vertexAssociationQuality_
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)
edm::View< reco::Candidate > CandidateView
std::vector< pat::PackedCandidate > PackedOutputCollection
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
uint fNumOfPUVtxsForCharged
edm::EDPutTokenT< edm::ValueMap< LorentzVector > > ptokenP4PupOut_
Particle reconstructed by the particle flow algorithm.
ParticleType translatePdgIdToType(int pdgid) const
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_
virtual float dz(size_t ipv=0) const
dz with respect to the PV[ipv]