CMS 3D CMS Logo

PFEGammaToCandidate.cc
Go to the documentation of this file.
1 
22 
24 public:
25  explicit PFEGammaToCandidate(const edm::ParameterSet &iConfig);
26  ~PFEGammaToCandidate() override = default;
27 
28  void produce(edm::StreamID iID, edm::Event &iEvent, const edm::EventSetup &iSetup) const override;
29  static void fillDescriptions(edm::ConfigurationDescriptions &descriptions);
30 
31 private:
35 
36  template <typename T>
37  void run(edm::Event &iEvent,
38  const edm::EDGetTokenT<edm::View<T>> &colltoken,
39  const edm::EDGetTokenT<edm::ValueMap<std::vector<reco::PFCandidateRef>>> &oldmaptoken,
40  const std::string &name) const {
41 
42  edm::Handle<edm::View<T>> collhandle;
43  iEvent.getByToken(colltoken, collhandle);
44 
46  iEvent.getByToken(oldmaptoken, oldmap);
47 
48  auto result = std::make_unique<std::vector<reco::VertexCompositePtrCandidate>>();
49  for (auto const &obj : *collhandle) {
51  for (reco::PFCandidateRef pfRef : (*oldmap)[obj.originalObjectRef()])
52  result->back().addDaughter(refToPtr(pfRef));
53  }
54  iEvent.put(std::move(result), name);
55  }
56 };
57 
59  : photons_(consumes<edm::View<pat::Photon>>(iConfig.getParameter<edm::InputTag>("photons"))),
60  electrons_(consumes<edm::View<pat::Electron>>(iConfig.getParameter<edm::InputTag>("electrons"))),
61  photon2pf_(
62  consumes<edm::ValueMap<std::vector<reco::PFCandidateRef>>>(iConfig.getParameter<edm::InputTag>("photon2pf"))),
63  electron2pf_(consumes<edm::ValueMap<std::vector<reco::PFCandidateRef>>>(
64  iConfig.getParameter<edm::InputTag>("electron2pf"))) {
65  produces<std::vector<reco::VertexCompositePtrCandidate>>("photons");
66  produces<std::vector<reco::VertexCompositePtrCandidate>>("electrons");
67 }
68 
70  run<pat::Photon>(iEvent, photons_, photon2pf_, "photons");
71  run<pat::Electron>(iEvent, electrons_, electron2pf_, "electrons");
72 }
73 
76  desc.add<edm::InputTag>("photons", edm::InputTag("selectedPatPhotons"));
77  desc.add<edm::InputTag>("electrons", edm::InputTag("selectedPatElectrons"));
78  desc.add<edm::InputTag>("photon2pf", edm::InputTag("particleBasedIsolation", "gedPhotons"));
79  desc.add<edm::InputTag>("electron2pf", edm::InputTag("particleBasedIsolation", "gedGsfElectrons"));
80  descriptions.addWithDefaultLabel(desc);
81 }
82 
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:137
Definition: Photon.py:1
Ptr< typename C::value_type > refToPtr(Ref< C, typename C::value_type, refhelper::FindUsingAdvance< C, typename C::value_type > > const &ref)
Definition: RefToPtr.h:18
const edm::EDGetTokenT< edm::ValueMap< std::vector< reco::PFCandidateRef > > > photon2pf_
const edm::EDGetTokenT< edm::ValueMap< std::vector< reco::PFCandidateRef > > > electron2pf_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:579
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
Definition: HeavyIon.h:7
int iEvent
Definition: GenABIO.cc:230
edm::Ref< PFCandidateCollection > PFCandidateRef
persistent reference to a PFCandidate
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void produce(edm::StreamID iID, edm::Event &iEvent, const edm::EventSetup &iSetup) const override
PFEGammaToCandidate(const edm::ParameterSet &iConfig)
fixed size matrix
HLT enums.
void run(edm::Event &iEvent, const edm::EDGetTokenT< edm::View< T >> &colltoken, const edm::EDGetTokenT< edm::ValueMap< std::vector< reco::PFCandidateRef >>> &oldmaptoken, const std::string &name) const
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
~PFEGammaToCandidate() override=default
const edm::EDGetTokenT< edm::View< pat::Photon > > photons_
const edm::EDGetTokenT< edm::View< pat::Electron > > electrons_
def move(src, dest)
Definition: eostools.py:510