12 std::vector<edm::InputTag> tags = iConfig.
getParameter<std::vector<edm::InputTag> >(
"PFCandidate");
13 for (
unsigned int i=0;
i<tags.size();++
i)
47 edm::LogError(
"PFLinker") <<
" cannot read several collections of PFCandidates and produce a new collection at the same time. " << std::endl;
50 if(producePFCandidates_) {
56 if(fillMuonRefs_) produces<edm::ValueMap<reco::PFCandidatePtr> > (
muonTag_.
label());
64 auto pfCandidates_p = std::make_unique<reco::PFCandidateCollection>();
69 std::map<reco::GsfElectronRef,reco::PFCandidatePtr> electronCandidateMap;
74 std::map<reco::PhotonRef,reco::PFCandidatePtr> photonCandidateMap;
80 std::map<reco::MuonRef,reco::PFCandidatePtr> muonCandidateMap;
85 for(
unsigned icol=0;icol<nColPF;++icol) {
87 unsigned ncand=pfCandidates->size();
89 for(
unsigned i=0;
i<ncand; ++
i) {
99 if ( !(isphoton || iselectron || hasNonNullMuonRef)){pfCandidates_p->push_back(cand);
continue;}
102 if (hasNonNullMuonRef) {
105 muonCandidateMap[muRef] = candPtr;
113 std::vector<reco::GsfElectron>::const_iterator itcheck=find_if(gsfElectrons->begin(),gsfElectrons->end(),myEqual);
114 if(itcheck==gsfElectrons->end()) {
115 std::ostringstream err;
116 err <<
" Problem in PFLinker: no GsfElectron " << std::endl;
124 cand.
setEcalEnergy(electronRef->superCluster()->rawEnergy(),electronRef->ecalEnergy());
127 electronCandidateMap[electronRef] = candPtr;
134 std::vector<reco::Photon>::const_iterator itcheck=find_if(photons->begin(),photons->end(),myEqual);
135 if(itcheck==photons->end()) {
136 std::ostringstream err;
137 err <<
" Problem in PFLinker: no Photon " << std::endl;
149 photonCandidateMap[photonRef] = candPtr;
152 pfCandidates_p->push_back(cand);
165 electronCandidateMap,
181 pfMapMuons = fillValueMap<reco::MuonCollection>(
iEvent,
188 auto pfMapMerged = std::make_unique<edm::ValueMap<reco::PFCandidatePtr>>();
191 *pfMapMerged += pfMapGsfElectrons;
192 *pfMapMerged += pfMapPhotons;
200 template<
typename TYPE>
207 auto pfMap_p = std::make_unique<edm::ValueMap<reco::PFCandidatePtr>>();
212 unsigned nObj=inputObjCollection->size();
213 std::vector<reco::PFCandidatePtr>
values(nObj);
215 for(
unsigned iobj=0; iobj < nObj; ++iobj) {
218 MapTYPE_it itcheck = mapToTheCandidate.find(objRef);
222 if(itcheck != mapToTheCandidate.end())
225 values[iobj] = candPtr;
228 filler.insert(inputObjCollection,values.begin(),values.end());
T getParameter(std::string const &) const
edm::InputTag muonTag_
Input Muons.
void setDeltaP(double dp)
set uncertainty on momentum
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
bool isNonnull() const
Checks for non-null.
void setGsfElectronRef(const reco::GsfElectronRef &ref)
set GsfElectronRef
edm::EDGetTokenT< reco::MuonCollection > inputTagMuons_
float mva_nothing_gamma() const
mva for gamma detection
bool getByToken(EDGetToken token, Handle< PROD > &result) const
virtual void produce(edm::Event &, const edm::EventSetup &) override
bool producePFCandidates_
Flags - if true: References will be towards new collection ; if false to the original one...
edm::EDGetTokenT< reco::PhotonCollection > inputTagPhotons_
Input Photons.
PFLinker(const edm::ParameterSet &)
edm::ValueMap< reco::PFCandidatePtr > fillValueMap(edm::Event &event, std::string label, edm::Handle< TYPE > &inputObjCollection, const std::map< edm::Ref< TYPE >, reco::PFCandidatePtr > &mapToTheCandidate, const edm::OrphanHandle< reco::PFCandidateCollection > &newPFCandColl) const
edm::EDGetTokenT< reco::MuonToMuonMap > inputTagMuonMap_
std::string nameOutputElectronsPF_
name of output ValueMap electrons
std::string nameOutputPhotonsPF_
name of output ValueMap photons
std::string nameOutputPF_
name of output collection of PFCandidate
reco::MuonRef muonRef() const
void setEcalEnergy(float eeRaw, float eeCorr)
set corrected Ecal energy
bool fillMuonRefs_
Set muon refs and produce the value map?
void setPhotonRef(const reco::PhotonRef &phRef)
set ref to the corresponding reco::Photon if any
virtual void setP4(const LorentzVector &p4) final
set 4-momentum
Particle reconstructed by the particle flow algorithm.
void setMuonRef(const reco::MuonRef &ref)
set muon reference
reco::GsfTrackRef gsfTrackRef() const
void setSuperClusterRef(const reco::SuperClusterRef &scRef)
virtual ParticleType particleId() const
edm::EDGetTokenT< reco::GsfElectronCollection > inputTagGsfElectrons_
Input GsfElectrons.
std::vector< edm::EDGetTokenT< reco::PFCandidateCollection > > inputTagPFCandidates_
Input PFCandidates.
std::string nameOutputMergedPF_
name of output merged ValueMap
reco::SuperClusterRef superClusterRef() const
return a reference to the corresponding SuperCluster if any