test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Selectors.cc
Go to the documentation of this file.
3 
4 // system include files
5 #include <memory>
6 
7 // user include files
10 
13 
15 
16 
18 
23 
26 
29 
32 
35 
38 
39 #include <vector>
40 #include <iostream>
41 
48 
55 
57 public:
58  explicit ElectronIdFilter(const edm::ParameterSet&);
60 
61 private:
62  virtual void beginJob() override ;
63  virtual bool filter(edm::Event&, const edm::EventSetup&) override;
64  virtual void endJob() override ;
65 
68  int eid_;
69  // ----------member data ---------------------------
70 };
71 
73  : recoGsfElectronCollectionToken_( consumes<reco::GsfElectronCollection>( iConfig.getParameter<edm::InputTag>( "src" ) ) )
74  , edmValueMapFloatToken_( consumes< edm::ValueMap<float> >( iConfig.getParameter<edm::InputTag>( "eidsrc" ) ) )
75  , eid_( iConfig.getParameter<int>( "eid" ) )
76 {
77  produces< reco::GsfElectronCollection >();
78 }
80 {
81 }
82 // ------------ method called to produce the data ------------
83 
84 bool
86 {
87  //cout << "NonVertexingLeptonFilter:: entering filter" << endl;
88 
90  iEvent.getByToken( recoGsfElectronCollectionToken_, electrons );
91 
93  iEvent.getByToken( edmValueMapFloatToken_, eIDValueMap );
94  const edm::ValueMap<float> & eIDmap = * eIDValueMap;
96 
97  // Loop over electrons
98  for (unsigned int i = 0; i < electrons->size(); i++){
99  edm::Ref<reco::GsfElectronCollection> electronRef(electrons,i);
100  if((eIDmap[electronRef]) == eid_)
101  product->push_back((*electrons)[i]);
102  }
103 
104  //cout << "Putting in the event" << endl;
105  std::auto_ptr<reco::GsfElectronCollection> collection(product);
106  iEvent.put(collection);
107  return true;
108 }
109 
110 void
112 }
113 void
115 }
116 
int i
Definition: DBlmapReader.cc:9
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:462
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
virtual void beginJob() override
Definition: Selectors.cc:111
SingleObjectSelector< reco::GenParticleCollection, StringCutObjectSelector< reco::GenParticle > > TauValGenPSelector
Definition: Selectors.cc:44
std::vector< GsfElectron > GsfElectronCollection
collection of GsfElectron objects
SingleObjectSelector< edm::View< reco::GsfElectron >, StringCutObjectSelector< reco::GsfElectron >, reco::GsfElectronCollection > TauValElectronSelector
Definition: Selectors.cc:47
ElectronIdFilter(const edm::ParameterSet &)
Definition: Selectors.cc:72
int iEvent
Definition: GenABIO.cc:230
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:121
SingleObjectSelector< reco::GenParticleRefVector, StringCutObjectSelector< reco::GenParticleRef > > TauValGenPRefSelector
Definition: Selectors.cc:45
virtual void endJob() override
Definition: Selectors.cc:114
SingleObjectSelector< std::vector< reco::Jet >, StringCutObjectSelector< reco::Jet > > TauValJetSelector
Definition: Selectors.cc:42
edm::EDGetTokenT< edm::ValueMap< float > > edmValueMapFloatToken_
Definition: Selectors.cc:67
SingleObjectSelector< reco::MuonCollection, StringCutObjectSelector< reco::Muon > > TauValMuonSelector
Definition: Selectors.cc:43
virtual bool filter(edm::Event &, const edm::EventSetup &) override
Definition: Selectors.cc:85
SingleObjectSelector< reco::PFJetCollection, StringCutObjectSelector< reco::PFJet > > TauValPFJetSelector
Definition: Selectors.cc:46
edm::EDGetTokenT< reco::GsfElectronCollection > recoGsfElectronCollectionToken_
Definition: Selectors.cc:66