Go to the documentation of this file.00001
00002 #include "GeneratorInterface/GenFilters/interface/TwoVBGenFilter.h"
00003 #include <iostream>
00004 using namespace std;
00005
00006 TwoVBGenFilter::TwoVBGenFilter(const edm::ParameterSet& iConfig)
00007 {
00008
00009 src_ = iConfig.getUntrackedParameter<edm::InputTag>("src",edm::InputTag("generator"));
00010
00011 eejj_ = iConfig.getParameter<bool>("eejj");
00012 enujj_ = iConfig.getParameter<bool>("enujj");
00013
00014 mumujj_ = iConfig.getParameter<bool>("mumujj");
00015 munujj_ = iConfig.getParameter<bool>("munujj");
00016
00017 tautaujj_ = iConfig.getParameter<bool>("tautaujj");
00018 taunujj_ = iConfig.getParameter<bool>("taunujj");
00019
00020 nunujj_ = iConfig.getParameter<bool>("nunujj");
00021
00022
00023
00024 }
00025
00026
00027 TwoVBGenFilter::~TwoVBGenFilter()
00028 {
00029
00030
00031
00032
00033 }
00034
00035
00036
00037
00038
00039
00040
00041 bool
00042 TwoVBGenFilter::filter(edm::Event& iEvent, const edm::EventSetup& iSetup)
00043 {
00044 int nj = 0;
00045 int ne = 0;
00046 int nnu = 0;
00047 int nmu = 0;
00048 int ntau = 0;
00049
00050 edm::Handle<edm::HepMCProduct> evt;
00051 iEvent.getByLabel(src_, evt);
00052
00053 const HepMC::GenEvent* myGenEvent = evt->GetEvent();
00054
00055 for ( HepMC::GenEvent::particle_const_iterator p = myGenEvent->particles_begin();
00056 p != myGenEvent->particles_end(); ++p ) {
00057
00058 if(abs((*p)->pdg_id()) !=23 && abs((*p)->pdg_id()) !=24) continue;
00059
00060 if ( (*p)->end_vertex() ) {
00061 for ( HepMC::GenVertex::particle_iterator des=(*p)->end_vertex()->particles_begin(HepMC::children);
00062 des != (*p)->end_vertex()->particles_end(HepMC::children); ++des ) {
00063
00064 const HepMC::GenParticle* theDaughter = *des;
00065 if(isQuark(theDaughter)) ++nj;
00066 else if(isNeutrino(theDaughter)) ++nnu;
00067 else if(isElectron(theDaughter)) ++ne;
00068 else if(isMuon(theDaughter)) ++nmu;
00069 else if(isTau(theDaughter)) ++ntau;
00070
00071 }
00072 }
00073 }
00074
00075 if (ne==2 && nj == 2 && eejj_) return true;
00076 else if (ne==1 && nj == 2 && nnu==1 && enujj_) return true;
00077 else if (nmu==2 && nj == 2 && mumujj_) return true;
00078 else if (nmu==1 && nj == 2 && nnu==1 && munujj_) return true;
00079 else if (ntau==2 && nj == 2 && tautaujj_) return true;
00080 else if (ntau==1 && nj == 2 && nnu==1 && taunujj_) return true;
00081 else if (nnu==2 && nj == 2 && nunujj_) return true;
00082 else return false;
00083 }
00084
00085
00086 void
00087 TwoVBGenFilter::beginJob()
00088 {
00089 }
00090
00091
00092 void
00093 TwoVBGenFilter::endJob() {
00094 }
00095
00096 bool TwoVBGenFilter::isQuark(const HepMC::GenParticle* p) {
00097 bool result;
00098 int pdgid = std::abs(p->pdg_id());
00099 if(pdgid == 1 || pdgid == 2 || pdgid == 3 ||
00100 pdgid == 4 || pdgid == 5 || pdgid == 6)
00101 result = true;
00102 else
00103 result = false;
00104 return result;
00105 }
00106
00107 bool TwoVBGenFilter::isNeutrino(const HepMC::GenParticle* p) {
00108 bool result;
00109 int pdgid = std::abs(p->pdg_id());
00110 if(pdgid == 12 || pdgid == 14 || pdgid == 16)
00111 result = true;
00112 else
00113 result = false;
00114 return result;
00115 }
00116
00117 bool TwoVBGenFilter::isElectron(const HepMC::GenParticle* p) {
00118 bool result;
00119 int pdgid = std::abs(p->pdg_id());
00120 if(pdgid == 11)
00121 result = true;
00122 else
00123 result = false;
00124 return result;
00125 }
00126
00127 bool TwoVBGenFilter::isMuon(const HepMC::GenParticle* p) {
00128 bool result;
00129 int pdgid = std::abs(p->pdg_id());
00130 if(pdgid == 13)
00131 result = true;
00132 else
00133 result = false;
00134 return result;
00135 }
00136
00137 bool TwoVBGenFilter::isTau(const HepMC::GenParticle* p) {
00138 bool result;
00139 int pdgid = std::abs(p->pdg_id());
00140 if(pdgid == 15)
00141 result = true;
00142 else
00143 result = false;
00144 return result;
00145 }
00146