CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PFEGFootprintGSFixLinker.cc
Go to the documentation of this file.
2 
4 
8 
11 
13 
15 
17 
19  electronsMapName_(_config.getParameter<std::string>("ValueMapElectrons")),
20  photonsMapName_(_config.getParameter<std::string>("ValueMapPhotons"))
21 {
22  getToken(newCandidatesToken_, _config, "PFCandidate");
23  getToken(newElectronsToken_, _config, "GsfElectrons");
24  getToken(newPhotonsToken_, _config, "Photons");
25  getToken(electronMapToken_, _config, "GsfElectrons");
26  getToken(photonMapToken_, _config, "Photons");
27  getToken(electronFootprintMapToken_, _config, "GsfElectronsFootprint");
28  getToken(photonFootprintMapToken_, _config, "PhotonsFootprint");
29 
30  // e/g collections to footprint PFs
31  produces<FootprintMap>(electronsMapName_);
32  produces<FootprintMap>(photonsMapName_);
33 }
34 
36 {
37 }
38 
39 void
41 {
42  auto&& newCandidatesHandle(getHandle(_event, newCandidatesToken_, "PFCandidate"));
43  auto&& newElectronsHandle(getHandle(_event, newElectronsToken_, "GsfElectrons"));
44  auto& electronMap(*getHandle(_event, electronMapToken_, "GsfElectronsMap"));
45  auto&& newPhotonsHandle(getHandle(_event, newPhotonsToken_, "Photons"));
46  auto& photonMap(*getHandle(_event, photonMapToken_, "PhotonsMap"));
47  auto& electronFootprintMap(*getHandle(_event, electronFootprintMapToken_, "GsfElectronsFootprint"));
48  auto& photonFootprintMap(*getHandle(_event, photonFootprintMapToken_, "PhotonsFootprint"));
49 
50  std::vector<Footprint> electronFootprints;
51 
52  for (unsigned iE(0); iE != newElectronsHandle->size(); ++iE) {
53  electronFootprints.emplace_back();
54  auto& footprint(electronFootprints.back());
55 
56  reco::GsfElectronRef ref(newElectronsHandle, iE);
57  auto& oldEleRef(electronMap[ref]);
58  auto& oldFootprint(electronFootprintMap[oldEleRef]);
59  // relying on PFGSFixLinker producing PF candidates in the same order
60  for (auto& pfref : oldFootprint)
61  footprint.emplace_back(newCandidatesHandle, pfref.key());
62  }
63 
64  std::auto_ptr<FootprintMap> pEleFPMap(new FootprintMap);
65  FootprintMap::Filler eleFPMapFiller(*pEleFPMap);
66  eleFPMapFiller.insert(newElectronsHandle, electronFootprints.begin(), electronFootprints.end());
67  eleFPMapFiller.fill();
68  _event.put(pEleFPMap, electronsMapName_);
69 
70  std::vector<Footprint> photonFootprints;
71 
72  for (unsigned iE(0); iE != newPhotonsHandle->size(); ++iE) {
73  photonFootprints.emplace_back();
74  auto& footprint(photonFootprints.back());
75 
76  reco::PhotonRef ref(newPhotonsHandle, iE);
77  auto& oldPhoRef(photonMap[ref]);
78  auto& oldFootprint(photonFootprintMap[oldPhoRef]);
79  // relying on PFGSFixLinker producing PF candidates in the same order
80  for (auto& pfref : oldFootprint)
81  footprint.emplace_back(newCandidatesHandle, pfref.key());
82  }
83 
84  std::auto_ptr<FootprintMap> pPhoFPMap(new FootprintMap);
85  FootprintMap::Filler phoFPMapFiller(*pPhoFPMap);
86  phoFPMapFiller.insert(newPhotonsHandle, photonFootprints.begin(), photonFootprints.end());
87  phoFPMapFiller.fill();
88  _event.put(pPhoFPMap, photonsMapName_);
89 }
90 
edm::EDGetTokenT< reco::PhotonCollection > newPhotonsToken_
edm::Handle< T > getHandle(edm::Event const &_event, edm::EDGetTokenT< T > const &token, std::string const &name)
edm::EDGetTokenT< FootprintMap > photonFootprintMapToken_
void produce(edm::Event &, const edm::EventSetup &) override
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
edm::EDGetTokenT< ElectronRefMap > electronMapToken_
void insert(const H &h, I begin, I end)
Definition: ValueMap.h:52
edm::EDGetTokenT< PhotonRefMap > photonMapToken_
edm::EDGetTokenT< reco::GsfElectronCollection > newElectronsToken_
edm::EDGetTokenT< FootprintMap > electronFootprintMapToken_
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:121
void getToken(edm::EDGetTokenT< T > &token, edm::ParameterSet const &pset, std::string const &label)
edm::EDGetTokenT< reco::PFCandidateCollection > newCandidatesToken_
edm::ValueMap< reco::PFCandidatePtr > PFPtrMap
PFEGFootprintGSFixLinker(const edm::ParameterSet &)