46 produces<edm::ValueMap<float> > ();
47 produces<edm::ValueMap<LorentzVector> > ();
48 produces< edm::ValueMap<reco::CandidatePtr> >();
50 if (fUseExistingWeights || fClonePackedCands)
51 produces<pat::PackedCandidateCollection>();
53 produces<reco::PFCandidateCollection>();
56 produces<double> (
"PuppiNAlgos");
57 produces<std::vector<double>> (
"PuppiRawAlphas");
58 produces<std::vector<double>> (
"PuppiAlphas");
59 produces<std::vector<double>> (
"PuppiAlphasMed");
60 produces<std::vector<double>> (
"PuppiAlphasRms");
80 const reco::VertexCollection::const_iterator vtxEnd = pvCol->end();
81 for (reco::VertexCollection::const_iterator vtxIter = pvCol->begin(); vtxEnd != vtxIter; ++vtxIter) {
89 for(
auto const& aPF : *pfCol) {
92 pReco.
eta = aPF.eta();
93 pReco.
phi = aPF.phi();
96 pReco.
charge = aPF.charge();
103 if(lPack ==
nullptr ) {
107 int closestVtxForUnassociateds = -9999;
109 for(
auto const& aV : *pvCol) {
112 pDZ = aTrackRef->dz(aV.position());
113 pD0 = aTrackRef->d0();
119 if(pDZ > -9999) pVtxId = 0;
126 double tmpdz = 99999;
127 if ( aTrackRef.
isNonnull() ) tmpdz = aTrackRef ->
dz(aV.position());
131 closestVtxForUnassociateds = pVtxId;
139 if (closestVtx !=
nullptr && pVtxId > 0) tmpFromPV = 0;
140 if (closestVtx !=
nullptr && pVtxId == 0) tmpFromPV = 3;
141 if (closestVtx ==
nullptr && closestVtxForUnassociateds == 0) tmpFromPV = 2;
142 if (closestVtx ==
nullptr && closestVtxForUnassociateds != 0) tmpFromPV = 1;
149 if (tmpFromPV == 0){ pReco.
id = 2; }
150 else if (tmpFromPV == 3){ pReco.
id = 1; }
151 else if (tmpFromPV == 1 || tmpFromPV == 2){
175 if (lPack->
fromPV() == 0){ pReco.
id = 2; }
200 std::vector<double> lWeights;
201 std::vector<PuppiCandidate> lCandidates;
210 for(
auto const& aPF : *pfCol) {
212 float curpupweight = -1.;
213 if(lPack ==
nullptr ) {
221 lWeights.push_back(curpupweight);
222 PuppiCandidate curjet( curpupweight*lPack->
px(), curpupweight*lPack->
py(), curpupweight*lPack->
pz(), curpupweight*lPack->
energy());
223 curjet.set_user_index(lPackCtr);
224 lCandidates.push_back(curjet);
232 lPupFiller.
insert(hPFProduct,lWeights.begin(),lWeights.end());
248 std::vector<reco::CandidatePtr>
values(hPFProduct->
size());
251 for (
auto const& aCand : *hPFProduct) {
253 std::unique_ptr<pat::PackedCandidate> pCand;
254 std::unique_ptr<reco::PFCandidate> pfCand;
269 if ( iPuppiMatched >= 0 ) {
270 auto const& puppiMatched = lCandidates[iPuppiMatched];
271 pVec.SetPxPyPzE(puppiMatched.px(),puppiMatched.py(),puppiMatched.pz(),puppiMatched.E());
274 pCand->setPuppiWeight(pCand->puppiWeight(),lWeights[
val]);
276 pCand->setPuppiWeight(lWeights[val],pCand->puppiWeightNoLep());
279 pVec.SetPxPyPzE( 0, 0, 0, 0);
281 pCand->setPuppiWeight(0,0);
284 puppiP4s.push_back( pVec );
288 pCand->setSourceCandidatePtr( aCand.sourceCandidatePtr(0) );
292 pfCand->setSourceCandidatePtr( aCand.sourceCandidatePtr(0) );
299 p4PupFiller.
insert(hPFProduct,puppiP4s.begin(), puppiP4s.end() );
306 for(
unsigned int ic=0, nc = oh->size(); ic < nc; ++ic) {
312 for(
unsigned int ic=0, nc = oh->size(); ic < nc; ++ic) {
329 std::unique_ptr<std::vector<double> > theAlphas(
new std::vector<double>(
fPuppiContainer->puppiAlphas()));
330 std::unique_ptr<std::vector<double> > theAlphasMed(
new std::vector<double>(
fPuppiContainer->puppiAlphasMed()));
331 std::unique_ptr<std::vector<double> > theAlphasRms(
new std::vector<double>(
fPuppiContainer->puppiAlphasRMS()));
332 std::unique_ptr<std::vector<double> > alphas(
new std::vector<double>(
fPuppiContainer->puppiRawAlphas()));
333 std::unique_ptr<double> nalgos(
new double(
fPuppiContainer->puppiNAlgos()));
353 desc.
add<
bool>(
"puppiDiagnostics",
false);
354 desc.
add<
bool>(
"puppiForLeptons",
false);
355 desc.
add<
bool>(
"UseFromPVLooseTight",
false);
356 desc.
add<
bool>(
"UseDeltaZCut",
true);
357 desc.
add<
double>(
"DeltaZCut", 0.3);
358 desc.
add<
double>(
"PtMaxCharged", 0.);
359 desc.
add<
double>(
"EtaMaxCharged", 99999.);
360 desc.
add<
double>(
"PtMaxNeutrals", 200.);
361 desc.
add<
double>(
"PtMaxNeutralsStartSlope", 0.);
362 desc.
add<
bool>(
"useExistingWeights",
false);
363 desc.
add<
bool>(
"useWeightsNoLep",
false);
364 desc.
add<
bool>(
"clonePackedCands",
false);
365 desc.
add<
int>(
"vtxNdofCut", 4);
366 desc.
add<
double>(
"vtxZCut", 24);
369 desc.
add<
bool>(
"applyCHS",
true);
370 desc.
add<
bool>(
"invertPuppi",
false);
371 desc.
add<
bool>(
"useExp",
false);
372 desc.
add<
double>(
"MinPuppiWeight", .01);
376 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.
double px() const override
x coordinate of momentum vector
float puppiWeightNoLep() const
Weight from full PUPPI.
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
math::XYZTLorentzVector LorentzVector
const reco::VertexRef vertexRef() const
std::unique_ptr< PuppiContainer > fPuppiContainer
double pz() const override
z coordinate of momentum vector
edm::EDGetTokenT< VertexCollection > tokenVertices_
double py() const override
y coordinate of momentum vector
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)
double energy() const override
energy
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
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