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>
10 
13 
15 
16 template<class algo>
18  public:
19  explicit ElectronIDExternalProducer(const edm::ParameterSet& iConfig) :
20  src_(iConfig.getParameter<edm::InputTag>("src")),
21  select_(iConfig)
22  {
23  produces<edm::ValueMap<float> >();
24  }
25 
27 
28  void produce(edm::Event & iEvent, const edm::EventSetup & iSetup) ;
29 
30  private:
32  algo select_ ;
33 
34 };
35 
36 template<typename algo>
38  // read input collection
40  iEvent.getByLabel(src_, electrons);
41 
42  // initialize common selector
43  select_.newEvent(iEvent, iSetup);
44 
45  // prepare room for output
46  std::vector<float> values; values.reserve(electrons->size());
47  for ( reco::GsfElectronCollection::const_iterator eleIt = electrons->begin () ;
48  eleIt != electrons->end () ;
49  ++eleIt ) {
50  values.push_back( float( select_((*eleIt),iEvent,iSetup) ) );
51  }
52 
53  // fill in the ValueMap
54  std::auto_ptr<edm::ValueMap<float> > out(new edm::ValueMap<float>());
55  edm::ValueMap<float>::Filler filler(*out);
56  filler.insert(electrons, values.begin(), values.end());
57  filler.fill();
58  // and put it into the event
59  iEvent.put(out);
60 
61 }
62 #endif
void produce(edm::Event &iEvent, const edm::EventSetup &iSetup)
void insert(const H &h, I begin, I end)
Definition: ValueMap.h:53
int iEvent
Definition: GenABIO.cc:243
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:84
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:355
tuple out
Definition: dbtoconf.py:99
ElectronIDExternalProducer(const edm::ParameterSet &iConfig)