CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_2_7_hltpatch2/src/Validation/RecoTau/plugins/Selectors.cc

Go to the documentation of this file.
00001 #include "FWCore/PluginManager/interface/ModuleDef.h"
00002 #include "FWCore/Framework/interface/MakerMacros.h"
00003 
00004 // system include files
00005 #include <memory>
00006 
00007 // user include files
00008 #include "FWCore/Framework/interface/Frameworkfwd.h"
00009 #include "FWCore/Framework/interface/EDFilter.h"
00010 
00011 #include "FWCore/Framework/interface/Event.h"
00012 #include "FWCore/Framework/interface/MakerMacros.h"
00013 
00014 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00015 
00016  
00017 #include "DataFormats/Common/interface/RefVector.h"
00018  
00019 #include "CommonTools/UtilAlgos/interface/StringCutObjectSelector.h"
00020 #include "CommonTools/UtilAlgos/interface/SingleObjectSelector.h"
00021 #include "CommonTools/UtilAlgos/interface/SingleElementCollectionSelector.h"
00022 #include "CommonTools/UtilAlgos/interface/ObjectCountFilter.h"
00023 
00024 #include "DataFormats/JetReco/interface/PFJet.h"
00025 #include "DataFormats/JetReco/interface/PFJetCollection.h"
00026 
00027 #include "DataFormats/JetReco/interface/Jet.h"
00028 #include "DataFormats/JetReco/interface/JetCollection.h"
00029 
00030 #include "DataFormats/MuonReco/interface/Muon.h"
00031 #include "DataFormats/MuonReco/interface/MuonFwd.h"
00032 
00033 #include "DataFormats/EgammaCandidates/interface/GsfElectron.h"
00034 #include "DataFormats/EgammaCandidates/interface/GsfElectronFwd.h"
00035 
00036 #include "DataFormats/HepMCCandidate/interface/GenParticle.h"
00037 #include "DataFormats/HepMCCandidate/interface/GenParticleFwd.h"
00038 
00039 #include <vector>
00040 #include <iostream>
00041 
00042 typedef SingleObjectSelector< std::vector<reco::Jet>        , StringCutObjectSelector<reco::Jet>            >   TauValJetSelector     ;
00043 typedef SingleObjectSelector< reco::MuonCollection          , StringCutObjectSelector<reco::Muon>           >   TauValMuonSelector    ;
00044 typedef SingleObjectSelector< reco::GenParticleCollection   , StringCutObjectSelector<reco::GenParticle>    >   TauValGenPSelector    ;
00045 typedef SingleObjectSelector< reco::GenParticleRefVector    , StringCutObjectSelector<reco::GenParticleRef> >   TauValGenPRefSelector ;
00046 typedef SingleObjectSelector< reco::PFJetCollection         , StringCutObjectSelector<reco::PFJet>          >   TauValPFJetSelector   ;
00047 typedef SingleObjectSelector< edm::View<reco::GsfElectron>  , StringCutObjectSelector<reco::GsfElectron>, reco::GsfElectronCollection > TauValElectronSelector;
00048 
00049 DEFINE_FWK_MODULE( TauValPFJetSelector );
00050 DEFINE_FWK_MODULE( TauValJetSelector );
00051 DEFINE_FWK_MODULE( TauValMuonSelector );
00052 DEFINE_FWK_MODULE( TauValElectronSelector );
00053 DEFINE_FWK_MODULE( TauValGenPSelector );
00054 DEFINE_FWK_MODULE( TauValGenPRefSelector );
00055 
00056 class ElectronIdFilter : public edm::EDFilter {
00057 public:
00058   explicit ElectronIdFilter(const edm::ParameterSet&);
00059   ~ElectronIdFilter();
00060 
00061 private:
00062   virtual void beginJob() ;
00063   virtual bool filter(edm::Event&, const edm::EventSetup&);
00064   virtual void endJob() ;
00065       
00066   edm::InputTag src_, eidsrc_;
00067   int eid_; 
00068   // ----------member data ---------------------------
00069 };
00070 
00071 ElectronIdFilter::ElectronIdFilter(const edm::ParameterSet& iConfig):
00072   src_(iConfig.getParameter<edm::InputTag>("src")),
00073   eidsrc_(iConfig.getParameter<edm::InputTag>("eidsrc")),
00074   eid_(iConfig.getParameter<int>("eid"))
00075 {
00076   produces< reco::GsfElectronCollection >();
00077 }
00078 ElectronIdFilter::~ElectronIdFilter()
00079 {
00080 }
00081 // ------------ method called to produce the data  ------------
00082 
00083 bool
00084 ElectronIdFilter::filter(edm::Event& iEvent, const edm::EventSetup& iSetup)
00085 {
00086   //cout << "NonVertexingLeptonFilter:: entering filter" << endl;
00087   using namespace reco;
00088   using namespace std;
00089   
00090   edm::Handle<GsfElectronCollection> electrons;
00091   iEvent.getByLabel(src_,electrons);
00092   
00093   edm::Handle<edm::ValueMap<float> > eIDValueMap;
00094   iEvent.getByLabel(eidsrc_, eIDValueMap);
00095   const edm::ValueMap<float> & eIDmap = * eIDValueMap;
00096   GsfElectronCollection *product = new GsfElectronCollection();
00097 
00098   // Loop over electrons
00099   for (unsigned int i = 0; i < electrons->size(); i++){
00100     edm::Ref<reco::GsfElectronCollection> electronRef(electrons,i);
00101     if((eIDmap[electronRef]) == eid_)
00102       product->push_back((*electrons)[i]);
00103   }
00104 
00105   //cout << "Putting in the event" << endl;
00106   std::auto_ptr<GsfElectronCollection> collection(product);
00107   iEvent.put(collection);
00108   return true;
00109 }
00110 
00111 void 
00112 ElectronIdFilter::beginJob() {
00113 }
00114 void 
00115 ElectronIdFilter::endJob() {
00116 }
00117 
00118 DEFINE_FWK_MODULE(ElectronIdFilter);