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>
33  void run(edm::Event & iEvent,
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) {
46  edm::Ref<std::vector<T>> egRef(handle,i);
47  for (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(new edm::ValueMap<std::vector<reco::PFCandidateRef>>());
54  filler.insert(handle, refs.begin(), refs.end());
55  filler.fill();
56  iEvent.put(std::move(out), name);
57  }
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_(consumes<edm::ValueMap<std::vector<reco::PFCandidateRef>>>(iConfig.getParameter<edm::InputTag>("photon2pf"))),
65  electron2pf_(consumes<edm::ValueMap<std::vector<reco::PFCandidateRef>>>(iConfig.getParameter<edm::InputTag>("electron2pf"))),
66  pf2pf_(consumes<edm::ValueMap<reco::PFCandidateRef>>(iConfig.getParameter<edm::InputTag>("pf2pf")))
67 {
68  produces<edm::ValueMap<std::vector<reco::PFCandidateRef>>>("photons");
69  produces<edm::ValueMap<std::vector<reco::PFCandidateRef>>>("electrons");
70 }
71 
72 
73 void
76  iEvent.getByToken(pf2pf_, pf2pf);
77  run<reco::Photon>(iEvent, photons_, photon2pf_, *pf2pf, "photons");
78  run<reco::GsfElectron>(iEvent, electrons_, electron2pf_, *pf2pf, "electrons");
79 }
80 
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:137
edm::EDGetTokenT< std::vector< reco::GsfElectron > > electrons_
Definition: Photon.py:1
void produce(edm::StreamID iID, edm::Event &iEvent, const edm::EventSetup &iSetup) const override
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:579
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
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< edm::ValueMap< reco::PFCandidateRef > > pf2pf_
PFEGammaToCandidateRemapper(const edm::ParameterSet &iConfig)
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
int iEvent
Definition: GenABIO.cc:230
edm::Ref< PFCandidateCollection > PFCandidateRef
persistent reference to a PFCandidate
edm::EDGetTokenT< edm::ValueMap< std::vector< reco::PFCandidateRef > > > electron2pf_
edm::EDGetTokenT< edm::ValueMap< std::vector< reco::PFCandidateRef > > > photon2pf_
edm::EDGetTokenT< std::vector< reco::Photon > > photons_
fixed size matrix
HLT enums.
def move(src, dest)
Definition: eostools.py:510