CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_1/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(edm::Handle<reco::GsfElectronCollection> electrons, 
00035                const edm::Event& iEvent , 
00036                const edm::EventSetup& iEs)
00037    {
00038      selected_.clear();
00039      select_.newEvent(iEvent, iEs);
00040      // Loop over electrons
00041      unsigned int i = 0 ;
00042      for ( reco::GsfElectronCollection::const_iterator eleIt = electrons->begin () ;
00043                                                        eleIt != electrons->end () ;
00044                                                        ++eleIt )
00045         {
00046          edm::Ref<reco::GsfElectronCollection> electronRef(electrons,i);
00047          if (select_((*eleIt),iEvent,iEs) > threshold_)
00048              selected_.push_back (electronRef) ;
00049              //selected_.push_back ( & * eleIt) ;
00050          ++i;
00051         }
00052    }
00053         
00054  private:       
00055    container selected_ ;
00056    algo select_ ;
00057    double threshold_ ;
00058   
00059 };
00060 
00061 #endif