44 produces<edm::ValueMap<float> > ();
45 produces<edm::ValueMap<LorentzVector> > ();
46 produces< edm::ValueMap<reco::CandidatePtr> >();
48 if (fUseExistingWeights || fClonePackedCands)
49 produces<pat::PackedCandidateCollection>();
51 produces<reco::PFCandidateCollection>();
54 produces<double> (
"PuppiNAlgos");
55 produces<std::vector<double>> (
"PuppiRawAlphas");
56 produces<std::vector<double>> (
"PuppiAlphas");
57 produces<std::vector<double>> (
"PuppiAlphasMed");
58 produces<std::vector<double>> (
"PuppiAlphasRms");
78 const reco::VertexCollection::const_iterator vtxEnd = pvCol->end();
79 for (reco::VertexCollection::const_iterator vtxIter = pvCol->begin(); vtxEnd != vtxIter; ++vtxIter) {
89 pReco.
pt = itPF->pt();
90 pReco.
eta = itPF->eta();
91 pReco.
phi = itPF->phi();
92 pReco.
m = itPF->mass();
94 pReco.
charge = itPF->charge();
101 if(lPack ==
nullptr ) {
105 int closestVtxForUnassociateds = -9999;
106 for(reco::VertexCollection::const_iterator iV = pvCol->begin(); iV!=pvCol->end(); ++iV) {
113 if(pDZ > -9999) pVtxId = 0;
115 if(iV->trackWeight(pPF->
trackRef())>0) {
120 double tmpdz = 99999;
125 closestVtxForUnassociateds = pVtxId;
132 if (closestVtx !=
nullptr &&
std::abs(pReco.
charge) > 0 && pVtxId > 0) tmpFromPV = 0;
133 if (closestVtx !=
nullptr &&
std::abs(pReco.
charge) > 0 && pVtxId == 0) tmpFromPV = 3;
134 if (closestVtx ==
nullptr &&
std::abs(pReco.
charge) > 0 && closestVtxForUnassociateds == 0) tmpFromPV = 2;
135 if (closestVtx ==
nullptr &&
std::abs(pReco.
charge) > 0 && closestVtxForUnassociateds != 0) tmpFromPV = 1;
141 if (tmpFromPV == 0){ pReco.
id = 2; }
142 if (tmpFromPV == 3){ pReco.
id = 1; }
143 if (tmpFromPV == 1 || tmpFromPV == 2){
161 if (lPack->
fromPV() == 0){ pReco.
id = 2; }
180 std::vector<double> lWeights;
181 std::vector<PuppiCandidate> lCandidates;
192 float curpupweight = -1.;
193 if(lPack ==
nullptr ) {
201 lWeights.push_back(curpupweight);
202 PuppiCandidate curjet( curpupweight*lPack->
px(), curpupweight*lPack->
py(), curpupweight*lPack->
pz(), curpupweight*lPack->
energy());
203 curjet.set_user_index(lPackCtr);
204 lCandidates.push_back(curjet);
212 lPupFiller.
insert(hPFProduct,lWeights.begin(),lWeights.end());
228 std::vector<reco::CandidatePtr>
values(hPFProduct->
size());
230 for (
auto i0 = hPFProduct->
begin(),
231 i0begin = hPFProduct->
begin(),
232 i0end = hPFProduct->
end(); i0 != i0end; ++i0 ) {
233 std::unique_ptr<pat::PackedCandidate> pCand;
234 std::unique_ptr<reco::PFCandidate> pfCand;
246 int val = i0 - i0begin;
249 auto puppiMatched = find_if( lCandidates.begin(), lCandidates.end(), [&
val](
PuppiCandidate const &
i ){
return i.user_index() ==
val; } );
250 if ( puppiMatched != lCandidates.end() ) {
251 pVec.SetPxPyPzE(puppiMatched->px(),puppiMatched->py(),puppiMatched->pz(),puppiMatched->E());
254 pCand->setPuppiWeight(pCand->puppiWeight(),lWeights[puppiMatched-lCandidates.begin()]);
256 pCand->setPuppiWeight(lWeights[puppiMatched-lCandidates.begin()],pCand->puppiWeightNoLep());
259 pVec.SetPxPyPzE( 0, 0, 0, 0);
261 pCand->setPuppiWeight(0,0);
264 puppiP4s.push_back( pVec );
268 pCand->setSourceCandidatePtr( i0->sourceCandidatePtr(0) );
272 pfCand->setSourceCandidatePtr( i0->sourceCandidatePtr(0) );
279 p4PupFiller.
insert(hPFProduct,puppiP4s.begin(), puppiP4s.end() );
286 for(
unsigned int ic=0, nc = oh->size(); ic < nc; ++ic) {
292 for(
unsigned int ic=0, nc = oh->size(); ic < nc; ++ic) {
309 std::unique_ptr<std::vector<double> > theAlphas(
new std::vector<double>(
fPuppiContainer->puppiAlphas()));
310 std::unique_ptr<std::vector<double> > theAlphasMed(
new std::vector<double>(
fPuppiContainer->puppiAlphasMed()));
311 std::unique_ptr<std::vector<double> > theAlphasRms(
new std::vector<double>(
fPuppiContainer->puppiAlphasRMS()));
312 std::unique_ptr<std::vector<double> > alphas(
new std::vector<double>(
fPuppiContainer->puppiRawAlphas()));
313 std::unique_ptr<double> nalgos(
new double(
fPuppiContainer->puppiNAlgos()));
float puppiWeight() const
Set both weights at once (with option for only full PUPPI)
virtual float dz(size_t ipv=0) const
dz with respect to the PV[ipv]
T getParameter(std::string const &) const
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
#define DEFINE_FWK_MODULE(type)
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
void addDefault(ParameterSetDescription const &psetDescription)
const_iterator begin() const
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
const LorentzVector & p4() const final
four-momentum Lorentz vector
void produce(edm::Event &, const edm::EventSetup &) override
PuppiProducer(const edm::ParameterSet &)
T const * product() const
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
ParticleType translatePdgIdToType(int pdgid) const
Particle reconstructed by the particle flow algorithm.
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
reco::GsfTrackRef gsfTrackRef() const
edm::EDGetTokenT< CandidateView > tokenPFCandidates_
const_iterator end() const
virtual float dxy() const
dxy with respect to the PV ref
~PuppiProducer() override
std::unique_ptr< PFOutputCollection > fPuppiCandidates