Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:33:59

0001 #include "FWCore/PluginManager/interface/ModuleDef.h"
0002 #include "FWCore/Framework/interface/MakerMacros.h"
0003 
0004 // system include files
0005 #include <memory>
0006 
0007 // user include files
0008 #include "FWCore/Framework/interface/Frameworkfwd.h"
0009 #include "FWCore/Framework/interface/EDFilter.h"
0010 
0011 #include "FWCore/Framework/interface/Event.h"
0012 #include "FWCore/Framework/interface/MakerMacros.h"
0013 
0014 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0015 
0016 #include "DataFormats/Common/interface/RefVector.h"
0017 
0018 #include "CommonTools/UtilAlgos/interface/StringCutObjectSelector.h"
0019 #include "CommonTools/UtilAlgos/interface/SingleObjectSelector.h"
0020 #include "CommonTools/UtilAlgos/interface/SingleElementCollectionSelector.h"
0021 #include "CommonTools/UtilAlgos/interface/ObjectCountFilter.h"
0022 
0023 #include "DataFormats/JetReco/interface/PFJet.h"
0024 #include "DataFormats/JetReco/interface/PFJetCollection.h"
0025 
0026 #include "DataFormats/JetReco/interface/Jet.h"
0027 #include "DataFormats/JetReco/interface/JetCollection.h"
0028 
0029 #include "DataFormats/MuonReco/interface/Muon.h"
0030 #include "DataFormats/MuonReco/interface/MuonFwd.h"
0031 
0032 #include "DataFormats/EgammaCandidates/interface/GsfElectron.h"
0033 #include "DataFormats/EgammaCandidates/interface/GsfElectronFwd.h"
0034 
0035 #include "DataFormats/HepMCCandidate/interface/GenParticle.h"
0036 #include "DataFormats/HepMCCandidate/interface/GenParticleFwd.h"
0037 
0038 #include <vector>
0039 #include <iostream>
0040 
0041 typedef SingleObjectSelector<std::vector<reco::Jet>, StringCutObjectSelector<reco::Jet> > TauValJetSelector;
0042 typedef SingleObjectSelector<reco::MuonCollection, StringCutObjectSelector<reco::Muon> > TauValMuonSelector;
0043 typedef SingleObjectSelector<reco::GenParticleCollection, StringCutObjectSelector<reco::GenParticle> >
0044     TauValGenPSelector;
0045 typedef SingleObjectSelector<reco::GenParticleRefVector, StringCutObjectSelector<reco::GenParticleRef> >
0046     TauValGenPRefSelector;
0047 typedef SingleObjectSelector<reco::PFJetCollection, StringCutObjectSelector<reco::PFJet> > TauValPFJetSelector;
0048 typedef SingleObjectSelector<edm::View<reco::GsfElectron>,
0049                              StringCutObjectSelector<reco::GsfElectron>,
0050                              reco::GsfElectronCollection>
0051     TauValElectronSelector;
0052 
0053 DEFINE_FWK_MODULE(TauValPFJetSelector);
0054 DEFINE_FWK_MODULE(TauValJetSelector);
0055 DEFINE_FWK_MODULE(TauValMuonSelector);
0056 DEFINE_FWK_MODULE(TauValElectronSelector);
0057 DEFINE_FWK_MODULE(TauValGenPSelector);
0058 DEFINE_FWK_MODULE(TauValGenPRefSelector);
0059 
0060 class ElectronIdFilter : public edm::EDFilter {
0061 public:
0062   explicit ElectronIdFilter(const edm::ParameterSet&);
0063   ~ElectronIdFilter() override;
0064 
0065 private:
0066   void beginJob() override;
0067   bool filter(edm::Event&, const edm::EventSetup&) override;
0068   void endJob() override;
0069 
0070   edm::EDGetTokenT<reco::GsfElectronCollection> recoGsfElectronCollectionToken_;
0071   edm::EDGetTokenT<edm::ValueMap<float> > edmValueMapFloatToken_;
0072   int eid_;
0073   // ----------member data ---------------------------
0074 };
0075 
0076 ElectronIdFilter::ElectronIdFilter(const edm::ParameterSet& iConfig)
0077     : recoGsfElectronCollectionToken_(
0078           consumes<reco::GsfElectronCollection>(iConfig.getParameter<edm::InputTag>("src"))),
0079       edmValueMapFloatToken_(consumes<edm::ValueMap<float> >(iConfig.getParameter<edm::InputTag>("eidsrc"))),
0080       eid_(iConfig.getParameter<int>("eid")) {
0081   produces<reco::GsfElectronCollection>();
0082 }
0083 ElectronIdFilter::~ElectronIdFilter() {}
0084 // ------------ method called to produce the data  ------------
0085 
0086 bool ElectronIdFilter::filter(edm::Event& iEvent, const edm::EventSetup& iSetup) {
0087   //cout << "NonVertexingLeptonFilter:: entering filter" << endl;
0088 
0089   edm::Handle<reco::GsfElectronCollection> electrons;
0090   iEvent.getByToken(recoGsfElectronCollectionToken_, electrons);
0091 
0092   edm::Handle<edm::ValueMap<float> > eIDValueMap;
0093   iEvent.getByToken(edmValueMapFloatToken_, eIDValueMap);
0094   const edm::ValueMap<float>& eIDmap = *eIDValueMap;
0095   reco::GsfElectronCollection* product = new reco::GsfElectronCollection();
0096 
0097   // Loop over electrons
0098   for (unsigned int i = 0; i < electrons->size(); i++) {
0099     edm::Ref<reco::GsfElectronCollection> electronRef(electrons, i);
0100     if ((eIDmap[electronRef]) == eid_)
0101       product->push_back((*electrons)[i]);
0102   }
0103 
0104   //cout << "Putting in the event" << endl;
0105   std::unique_ptr<reco::GsfElectronCollection> collection(product);
0106   iEvent.put(std::move(collection));
0107   return true;
0108 }
0109 
0110 void ElectronIdFilter::beginJob() {}
0111 void ElectronIdFilter::endJob() {}
0112 
0113 DEFINE_FWK_MODULE(ElectronIdFilter);