6 #include "HepMC/GenEvent.h"
7 #include "HepMC/PdfInfo.h"
8 #include "HepMC/PythiaWrapper6_2.h"
9 #include "HepMC/HEPEVT_Wrapper.h"
10 #include "HepMC/IO_HEPEVT.h"
25 #include "HepPID/ParticleIDTranslations.hh"
87 double p[5][pyjets_maxn],
v[5][pyjets_maxn];
95 fCOMEnergy(ps.getParameter<double>(
"comEnergy")),
96 fHepMCVerbosity(ps.getUntrackedParameter<bool>(
"pythiaHepMCVerbosity",
false)),
97 fMaxEventsToPrint(ps.getUntrackedParameter<int>(
"maxEventsToPrint", 0)),
98 fPythiaListVerbosity(ps.getUntrackedParameter<int>(
"pythiaPylistVerbosity", 0)),
99 fDisplayPythiaBanner(ps.getUntrackedParameter<bool>(
"displayPythiaBanner",
false)),
100 fDisplayPythiaCards(ps.getUntrackedParameter<bool>(
"displayPythiaCards",
false))
109 if ( ps.
exists(
"stopHadrons" ) )
113 if ( ps.
exists(
"gluinoHadrons" ) )
117 if ( ps.
exists(
"imposeProperTime" ) )
123 if ( ps.
exists(
"doPDGConvert" ) )
126 if ( ps.
exists(
"jetMatching") )
142 <<
" Pythia did not accept MSTU(12)=12345";
153 <<
" Pythia did not accept MSTU(13)=0";
174 for (
int ip=0; ip<pyjets_maxn; ip++ )
176 for (
int i=0;
i<5;
i++ )
192 for (
int ip=0; ip<pyjets_maxn; ip++ )
194 for (
int i=0;
i<5;
i++ )
225 if (
event()->signal_process_id() <= 0)
event()->set_signal_process_id(
pypars.msti[0] );
226 if (
event()->event_scale() <=0 )
event()->set_event_scale(
pypars.pari[22] );
233 if ( pdf.id1() <= 0) pdf.set_id1(
pyint1.mint[14] == 21 ? 0 :
pyint1.mint[14] );
234 if ( pdf.id2() <= 0) pdf.set_id2(
pyint1.mint[15] == 21 ? 0 :
pyint1.mint[15] );
235 if ( pdf.x1() <= 0) pdf.set_x1(
pyint1.vint[40] );
236 if ( pdf.x2() <= 0) pdf.set_x2(
pyint1.vint[41] );
237 if ( pdf.pdf1() <= 0) pdf.set_pdf1(
pyint1.vint[38] /
pyint1.vint[40] );
238 if ( pdf.pdf2() <= 0) pdf.set_pdf2(
pyint1.vint[39] /
pyint1.vint[41] );
239 if ( pdf.scalePDF() <= 0) pdf.set_scalePDF(
pyint1.vint[50] );
268 event()->set_pdf_info( pdf ) ;
274 event()->weights().push_back(
pyint1.vint[96] * 1.0e9 );
280 event()->weights().push_back( 1./(
pyint1.vint[98]) );
292 eventInfo()->setBinningValues( std::vector<double>(1,
pypars.pari[16]) );
301 for ( HepMC::GenEvent::particle_iterator
part =
event()->particles_begin();
303 (*part)->set_pdg_id(HepPID::translatePythiatoPDT((*part)->pdg_id()));
316 <<
"----------------------" << std::endl;
358 if (
pyint1.mint[50] != 0 )
429 if (
pyint1.mint[50] != 0 )
461 int NPartsAfterDecays =
event().get()->particles_size();
462 int barcode = NPartsAfterDecays;
472 for (
int ipart=NPartsAfterDecays; ipart>NPartsBeforeDecays; ipart-- )
475 int status = part->status();
476 if ( status != 1 )
continue;
478 int pdgid = part->pdg_id();
480 if ( pydat3.mdcy[0][py6ptr-1] != 1 )
continue;
481 int py6id = HepPID::translatePDTtoPythia( pdgid );
487 if ( part->momentum().t() <= part->generated_mass() )
494 for (
int i=0;
i<5;
i++ )
501 pyjets.k[1][0] = py6id;
502 pyjets.p[4][0] = part->generated_mass();
503 pyjets.p[3][0] = part->momentum().t();
504 pyjets.p[0][0] = part->momentum().x();
505 pyjets.p[1][0] = part->momentum().y();
506 pyjets.p[2][0] = part->momentum().z();
507 HepMC::GenVertex* prod_vtx = part->production_vertex();
508 if ( !prod_vtx )
continue;
509 pyjets.v[0][0] = prod_vtx->position().x();
510 pyjets.v[1][0] = prod_vtx->position().y();
511 pyjets.v[2][0] = prod_vtx->position().z();
512 pyjets.v[3][0] = prod_vtx->position().t();
525 for (
int iprt1=1; iprt1<pyjets.n; iprt1++ )
527 part->set_status( 2 );
529 HepMC::GenVertex* DecVtx =
new HepMC::GenVertex( HepMC::FourVector(pyjets.v[0][iprt1],
532 pyjets.v[3][iprt1]) );
533 DecVtx->add_particle_in( part );
536 HepMC::FourVector pmom(pyjets.p[0][iprt1],pyjets.p[1][iprt1],
537 pyjets.p[2][iprt1],pyjets.p[3][iprt1] );
540 if ( pyjets.k[0][iprt1] >= 1 && pyjets.k[0][iprt1] <= 10 )
544 else if ( pyjets.k[0][iprt1] >= 11 && pyjets.k[0][iprt1] <= 20 )
548 else if ( pyjets.k[0][iprt1] >= 21 && pyjets.k[0][iprt1] <= 30 )
552 else if ( pyjets.k[0][iprt1] >= 31 && pyjets.k[0][iprt1] <= 100 )
554 dstatus = pyjets.k[0][iprt1];
557 HepPID::translatePythiatoPDT( pyjets.k[1][iprt1] ),
560 daughter->suggest_barcode( barcode );
561 DecVtx->add_particle_out( daughter );
564 for ( iprt2=iprt1+1; iprt2<pyjets.n; iprt2++ )
566 if ( pyjets.k[2][iprt2] != parent )
568 parent = pyjets.k[2][iprt2];
572 HepMC::FourVector pmomN(pyjets.p[0][iprt2],pyjets.p[1][iprt2],
573 pyjets.p[2][iprt2],pyjets.p[3][iprt2] );
576 if ( pyjets.k[0][iprt2] >= 1 && pyjets.k[0][iprt2] <= 10 )
580 else if ( pyjets.k[0][iprt2] >= 11 && pyjets.k[0][iprt2] <= 20 )
584 else if ( pyjets.k[0][iprt2] >= 21 && pyjets.k[0][iprt2] <= 30 )
588 else if ( pyjets.k[0][iprt2] >= 31 && pyjets.k[0][iprt2] <= 100 )
590 dstatus = pyjets.k[0][iprt2];
593 HepPID::translatePythiatoPDT( pyjets.k[1][iprt2] ),
596 daughterN->suggest_barcode( barcode );
597 DecVtx->add_particle_out( daughterN );
603 event().get()->add_vertex( DecVtx );
619 for (
int i=0;
i<5;
i++ )
661 call_pyinit(
"USER",
"",
"", 0.0);
668 <<
"Pythia6 hadronisation found an SLHA header, "
669 <<
"will be passed on to Pythia." << std::endl;
719 for (
unsigned int i=0;
i<pdg.size();
i++ )
721 int PyID = HepPID::translatePDTtoPythia( pdg[
i] );
726 std::ostringstream pyCard ;
727 pyCard <<
"MDCY(" << pyCode <<
",1)=0";
741 for (
unsigned int iss=0; iss<settings.size(); iss++ )
743 if ( settings[iss].
find(
"QED-brem-off") == std::string::npos )
continue;
744 size_t fnd1 = settings[iss].find(
":");
745 if ( fnd1 == std::string::npos )
continue;
747 std::string
value = settings[iss].substr (fnd1+1);
749 if ( value ==
"all" )
755 int number = atoi(value.c_str());
756 int PyID = HepPID::translatePDTtoPythia( number );
767 <<
" Fatal conflict: \n mandatory internal directive to set MSTJ(39)=" << pyCode
768 <<
" overrides user setting MSTJ(39)=" <<
pydat1_.mstj[38] <<
" - user will not get expected behaviour \n";
770 std::ostringstream pyCard ;
771 pyCard <<
"MSTJ(39)=" << pyCode ;
788 HepMC::GenEvent::vertex_const_iterator
vbegin =
event()->vertices_begin();
789 HepMC::GenEvent::vertex_const_iterator
vend =
event()->vertices_end();
790 HepMC::GenEvent::vertex_const_iterator vitr =
vbegin;
791 for (; vitr !=
vend; ++vitr )
793 HepMC::GenVertex::particle_iterator pbegin = (*vitr)->particles_begin(HepMC::children);
794 HepMC::GenVertex::particle_iterator pend = (*vitr)->particles_end(HepMC::children);
795 HepMC::GenVertex::particle_iterator pitr = pbegin;
796 for (; pitr != pend; ++pitr)
798 if ((*pitr)->end_vertex())
continue;
799 if ((*pitr)->status()!=1)
continue;
801 int pdgcode=
abs((*pitr)->pdg_id());
803 if ( pydat3.mdcy[0][
pycomp_(pdgcode)-1] !=1 )
continue;
805 double ctau = pydat2.pmas[3][
pycomp_(pdgcode)-1];
806 HepMC::FourVector mom = (*pitr)->momentum();
807 HepMC::FourVector vin = (*vitr)->position();
812 bool decayInRange =
false;
813 while (!decayInRange)
817 double proper_length = - ctau *
log(unif_rand);
818 double factor = proper_length/mom.m();
819 x = vin.x() + factor * mom.px();
820 y = vin.y() + factor * mom.py();
821 z = vin.z() + factor * mom.pz();
822 t = vin.t() + factor * mom.e();
828 else if (
pydat1.mstj[21]==3) {
837 HepMC::GenVertex* vdec =
new HepMC::GenVertex(HepMC::FourVector(x,y,z,t));
838 event()->add_vertex(vdec);
839 vdec->add_particle_in((*pitr));
850 if ( !
runInfo().internalXSec() )
853 double cs =
pypars.pari[0];
867 return "gen::Pythia6Hadronizer";
T getParameter(std::string const &) const
static std::auto_ptr< JetMatching > create(const edm::ParameterSet ¶ms)
T getUntrackedParameter(std::string const &, T const &) const
unsigned int fPythiaListVerbosity
bool fDisplayPythiaBanner
Pythia6ServiceWithCallback(const edm::ParameterSet &ps)
static struct gen::@303 pyjets_local
unsigned int fMaxEventsToPrint
static HepMC::IO_HEPEVT conv
void fillEventInfo(HepMC::GenEvent *hepmc) const
static JetMatching * getJetMatching()
bool call_pygive(const std::string &line)
bool exists(std::string const ¶meterName) const
checks if a parameter exists
const char * classname() const
void setLHERunInfo(lhef::LHERunInfo *lheri)
void count(LHERunInfo::CountMode count, double weight=1.0, double matchWeight=1.0)
virtual void beforeHadronisation(const lhef::LHEEvent *event)
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
bool declareSpecialSettings(const std::vector< std::string >)
void setInternalXSec(const XSec &xsec)
std::auto_ptr< HepMC::GenEvent > & event()
bool initializeForInternalPartons()
GenRunInfoProduct & runInfo()
void call_pylist(int mode)
void resetMatchingStatus()
lhef::LHEEvent * lheEvent()
void setSLHAFromHeader(const std::vector< std::string > &lines)
void fillPdfInfo(HepMC::PdfInfo *info) const
void setPYUPDAParams(bool afterPyinit)
bool initializeForExternalPartons()
Pythia6Hadronizer(edm::ParameterSet const &ps)
std::auto_ptr< GenEventInfoProduct > & eventInfo()
lhef::LHERunInfo * lheRunInfo()
static FortranCallback * getInstance()
Pythia6Service * fPy6Service
void setLHEEvent(lhef::LHEEvent *lhee)
Log< T >::type log(const T &t)
bool generatePartonsAndHadronize()
virtual void beforeHadronisationExec()
void resetIterationsPerEvent()
bool fGluinoHadronsEnabled
virtual int match(const HepMC::GenEvent *partonLevel, const HepMC::GenEvent *finalState, bool showeredFinalState=false)=0
std::vector< std::string > findHeader(const std::string &tag) const
virtual void init(const lhef::LHERunInfo *runInfo)
bool declareStableParticles(const std::vector< int >)
static JetMatching * fJetMatching