Go to the documentation of this file.00001
00002 #include "GeneratorInterface/GenFilters/interface/PythiaDauFilter.h"
00003
00004
00005 #include "SimDataFormats/GeneratorProducts/interface/HepMCProduct.h"
00006 #include "HepMC/PythiaWrapper6_2.h"
00007 #include <iostream>
00008
00009 using namespace edm;
00010 using namespace std;
00011
00012
00013 PythiaDauFilter::PythiaDauFilter(const edm::ParameterSet& iConfig) :
00014 label_(iConfig.getUntrackedParameter("moduleLabel",std::string("generator"))),
00015 particleID(iConfig.getUntrackedParameter("ParticleID", 0)),
00016 chargeconju(iConfig.getUntrackedParameter("ChargeConjugation", true)),
00017 ndaughters(iConfig.getUntrackedParameter("NumberDaughters", 0)),
00018 minptcut(iConfig.getUntrackedParameter("MinPt", 0.)),
00019 maxptcut(iConfig.getUntrackedParameter("MaxPt", 14000.)),
00020 minetacut(iConfig.getUntrackedParameter("MinEta", -10.)),
00021 maxetacut(iConfig.getUntrackedParameter("MaxEta", 10.))
00022 {
00023
00024 vector<int> defdauID;
00025 defdauID.push_back(0);
00026 dauIDs = iConfig.getUntrackedParameter< vector<int> >("DaughterIDs",defdauID);
00027 }
00028
00029
00030 PythiaDauFilter::~PythiaDauFilter()
00031 {
00032
00033
00034
00035
00036 }
00037
00038
00039
00040
00041
00042
00043
00044 bool PythiaDauFilter::filter(edm::Event& iEvent, const edm::EventSetup& iSetup)
00045 {
00046 using namespace edm;
00047 bool accepted = false;
00048 Handle<HepMCProduct> evt;
00049 iEvent.getByLabel(label_, evt);
00050
00051 const HepMC::GenEvent * myGenEvent = evt->GetEvent();
00052
00053
00054 for ( HepMC::GenEvent::particle_const_iterator p = myGenEvent->particles_begin();
00055 p != myGenEvent->particles_end(); ++p ) {
00056
00057 if( (*p)->pdg_id() != particleID ) continue ;
00058 int ndauac = 0;
00059 int ndau = 0;
00060 if ( (*p)->end_vertex() ) {
00061 for ( HepMC::GenVertex::particle_iterator
00062 des=(*p)->end_vertex()->particles_begin(HepMC::children);
00063 des != (*p)->end_vertex()->particles_end(HepMC::children);
00064 ++des ) {
00065 ++ndau;
00066 for( unsigned int i=0; i<dauIDs.size(); ++i) {
00067 if( (*des)->pdg_id() != dauIDs[i] ) continue ;
00068 if( (*des)->momentum().perp() > minptcut &&
00069 (*des)->momentum().perp() < maxptcut &&
00070 (*des)->momentum().eta() > minetacut &&
00071 (*des)->momentum().eta() < maxetacut ) {
00072 ++ndauac;
00073 break;
00074 }
00075 }
00076 }
00077 }
00078 if( ndau == ndaughters && ndauac == ndaughters ) {
00079 accepted = true;
00080 break;
00081 }
00082
00083 }
00084
00085
00086 if( !accepted && chargeconju ) {
00087
00088 for ( HepMC::GenEvent::particle_const_iterator p = myGenEvent->particles_begin();
00089 p != myGenEvent->particles_end(); ++p ) {
00090
00091 if( (*p)->pdg_id() != -particleID ) continue ;
00092 int ndauac = 0;
00093 int ndau = 0;
00094 if ( (*p)->end_vertex() ) {
00095 for ( HepMC::GenVertex::particle_iterator
00096 des=(*p)->end_vertex()->particles_begin(HepMC::children);
00097 des != (*p)->end_vertex()->particles_end(HepMC::children);
00098 ++des ) {
00099 ++ndau;
00100 for( unsigned int i=0; i<dauIDs.size(); ++i) {
00101 int IDanti = -dauIDs[i];
00102 int pythiaCode = PYCOMP(dauIDs[i]);
00103 int has_antipart = pydat2.kchg[3-1][pythiaCode-1];
00104 if( has_antipart == 0 ) IDanti = dauIDs[i];
00105 if( (*des)->pdg_id() != IDanti ) continue ;
00106 if( (*des)->momentum().perp() > minptcut &&
00107 (*des)->momentum().perp() < maxptcut &&
00108 (*des)->momentum().eta() > minetacut &&
00109 (*des)->momentum().eta() < maxetacut ) {
00110 ++ndauac;
00111 break;
00112 }
00113 }
00114 }
00115 }
00116 if( ndau == ndaughters && ndauac == ndaughters ) {
00117 accepted = true;
00118 break;
00119 }
00120 }
00121
00122 }
00123
00124 if (accepted){
00125 return true; } else {return false;}
00126
00127 }