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) {
87 for(
auto const& aPF : *pfCol) {
90 pReco.
eta = aPF.eta();
91 pReco.
phi = aPF.phi();
94 pReco.
charge = aPF.charge();
101 if(lPack ==
nullptr ) {
105 int closestVtxForUnassociateds = -9999;
107 for(
auto const& aV : *pvCol) {
110 pDZ = aTrackRef->dz(aV.position());
111 pD0 = aTrackRef->d0();
117 if(pDZ > -9999) pVtxId = 0;
124 double tmpdz = 99999;
125 if ( aTrackRef.
isNonnull() ) tmpdz = aTrackRef ->
dz(aV.position());
129 closestVtxForUnassociateds = pVtxId;
137 if (closestVtx !=
nullptr && pVtxId > 0) tmpFromPV = 0;
138 if (closestVtx !=
nullptr && pVtxId == 0) tmpFromPV = 3;
139 if (closestVtx ==
nullptr && closestVtxForUnassociateds == 0) tmpFromPV = 2;
140 if (closestVtx ==
nullptr && closestVtxForUnassociateds != 0) tmpFromPV = 1;
147 if (tmpFromPV == 0){ pReco.
id = 2; }
148 if (tmpFromPV == 3){ pReco.
id = 1; }
149 if (tmpFromPV == 1 || tmpFromPV == 2){
167 if (lPack->
fromPV() == 0){ pReco.
id = 2; }
186 std::vector<double> lWeights;
187 std::vector<PuppiCandidate> lCandidates;
196 for(
auto const& aPF : *pfCol) {
198 float curpupweight = -1.;
199 if(lPack ==
nullptr ) {
207 lWeights.push_back(curpupweight);
208 PuppiCandidate curjet( curpupweight*lPack->
px(), curpupweight*lPack->
py(), curpupweight*lPack->
pz(), curpupweight*lPack->
energy());
209 curjet.set_user_index(lPackCtr);
210 lCandidates.push_back(curjet);
218 lPupFiller.
insert(hPFProduct,lWeights.begin(),lWeights.end());
234 std::vector<reco::CandidatePtr>
values(hPFProduct->
size());
237 for (
auto const& aCand : *hPFProduct) {
239 std::unique_ptr<pat::PackedCandidate> pCand;
240 std::unique_ptr<reco::PFCandidate> pfCand;
255 if ( iPuppiMatched >= 0 ) {
256 auto const& puppiMatched = lCandidates[iPuppiMatched];
257 pVec.SetPxPyPzE(puppiMatched.px(),puppiMatched.py(),puppiMatched.pz(),puppiMatched.E());
260 pCand->setPuppiWeight(pCand->puppiWeight(),lWeights[iPuppiMatched]);
262 pCand->setPuppiWeight(lWeights[iPuppiMatched],pCand->puppiWeightNoLep());
265 pVec.SetPxPyPzE( 0, 0, 0, 0);
267 pCand->setPuppiWeight(0,0);
270 puppiP4s.push_back( pVec );
274 pCand->setSourceCandidatePtr( aCand.sourceCandidatePtr(0) );
278 pfCand->setSourceCandidatePtr( aCand.sourceCandidatePtr(0) );
285 p4PupFiller.
insert(hPFProduct,puppiP4s.begin(), puppiP4s.end() );
292 for(
unsigned int ic=0, nc = oh->size(); ic < nc; ++ic) {
298 for(
unsigned int ic=0, nc = oh->size(); ic < nc; ++ic) {
315 std::unique_ptr<std::vector<double> > theAlphas(
new std::vector<double>(
fPuppiContainer->puppiAlphas()));
316 std::unique_ptr<std::vector<double> > theAlphasMed(
new std::vector<double>(
fPuppiContainer->puppiAlphasMed()));
317 std::unique_ptr<std::vector<double> > theAlphasRms(
new std::vector<double>(
fPuppiContainer->puppiAlphasRMS()));
318 std::unique_ptr<std::vector<double> > alphas(
new std::vector<double>(
fPuppiContainer->puppiRawAlphas()));
319 std::unique_ptr<double> nalgos(
new double(
fPuppiContainer->puppiNAlgos()));
float puppiWeight() const
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
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)
void addDefault(ParameterSetDescription const &psetDescription)
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
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.
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