130 ptokenValues_ = produces<edm::ValueMap<reco::CandidatePtr>>();
132 if (fUseExistingWeights || fClonePackedCands)
141 ptokenAlphas_ = produces<std::vector<double>>(
"PuppiAlphas");
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) {
305 }
else if (lPack->
fromPV() == 0) {
310 if (lPack->
fromPV(puVtx_idx) >= 2) {
347 for (
auto const& aPF : *pfCol) {
349 float curpupweight = -1.;
350 if (lPack ==
nullptr) {
353 "PuppiProducer: cannot get weights since inputs are not PackedCandidates");
365 lWeights.push_back(curpupweight);
373 lPupFiller.
insert(hPFProduct, lWeights.begin(), lWeights.end());
390 std::vector<reco::CandidatePtr>
values(hPFProduct->size());
393 for (
auto const& aCand : *hPFProduct) {
395 std::unique_ptr<pat::PackedCandidate> pCand;
396 std::unique_ptr<reco::PFCandidate> pfCand;
402 pCand = std::make_unique<pat::PackedCandidate>(*cand);
406 pfCand = std::make_unique<reco::PFCandidate>(cand ? *cand :
reco::PFCandidate(aCand.charge(), aCand.p4(),
id));
412 pCand->setPuppiWeight(pCand->puppiWeight(), lWeights[iCand]);
414 pCand->setPuppiWeight(lWeights[iCand], pCand->puppiWeightNoLep());
417 puppiP4s.emplace_back(lWeights[iCand] * aCand.px(),
418 lWeights[iCand] * aCand.py(),
419 lWeights[iCand] * aCand.pz(),
420 lWeights[iCand] * aCand.energy());
426 pCand->setP4(puppiP4s.back());
427 pCand->setSourceCandidatePtr(aCand.sourceCandidatePtr(0));
428 fPackedPuppiCandidates.push_back(*pCand);
430 pfCand->setP4(puppiP4s.back());
431 pfCand->setSourceCandidatePtr(aCand.sourceCandidatePtr(0));
432 fPuppiCandidates.push_back(*pfCand);
438 p4PupFiller.
insert(hPFProduct, puppiP4s.begin(), puppiP4s.end());
446 for (
unsigned int ic = 0, nc = oh->size(); ic < nc; ++ic) {
452 for (
unsigned int ic = 0, nc = oh->size(); ic < nc; ++ic) {
488 desc.
add<
bool>(
"puppiDiagnostics",
false);
489 desc.
add<
bool>(
"puppiNoLep",
false);
490 desc.
add<
bool>(
"UseFromPVLooseTight",
false);
491 desc.
add<
bool>(
"UseDeltaZCut",
true);
492 desc.
add<
double>(
"DeltaZCut", 0.3);
493 desc.
add<
double>(
"EtaMinUseDeltaZ", 0.);
494 desc.
add<
double>(
"PtMaxCharged", -1.);
495 desc.
add<
double>(
"EtaMaxCharged", 99999.);
496 desc.
add<
double>(
"PtMaxPhotons", -1.);
497 desc.
add<
double>(
"EtaMaxPhotons", 2.5);
498 desc.
add<
double>(
"PtMaxNeutrals", 200.);
499 desc.
add<
double>(
"PtMaxNeutralsStartSlope", 0.);
500 desc.
add<
uint>(
"NumOfPUVtxsForCharged", 0);
501 desc.
add<
double>(
"DeltaZCutForChargedFromPUVtxs", 0.2);
502 desc.
add<
bool>(
"useExistingWeights",
false);
503 desc.
add<
bool>(
"clonePackedCands",
false);
504 desc.
add<
int>(
"vtxNdofCut", 4);
505 desc.
add<
double>(
"vtxZCut", 24);
508 desc.
add<
bool>(
"useVertexAssociation",
false);
509 desc.
add<
int>(
"vertexAssociationQuality", 0);
511 desc.
add<
bool>(
"applyCHS",
true);
512 desc.
add<
bool>(
"invertPuppi",
false);
513 desc.
add<
bool>(
"useExp",
false);
514 desc.
add<
double>(
"MinPuppiWeight", .01);
515 desc.
add<
bool>(
"usePUProxyValue",
false);
520 descriptions.
add(
"PuppiProducer", desc);
float puppiWeight() const
virtual float dz(size_t ipv=0) const
dz with respect to the PV[ipv]
std::vector< reco::PFCandidate > PFInputCollection
bool fUseFromPVLooseTight
edm::EDPutTokenT< pat::PackedCandidateCollection > ptokenPackedPuppiCandidates_
edm::EDPutTokenT< std::vector< double > > ptokenAlphasMed_
bool isNonnull() const
Checks for non-null.
edm::EDGetTokenT< PuppiContainer > tokenPuppiContainer_
float puppiWeightNoLep() const
Weight from full PUPPI.
uint16_t *__restrict__ id
double fDZCutForChargedFromPUVtxs
bool getByToken(EDGetToken token, Handle< PROD > &result) const
#define DEFINE_FWK_MODULE(type)
uint32_t const *__restrict__ Quality * quality
static void fillDescriptionsPuppiAlgo(edm::ParameterSetDescription &desc)
bool fUseVertexAssociation
void insert(const H &h, I begin, I end)
std::vector< RecoObj > fRecoObjCollection
std::vector< Vertex > VertexCollection
collection of Vertex objects
std::vector< LorentzVector > LorentzVectorCollection
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.
math::XYZTLorentzVector LorentzVector
const reco::VertexRef vertexRef() const
std::unique_ptr< PuppiContainer > fPuppiContainer
edm::EDGetTokenT< PFOutputCollection > tokenPuppiCandidates_
edm::EDPutTokenT< edm::ValueMap< reco::CandidatePtr > > ptokenValues_
reco::TrackRef trackRef() const
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
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
void produce(edm::Event &, const edm::EventSetup &) override
std::vector< pat::PackedCandidate > PackedOutputCollection
T const * get() const
Returns C++ pointer to the item.
ParameterDescriptionBase * add(U const &iLabel, T const &value)
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_
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
T const * product() const
OrphanHandle< PROD > emplace(EDPutTokenT< PROD > token, Args &&...args)
puts a new product
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
T getParameter(std::string const &) const
void add(std::string const &label, ParameterSetDescription const &psetDescription)
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::View< reco::PFCandidate > PFView
edm::EDPutTokenT< std::vector< double > > ptokenAlphasRms_
edm::EDGetTokenT< PackedOutputCollection > tokenPackedPuppiCandidates_
virtual float dxy() const
dxy with respect to the PV ref
~PuppiProducer() override