52 produces<PFOutputCollection>();
53 produces< edm::ValueMap<reco::CandidatePtr> >();
60 std::vector<const reco::Candidate*> phoCands;
61 std::vector<uint16_t> phoIndx;
75 for(
const auto & pho : *pfCol) {
77 if(pho.pt() <
pt_)
continue;
78 if(
std::abs(pho.pdgId())!=22)
continue;
79 if(fabs(pho.eta()) <
eta_ ) {
80 phoIndx.push_back(iC);
81 phoCands.push_back(&pho);
94 bool passObject =
false;
95 if(itPho->isPhoton() &&
usePhotonId_) passObject = (*photonId) [phoCol->
ptrAt(iC)];
96 if(itPho->pt() <
pt_)
continue;
102 if(fabs(ref->eta()) <
eta_ ) {
103 phoIndx.push_back(ref.key());
104 phoCands.push_back(&(*(pfCol->
ptrAt(ref.key()))));
112 if(fabs(ref->eta()) <
eta_ ) {
113 phoIndx.push_back(ref.key());
114 phoCands.push_back(&(*(pfCol->
ptrAt(ref.key()))));
118 for(
const edm::Ref<std::vector<reco::PFCandidate> > & ref : (*reco2pf)[phoCol->
ptrAt(iC)] ) {
119 if(fabs(ref->eta()) <
eta_ ) {
120 phoIndx.push_back(ref.key());
121 phoCands.push_back(&(*(pfCol->
ptrAt(ref.key()))));
133 std::vector<reco::CandidatePtr>
values(hPFProduct->
size());
135 std::vector<float> lWeights;
138 std::set<int> foundPhoIndex;
148 for(std::vector<const reco::Candidate*>::iterator itPho = phoCands.begin(); itPho!=phoCands.end(); itPho++) {
150 if((!
matchPFCandidate(&(*itPF),*itPho))||(foundPhoIndex.count(iPho)!=0))
continue;
152 if(!
useValueMap_ && itPF->pt() != 0) pWeight = pWeight*(phoCands[iPho]->
pt()/itPF->pt());
153 if(!
useValueMap_ && itPF->pt() == 0) pVec.SetPxPyPzE(phoCands[iPho]->px()*pWeight,phoCands[iPho]->py()*pWeight,phoCands[iPho]->pz()*pWeight,phoCands[iPho]->energy()*pWeight);
154 foundPhoIndex.insert(iPho);
158 for(std::vector<uint16_t>::const_iterator itPho = phoIndx.begin(); itPho!=phoIndx.end(); itPho++) {
160 if(pupCol->
refAt(iPF).key() != *itPho)
continue;
162 if(!
useValueMap_ && itPF->pt() != 0) pWeight = pWeight*(phoCands[iPho]->
pt()/itPF->pt());
163 if(!
useValueMap_ && itPF->pt() == 0) pVec.SetPxPyPzE(phoCands[iPho]->px()*pWeight,phoCands[iPho]->py()*pWeight,phoCands[iPho]->pz()*pWeight,phoCands[iPho]->energy()*pWeight);
164 foundPhoIndex.insert(iPho);
167 if(itPF->pt() != 0) pVec.SetPxPyPzE(itPF->px()*pWeight,itPF->py()*pWeight,itPF->pz()*pWeight,itPF->energy()*pWeight);
169 lWeights.push_back(pWeight);
171 puppiP4s.push_back( pVec );
177 for(
unsigned int iPho = 0; iPho < phoCands.size(); iPho++) {
178 if(foundPhoIndex.count(iPho)!=0)
continue;
183 pVec.SetPxPyPzE(phoCands[iPho]->px()*
weight_,phoCands[iPho]->py()*
weight_,phoCands[iPho]->pz()*
weight_,phoCands[iPho]->energy()*
weight_);
186 puppiP4s.push_back( pVec );
191 for(
unsigned int ic=0, nc = pupCol->
size(); ic < nc; ++ic) {
203 if(iPF->
pdgId() != iPho->
pdgId())
return false;
205 for(
unsigned int i0 = 0; i0 <
pdgIds_.size(); i0++) {
std::vector< int32_t > pdgIds_
T getParameter(std::string const &) const
Analysis-level Photon class.
edm::EDGetTokenT< CandidateView > tokenPhotonCandidates_
PuppiPhoton(const edm::ParameterSet &)
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Ptr< value_type > ptrAt(size_type i) const
std::vector< reco::PFCandidate > PFOutputCollection
#define DEFINE_FWK_MODULE(type)
void insert(const H &h, I begin, I end)
edm::RefVector< pat::PackedCandidateCollection > associatedPackedPFCandidates() const
References to PFCandidates linked to this object (e.g. for isolation vetos or masking before jet recl...
void setSourceCandidatePtr(const PFCandidatePtr &ptr)
edm::EDGetTokenT< CandidateView > tokenPuppiCandidates_
std::unique_ptr< PFOutputCollection > corrCandidates_
edm::EDGetTokenT< edm::ValueMap< std::vector< reco::PFCandidateRef > > > reco2pf_
RefToBase< value_type > refAt(size_type i) const
void addDefault(ParameterSetDescription const &psetDescription)
const_iterator begin() const
virtual int pdgId() const =0
PDG identifier.
Abs< T >::type abs(const T &t)
virtual void produce(edm::Event &, const edm::EventSetup &)
bool matchPFCandidate(const reco::Candidate *iPF, const reco::Candidate *iPho)
double deltaR(double eta1, double eta2, double phi1, double phi2)
virtual double eta() const =0
momentum pseudorapidity
T const * product() const
edm::EDGetTokenT< edm::ValueMap< float > > tokenWeights_
Analysis-level electron class.
virtual void setP4(const LorentzVector &p4) final
set 4-momentum
ParticleType translatePdgIdToType(int pdgid) const
std::vector< double > dRMatch_
Particle reconstructed by the particle flow algorithm.
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
edm::EDGetTokenT< edm::ValueMap< bool > > tokenPhotonId_
const_iterator end() const
math::XYZTLorentzVector LorentzVector
edm::EDGetTokenT< CandidateView > tokenPFCandidates_
virtual double phi() const =0
momentum azimuthal angle
edm::RefVector< pat::PackedCandidateCollection > associatedPackedPFCandidates() const
References to PFCandidates linked to this object (e.g. for isolation vetos or masking before jet recl...
std::vector< LorentzVector > LorentzVectorCollection
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)