49 produces<edm::ValueMap<float> > ();
50 produces<edm::ValueMap<LorentzVector> > ();
51 produces< edm::ValueMap<reco::CandidatePtr> >();
53 if (fUseExistingWeights || fClonePackedCands)
54 produces<pat::PackedCandidateCollection>();
56 produces<reco::PFCandidateCollection>();
59 produces<double> (
"PuppiNAlgos");
60 produces<std::vector<double>> (
"PuppiRawAlphas");
61 produces<std::vector<double>> (
"PuppiAlphas");
62 produces<std::vector<double>> (
"PuppiAlphasMed");
63 produces<std::vector<double>> (
"PuppiAlphasRms");
83 const reco::VertexCollection::const_iterator vtxEnd = pvCol->end();
84 for (reco::VertexCollection::const_iterator vtxIter = pvCol->begin(); vtxEnd != vtxIter; ++vtxIter) {
89 std::vector<double> lWeights;
90 std::vector<PuppiCandidate> lCandidates;
95 for(
auto const& aPF : *pfCol) {
98 pReco.
eta = aPF.eta();
99 pReco.
phi = aPF.phi();
100 pReco.
m = aPF.mass();
102 pReco.
charge = aPF.charge();
108 if(lPack ==
nullptr ) {
112 int closestVtxForUnassociateds = -9999;
115 for(
auto const& aV : *pvCol) {
118 pDZ = aTrackRef->dz(aV.position());
119 pD0 = aTrackRef->d0();
125 if(pDZ > -9999) pVtxId = 0;
132 double tmpdz = 99999;
133 if ( aTrackRef.
isNonnull() ) tmpdz = aTrackRef ->
dz(aV.position());
137 closestVtxForUnassociateds = pVtxId;
145 if (closestVtx !=
nullptr && pVtxId > 0) tmpFromPV = 0;
146 if (closestVtx !=
nullptr && pVtxId == 0) tmpFromPV = 3;
147 if (closestVtx ==
nullptr && closestVtxForUnassociateds == 0) tmpFromPV = 2;
148 if (closestVtx ==
nullptr && closestVtxForUnassociateds != 0) tmpFromPV = 1;
155 if (tmpFromPV == 0) {
160 }
else if (tmpFromPV == 3){ pReco.
id = 1; }
161 else if (tmpFromPV == 1 || tmpFromPV == 2){
185 if (lPack->
fromPV() == 0){
190 if (lPack->
fromPV(puVtx_idx) >= 2) {
227 lWeights.reserve(pfCol->
size());
228 for(
auto const& aPF : *pfCol) {
230 float curpupweight = -1.;
231 if(lPack ==
nullptr ) {
239 lWeights.push_back(curpupweight);
247 lPupFiller.
insert(hPFProduct,lWeights.begin(),lWeights.end());
263 std::vector<reco::CandidatePtr>
values(hPFProduct->
size());
266 puppiP4s.reserve(hPFProduct->
size());
271 for (
auto const& aCand : *hPFProduct) {
273 std::unique_ptr<pat::PackedCandidate> pCand;
274 std::unique_ptr<reco::PFCandidate> pfCand;
288 puppiP4s.emplace_back(lWeights[val]*aCand.px(), lWeights[
val]*aCand.py(), lWeights[
val]*aCand.pz(), lWeights[
val]*aCand.energy());
292 if ( iPuppiMatched >= 0 ) {
293 auto const& puppiMatched = lCandidates[iPuppiMatched];
294 puppiP4s.emplace_back(puppiMatched.px,puppiMatched.py,puppiMatched.pz,puppiMatched.e);
297 pCand->setPuppiWeight(pCand->puppiWeight(),lWeights[
val]);
299 pCand->setPuppiWeight(lWeights[val],pCand->puppiWeightNoLep());
302 puppiP4s.emplace_back( 0, 0, 0, 0);
304 pCand->setPuppiWeight(0,0);
310 pCand->setP4(puppiP4s.back());
311 pCand->setSourceCandidatePtr( aCand.sourceCandidatePtr(0) );
314 pfCand->setP4(puppiP4s.back());
315 pfCand->setSourceCandidatePtr( aCand.sourceCandidatePtr(0) );
322 p4PupFiller.
insert(hPFProduct,puppiP4s.begin(), puppiP4s.end() );
329 for(
unsigned int ic=0, nc = oh->size(); ic < nc; ++ic) {
335 for(
unsigned int ic=0, nc = oh->size(); ic < nc; ++ic) {
352 std::unique_ptr<std::vector<double> > theAlphas(
new std::vector<double>(
fPuppiContainer->puppiAlphas()));
353 std::unique_ptr<std::vector<double> > theAlphasMed(
new std::vector<double>(
fPuppiContainer->puppiAlphasMed()));
354 std::unique_ptr<std::vector<double> > theAlphasRms(
new std::vector<double>(
fPuppiContainer->puppiAlphasRMS()));
355 std::unique_ptr<std::vector<double> > alphas(
new std::vector<double>(
fPuppiContainer->puppiRawAlphas()));
356 std::unique_ptr<double> nalgos(
new double(
fPuppiContainer->puppiNAlgos()));
376 desc.
add<
bool>(
"puppiDiagnostics",
false);
377 desc.
add<
bool>(
"puppiForLeptons",
false);
378 desc.
add<
bool>(
"UseFromPVLooseTight",
false);
379 desc.
add<
bool>(
"UseDeltaZCut",
true);
380 desc.
add<
double>(
"DeltaZCut", 0.3);
381 desc.
add<
double>(
"EtaMinUseDeltaZ", 0.);
382 desc.
add<
double>(
"PtMaxCharged", 0.);
383 desc.
add<
double>(
"EtaMaxCharged", 99999.);
384 desc.
add<
double>(
"PtMaxNeutrals", 200.);
385 desc.
add<
double>(
"PtMaxNeutralsStartSlope", 0.);
386 desc.
add<
uint>(
"NumOfPUVtxsForCharged", 0);
387 desc.
add<
double>(
"DeltaZCutForChargedFromPUVtxs", 0.2);
388 desc.
add<
bool>(
"useExistingWeights",
false);
389 desc.
add<
bool>(
"useWeightsNoLep",
false);
390 desc.
add<
bool>(
"clonePackedCands",
false);
391 desc.
add<
int>(
"vtxNdofCut", 4);
392 desc.
add<
double>(
"vtxZCut", 24);
395 desc.
add<
bool>(
"applyCHS",
true);
396 desc.
add<
bool>(
"invertPuppi",
false);
397 desc.
add<
bool>(
"useExp",
false);
398 desc.
add<
double>(
"MinPuppiWeight", .01);
402 descriptions.
add(
"PuppiProducer", desc);
float puppiWeight() const
virtual float dz(size_t ipv=0) const
dz with respect to the PV[ipv]
T getParameter(std::string const &) const
bool fUseFromPVLooseTight
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
bool isNonnull() const
Checks for non-null.
float puppiWeightNoLep() const
Weight from full PUPPI.
double fDZCutForChargedFromPUVtxs
bool getByToken(EDGetToken token, Handle< PROD > &result) const
std::vector< reco::PFCandidate > PFOutputCollection
static void fillDescriptionsPuppiAlgo(edm::ParameterSetDescription &desc)
void insert(const H &h, I begin, I end)
std::vector< pat::PackedCandidate > PackedOutputCollection
std::vector< RecoObj > fRecoObjCollection
std::vector< Vertex > VertexCollection
collection of Vertex objects
std::vector< LorentzVector > LorentzVectorCollection
const reco::VertexRef vertexRef() const
std::unique_ptr< PuppiContainer > fPuppiContainer
edm::EDGetTokenT< VertexCollection > tokenVertices_
reco::TrackRef trackRef() const
#define DEFINE_FWK_MODULE(type)
const PVAssoc fromPV(size_t ipv=0) const
std::unique_ptr< PackedOutputCollection > fPackedPuppiCandidates
Abs< T >::type abs(const T &t)
void produce(edm::Event &, const edm::EventSetup &) override
ParameterDescriptionBase * add(U const &iLabel, T const &value)
PuppiProducer(const edm::ParameterSet &)
T const * product() const
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
ParticleType translatePdgIdToType(int pdgid) const
uint fNumOfPUVtxsForCharged
Particle reconstructed by the particle flow algorithm.
reco::GsfTrackRef gsfTrackRef() const
edm::EDGetTokenT< CandidateView > tokenPFCandidates_
virtual float dxy() const
dxy with respect to the PV ref
~PuppiProducer() override
std::unique_ptr< PFOutputCollection > fPuppiCandidates