19 electronsMapName_(_config.getParameter<std::
string>(
"ValueMapElectrons")),
20 photonsMapName_(_config.getParameter<std::
string>(
"ValueMapPhotons"))
28 produces<reco::PFCandidateCollection>();
52 std::vector<reco::PFCandidatePtr> oldPtrs;
53 std::vector<unsigned> pfElectronIndices(inElectronsHandle->size(), -1);
54 std::vector<unsigned> pfPhotonIndices(inPhotonsHandle->size(), -1);
57 for (
auto& inCand : inCandidates) {
58 oldPtrs.emplace_back(inCandidates.ptrAt(iP++));
60 pOutput->emplace_back(inCand);
61 auto& outCand(pOutput->back());
63 auto&& eRef(inCand.gsfElectronRef());
64 if (eRef.isNonnull()) {
67 auto& newSC(*newE.superCluster());
69 pfElectronIndices[newERef.key()] = pOutput->size() - 1;
71 outCand.setGsfElectronRef(newERef);
72 outCand.setSuperClusterRef(newE.superCluster());
73 outCand.setEcalEnergy(newSC.rawEnergy(), newE.ecalEnergy());
78 auto&& phRef(inCand.photonRef());
79 if (phRef.isNonnull()) {
81 auto& newPh(*newPhRef);
82 auto& newSC(*newPh.superCluster());
84 pfPhotonIndices[newPhRef.key()] = pOutput->size() - 1;
86 outCand.setPhotonRef(newPhRef);
87 outCand.setSuperClusterRef(newPh.superCluster());
94 auto&& outCandsHandle(_event.
put(pOutput));
96 std::auto_ptr<PFPtrMap> pPFMap(
new PFPtrMap);
98 pfMapFiller.
insert(outCandsHandle, oldPtrs.begin(), oldPtrs.end());
103 for (
unsigned idx : pfElectronIndices) {
104 if (
idx ==
unsigned(-1))
105 pfElectrons.emplace_back();
107 pfElectrons.emplace_back(outCandsHandle,
idx);
110 std::auto_ptr<PFPtrMap> pEleMap(
new PFPtrMap);
112 eleMapFiller.
insert(inElectronsHandle, pfElectrons.begin(), pfElectrons.end());
116 std::vector<reco::PFCandidatePtr>
pfPhotons;
117 for (
unsigned idx : pfPhotonIndices) {
118 if (
idx ==
unsigned(-1))
119 pfPhotons.emplace_back();
121 pfPhotons.emplace_back(outCandsHandle,
idx);
124 std::auto_ptr<PFPtrMap> pPhoMap(
new PFPtrMap);
126 phoMapFiller.
insert(inPhotonsHandle, pfPhotons.begin(), pfPhotons.end());
edm::Handle< T > getHandle(edm::Event const &_event, edm::EDGetTokenT< T > const &token, std::string const &name)
#define DEFINE_FWK_MODULE(type)
void insert(const H &h, I begin, I end)
void produce(edm::Event &, const edm::EventSetup &) override
std::string electronsMapName_
PFGSFixLinker(const edm::ParameterSet &)
edm::EDGetTokenT< reco::PhotonCollection > inputPhotonsToken_
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
edm::EDGetTokenT< PFCandidateView > inputCandidatesToken_
edm::EDGetTokenT< ElectronRefMap > electronMapToken_
edm::EDGetTokenT< reco::GsfElectronCollection > inputElectronsToken_
void getToken(edm::EDGetTokenT< T > &token, edm::ParameterSet const &pset, std::string const &label)
std::vector< reco::PFCandidate > PFCandidateCollection
collection of PFCandidates
tuple idx
DEBUGGING if hasattr(process,"trackMonIterativeTracking2012"): print "trackMonIterativeTracking2012 D...
std::string photonsMapName_
edm::EDGetTokenT< PhotonRefMap > photonMapToken_