3 #include "HepMC/GenEvent.h"
4 #include "HepMC/PdfInfo.h"
5 #include "HepMC/PythiaWrapper6_4.h"
8 #include "HepMC/HEPEVT_Wrapper.h"
9 #include "HepMC/IO_HEPEVT.h"
10 #include "HepMC/IO_GenEvent.h"
19 #include "HepPID/ParticleIDTranslations.hh"
30 #include "CLHEP/Random/RandomEngine.h"
46 if (
debug && ++call < 100)
47 cout <<
"dcasrn from c++, call: " << call <<
" random number: " << rdm_nb << endl;
60 void upInit()
override { FortranCallback::getInstance()->fillHeader(); }
62 void upEvnt()
override { FortranCallback::getInstance()->fillEvent(); }
74 double p[5][pyjets_maxn],
v[5][pyjets_maxn];
84 fComEnergy(
pset.getParameter<double>(
"comEnergy")),
85 fextCrossSection(
pset.getUntrackedParameter<double>(
"crossSection", -1.)),
86 fextCrossSectionError(
pset.getUntrackedParameter<double>(
"crossSectionError", -1.)),
87 fFilterEfficiency(
pset.getUntrackedParameter<double>(
"filterEfficiency", -1.)),
89 fMaxEventsToPrint(
pset.getUntrackedParameter<
int>(
"maxEventsToPrint", 0)),
90 fHepMCVerbosity(
pset.getUntrackedParameter<
bool>(
"pythiaHepMCVerbosity",
false)),
91 fPythiaListVerbosity(
pset.getUntrackedParameter<
int>(
"pythiaPylistVerbosity", 0)),
93 fDisplayPythiaBanner(
pset.getUntrackedParameter<
bool>(
"displayPythiaBanner",
false)),
94 fDisplayPythiaCards(
pset.getUntrackedParameter<
bool>(
"displayPythiaCards",
false)) {
98 if (
pset.exists(
"doPDGConvert"))
135 for (
int ip = 0; ip < pyjets_maxn; ip++) {
136 for (
int i = 0;
i < 5;
i++) {
149 for (
int ip = 0; ip < pyjets_maxn; ip++) {
150 for (
int i = 0;
i < 5;
i++) {
164 if (
event()->signal_process_id() <= 0)
166 if (
event()->event_scale() <= 0)
168 if (
event()->alphaQED() <= 0)
170 if (
event()->alphaQCD() <= 0)
177 pdf.set_id1(
pyint1.mint[14] == 21 ? 0 :
pyint1.mint[14]);
179 pdf.set_id2(
pyint1.mint[15] == 21 ? 0 :
pyint1.mint[15]);
181 pdf.set_x1(
pyint1.vint[40]);
183 pdf.set_x2(
pyint1.vint[41]);
188 if (pdf.scalePDF() <= 0)
189 pdf.set_scalePDF(
pyint1.vint[50]);
191 event()->set_pdf_info(pdf);
194 cout <<
"standard Py6 event weight: pyint1.vint[96]: " <<
pyint1.vint[96] << endl;
195 cout <<
"event weight returned by PYEVWT: 1./(pyint1.vint[98]): " << 1. / (
pyint1.vint[98]) << endl;
205 event()->weights().push_back(1.);
225 for (HepMC::GenEvent::particle_iterator
part =
event()->particles_begin();
part !=
event()->particles_end();
227 (*part)->set_pdg_id(HepPID::translatePythiatoPDT((*part)->pdg_id()));
237 cout <<
"Event process = " <<
pypars.msti[0] << endl <<
"----------------------" << endl;
254 if (
pyint1.mint[50] != 0) {
282 int NPartsAfterDecays =
event().get()->particles_size();
283 int barcode = NPartsAfterDecays;
293 for (
int ipart = NPartsAfterDecays; ipart > NPartsBeforeDecays; ipart--) {
302 if (pydat3.mdcy[0][py6ptr - 1] != 1)
305 int py6id = HepPID::translatePDTtoPythia(
pdgid);
311 if (
part->momentum().t() <=
part->generated_mass()) {
318 for (
int i = 0;
i < 5;
i++) {
325 pyjets.k[1][0] = py6id;
326 pyjets.p[4][0] =
part->generated_mass();
327 pyjets.p[3][0] =
part->momentum().t();
328 pyjets.p[0][0] =
part->momentum().x();
329 pyjets.p[1][0] =
part->momentum().y();
330 pyjets.p[2][0] =
part->momentum().z();
331 HepMC::GenVertex* prod_vtx =
part->production_vertex();
334 pyjets.v[0][0] = prod_vtx->position().x();
335 pyjets.v[1][0] = prod_vtx->position().y();
336 pyjets.v[2][0] = prod_vtx->position().z();
337 pyjets.v[3][0] = prod_vtx->position().t();
350 for (
int iprt1 = 1; iprt1 < pyjets.n; iprt1++) {
353 HepMC::GenVertex* DecVtx =
new HepMC::GenVertex(
354 HepMC::FourVector(pyjets.v[0][iprt1], pyjets.v[1][iprt1], pyjets.v[2][iprt1], pyjets.v[3][iprt1]));
355 DecVtx->add_particle_in(
part);
358 HepMC::FourVector pmom(pyjets.p[0][iprt1], pyjets.p[1][iprt1], pyjets.p[2][iprt1], pyjets.p[3][iprt1]);
361 if (pyjets.k[0][iprt1] >= 1 && pyjets.k[0][iprt1] <= 10)
363 else if (pyjets.k[0][iprt1] >= 11 && pyjets.k[0][iprt1] <= 20)
365 else if (pyjets.k[0][iprt1] >= 21 && pyjets.k[0][iprt1] <= 30)
367 else if (pyjets.k[0][iprt1] >= 31 && pyjets.k[0][iprt1] <= 100)
368 dstatus = pyjets.k[0][iprt1];
371 new HepMC::GenParticle(pmom, HepPID::translatePythiatoPDT(pyjets.k[1][iprt1]), dstatus);
373 daughter->suggest_barcode(barcode);
374 DecVtx->add_particle_out(daughter);
377 for (iprt2 = iprt1 + 1; iprt2 < pyjets.n; iprt2++) {
379 if (pyjets.k[2][iprt2] !=
parent) {
380 parent = pyjets.k[2][iprt2];
384 HepMC::FourVector pmomN(pyjets.p[0][iprt2], pyjets.p[1][iprt2], pyjets.p[2][iprt2], pyjets.p[3][iprt2]);
387 if (pyjets.k[0][iprt2] >= 1 && pyjets.k[0][iprt2] <= 10)
389 else if (pyjets.k[0][iprt2] >= 11 && pyjets.k[0][iprt2] <= 20)
391 else if (pyjets.k[0][iprt2] >= 21 && pyjets.k[0][iprt2] <= 30)
393 else if (pyjets.k[0][iprt2] >= 31 && pyjets.k[0][iprt2] <= 100)
394 dstatus = pyjets.k[0][iprt2];
397 new HepMC::GenParticle(pmomN, HepPID::translatePythiatoPDT(pyjets.k[1][iprt2]), dstatus);
399 daughterN->suggest_barcode(barcode);
400 DecVtx->add_particle_out(daughterN);
406 event().get()->add_vertex(DecVtx);
419 for (
int i = 0;
i < 5;
i++) {
478 for (
unsigned i = 0;
i < AllSets.size(); ++
i) {
479 string Set = AllSets[
i];
483 for (vector<string>::const_iterator itPara = Para_Set.begin(); itPara != Para_Set.end(); ++itPara) {
486 <<
" Cascade did not accept the following parameter: \"" << *itPara <<
"\"" << endl;
516 vector<int>
pdg = _pdg;
517 for (
size_t i = 0;
i <
pdg.size();
i++) {
518 int PyID = HepPID::translatePDTtoPythia(
pdg[
i]);
522 ostringstream pyCard;
523 pyCard <<
"MDCY(" << pyCode <<
",1)=0";
538 HepMC::GenEvent::vertex_const_iterator
vbegin =
event()->vertices_begin();
539 HepMC::GenEvent::vertex_const_iterator
vend =
event()->vertices_end();
540 HepMC::GenEvent::vertex_const_iterator vitr =
vbegin;
542 for (; vitr !=
vend; ++vitr) {
543 HepMC::GenVertex::particle_iterator pbegin = (*vitr)->particles_begin(
HepMC::children);
544 HepMC::GenVertex::particle_iterator pend = (*vitr)->particles_end(
HepMC::children);
545 HepMC::GenVertex::particle_iterator pitr = pbegin;
547 for (; pitr != pend; ++pitr) {
548 if ((*pitr)->end_vertex())
550 if ((*pitr)->status() != 1)
553 int pdgcode =
abs((*pitr)->pdg_id());
555 if (pydat3.mdcy[0][
pycomp_(pdgcode) - 1] != 1)
558 double ctau = pydat2.pmas[3][
pycomp_(pdgcode) - 1];
559 HepMC::FourVector mom = (*pitr)->momentum();
560 HepMC::FourVector vin = (*vitr)->position();
565 bool decayInRange =
false;
566 while (!decayInRange) {
569 double proper_length = -ctau *
log(unif_rand);
570 double factor = proper_length / mom.m();
571 x = vin.x() +
factor * mom.px();
572 y = vin.y() +
factor * mom.py();
573 z = vin.z() +
factor * mom.pz();
574 t = vin.t() +
factor * mom.e();
577 if (
pydat1.mstj[21] == 4) {
581 }
else if (
pydat1.mstj[21] == 3) {
582 if (
sqrt(x * x + y * y + z * z) >
pydat1.parj[71])
591 HepMC::GenVertex* vdec =
new HepMC::GenVertex(HepMC::FourVector(x, y, z,
t));
592 event()->add_vertex(vdec);
593 vdec->add_particle_in((*pitr));
605 if (!
runInfo().internalXSec()) {
606 double sigma_CMS = 0.001 *
caeffic.avgi;
607 double error_CMS = 0.001 *
caeffic.sd;
627 if (!strncmp(ParameterString.c_str(),
"KE", 2))
628 caluco.ke = atoi(&ParameterString[strcspn(ParameterString.c_str(),
"=") + 1]);
630 else if (!strncmp(ParameterString.c_str(),
"IRES(1)", 7))
631 capar6.ires[0] = atoi(&ParameterString[strcspn(ParameterString.c_str(),
"=") + 1]);
633 else if (!strncmp(ParameterString.c_str(),
"KP", 2))
634 caluco.kp = atoi(&ParameterString[strcspn(ParameterString.c_str(),
"=") + 1]);
636 else if (!strncmp(ParameterString.c_str(),
"IRES(2)", 7))
637 capar6.ires[1] = atoi(&ParameterString[strcspn(ParameterString.c_str(),
"=") + 1]);
639 else if (!strncmp(ParameterString.c_str(),
"NFRAG", 5))
640 cainpu.nfrag = atoi(&ParameterString[strcspn(ParameterString.c_str(),
"=") + 1]);
642 else if (!strncmp(ParameterString.c_str(),
"IPST", 4))
643 cashower.ipst = atoi(&ParameterString[strcspn(ParameterString.c_str(),
"=") + 1]);
645 else if (!strncmp(ParameterString.c_str(),
"IPSIPOL", 7))
646 jpsi.ipsipol = atoi(&ParameterString[strcspn(ParameterString.c_str(),
"=") + 1]);
652 else if (!strncmp(ParameterString.c_str(),
"IFPS", 4))
653 cainpu.ifps = atoi(&ParameterString[strcspn(ParameterString.c_str(),
"=") + 1]);
655 else if (!strncmp(ParameterString.c_str(),
"ITIMSHR", 7))
656 casshwr.itimshr = atoi(&ParameterString[strcspn(ParameterString.c_str(),
"=") + 1]);
658 else if (!strncmp(ParameterString.c_str(),
"IRUNAEM", 7))
659 capar1.irunaem = atoi(&ParameterString[strcspn(ParameterString.c_str(),
"=") + 1]);
661 else if (!strncmp(ParameterString.c_str(),
"IRUNA", 5))
662 capar1.iruna = atoi(&ParameterString[strcspn(ParameterString.c_str(),
"=") + 1]);
664 else if (!strncmp(ParameterString.c_str(),
"IQ2", 3))
665 capar1.iq2 = atoi(&ParameterString[strcspn(ParameterString.c_str(),
"=") + 1]);
667 else if (!strncmp(ParameterString.c_str(),
"IPRO", 4))
668 capar1.ipro = atoi(&ParameterString[strcspn(ParameterString.c_str(),
"=") + 1]);
670 else if (!strncmp(ParameterString.c_str(),
"NFLAV", 5))
671 caluco.nflav = atoi(&ParameterString[strcspn(ParameterString.c_str(),
"=") + 1]);
673 else if (!strncmp(ParameterString.c_str(),
"INTER", 5))
674 cainpu.inter = atoi(&ParameterString[strcspn(ParameterString.c_str(),
"=") + 1]);
676 else if (!strncmp(ParameterString.c_str(),
"IHFLA", 5))
677 cahflav.ihfla = atoi(&ParameterString[strcspn(ParameterString.c_str(),
"=") + 1]);
679 else if (!strncmp(ParameterString.c_str(),
"IRPA", 4))
680 cascol.irpa = atoi(&ParameterString[strcspn(ParameterString.c_str(),
"=") + 1]);
682 else if (!strncmp(ParameterString.c_str(),
"IRPB", 4))
683 cascol.irpb = atoi(&ParameterString[strcspn(ParameterString.c_str(),
"=") + 1]);
685 else if (!strncmp(ParameterString.c_str(),
"IRPC", 4))
686 cascol.irpc = atoi(&ParameterString[strcspn(ParameterString.c_str(),
"=") + 1]);
688 else if (!strncmp(ParameterString.c_str(),
"ICCFM", 5))
689 casshwr.iccfm = atoi(&ParameterString[strcspn(ParameterString.c_str(),
"=") + 1]);
691 else if (!strncmp(ParameterString.c_str(),
"IFINAL", 6))
692 cainpu.ifinal = atoi(&ParameterString[strcspn(ParameterString.c_str(),
"=") + 1]);
694 else if (!strncmp(ParameterString.c_str(),
"IGLU", 4))
695 cagluon.iglu = atoi(&ParameterString[strcspn(ParameterString.c_str(),
"=") + 1]);
697 else if (!strncmp(ParameterString.c_str(),
"IRspl", 5))
698 casprre.irspl = atoi(&ParameterString[strcspn(ParameterString.c_str(),
"=") + 1]);
700 else if (!strncmp(ParameterString.c_str(),
"PT2CUT", 6))
701 captcut.pt2cut[
capar1.ipro - 1] = atof(&ParameterString[strcspn(ParameterString.c_str(),
"=") + 1]);
703 else if (!strncmp(ParameterString.c_str(),
"NCB", 3))
704 integr.ncb = atoi(&ParameterString[strcspn(ParameterString.c_str(),
"=") + 1]);
706 else if (!strncmp(ParameterString.c_str(),
"ACC1", 4))
707 integr.acc1 = atof(&ParameterString[strcspn(ParameterString.c_str(),
"=") + 1]);
709 else if (!strncmp(ParameterString.c_str(),
"ACC2", 4))
710 integr.acc2 = atof(&ParameterString[strcspn(ParameterString.c_str(),
"=") + 1]);
712 else if (!strncmp(ParameterString.c_str(),
"SCALFAF", 7))
713 scalf.scalfaf = atof(&ParameterString[strcspn(ParameterString.c_str(),
"=") + 1]);
715 else if (!strncmp(ParameterString.c_str(),
"SCALFA", 6))
716 scalf.scalfa = atof(&ParameterString[strcspn(ParameterString.c_str(),
"=") + 1]);
726 cout <<
"----------------------------------" << endl;
727 cout <<
"---- Cascade Parameters ----" << endl;
728 cout <<
"----------------------------------" << endl;
731 cout <<
"computation switch: " << endl;
732 cout <<
"number of calls per iteration for bases: " <<
integr.ncb << endl;
733 cout <<
"relative precision for grid optimisation: " <<
integr.acc1 <<
" %" << endl;
734 cout <<
"relative precision for integration: " <<
integr.acc2 <<
" %" << endl;
737 cout <<
"kinematics: " << endl;
738 cout <<
"flavour code of beam 1: " <<
caluco.ke << endl;
739 cout <<
"direct or resolved particle 1: " <<
capar6.ires[0] << endl;
740 cout <<
"pz of incoming beam 1: " <<
cainpu.plepin <<
" GeV" << endl;
741 cout <<
"flavour code of beam 2: " <<
caluco.kp << endl;
742 cout <<
"direct or resolved particle 2: " <<
capar6.ires[1] << endl;
743 cout <<
"pz of incoming beam 2: " <<
cainpu.ppin <<
" GeV" << endl;
744 cout <<
"number of active flavors: " <<
caluco.nflav << endl;
747 cout <<
"hard subprocess selection: " << endl;
748 cout <<
"hard subprocess number (IPRO): " <<
capar1.ipro << endl;
749 cout <<
"IPRO = 10, switch to select QCD process g* g* -> q qbar: " <<
cascol.irpa << endl;
750 cout <<
"IPRO = 10, switch to select QCD process g* g -> g g: " <<
cascol.irpb << endl;
751 cout <<
"IPRO = 10, switch to select QCD process g* q -> g q: " <<
cascol.irpc << endl;
752 cout <<
"flavor of heavy quark produced (IPRO = 11, 504, 514): " <<
cahflav.ihfla << endl;
754 cout <<
"use matrix element including J/psi (Upsilon) polarisation: " <<
jpsi.ipsipol << endl;
755 cout <<
"pt2 cut in matrix element for massless partons: " <<
captcut.pt2cut[
capar1.ipro - 1] <<
" GeV^2" << endl;
758 cout <<
"parton shower and fragmentation: " << endl;
759 cout <<
"switch for fragmentation: " <<
cainpu.nfrag << endl;
760 cout <<
"switch for parton shower (0 off - 1 initial state - 2 final state - 3 initial & final state): "
762 cout <<
"switch for time like parton shower in initial state: " <<
casshwr.itimshr << endl;
763 cout <<
"select CCFM (1) or DGLAP (0) evolution: " <<
casshwr.iccfm << endl;
764 cout <<
"scale switch for final state parton shower: " <<
cainpu.ifinal << endl;
765 cout <<
"scale factor for final state parton shower: " <<
scalf.scalfaf << endl;
766 cout <<
"switch for proton remnant treatment: " <<
casprre.irspl << endl;
767 cout <<
"keep track of intermediate state in parton shower: " <<
cashower.ipst << endl;
768 cout <<
"mode of interaction for e p: " <<
cainpu.inter << endl;
771 cout <<
"pdfs, couplings and scales: " << endl;
772 cout <<
"switch for running alphaem: " <<
capar1.irunaem << endl;
773 cout <<
"switch for running alphas: " <<
capar1.iruna << endl;
774 cout <<
"scale in alphas: " <<
capar1.iq2 << endl;
775 cout <<
"scale factor for scale in alphas: " <<
scalf.scalfa << endl;
776 cout <<
"unintegrated pdf: " <<
cagluon.iglu << endl;
777 cout <<
"path where updf are stored: " <<
caspdf.pdfpath << endl;
780 cout <<
"center of mass energy, cross section, filter efficiency: " << endl;
781 cout <<
"center of mass energy: " <<
fComEnergy <<
" GeV" << endl;
789 cout <<
"----------------------------------" << endl;
790 cout <<
"---- Pythia6 Parameters ----" << endl;
791 cout <<
"----------------------------------" << endl;
794 cout <<
"charm mass: " << pydat2.pmas[0][3] <<
" GeV (default value = 1.5 GeV)" << endl;
795 cout <<
"bottom mass: " << pydat2.pmas[0][4] <<
" GeV (default value = 4.8 GeV)" << endl;
796 cout <<
"Higgs mass: " << pydat2.pmas[0][24] <<
" GeV (default value = 115 GeV)" << endl;
798 cout <<
"lambda QCD: " <<
pydat1.paru[111] <<
" GeV (default value = 0.25 GeV)" << endl;
800 cout <<
"alphas behaviour: " <<
pydat1.mstu[110] <<
" (default value = 1)" << endl;
801 cout <<
"nr of flavours wrt lambda QCD: " <<
pydat1.mstu[111] <<
" (default value = 5)" << endl;
802 cout <<
"min nr of flavours for alphas: " <<
pydat1.mstu[112] <<
" (default value = 3)" << endl;
803 cout <<
"max nr of flavours for alphas: " <<
pydat1.mstu[113] <<
" (default value = 5)" << endl;
805 cout <<
"maximum angle settings: " <<
pydat1.mstj[47] <<
" (default value = 0)" << endl;