CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
ElectronIDExternalProducer.h
Go to the documentation of this file.
1 #ifndef RecoEgamma_ElectronIdentification_ElectronIDExternalProducer_h
2 #define RecoEgamma_ElectronIdentification_ElectronIDExternalProducer_h
3 
4 #include <memory>
11 
14 
16 
17 template <class algo>
19 public:
21  : srcToken_(consumes<reco::GsfElectronCollection>(iConfig.getParameter<edm::InputTag>("src"))),
22  select_(iConfig, consumesCollector()) {
23  produces<edm::ValueMap<float>>();
24  }
25 
27 
28  void produce(edm::Event& iEvent, const edm::EventSetup& iSetup) override;
29 
30 private:
33 };
34 
35 template <typename algo>
37  // read input collection
39  iEvent.getByToken(srcToken_, electrons);
40 
41  // initialize common selector
42  select_.newEvent(iEvent, iSetup);
43 
44  // prepare room for output
45  std::vector<float> values;
46  values.reserve(electrons->size());
47  for (reco::GsfElectronCollection::const_iterator eleIt = electrons->begin(); eleIt != electrons->end(); ++eleIt) {
48  values.push_back(float(select_((*eleIt), iEvent, iSetup)));
49  }
50 
51  // fill in the ValueMap
52  auto out = std::make_unique<edm::ValueMap<float>>();
54  filler.insert(electrons, values.begin(), values.end());
55  filler.fill();
56  // and put it into the event
57  iEvent.put(std::move(out));
58 }
59 #endif
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
edm::EDGetTokenT< reco::GsfElectronCollection > srcToken_
std::vector< GsfElectron > GsfElectronCollection
collection of GsfElectron objects
int iEvent
Definition: GenABIO.cc:224
def move
Definition: eostools.py:511
ElectronIDExternalProducer(const edm::ParameterSet &iConfig)
void produce(edm::Event &iEvent, const edm::EventSetup &iSetup) override