CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/GeneratorInterface/GenFilters/src/Zto2lFilter.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:    Zto2lFilter
00004 // Class:      Zto2lFilter
00005 // 
00013 //
00014 // Original Author:  Aruna Nayak
00015 //         Created:  Thu Aug 23 11:37:45 CEST 2007
00016 // $Id: Zto2lFilter.cc,v 1.6 2010/09/07 11:45:06 fabstoec Exp $
00017 //
00018 //
00019 
00020 
00021 // system include files
00022 #include <memory>
00023 #include "GeneratorInterface/GenFilters/interface/Zto2lFilter.h"
00024 
00025 #include <vector>
00026 #include "SimDataFormats/GeneratorProducts/interface/HepMCProduct.h"
00027 #include "TLorentzVector.h"
00028 
00029 //
00030 // constants, enums and typedefs
00031 //
00032 
00033 using namespace std; 
00034 using namespace edm;
00035 //
00036 // static data member definitions
00037 //
00038 
00039 //
00040 // constructors and destructor
00041 //
00042 Zto2lFilter::Zto2lFilter(const edm::ParameterSet& iConfig)
00043 {
00044    //now do what ever initialization is needed
00045   fLabel_ = iConfig.getUntrackedParameter("moduleLabel",std::string("generator"));
00046   maxEtaLepton_ = iConfig.getUntrackedParameter<double>("MaxEtaLepton");
00047   minInvariantMass_ = iConfig.getUntrackedParameter<double>("MindiLeptonInvariantMass");
00048   
00049 }
00050 
00051 
00052 Zto2lFilter::~Zto2lFilter()
00053 {
00054  
00055    // do anything here that needs to be done at desctruction time
00056    // (e.g. close files, deallocate resources etc.)
00057 
00058 }
00059 
00060 
00061 //
00062 // member functions
00063 //
00064 
00065 // ------------ method called on each new Event  ------------
00066 bool
00067 Zto2lFilter::filter(edm::Event& iEvent, const edm::EventSetup& iSetup)
00068 {
00069    using namespace edm;
00070 
00071    bool accept = false;
00072 
00073    Handle<HepMCProduct> EvtHandle ;
00074    iEvent.getByLabel( fLabel_, EvtHandle ) ;
00075    const HepMC::GenEvent* evt = EvtHandle->GetEvent();
00076    
00077    vector<TLorentzVector> Lepton; Lepton.clear();
00078    for (HepMC::GenEvent::particle_const_iterator p = evt->particles_begin();
00079         p != evt->particles_end(); ++p) {
00080      if((*p)->status()==3){
00081        if ( abs((*p)->pdg_id()) == 11 || abs((*p)->pdg_id()) == 13 || abs((*p)->pdg_id()) == 15  ){
00082          if(fabs((*p)->momentum().eta()) < maxEtaLepton_){
00083            TLorentzVector LeptP((*p)->momentum().px(), (*p)->momentum().py(), (*p)->momentum().pz(), (*p)->momentum().e()); 
00084            Lepton.push_back(LeptP);
00085          }
00086        }
00087      }
00088    }
00089    if(Lepton.size() == 2){
00090      if((Lepton[0]+Lepton[1]).M() > minInvariantMass_ )accept = true;
00091    }
00092    delete evt;
00093    return accept;
00094 }
00095 
00096 // ------------ method called once each job just before starting event loop  ------------
00097 
00098 // ------------ method called once each job just after ending the event loop  ------------
00099 void 
00100 Zto2lFilter::endJob() {
00101 }
00102 
00103 //define this as a plug-in
00104 //DEFINE_FWK_MODULE(Zto2lFilter);