CMS 3D CMS Logo

PFEGammaToCandidateRemapper.cc
Go to the documentation of this file.
1 
18 
20 public:
21  explicit PFEGammaToCandidateRemapper(const edm::ParameterSet &iConfig);
23 
24  void produce(edm::StreamID iID, edm::Event &iEvent, const edm::EventSetup &iSetup) const override;
25 
26 private:
31 
32  template <typename T>
34  const edm::EDGetTokenT<std::vector<T>> &colltoken,
35  const edm::EDGetTokenT<edm::ValueMap<std::vector<reco::PFCandidateRef>>> &oldmaptoken,
37  const std::string &name) const {
39  iEvent.getByToken(colltoken, handle);
40 
42  iEvent.getByToken(oldmaptoken, oldmap);
43 
44  std::vector<std::vector<reco::PFCandidateRef>> refs(handle->size());
45  for (unsigned int i = 0, n = handle->size(); i < n; ++i) {
47  for (const reco::PFCandidateRef &pfRef : (*oldmap)[egRef]) {
48  refs[i].push_back(pf2pf[pfRef]);
49  }
50  }
51 
52  std::unique_ptr<edm::ValueMap<std::vector<reco::PFCandidateRef>>> out(
53  new edm::ValueMap<std::vector<reco::PFCandidateRef>>());
55  filler.insert(handle, refs.begin(), refs.end());
56  filler.fill();
57  iEvent.put(std::move(out), name);
58  }
59 };
60 
62  : photons_(consumes<std::vector<reco::Photon>>(iConfig.getParameter<edm::InputTag>("photons"))),
63  electrons_(consumes<std::vector<reco::GsfElectron>>(iConfig.getParameter<edm::InputTag>("electrons"))),
64  photon2pf_(
65  consumes<edm::ValueMap<std::vector<reco::PFCandidateRef>>>(iConfig.getParameter<edm::InputTag>("photon2pf"))),
66  electron2pf_(consumes<edm::ValueMap<std::vector<reco::PFCandidateRef>>>(
67  iConfig.getParameter<edm::InputTag>("electron2pf"))),
68  pf2pf_(consumes<edm::ValueMap<reco::PFCandidateRef>>(iConfig.getParameter<edm::InputTag>("pf2pf"))) {
69  produces<edm::ValueMap<std::vector<reco::PFCandidateRef>>>("photons");
70  produces<edm::ValueMap<std::vector<reco::PFCandidateRef>>>("electrons");
71 }
72 
75  iEvent.getByToken(pf2pf_, pf2pf);
76  run<reco::Photon>(iEvent, photons_, photon2pf_, *pf2pf, "photons");
77  run<reco::GsfElectron>(iEvent, electrons_, electron2pf_, *pf2pf, "electrons");
78 }
79 
edm::EDGetTokenT< std::vector< reco::GsfElectron > > electrons_
Definition: Photon.py:1
edm::EDGetTokenT< edm::ValueMap< reco::PFCandidateRef > > pf2pf_
PFEGammaToCandidateRemapper(const edm::ParameterSet &iConfig)
void produce(edm::StreamID iID, edm::Event &iEvent, const edm::EventSetup &iSetup) const override
int iEvent
Definition: GenABIO.cc:224
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
edm::EDGetTokenT< edm::ValueMap< std::vector< reco::PFCandidateRef > > > electron2pf_
edm::EDGetTokenT< edm::ValueMap< std::vector< reco::PFCandidateRef > > > photon2pf_
void run(edm::Event &iEvent, const edm::EDGetTokenT< std::vector< T >> &colltoken, const edm::EDGetTokenT< edm::ValueMap< std::vector< reco::PFCandidateRef >>> &oldmaptoken, const edm::ValueMap< reco::PFCandidateRef > &pf2pf, const std::string &name) const
edm::EDGetTokenT< std::vector< reco::Photon > > photons_
fixed size matrix
HLT enums.
edm::Ref< l1t::PFCandidateCollection > PFCandidateRef
Definition: PFCandidate.h:83
def move(src, dest)
Definition: eostools.py:511