CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_5/src/RecoEgamma/ElectronIdentification/plugins/ElectronIDSelector.h

Go to the documentation of this file.
00001 #ifndef ELECTRONIDSELECTOR
00002 #define ELECTRONIDSELECTOR
00003 
00004 #include <memory>
00005 #include "FWCore/Framework/interface/Event.h"
00006 #include "FWCore/Framework/interface/EventSetup.h"
00007 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00008 #include "FWCore/Utilities/interface/InputTag.h"
00009 
00010 #include "DataFormats/EgammaCandidates/interface/GsfElectron.h"
00011 #include "DataFormats/EgammaCandidates/interface/GsfElectronFwd.h"
00012 
00013 template<class algo>
00014 struct ElectronIDSelector{
00015  public:
00016    explicit ElectronIDSelector(const edm::ParameterSet& iConfig) :
00017             select_(iConfig),
00018             threshold_(iConfig.getParameter<double>("threshold")) 
00019    {
00020    }
00021 
00022    virtual ~ElectronIDSelector() {};
00023 
00024    // Collections to be selected
00025    typedef reco::GsfElectronCollection collection;
00026    typedef std::vector<reco::GsfElectronRef> container ; 
00027    //typedef std::vector<reco::GsfElectron> container ; 
00028    typedef container::const_iterator const_iterator;
00029 
00030    //define iterators with above typedef
00031    const_iterator begin () const { return selected_.begin () ; }
00032    const_iterator end () const { return  selected_.end () ; }
00033 
00034    void select(const edm::Handle<reco::GsfElectronCollection>& _electrons, 
00035                const edm::Event& iEvent , 
00036                const edm::EventSetup& iEs)
00037    {
00038      edm::Handle<reco::GsfElectronCollection> electrons = _electrons;
00039      selected_.clear();
00040      select_.newEvent(iEvent, iEs);
00041      // Loop over electrons
00042      unsigned int i = 0 ;
00043      for ( reco::GsfElectronCollection::const_iterator eleIt = electrons->begin () ;
00044                                                        eleIt != electrons->end () ;
00045                                                        ++eleIt )
00046         {
00047          edm::Ref<reco::GsfElectronCollection> electronRef(electrons,i);
00048          if (select_((*eleIt),iEvent,iEs) > threshold_)
00049              selected_.push_back (electronRef) ;
00050              //selected_.push_back ( & * eleIt) ;
00051          ++i;
00052         }
00053    }
00054         
00055  private:       
00056    container selected_ ;
00057    algo select_ ;
00058    double threshold_ ;
00059   
00060 };
00061 
00062 #endif