File indexing completed on 2024-09-07 04:37:30
0001 #ifndef ELECTRONIDSELECTOR
0002 #define ELECTRONIDSELECTOR
0003
0004 #include <memory>
0005 #include "FWCore/Framework/interface/Event.h"
0006 #include "FWCore/Framework/interface/EventSetup.h"
0007 #include "FWCore/Framework/interface/ConsumesCollector.h"
0008 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0009 #include "FWCore/Utilities/interface/InputTag.h"
0010
0011 #include "DataFormats/EgammaCandidates/interface/GsfElectron.h"
0012 #include "DataFormats/EgammaCandidates/interface/GsfElectronFwd.h"
0013
0014 template <class algo>
0015 struct ElectronIDSelector {
0016 public:
0017 explicit ElectronIDSelector(const edm::ParameterSet& iConfig, edm::ConsumesCollector&& iC)
0018 : select_(iConfig, iC), threshold_(iConfig.getParameter<double>("threshold")) {}
0019
0020 virtual ~ElectronIDSelector() {}
0021
0022
0023 typedef reco::GsfElectronCollection collection;
0024 typedef std::vector<reco::GsfElectronRef> container;
0025
0026 typedef container::const_iterator const_iterator;
0027
0028
0029 const_iterator begin() const { return selected_.begin(); }
0030 const_iterator end() const { return selected_.end(); }
0031
0032 void select(const edm::Handle<reco::GsfElectronCollection>& _electrons,
0033 const edm::Event& iEvent,
0034 const edm::EventSetup& iEs) {
0035 const edm::Handle<reco::GsfElectronCollection>& electrons = _electrons;
0036 selected_.clear();
0037 select_.newEvent(iEvent, iEs);
0038
0039 unsigned int i = 0;
0040 for (reco::GsfElectronCollection::const_iterator eleIt = electrons->begin(); eleIt != electrons->end(); ++eleIt) {
0041 edm::Ref<reco::GsfElectronCollection> electronRef(electrons, i);
0042 if (select_((*eleIt), iEvent, iEs) > threshold_)
0043 selected_.push_back(electronRef);
0044
0045 ++i;
0046 }
0047 }
0048
0049 private:
0050 container selected_;
0051 algo select_;
0052 double threshold_;
0053 };
0054
0055 #endif