CMS 3D CMS Logo

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

Go to the documentation of this file.
00001 #include "GeneratorInterface/GenFilters/interface/PythiaFilterTTBar.h"
00002 
00003 
00004 //
00005 // constants, enums and typedefs
00006 //
00007 
00008 //
00009 // static data member definitions
00010 //
00011 
00012 //
00013 // constructors and destructor
00014 //
00015 
00016 PythiaFilterTTBar::PythiaFilterTTBar(const edm::ParameterSet& iConfig) : 
00017   label_(iConfig.getUntrackedParameter("moduleLabel",std::string("generator"))),
00018   decayType_(iConfig.getUntrackedParameter("decayType",1)),
00019   leptonFlavour_(iConfig.getUntrackedParameter("leptonFlavour",0))           
00020 {
00021 }
00022 
00023 
00024 PythiaFilterTTBar::~PythiaFilterTTBar()
00025 {
00026  
00027    // do anything here that needs to be done at desctruction time
00028    // (e.g. close files, deallocate resources etc.)
00029 
00030 }
00031 
00032 
00033 //
00034 // member functions
00035 //
00036 
00037 // ------------ method called on each new Event  ------------
00038 bool
00039 PythiaFilterTTBar::filter(edm::Event& iEvent, const edm::EventSetup& iSetup)
00040 {
00041 
00042   bool accept=false;
00043 
00044   edm::Handle<edm::HepMCProduct> evt;
00045   iEvent.getByLabel(label_, evt);
00046 
00047   const HepMC::GenEvent * myGenEvent = evt->GetEvent();
00048 
00049   unsigned int iE=0, iMu=0, iTau=0;
00050 
00051   unsigned int iNuE=0, iNuMu=0, iNuTau=0;
00052 
00053   unsigned int iLep=0, iNu=0;
00054 
00055 
00056   for ( HepMC::GenEvent::particle_const_iterator p = myGenEvent->particles_begin();   p != myGenEvent->particles_end(); ++p ) {
00057 
00058     int pdgID = (*p)->pdg_id();
00059     
00060     int status = (*p)->status();
00061 
00062     if ( status == 3 ) {
00063 
00064       // count the final state leptons
00065 
00066       if (fabs(pdgID) == 11)
00067         iE++;
00068 
00069       if(fabs(pdgID) == 13)
00070         iMu++;
00071       
00072       if(fabs(pdgID) == 15)
00073         iTau++;
00074 
00075       // count the final state neutrinos
00076       
00077       if(fabs(pdgID) == 12)
00078         iNuE++;
00079 
00080       if(fabs(pdgID) == 14)
00081         iNuMu++;
00082       
00083       if(fabs(pdgID) == 16)
00084         iNuTau++;
00085 
00086     }
00087 
00088   }
00089 
00090   iLep = (iE+iMu+iTau);
00091   iNu = (iNuE+iNuMu+iNuTau);
00092 
00093   if (decayType_ == 1) { // semi-leptonic decay
00094     
00095     // l = e,mu,tau
00096 
00097     if (leptonFlavour_ == 0 && iLep == 1 && iNu == 1)
00098       accept=true;
00099     
00100     // l = e
00101 
00102     else if (leptonFlavour_ == 1 && iE == 1 && iNuE == 1 && iLep == 1 && iNu == 1)
00103       accept=true;
00104 
00105     // l = mu
00106 
00107     else if (leptonFlavour_ == 2 && iMu == 1 && iNuMu == 1 && iLep == 1 && iNu == 1)
00108       accept=true;
00109     
00110     // l = tau 
00111 
00112     else if (leptonFlavour_ == 3 && iTau == 1 && iNuTau == 1 && iLep == 1 && iNu == 1)
00113       accept=true;
00114 
00115   }
00116 
00117   else if (decayType_ == 2) { // di-leptonic decay (inclusive)
00118 
00119     if (iLep == 2 && iNu == 2) 
00120       accept=true;
00121     
00122   }
00123   
00124   else if (decayType_ == 3) { // fully-hadronic decay
00125 
00126     if (iLep == 0 && iNu == 0)
00127       accept=true;
00128   }
00129 
00130   else
00131     accept=false;
00132   
00133   
00134   return accept;
00135 }
00136