12 std::vector<edm::InputTag> tags = iConfig.
getParameter<std::vector<edm::InputTag> >(
"PFCandidate");
13 for (
unsigned int i=0;
i<tags.size();++
i)
50 edm::LogError(
"PFLinker") <<
" cannot read several collections of PFCandidates and produce a new collection at the same time. " << std::endl;
53 if(producePFCandidates_) {
59 if(fillMuonRefs_) produces<edm::ValueMap<reco::PFCandidatePtr> > (
muonTag_.
label());
67 auto pfCandidates_p = std::make_unique<reco::PFCandidateCollection>();
72 std::map<reco::GsfElectronRef,reco::PFCandidatePtr> electronCandidateMap;
77 std::map<reco::PhotonRef,reco::PFCandidatePtr> photonCandidateMap;
83 std::map<reco::MuonRef,reco::PFCandidatePtr> muonCandidateMap;
88 for(
unsigned icol=0;icol<nColPF;++icol) {
90 unsigned ncand=pfCandidates->size();
92 for(
unsigned i=0;
i<ncand; ++
i) {
102 if ( !(isphoton || iselectron || hasNonNullMuonRef)){pfCandidates_p->push_back(cand);
continue;}
105 if (hasNonNullMuonRef) {
108 muonCandidateMap[muRef] = candPtr;
116 std::vector<reco::GsfElectron>::const_iterator itcheck=find_if(gsfElectrons->begin(),gsfElectrons->end(),myEqual);
117 if(itcheck==gsfElectrons->end()) {
119 std::ostringstream err;
120 err <<
" Problem in PFLinker: no GsfElectron " << std::endl;
124 <<
"Forcing an electron pfCandidate at: " << cand.
eta()
125 <<
" in HGCAL" << std::endl;
126 pfCandidates_p->push_back(cand);
134 cand.
setEcalEnergy(electronRef->superCluster()->rawEnergy(),electronRef->ecalEnergy());
137 electronCandidateMap[electronRef] = candPtr;
144 std::vector<reco::Photon>::const_iterator itcheck=find_if(photons->begin(),photons->end(),myEqual);
145 if(itcheck==photons->end()) {
146 std::ostringstream err;
147 err <<
" Problem in PFLinker: no Photon " << std::endl;
159 photonCandidateMap[photonRef] = candPtr;
162 pfCandidates_p->push_back(cand);
175 electronCandidateMap,
191 pfMapMuons = fillValueMap<reco::MuonCollection>(
iEvent,
198 auto pfMapMerged = std::make_unique<edm::ValueMap<reco::PFCandidatePtr>>();
201 *pfMapMerged += pfMapGsfElectrons;
202 *pfMapMerged += pfMapPhotons;
210 template<
typename TYPE>
217 auto pfMap_p = std::make_unique<edm::ValueMap<reco::PFCandidatePtr>>();
222 unsigned nObj=inputObjCollection->size();
223 std::vector<reco::PFCandidatePtr>
values(nObj);
225 for(
unsigned iobj=0; iobj < nObj; ++iobj) {
228 MapTYPE_it itcheck = mapToTheCandidate.find(objRef);
232 if(itcheck != mapToTheCandidate.end())
235 values[iobj] = candPtr;
238 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
virtual double eta() const final
momentum pseudorapidity
bool getByToken(EDGetToken token, Handle< PROD > &result) const
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
bool forceElectronsInHGCAL_
Put Electrons within HGCAL coming from SimPFProducer.
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