Go to the documentation of this file.00001 #include "GeneratorInterface/Pythia8Interface/interface/Py8GunBase.h"
00002
00003
00004
00005 using namespace Pythia8;
00006
00007 namespace gen {
00008
00009 Py8GunBase::Py8GunBase( edm::ParameterSet const& ps )
00010 : Py8InterfaceBase(ps)
00011 {
00012
00013 runInfo().setFilterEfficiency(
00014 ps.getUntrackedParameter<double>("filterEfficiency", -1.) );
00015 runInfo().setExternalXSecLO(
00016 GenRunInfoProduct::XSec(ps.getUntrackedParameter<double>("crossSection", -1.)) );
00017 runInfo().setExternalXSecNLO(
00018 GenRunInfoProduct::XSec(ps.getUntrackedParameter<double>("crossSectionNLO", -1.)) );
00019
00020
00021
00022
00023 edm::ParameterSet pgun_params =
00024 ps.getParameter<edm::ParameterSet>("PGunParameters");
00025
00026
00027
00028
00029
00030
00031 fPartIDs = pgun_params.getParameter< std::vector<int> >("ParticleID");
00032 fMinPhi = pgun_params.getParameter<double>("MinPhi");
00033 fMaxPhi = pgun_params.getParameter<double>("MaxPhi");
00034
00035 }
00036
00037
00038
00039 bool Py8GunBase::initializeForInternalPartons()
00040 {
00041
00042
00043
00044
00045
00046 fMasterGen->readString("ProcessLevel:all = off");
00047 fMasterGen->readString("Standalone:allowResDec=on");
00048
00049 fMasterGen->init();
00050
00051
00052 fDecayer->readString("ProcessLevel:all = off");
00053 fDecayer->readString("Standalone:allowResDec=on");
00054
00055 fDecayer->init();
00056
00057 return true;
00058
00059 }
00060
00061 bool Py8GunBase::residualDecay()
00062 {
00063
00064 Event* pythiaEvent = &(fMasterGen->event);
00065
00066 int NPartsBeforeDecays = pythiaEvent->size()-1;
00067
00068
00069
00070 int NPartsAfterDecays = event().get()->particles_size();
00071 int NewBarcode = NPartsAfterDecays;
00072
00073 for ( int ipart=NPartsAfterDecays; ipart>NPartsBeforeDecays; ipart-- )
00074 {
00075
00076 HepMC::GenParticle* part = event().get()->barcode_to_particle( ipart );
00077
00078 if ( part->status() == 1 )
00079 {
00080 fDecayer->event.reset();
00081 Particle py8part( part->pdg_id(), 93, 0, 0, 0, 0, 0, 0,
00082 part->momentum().x(),
00083 part->momentum().y(),
00084 part->momentum().z(),
00085 part->momentum().t(),
00086 part->generated_mass() );
00087 HepMC::GenVertex* ProdVtx = part->production_vertex();
00088 py8part.vProd( ProdVtx->position().x(), ProdVtx->position().y(),
00089 ProdVtx->position().z(), ProdVtx->position().t() );
00090 py8part.tau( (fDecayer->particleData).tau0( part->pdg_id() ) );
00091 fDecayer->event.append( py8part );
00092 int nentries = fDecayer->event.size();
00093 if ( !fDecayer->event[nentries-1].mayDecay() ) continue;
00094 fDecayer->next();
00095 int nentries1 = fDecayer->event.size();
00096 if ( nentries1 <= nentries ) continue;
00097
00098 part->set_status(2);
00099
00100 Particle& py8daughter = fDecayer->event[nentries];
00101 HepMC::GenVertex* DecVtx = new HepMC::GenVertex( HepMC::FourVector(py8daughter.xProd(),
00102 py8daughter.yProd(),
00103 py8daughter.zProd(),
00104 py8daughter.tProd()) );
00105
00106 DecVtx->add_particle_in( part );
00107
00108
00109 HepMC::FourVector pmom( py8daughter.px(), py8daughter.py(), py8daughter.pz(), py8daughter.e() );
00110
00111 HepMC::GenParticle* daughter =
00112 new HepMC::GenParticle( pmom, py8daughter.id(), 1 );
00113
00114 NewBarcode++;
00115 daughter->suggest_barcode( NewBarcode );
00116 DecVtx->add_particle_out( daughter );
00117
00118 for ( ipart=nentries+1; ipart<nentries1; ipart++ )
00119 {
00120 py8daughter = fDecayer->event[ipart];
00121 HepMC::FourVector pmomN( py8daughter.px(), py8daughter.py(), py8daughter.pz(), py8daughter.e() );
00122 HepMC::GenParticle* daughterN =
00123 new HepMC::GenParticle( pmomN, py8daughter.id(), 1 );
00124 NewBarcode++;
00125 daughterN->suggest_barcode( NewBarcode );
00126 DecVtx->add_particle_out( daughterN );
00127 }
00128
00129 event().get()->add_vertex( DecVtx );
00130
00131 }
00132 }
00133
00134 return true;
00135
00136 }
00137
00138 void Py8GunBase::finalizeEvent()
00139 {
00140
00141
00142
00143
00144
00145
00146 if (maxEventsToPrint > 0 &&
00147 (pythiaPylistVerbosity || pythiaHepMCVerbosity))
00148 {
00149 maxEventsToPrint--;
00150 if (pythiaPylistVerbosity)
00151 {
00152 fMasterGen->info.list(std::cout);
00153 fMasterGen->event.list(std::cout);
00154 }
00155
00156 if (pythiaHepMCVerbosity)
00157 {
00158 std::cout << "Event process = "
00159 << fMasterGen->info.code() << "\n"
00160 << "----------------------" << std::endl;
00161 event()->print();
00162 }
00163 }
00164
00165 return;
00166 }
00167
00168 void Py8GunBase::statistics()
00169 {
00170
00171 fMasterGen->statistics();
00172
00173 double xsec = fMasterGen->info.sigmaGen();
00174 xsec *= 1.0e9;
00175 runInfo().setInternalXSec(xsec);
00176 return;
00177
00178 }
00179
00180 }