5 #include "HepMC/GenEvent.h"
6 #include "HepMC/PdfInfo.h"
7 #include "HepMC/PythiaWrapper6_4.h"
10 #include "HepMC/HEPEVT_Wrapper.h"
11 #include "HepMC/IO_HEPEVT.h"
12 #include "HepMC/IO_GenEvent.h"
21 #include "HepPID/ParticleIDTranslations.hh"
32 #include "CLHEP/Random/RandomEngine.h"
48 if (
debug && ++call < 100)
49 cout <<
"dcasrn from c++, call: " << call <<
" random number: " << rdm_nb << endl;
62 void upInit()
override { FortranCallback::getInstance()->fillHeader(); }
64 void upEvnt()
override { FortranCallback::getInstance()->fillEvent(); }
76 double p[5][pyjets_maxn],
v[5][pyjets_maxn];
86 fComEnergy(
pset.getParameter<double>(
"comEnergy")),
87 fextCrossSection(
pset.getUntrackedParameter<double>(
"crossSection", -1.)),
88 fextCrossSectionError(
pset.getUntrackedParameter<double>(
"crossSectionError", -1.)),
89 fFilterEfficiency(
pset.getUntrackedParameter<double>(
"filterEfficiency", -1.)),
91 fMaxEventsToPrint(
pset.getUntrackedParameter<
int>(
"maxEventsToPrint", 0)),
92 fHepMCVerbosity(
pset.getUntrackedParameter<
bool>(
"pythiaHepMCVerbosity",
false)),
93 fPythiaListVerbosity(
pset.getUntrackedParameter<
int>(
"pythiaPylistVerbosity", 0)),
95 fDisplayPythiaBanner(
pset.getUntrackedParameter<
bool>(
"displayPythiaBanner",
false)),
96 fDisplayPythiaCards(
pset.getUntrackedParameter<
bool>(
"displayPythiaCards",
false)) {
100 if (
pset.exists(
"doPDGConvert"))
137 for (
int ip = 0; ip < pyjets_maxn; ip++) {
138 for (
int i = 0;
i < 5;
i++) {
151 for (
int ip = 0; ip < pyjets_maxn; ip++) {
152 for (
int i = 0;
i < 5;
i++) {
166 if (
event()->signal_process_id() <= 0)
168 if (
event()->event_scale() <= 0)
170 if (
event()->alphaQED() <= 0)
172 if (
event()->alphaQCD() <= 0)
179 pdf.set_id1(
pyint1.mint[14] == 21 ? 0 :
pyint1.mint[14]);
181 pdf.set_id2(
pyint1.mint[15] == 21 ? 0 :
pyint1.mint[15]);
183 pdf.set_x1(
pyint1.vint[40]);
185 pdf.set_x2(
pyint1.vint[41]);
190 if (pdf.scalePDF() <= 0)
191 pdf.set_scalePDF(
pyint1.vint[50]);
193 event()->set_pdf_info(pdf);
196 cout <<
"standard Py6 event weight: pyint1.vint[96]: " <<
pyint1.vint[96] << endl;
197 cout <<
"event weight returned by PYEVWT: 1./(pyint1.vint[98]): " << 1. / (
pyint1.vint[98]) << endl;
207 event()->weights().push_back(1.);
227 for (HepMC::GenEvent::particle_iterator
part =
event()->particles_begin();
part !=
event()->particles_end();
229 (*part)->set_pdg_id(HepPID::translatePythiatoPDT((*part)->pdg_id()));
239 cout <<
"Event process = " <<
pypars.msti[0] << endl <<
"----------------------" << endl;
256 if (
pyint1.mint[50] != 0) {
284 int NPartsAfterDecays =
event().get()->particles_size();
285 int barcode = NPartsAfterDecays;
295 for (
int ipart = NPartsAfterDecays; ipart > NPartsBeforeDecays; ipart--) {
304 if (pydat3.mdcy[0][py6ptr - 1] != 1)
307 int py6id = HepPID::translatePDTtoPythia(
pdgid);
313 if (
part->momentum().t() <=
part->generated_mass()) {
320 for (
int i = 0;
i < 5;
i++) {
327 pyjets.k[1][0] = py6id;
328 pyjets.p[4][0] =
part->generated_mass();
329 pyjets.p[3][0] =
part->momentum().t();
330 pyjets.p[0][0] =
part->momentum().x();
331 pyjets.p[1][0] =
part->momentum().y();
332 pyjets.p[2][0] =
part->momentum().z();
333 HepMC::GenVertex* prod_vtx =
part->production_vertex();
336 pyjets.v[0][0] = prod_vtx->position().x();
337 pyjets.v[1][0] = prod_vtx->position().y();
338 pyjets.v[2][0] = prod_vtx->position().z();
339 pyjets.v[3][0] = prod_vtx->position().t();
352 for (
int iprt1 = 1; iprt1 < pyjets.n; iprt1++) {
355 HepMC::GenVertex* DecVtx =
new HepMC::GenVertex(
356 HepMC::FourVector(pyjets.v[0][iprt1], pyjets.v[1][iprt1], pyjets.v[2][iprt1], pyjets.v[3][iprt1]));
357 DecVtx->add_particle_in(
part);
360 HepMC::FourVector pmom(pyjets.p[0][iprt1], pyjets.p[1][iprt1], pyjets.p[2][iprt1], pyjets.p[3][iprt1]);
363 if (pyjets.k[0][iprt1] >= 1 && pyjets.k[0][iprt1] <= 10)
365 else if (pyjets.k[0][iprt1] >= 11 && pyjets.k[0][iprt1] <= 20)
367 else if (pyjets.k[0][iprt1] >= 21 && pyjets.k[0][iprt1] <= 30)
369 else if (pyjets.k[0][iprt1] >= 31 && pyjets.k[0][iprt1] <= 100)
370 dstatus = pyjets.k[0][iprt1];
373 new HepMC::GenParticle(pmom, HepPID::translatePythiatoPDT(pyjets.k[1][iprt1]), dstatus);
375 daughter->suggest_barcode(barcode);
376 DecVtx->add_particle_out(daughter);
379 for (iprt2 = iprt1 + 1; iprt2 < pyjets.n; iprt2++) {
381 if (pyjets.k[2][iprt2] !=
parent) {
382 parent = pyjets.k[2][iprt2];
386 HepMC::FourVector pmomN(pyjets.p[0][iprt2], pyjets.p[1][iprt2], pyjets.p[2][iprt2], pyjets.p[3][iprt2]);
389 if (pyjets.k[0][iprt2] >= 1 && pyjets.k[0][iprt2] <= 10)
391 else if (pyjets.k[0][iprt2] >= 11 && pyjets.k[0][iprt2] <= 20)
393 else if (pyjets.k[0][iprt2] >= 21 && pyjets.k[0][iprt2] <= 30)
395 else if (pyjets.k[0][iprt2] >= 31 && pyjets.k[0][iprt2] <= 100)
396 dstatus = pyjets.k[0][iprt2];
399 new HepMC::GenParticle(pmomN, HepPID::translatePythiatoPDT(pyjets.k[1][iprt2]), dstatus);
401 daughterN->suggest_barcode(barcode);
402 DecVtx->add_particle_out(daughterN);
408 event().get()->add_vertex(DecVtx);
421 for (
int i = 0;
i < 5;
i++) {
480 for (
unsigned i = 0;
i < AllSets.size(); ++
i) {
481 string Set = AllSets[
i];
485 for (vector<string>::const_iterator itPara = Para_Set.begin(); itPara != Para_Set.end(); ++itPara) {
488 <<
" Cascade did not accept the following parameter: \"" << *itPara <<
"\"" << endl;
518 vector<int>
pdg = _pdg;
519 for (
size_t i = 0;
i <
pdg.size();
i++) {
520 int PyID = HepPID::translatePDTtoPythia(
pdg[
i]);
524 ostringstream pyCard;
525 pyCard <<
"MDCY(" << pyCode <<
",1)=0";
540 HepMC::GenEvent::vertex_const_iterator vbegin =
event()->vertices_begin();
541 HepMC::GenEvent::vertex_const_iterator vend =
event()->vertices_end();
542 HepMC::GenEvent::vertex_const_iterator vitr = vbegin;
544 for (; vitr != vend; ++vitr) {
545 HepMC::GenVertex::particle_iterator pbegin = (*vitr)->particles_begin(
HepMC::children);
546 HepMC::GenVertex::particle_iterator pend = (*vitr)->particles_end(
HepMC::children);
547 HepMC::GenVertex::particle_iterator pitr = pbegin;
549 for (; pitr != pend; ++pitr) {
550 if ((*pitr)->end_vertex())
552 if ((*pitr)->status() != 1)
555 int pdgcode =
abs((*pitr)->pdg_id());
557 if (pydat3.mdcy[0][
pycomp_(pdgcode) - 1] != 1)
560 double ctau = pydat2.pmas[3][
pycomp_(pdgcode) - 1];
561 HepMC::FourVector mom = (*pitr)->momentum();
562 HepMC::FourVector vin = (*vitr)->position();
567 bool decayInRange =
false;
568 while (!decayInRange) {
571 double proper_length = -ctau *
log(unif_rand);
572 double factor = proper_length / mom.m();
573 x = vin.x() +
factor * mom.px();
574 y = vin.y() +
factor * mom.py();
575 z = vin.z() +
factor * mom.pz();
576 t = vin.t() +
factor * mom.e();
579 if (
pydat1.mstj[21] == 4) {
583 }
else if (
pydat1.mstj[21] == 3) {
584 if (
sqrt(x * x + y * y + z * z) >
pydat1.parj[71])
593 HepMC::GenVertex* vdec =
new HepMC::GenVertex(HepMC::FourVector(x, y, z,
t));
594 event()->add_vertex(vdec);
595 vdec->add_particle_in((*pitr));
607 if (!
runInfo().internalXSec()) {
608 double sigma_CMS = 0.001 *
caeffic.avgi;
609 double error_CMS = 0.001 *
caeffic.sd;
627 bool accepted =
true;
629 if (!strncmp(ParameterString.c_str(),
"KE", 2))
630 caluco.ke = atoi(&ParameterString[strcspn(ParameterString.c_str(),
"=") + 1]);
632 else if (!strncmp(ParameterString.c_str(),
"IRES(1)", 7))
633 capar6.ires[0] = atoi(&ParameterString[strcspn(ParameterString.c_str(),
"=") + 1]);
635 else if (!strncmp(ParameterString.c_str(),
"KP", 2))
636 caluco.kp = atoi(&ParameterString[strcspn(ParameterString.c_str(),
"=") + 1]);
638 else if (!strncmp(ParameterString.c_str(),
"IRES(2)", 7))
639 capar6.ires[1] = atoi(&ParameterString[strcspn(ParameterString.c_str(),
"=") + 1]);
641 else if (!strncmp(ParameterString.c_str(),
"NFRAG", 5))
642 cainpu.nfrag = atoi(&ParameterString[strcspn(ParameterString.c_str(),
"=") + 1]);
644 else if (!strncmp(ParameterString.c_str(),
"IPST", 4))
645 cashower.ipst = atoi(&ParameterString[strcspn(ParameterString.c_str(),
"=") + 1]);
647 else if (!strncmp(ParameterString.c_str(),
"IPSIPOL", 7))
648 jpsi.ipsipol = atoi(&ParameterString[strcspn(ParameterString.c_str(),
"=") + 1]);
654 else if (!strncmp(ParameterString.c_str(),
"IFPS", 4))
655 cainpu.ifps = atoi(&ParameterString[strcspn(ParameterString.c_str(),
"=") + 1]);
657 else if (!strncmp(ParameterString.c_str(),
"ITIMSHR", 7))
658 casshwr.itimshr = atoi(&ParameterString[strcspn(ParameterString.c_str(),
"=") + 1]);
660 else if (!strncmp(ParameterString.c_str(),
"IRUNAEM", 7))
661 capar1.irunaem = atoi(&ParameterString[strcspn(ParameterString.c_str(),
"=") + 1]);
663 else if (!strncmp(ParameterString.c_str(),
"IRUNA", 5))
664 capar1.iruna = atoi(&ParameterString[strcspn(ParameterString.c_str(),
"=") + 1]);
666 else if (!strncmp(ParameterString.c_str(),
"IQ2", 3))
667 capar1.iq2 = atoi(&ParameterString[strcspn(ParameterString.c_str(),
"=") + 1]);
669 else if (!strncmp(ParameterString.c_str(),
"IPRO", 4))
670 capar1.ipro = atoi(&ParameterString[strcspn(ParameterString.c_str(),
"=") + 1]);
672 else if (!strncmp(ParameterString.c_str(),
"NFLAV", 5))
673 caluco.nflav = atoi(&ParameterString[strcspn(ParameterString.c_str(),
"=") + 1]);
675 else if (!strncmp(ParameterString.c_str(),
"INTER", 5))
676 cainpu.inter = atoi(&ParameterString[strcspn(ParameterString.c_str(),
"=") + 1]);
678 else if (!strncmp(ParameterString.c_str(),
"IHFLA", 5))
679 cahflav.ihfla = atoi(&ParameterString[strcspn(ParameterString.c_str(),
"=") + 1]);
681 else if (!strncmp(ParameterString.c_str(),
"IRPA", 4))
682 cascol.irpa = atoi(&ParameterString[strcspn(ParameterString.c_str(),
"=") + 1]);
684 else if (!strncmp(ParameterString.c_str(),
"IRPB", 4))
685 cascol.irpb = atoi(&ParameterString[strcspn(ParameterString.c_str(),
"=") + 1]);
687 else if (!strncmp(ParameterString.c_str(),
"IRPC", 4))
688 cascol.irpc = atoi(&ParameterString[strcspn(ParameterString.c_str(),
"=") + 1]);
690 else if (!strncmp(ParameterString.c_str(),
"ICCFM", 5))
691 casshwr.iccfm = atoi(&ParameterString[strcspn(ParameterString.c_str(),
"=") + 1]);
693 else if (!strncmp(ParameterString.c_str(),
"IFINAL", 6))
694 cainpu.ifinal = atoi(&ParameterString[strcspn(ParameterString.c_str(),
"=") + 1]);
696 else if (!strncmp(ParameterString.c_str(),
"IGLU", 4))
697 cagluon.iglu = atoi(&ParameterString[strcspn(ParameterString.c_str(),
"=") + 1]);
699 else if (!strncmp(ParameterString.c_str(),
"IRspl", 5))
700 casprre.irspl = atoi(&ParameterString[strcspn(ParameterString.c_str(),
"=") + 1]);
702 else if (!strncmp(ParameterString.c_str(),
"PT2CUT", 6))
703 captcut.pt2cut[
capar1.ipro - 1] = atof(&ParameterString[strcspn(ParameterString.c_str(),
"=") + 1]);
705 else if (!strncmp(ParameterString.c_str(),
"NCB", 3))
706 integr.ncb = atoi(&ParameterString[strcspn(ParameterString.c_str(),
"=") + 1]);
708 else if (!strncmp(ParameterString.c_str(),
"ACC1", 4))
709 integr.acc1 = atof(&ParameterString[strcspn(ParameterString.c_str(),
"=") + 1]);
711 else if (!strncmp(ParameterString.c_str(),
"ACC2", 4))
712 integr.acc2 = atof(&ParameterString[strcspn(ParameterString.c_str(),
"=") + 1]);
714 else if (!strncmp(ParameterString.c_str(),
"SCALFAF", 7))
715 scalf.scalfaf = atof(&ParameterString[strcspn(ParameterString.c_str(),
"=") + 1]);
717 else if (!strncmp(ParameterString.c_str(),
"SCALFA", 6))
718 scalf.scalfa = atof(&ParameterString[strcspn(ParameterString.c_str(),
"=") + 1]);
728 cout <<
"----------------------------------" << endl;
729 cout <<
"---- Cascade Parameters ----" << endl;
730 cout <<
"----------------------------------" << endl;
733 cout <<
"computation switch: " << endl;
734 cout <<
"number of calls per iteration for bases: " <<
integr.ncb << endl;
735 cout <<
"relative precision for grid optimisation: " <<
integr.acc1 <<
" %" << endl;
736 cout <<
"relative precision for integration: " <<
integr.acc2 <<
" %" << endl;
739 cout <<
"kinematics: " << endl;
740 cout <<
"flavour code of beam 1: " <<
caluco.ke << endl;
741 cout <<
"direct or resolved particle 1: " <<
capar6.ires[0] << endl;
742 cout <<
"pz of incoming beam 1: " <<
cainpu.plepin <<
" GeV" << endl;
743 cout <<
"flavour code of beam 2: " <<
caluco.kp << endl;
744 cout <<
"direct or resolved particle 2: " <<
capar6.ires[1] << endl;
745 cout <<
"pz of incoming beam 2: " <<
cainpu.ppin <<
" GeV" << endl;
746 cout <<
"number of active flavors: " <<
caluco.nflav << endl;
749 cout <<
"hard subprocess selection: " << endl;
750 cout <<
"hard subprocess number (IPRO): " <<
capar1.ipro << endl;
751 cout <<
"IPRO = 10, switch to select QCD process g* g* -> q qbar: " <<
cascol.irpa << endl;
752 cout <<
"IPRO = 10, switch to select QCD process g* g -> g g: " <<
cascol.irpb << endl;
753 cout <<
"IPRO = 10, switch to select QCD process g* q -> g q: " <<
cascol.irpc << endl;
754 cout <<
"flavor of heavy quark produced (IPRO = 11, 504, 514): " <<
cahflav.ihfla << endl;
756 cout <<
"use matrix element including J/psi (Upsilon) polarisation: " <<
jpsi.ipsipol << endl;
757 cout <<
"pt2 cut in matrix element for massless partons: " <<
captcut.pt2cut[
capar1.ipro - 1] <<
" GeV^2" << endl;
760 cout <<
"parton shower and fragmentation: " << endl;
761 cout <<
"switch for fragmentation: " <<
cainpu.nfrag << endl;
762 cout <<
"switch for parton shower (0 off - 1 initial state - 2 final state - 3 initial & final state): "
764 cout <<
"switch for time like parton shower in initial state: " <<
casshwr.itimshr << endl;
765 cout <<
"select CCFM (1) or DGLAP (0) evolution: " <<
casshwr.iccfm << endl;
766 cout <<
"scale switch for final state parton shower: " <<
cainpu.ifinal << endl;
767 cout <<
"scale factor for final state parton shower: " <<
scalf.scalfaf << endl;
768 cout <<
"switch for proton remnant treatment: " <<
casprre.irspl << endl;
769 cout <<
"keep track of intermediate state in parton shower: " <<
cashower.ipst << endl;
770 cout <<
"mode of interaction for e p: " <<
cainpu.inter << endl;
773 cout <<
"pdfs, couplings and scales: " << endl;
774 cout <<
"switch for running alphaem: " <<
capar1.irunaem << endl;
775 cout <<
"switch for running alphas: " <<
capar1.iruna << endl;
776 cout <<
"scale in alphas: " <<
capar1.iq2 << endl;
777 cout <<
"scale factor for scale in alphas: " <<
scalf.scalfa << endl;
778 cout <<
"unintegrated pdf: " <<
cagluon.iglu << endl;
779 cout <<
"path where updf are stored: " <<
caspdf.pdfpath << endl;
782 cout <<
"center of mass energy, cross section, filter efficiency: " << endl;
783 cout <<
"center of mass energy: " <<
fComEnergy <<
" GeV" << endl;
791 cout <<
"----------------------------------" << endl;
792 cout <<
"---- Pythia6 Parameters ----" << endl;
793 cout <<
"----------------------------------" << endl;
796 cout <<
"charm mass: " << pydat2.pmas[0][3] <<
" GeV (default value = 1.5 GeV)" << endl;
797 cout <<
"bottom mass: " << pydat2.pmas[0][4] <<
" GeV (default value = 4.8 GeV)" << endl;
798 cout <<
"Higgs mass: " << pydat2.pmas[0][24] <<
" GeV (default value = 115 GeV)" << endl;
800 cout <<
"lambda QCD: " <<
pydat1.paru[111] <<
" GeV (default value = 0.25 GeV)" << endl;
802 cout <<
"alphas behaviour: " <<
pydat1.mstu[110] <<
" (default value = 1)" << endl;
803 cout <<
"nr of flavours wrt lambda QCD: " <<
pydat1.mstu[111] <<
" (default value = 5)" << endl;
804 cout <<
"min nr of flavours for alphas: " <<
pydat1.mstu[112] <<
" (default value = 3)" << endl;
805 cout <<
"max nr of flavours for alphas: " <<
pydat1.mstu[113] <<
" (default value = 5)" << endl;
807 cout <<
"maximum angle settings: " <<
pydat1.mstj[47] <<
" (default value = 0)" << endl;