CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_13_patch3/src/TauAnalysis/MCEmbeddingTools/plugins/SelectZmumuevents.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:    SelectZmumuevents
00004 // Class:      SelectZmumuevents
00005 // 
00013 //
00014 // Original Author:  Tomasz Maciej Frueboes
00015 //         Created:  Fri Dec 18 14:29:14 CET 2009
00016 // $Id: SelectZmumuevents.cc,v 1.1 2010/03/17 16:14:10 fruboes Exp $
00017 //
00018 //
00019 
00020 
00021 // system include files
00022 #include <memory>
00023 
00024 // user include files
00025 #include "FWCore/Framework/interface/Frameworkfwd.h"
00026 #include "FWCore/Framework/interface/EDFilter.h"
00027 
00028 #include "FWCore/Framework/interface/Event.h"
00029 #include "FWCore/Framework/interface/MakerMacros.h"
00030 
00031 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00032 
00033 #include <DataFormats/ParticleFlowCandidate/interface/PFCandidate.h>
00034 #include <DataFormats/ParticleFlowCandidate/interface/PFCandidateFwd.h>
00035 //
00036 // class declaration
00037 //
00038 
00039 class SelectZmumuevents : public edm::EDFilter {
00040    public:
00041       explicit SelectZmumuevents(const edm::ParameterSet&);
00042       ~SelectZmumuevents();
00043 
00044    private:
00045       virtual void beginJob() ;
00046       virtual bool filter(edm::Event&, const edm::EventSetup&);
00047       virtual void endJob() ;
00048       
00049       // ----------member data ---------------------------
00050       double _etaMax;
00051       double _ptMin;
00052       edm::InputTag _pfColl;
00053 };
00054 
00055 //
00056 // constants, enums and typedefs
00057 //
00058 
00059 //
00060 // static data member definitions
00061 //
00062 
00063 //
00064 // constructors and destructor
00065 //
00066 SelectZmumuevents::SelectZmumuevents(const edm::ParameterSet& iConfig)
00067   : _etaMax(iConfig.getUntrackedParameter<double>("etaMax")),
00068     _ptMin(iConfig.getUntrackedParameter<double>("ptMin")),
00069     _pfColl(iConfig.getUntrackedParameter<edm::InputTag>("pfCol"))
00070 {
00071 
00072 }
00073 
00074 
00075 SelectZmumuevents::~SelectZmumuevents()
00076 {
00077  
00078    // do anything here that needs to be done at desctruction time
00079    // (e.g. close files, deallocate resources etc.)
00080 }
00081 
00082 
00083 //
00084 // member functions
00085 //
00086 
00087 // ------------ method called on each new Event  ------------
00088 bool
00089 SelectZmumuevents::filter(edm::Event& iEvent, const edm::EventSetup& iSetup)
00090 {
00091   using namespace edm;
00092   Handle< View<reco::Candidate> > genParts;
00093   iEvent.getByLabel(_pfColl, genParts);
00094   
00095   int cnt = 0;
00096   for( edm::View<reco::Candidate>::const_iterator it = genParts->begin(); it != genParts->end(); it++ ) 
00097   {
00098     if (std::abs(it->pdgId()) == 13 
00099         && std::abs(it->eta()) < _etaMax
00100         && it->pt() > _ptMin ) 
00101     {
00102       ++cnt; 
00103     }
00104   }
00105 
00106    return cnt>1;
00107 }
00108 
00109 // ------------ method called once each job just before starting event loop  ------------
00110 void 
00111 SelectZmumuevents::beginJob()
00112 {
00113 }
00114 
00115 // ------------ method called once each job just after ending the event loop  ------------
00116 void 
00117 SelectZmumuevents::endJob() {
00118 }
00119 
00120 //define this as a plug-in
00121 DEFINE_FWK_MODULE(SelectZmumuevents);