CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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:
20  explicit ElectronIDExternalProducer(const edm::ParameterSet& iConfig) :
21  srcToken_(consumes<reco::GsfElectronCollection>(iConfig.getParameter<edm::InputTag>("src"))),
22  select_(iConfig, consumesCollector())
23  {
24  produces<edm::ValueMap<float> >();
25  }
26 
28 
29  void produce(edm::Event & iEvent, const edm::EventSetup & iSetup) ;
30 
31  private:
33  algo select_ ;
34 
35 };
36 
37 template<typename algo>
39  // read input collection
41  iEvent.getByToken(srcToken_, electrons);
42 
43  // initialize common selector
44  select_.newEvent(iEvent, iSetup);
45 
46  // prepare room for output
47  std::vector<float> values; values.reserve(electrons->size());
48  for ( reco::GsfElectronCollection::const_iterator eleIt = electrons->begin () ;
49  eleIt != electrons->end () ;
50  ++eleIt ) {
51  values.push_back( float( select_((*eleIt),iEvent,iSetup) ) );
52  }
53 
54  // fill in the ValueMap
55  std::auto_ptr<edm::ValueMap<float> > out(new edm::ValueMap<float>());
56  edm::ValueMap<float>::Filler filler(*out);
57  filler.insert(electrons, values.begin(), values.end());
58  filler.fill();
59  // and put it into the event
60  iEvent.put(out);
61 
62 }
63 #endif
void produce(edm::Event &iEvent, const edm::EventSetup &iSetup)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
void insert(const H &h, I begin, I end)
Definition: ValueMap.h:52
edm::EDGetTokenT< reco::GsfElectronCollection > srcToken_
std::vector< GsfElectron > GsfElectronCollection
collection of GsfElectron objects
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
int iEvent
Definition: GenABIO.cc:243
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:116
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
tuple out
Definition: dbtoconf.py:99
ElectronIDExternalProducer(const edm::ParameterSet &iConfig)