CMS 3D CMS Logo

GEDGsfElectronValueMapProducer.cc
Go to the documentation of this file.
9 
11 public:
13  void produce(edm::StreamID, edm::Event&, const edm::EventSetup&) const override;
14  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
15 
16 private:
20 };
21 
23  : electronsToken_(consumes<reco::GsfElectronCollection>(cfg.getParameter<edm::InputTag>("gedGsfElectrons"))),
24  pfCandsToken_(consumes<reco::PFCandidateCollection>(cfg.getParameter<edm::InputTag>("egmPFCandidatesTag"))),
25  putToken_{produces<edm::ValueMap<reco::GsfElectronRef>>()} {}
26 
28  auto electrons = event.getHandle(electronsToken_);
29  auto pfCandidatesHandle = event.getHandle(pfCandsToken_);
30 
31  // ValueMap
34 
35  //Loop over the collection of PFFCandidates
36  std::vector<reco::GsfElectronRef> values;
37 
38  for (auto const& pfCandidate : *pfCandidatesHandle) {
40  // First check that the GsfTrack is non null
41  if (pfCandidate.gsfTrackRef().isNonnull()) {
42  // now look for the corresponding GsfElectron
43  const auto itcheck = std::find_if(electrons->begin(), electrons->end(), [&pfCandidate](const auto& ele) {
44  return (ele.gsfTrack() == pfCandidate.gsfTrackRef());
45  });
46  if (itcheck != electrons->end()) {
47  // Build the Ref from the handle and the index
48  myRef = reco::GsfElectronRef(electrons, itcheck - electrons->begin());
49  }
50  }
51  values.push_back(myRef);
52  }
53  valMapFiller.insert(pfCandidatesHandle, values.begin(), values.end());
54 
55  valMapFiller.fill();
56  event.emplace(putToken_, valMap);
57 }
58 
61  desc.add<edm::InputTag>("gedGsfElectrons", {"gedGsfElectronsTmp"});
62  desc.add<edm::InputTag>("egmPFCandidatesTag", {"particleFlowEGamma"});
63  descriptions.add("gedGsfElectronValueMapsTmp", desc);
64 }
65 
ConfigurationDescriptions.h
edm::StreamID
Definition: StreamID.h:30
edm::helper::Filler::insert
void insert(const H &h, I begin, I end)
Definition: ValueMap.h:53
GEDGsfElectronValueMapProducer::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: GEDGsfElectronValueMapProducer.cc:59
edm::ParameterSetDescription::add
ParameterDescriptionBase * add(U const &iLabel, T const &value)
Definition: ParameterSetDescription.h:95
PFCandidate.h
GEDGsfElectronValueMapProducer
Definition: GEDGsfElectronValueMapProducer.cc:10
edm::EDGetTokenT< reco::GsfElectronCollection >
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::EDPutTokenT
Definition: EDPutToken.h:33
edm::helper::Filler::fill
void fill()
Definition: ValueMap.h:65
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
reco::GsfElectronCollection
std::vector< GsfElectron > GsfElectronCollection
collection of GsfElectron objects
Definition: GsfElectronFwd.h:14
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
singleTopDQM_cfi.setup
setup
Definition: singleTopDQM_cfi.py:37
edm::Ref
Definition: AssociativeIterator.h:58
MakerMacros.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
contentValuesCheck.values
values
Definition: contentValuesCheck.py:38
reco::GsfElectronRef
edm::Ref< GsfElectronCollection > GsfElectronRef
reference to an object in a collection of GsfElectron objects
Definition: GsfElectronFwd.h:21
ParameterSetDescription.h
GsfElectron.h
edm::global::EDProducer
Definition: EDProducer.h:32
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
HLT_2018_cff.InputTag
InputTag
Definition: HLT_2018_cff.py:79016
edm::ParameterSet
Definition: ParameterSet.h:36
Event.h
GEDGsfElectronValueMapProducer::putToken_
const edm::EDPutTokenT< edm::ValueMap< reco::GsfElectronRef > > putToken_
Definition: GEDGsfElectronValueMapProducer.cc:19
edm::EventSetup
Definition: EventSetup.h:57
l1t::PFCandidateCollection
std::vector< l1t::PFCandidate > PFCandidateCollection
Definition: PFCandidate.h:57
looper.cfg
cfg
Definition: looper.py:297
ValueMap.h
pwdgSkimBPark_cfi.electrons
electrons
Definition: pwdgSkimBPark_cfi.py:6
edm::ValueMap
Definition: ValueMap.h:107
GEDGsfElectronValueMapProducer::electronsToken_
const edm::EDGetTokenT< reco::GsfElectronCollection > electronsToken_
Definition: GEDGsfElectronValueMapProducer.cc:17
GEDGsfElectronValueMapProducer::produce
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
Definition: GEDGsfElectronValueMapProducer.cc:27
edm::helper::Filler
Definition: ValueMap.h:22
ParameterSet.h
EDProducer.h
event
Definition: event.py:1
edm::Event
Definition: Event.h:73
edm::InputTag
Definition: InputTag.h:15
GEDGsfElectronValueMapProducer::GEDGsfElectronValueMapProducer
GEDGsfElectronValueMapProducer(const edm::ParameterSet &)
Definition: GEDGsfElectronValueMapProducer.cc:22
GEDGsfElectronValueMapProducer::pfCandsToken_
const edm::EDGetTokenT< reco::PFCandidateCollection > pfCandsToken_
Definition: GEDGsfElectronValueMapProducer.cc:18