CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
PFEGammaToCandidateRemapper.cc
Go to the documentation of this file.
1 
18 
20 public:
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) {
46  edm::Ref<std::vector<T>> egRef(handle, 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 
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
edm::EDGetTokenT< std::vector< reco::GsfElectron > > electrons_
constexpr char Photon[]
Definition: modules.cc:14
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
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)
void produce(edm::StreamID iID, edm::Event &iEvent, const edm::EventSetup &iSetup) const override
int iEvent
Definition: GenABIO.cc:224
def move
Definition: eostools.py:511
tuple handle
Definition: patZpeak.py:23
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_
edm::Ref< l1t::PFCandidateCollection > PFCandidateRef
Definition: PFCandidate.h:58