25 #include "fastjet/PseudoJet.hh"
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) {
94 pReco.
pt = itPF->pt();
95 pReco.
eta = itPF->eta();
96 pReco.
phi = itPF->phi();
97 pReco.
m = itPF->mass();
99 pReco.
charge = itPF->charge();
110 int closestVtxForUnassociateds = -9999;
111 for(reco::VertexCollection::const_iterator iV = pvCol->begin(); iV!=pvCol->end(); ++iV) {
118 if(pDZ > -9999) pVtxId = 0;
120 if(iV->trackWeight(pPF->
trackRef())>0) {
125 double tmpdz = 99999;
128 if (fabs(tmpdz) < curdz){
130 closestVtxForUnassociateds = pVtxId;
137 if (closestVtx != 0 && fabs(pReco.
charge) > 0 && pVtxId > 0) tmpFromPV = 0;
138 if (closestVtx != 0 && fabs(pReco.
charge) > 0 && pVtxId == 0) tmpFromPV = 3;
139 if (closestVtx == 0 && fabs(pReco.
charge) > 0 && closestVtxForUnassociateds == 0) tmpFromPV = 2;
140 if (closestVtx == 0 && fabs(pReco.
charge) > 0 && closestVtxForUnassociateds != 0) tmpFromPV = 1;
144 if (fabs(pReco.
charge) == 0){ pReco.
id = 0; }
146 if (tmpFromPV == 0){ pReco.
id = 2; }
147 if (tmpFromPV == 3){ pReco.
id = 1; }
148 if (tmpFromPV == 1 || tmpFromPV == 2){
165 if (fabs(pReco.
charge) == 0){ pReco.
id = 0; }
166 if (fabs(pReco.
charge) > 0){
167 if (lPack->
fromPV() == 0){ pReco.
id = 2; }
186 std::vector<double> lWeights;
187 std::vector<fastjet::PseudoJet> lCandidates;
198 float curpupweight = -1.;
208 lWeights.push_back(curpupweight);
209 fastjet::PseudoJet curjet( curpupweight*lPack->
px(), curpupweight*lPack->
py(), curpupweight*lPack->
pz(), curpupweight*lPack->
energy());
210 curjet.set_user_index(lPackCtr);
211 lCandidates.push_back(curjet);
219 lPupFiller.
insert(hPFProduct,lWeights.begin(),lWeights.end());
235 std::vector<reco::CandidatePtr>
values(hPFProduct->size());
237 for (
auto i0 = hPFProduct->begin(),
238 i0begin = hPFProduct->begin(),
239 i0end = hPFProduct->end(); i0 != i0end; ++i0 ) {
240 std::unique_ptr<pat::PackedCandidate> pCand;
241 std::unique_ptr<reco::PFCandidate> pfCand;
253 int val = i0 - i0begin;
256 auto puppiMatched = find_if( lCandidates.begin(), lCandidates.end(), [&val]( fastjet::PseudoJet
const &
i ){
return i.user_index() == val; } );
257 if ( puppiMatched != lCandidates.end() ) {
258 pVec.SetPxPyPzE(puppiMatched->px(),puppiMatched->py(),puppiMatched->pz(),puppiMatched->E());
260 pVec.SetPxPyPzE( 0, 0, 0, 0);
262 puppiP4s.push_back( pVec );
266 pCand->setSourceCandidatePtr( i0->sourceCandidatePtr(0) );
270 pfCand->setSourceCandidatePtr( i0->sourceCandidatePtr(0) );
277 p4PupFiller.
insert(hPFProduct,puppiP4s.begin(), puppiP4s.end() );
281 iEvent.
put(p4PupOut);
284 for(
unsigned int ic=0, nc = oh->size(); ic < nc; ++ic) {
290 for(
unsigned int ic=0, nc = oh->size(); ic < nc; ++ic) {
307 std::auto_ptr<std::vector<double> > theAlphas(
new std::vector<double>(
fPuppiContainer->puppiAlphas()));
308 std::auto_ptr<std::vector<double> > theAlphasMed(
new std::vector<double>(
fPuppiContainer->puppiAlphasMed()));
309 std::auto_ptr<std::vector<double> > theAlphasRms(
new std::vector<double>(
fPuppiContainer->puppiAlphasRMS()));
310 std::auto_ptr<std::vector<double> > alphas(
new std::vector<double>(
fPuppiContainer->puppiRawAlphas()));
311 std::auto_ptr<double> nalgos(
new double(
fPuppiContainer->puppiNAlgos()));
313 iEvent.
put(alphas,
"PuppiRawAlphas");
314 iEvent.
put(nalgos,
"PuppiNAlgos");
315 iEvent.
put(theAlphas,
"PuppiAlphas");
316 iEvent.
put(theAlphasMed,
"PuppiAlphasMed");
317 iEvent.
put(theAlphasRms,
"PuppiAlphasRms");
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
virtual void produce(edm::Event &, const edm::EventSetup &)
bool isNonnull() const
Checks for non-null.
std::auto_ptr< PackedOutputCollection > fPackedPuppiCandidates
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
edm::EDGetTokenT< VertexCollection > tokenVertices_
reco::TrackRef trackRef() const
void addDefault(ParameterSetDescription const &psetDescription)
const_iterator begin() const
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
const PVAssoc fromPV(size_t ipv=0) const
virtual double py() const
y coordinate of momentum vector
virtual double energy() const
energy
PuppiProducer(const edm::ParameterSet &)
virtual void beginRun(edm::Run &, edm::EventSetup const &)
virtual void endLuminosityBlock(edm::LuminosityBlock &, edm::EventSetup const &)
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_
std::auto_ptr< PFOutputCollection > fPuppiCandidates
const_iterator end() const
virtual void endRun(edm::Run &, edm::EventSetup const &)
virtual double px() const
x coordinate of momentum vector
virtual void beginLuminosityBlock(edm::LuminosityBlock &, edm::EventSetup const &)
virtual float dxy() const
dxy with respect to the PV ref
virtual double pz() const
z coordinate of momentum vector
virtual const LorentzVector & p4() const final
four-momentum Lorentz vector