21 double string_tension,
double time_formation,
double gluon_beta,
22 double gluon_pmin,
double quark_alpha,
double quark_beta,
23 double strange_supp,
double diquark_supp,
double sigma_perp,
24 double stringz_a_leading,
double stringz_b_leading,
double stringz_a,
25 double stringz_b,
double string_sigma_T,
double factor_t_form,
26 bool mass_dependent_formation_times,
double prob_proton_to_d_uu,
27 bool separate_fragment_baryon,
double popcorn_rate)
28 : pmin_gluon_lightcone_(gluon_pmin),
29 pow_fgluon_beta_(gluon_beta),
30 pow_fquark_alpha_(quark_alpha),
31 pow_fquark_beta_(quark_beta),
32 sigma_qperp_(sigma_perp),
33 stringz_a_leading_(stringz_a_leading),
34 stringz_b_leading_(stringz_b_leading),
35 stringz_a_produce_(stringz_a),
36 stringz_b_produce_(stringz_b),
37 kappa_tension_string_(string_tension),
38 additional_xsec_supp_(0.7),
39 time_formation_const_(time_formation),
40 soft_t_form_(factor_t_form),
42 mass_dependent_formation_times_(mass_dependent_formation_times),
43 prob_proton_to_d_uu_(prob_proton_to_d_uu),
44 separate_fragment_baryon_(separate_fragment_baryon) {
46 pythia_parton_ = make_unique<Pythia8::Pythia>(PYTHIA_XML_DIR,
false);
53 popcorn_rate, stringz_a, stringz_b, string_sigma_T);
56 pythia_hadron_ = make_unique<Pythia8::Pythia>(PYTHIA_XML_DIR,
false);
58 pythia_hadron_->readString(
"ProcessLevel:all = off");
60 popcorn_rate, stringz_a, stringz_b, string_sigma_T);
63 pythia_hadron_->init();
65 &pythia_hadron_->particleData, &pythia_hadron_->rndm);
67 &pythia_hadron_->particleData, &pythia_hadron_->rndm,
68 &pythia_hadron_->info);
70 &pythia_hadron_->particleData);
72 for (
int imu = 0; imu < 3; imu++) {
82 double popcorn_rate,
double stringz_a,
84 double string_sigma_T) {
86 pythia_in->readString(
"ParticleData:modeBreitWigner = 4");
89 pythia_in->readString(
"MultipartonInteractions:pTmin = 1.5");
90 pythia_in->readString(
"MultipartonInteractions:nSample = 10000");
92 pythia_in->readString(
"StringPT:sigma = " + std::to_string(string_sigma_T));
94 pythia_in->readString(
"StringFlav:probQQtoQ = " +
95 std::to_string(diquark_supp));
97 pythia_in->readString(
"StringFlav:probStoUD = " +
98 std::to_string(strange_supp));
99 pythia_in->readString(
"StringFlav:popcornRate = " +
100 std::to_string(popcorn_rate));
102 pythia_in->readString(
"StringZ:aLund = " + std::to_string(stringz_a));
103 pythia_in->readString(
"StringZ:bLund = " + std::to_string(stringz_b));
106 pythia_in->readString(
"PDF:pSet = 13");
107 pythia_in->readString(
"PDF:pSetB = 13");
108 pythia_in->readString(
"PDF:piSet = 1");
109 pythia_in->readString(
"PDF:piSetB = 1");
110 pythia_in->readString(
"Beams:idA = 2212");
111 pythia_in->readString(
"Beams:idB = 2212");
112 pythia_in->readString(
"Beams:eCM = 10.");
115 pythia_in->readString(
"Random:setSeed = on");
117 pythia_in->readString(
"Print:quiet = on");
119 pythia_in->readString(
"HadronLevel:Decay = off");
122 int pdgid = ptype.pdgcode().get_decimal();
123 double mass_pole = ptype.mass();
124 double width_pole = ptype.width_at_pole();
126 if (pythia_in->particleData.isParticle(pdgid)) {
128 pythia_in->particleData.m0(pdgid, mass_pole);
129 pythia_in->particleData.mWidth(pdgid, width_pole);
130 }
else if (pdgid == 310 || pdgid == 130) {
132 pythia_in->particleData.m0(pdgid,
kaon_mass);
133 pythia_in->particleData.mWidth(pdgid, 0.);
138 pythia_in->readString(
"Check:epTolErr = 1e-6");
139 pythia_in->readString(
"Check:epTolWarn = 1e-8");
151 bstring += data.pdgcode().baryon_number();
164 for (
int i = 0; i < nfrag; i++) {
165 ThreeVector velocity = intermediate_particles[i].momentum().velocity();
166 double gamma = 1. / intermediate_particles[i].inverse_gamma();
169 intermediate_particles[i].momentum().
LorentzBoost(-vstring);
170 intermediate_particles[i].set_4momentum(momentum);
174 double tau_prod = M_SQRT2 * intermediate_particles[i].effective_mass() /
176 double t_prod = tau_prod * gamma;
180 fragment_position = fragment_position.
LorentzBoost(-vstring);
182 intermediate_particles[i].set_slow_formation_times(
187 double gamma_factor = 1.0 / std::sqrt(1 - (v_calc).sqr());
188 intermediate_particles[i].set_slow_formation_times(
202 massA_ = incoming[0].effective_mass();
203 massB_ = incoming[1].effective_mass();
205 plab_[0] = incoming[0].momentum();
206 plab_[1] = incoming[1].momentum();
239 double QTrn, QTrx, QTry;
240 double pabscomHX_sqr, massX;
249 if (mstrMin > mstrMax) {
255 QTrn = std::sqrt(QTrx * QTrx + QTry * QTry);
262 const bool foundPabsX = pabscomHX_sqr > QTrn * QTrn;
267 double sign_direction = is_AB_to_AX ? 1. : -1.;
271 (
evecBasisAB_[0] * std::sqrt(pabscomHX_sqr - QTrn * QTrn) +
273 const FourVector pstrHcom(std::sqrt(pabscomHX_sqr + massH * massH),
275 const FourVector pstrXcom(std::sqrt(pabscomHX_sqr + massX * massX),
283 is_AB_to_AX ?
pcom_[1].threevec() :
pcom_[0].threevec();
288 ParticleList new_intermediate_particles;
290 new_intermediate_particles);
299 PdgCode hadron_code = is_AB_to_AX ? PDGcodes_[0] : PDGcodes_[1];
311 const std::array<std::array<int, 2>, 2> &quarks,
312 const std::array<FourVector, 2> &pstr_com, std::array<double, 2> &m_str,
313 std::array<ThreeVector, 2> &evec_str) {
314 std::array<bool, 2> found_mass;
315 for (
int i = 0; i < 2; i++) {
316 found_mass[i] =
false;
318 m_str[i] = pstr_com[i].sqr();
319 m_str[i] = (m_str[i] > 0.) ? std::sqrt(m_str[i]) : 0.;
320 const double threshold =
pythia_hadron_->particleData.m0(quarks[i][0]) +
323 if (m_str[i] > threshold) {
324 found_mass[i] =
true;
340 evec_str[i] = prs.threevec() / prs.threevec().abs();
344 return found_mass[0] && found_mass[1];
348 const std::array<std::array<int, 2>, 2> &quarks,
349 const std::array<FourVector, 2> &pstr_com,
350 const std::array<double, 2> &m_str,
351 const std::array<ThreeVector, 2> &evec_str,
bool flip_string_ends,
352 bool separate_fragment_baryon) {
353 const std::array<FourVector, 2> ustr_com = {pstr_com[0] / m_str[0],
354 pstr_com[1] / m_str[1]};
355 for (
int i = 0; i < 2; i++) {
356 ParticleList new_intermediate_particles;
361 int nfrag =
fragment_string(quarks[i][0], quarks[i][1], m_str[i], evec,
362 flip_string_ends, separate_fragment_baryon,
363 new_intermediate_particles);
386 std::array<std::array<int, 2>, 2> quarks;
387 std::array<FourVector, 2> pstr_com;
388 std::array<double, 2> m_str;
389 std::array<ThreeVector, 2> evec_str;
399 const double xfracA =
401 const double xfracB =
406 const double QTrn = std::sqrt(QTrx * QTrx + QTry * QTry);
408 const double QPos = -QTrn * QTrn / (2. * xfracB *
PNegB_);
409 const double QNeg = QTrn * QTrn / (2. * xfracA *
PPosA_);
423 const bool found_masses =
428 const bool flip_string_ends =
true;
430 quarks, pstr_com, m_str, evec_str, flip_string_ends,
false);
441 std::array<std::array<int, 2>, 2> quarks;
442 std::array<FourVector, 2> pstr_com;
443 std::array<double, 2> m_str;
444 std::array<ThreeVector, 2> evec_str;
447 int idqA1, idqA2, idqB1, idqB2;
451 const int bar_a =
PDGcodes_[0].baryon_number(),
454 (bar_a == 0 && bar_b == 1) ||
455 (bar_a == 0 && bar_b == 0)) {
456 quarks[0][0] = idqB1;
457 quarks[0][1] = idqA2;
458 quarks[1][0] = idqA1;
459 quarks[1][1] = idqB2;
460 }
else if (((bar_a == 0) && (bar_b == -1)) ||
463 quarks[0][0] = idqA1;
464 quarks[0][1] = idqB2;
465 quarks[1][0] = idqB1;
466 quarks[1][1] = idqA2;
468 std::stringstream ss;
469 ss <<
" StringProcess::next_NDiff : baryonA = " << bar_a
470 <<
", baryonB = " << bar_b;
471 throw std::runtime_error(ss.str());
479 const double QTrn = std::sqrt(QTrx * QTrx + QTry * QTry);
481 const double QPos = -QTrn * QTrn / (2. * xfracB *
PNegB_);
482 const double QNeg = QTrn * QTrn / (2. * xfracA *
PPosA_);
483 const double dPPos = -xfracA *
PPosA_ - QPos;
484 const double dPNeg = xfracB *
PNegB_ - QNeg;
491 m_str[0] = pstr_com[0].sqr();
499 const bool found_masses =
504 const bool flip_string_ends =
false;
513 const auto &log = logger<LogArea::Pythia>();
520 std::array<int, 2> pdg_for_pythia;
521 std::array<std::array<int, 5>, 2> excess_quark;
522 std::array<std::array<int, 5>, 2> excess_antiq;
523 for (
int i = 0; i < 2; i++) {
524 for (
int j = 0; j < 5; j++) {
525 excess_quark[i][j] = 0;
526 excess_antiq[i][j] = 0;
531 log.debug(
" incoming particle ", i,
" : ",
PDGcodes_[i],
532 " is mapped onto ", pdg_for_pythia[i]);
534 PdgCode pdgcode_for_pythia(std::to_string(pdg_for_pythia[i]));
539 log.debug(
" excess_quark[", i,
"] = (", excess_quark[i][0],
", ",
540 excess_quark[i][1],
", ", excess_quark[i][2],
", ",
541 excess_quark[i][3],
", ", excess_quark[i][4],
")");
542 log.debug(
" excess_antiq[", i,
"] = (", excess_antiq[i][0],
", ",
543 excess_antiq[i][1],
", ", excess_antiq[i][2],
", ",
544 excess_antiq[i][3],
", ", excess_antiq[i][4],
")");
551 bool same_initial_state = previous_idA == pdg_for_pythia[0] &&
552 previous_idB == pdg_for_pythia[1] &&
563 log.debug(
"Pythia initialized with ", pdg_for_pythia[0],
" + ",
564 pdg_for_pythia[1],
" at CM energy [GeV] ",
sqrtsAB_);
566 throw std::runtime_error(
"Pythia failed to initialize.");
575 log.debug(
"pythia_parton_ : rndm is initialized with seed ", seed_new);
579 log.debug(
"Pythia hard event created");
581 log.debug(
"Pythia final state computed, success = ", final_state_success);
582 if (!final_state_success) {
586 ParticleList new_intermediate_particles;
587 ParticleList new_non_hadron_particles;
589 Pythia8::Vec4 pSum = 0.;
612 std::array<int, 3> col;
613 for (
int j = 0; j < 3; j++) {
626 bool correct_constituents =
628 if (!correct_constituents) {
629 log.debug(
"failed to find correct partonic constituents.");
635 while (ipart < npart) {
640 log.debug(
"PDG ID from Pythia: ", pdgid);
642 log.debug(
"4-momentum from Pythia: ", momentum);
646 log.warn(
"PDG ID ", pdgid,
647 " does not exist in ParticleType - start over.");
648 final_state_success =
false;
657 bool hadronize_success =
false;
658 bool find_forward_string =
true;
659 log.debug(
"Hard non-diff: partonic process gives ",
666 log.debug(
" Dummy event in hard string routine failed.");
667 hadronize_success =
false;
684 log.debug(
"Pythia hadronized, success = ", hadronize_success);
686 new_intermediate_particles.clear();
687 if (hadronize_success) {
688 for (
int i = 0; i < event_hadron.size(); i++) {
689 if (event_hadron[i].isFinal()) {
690 int pythia_id = event_hadron[i].id();
691 log.debug(
"PDG ID from Pythia: ", pythia_id);
704 log.debug(
"4-momentum from Pythia: ", momentum);
705 log.debug(
"appending the particle ", pythia_id,
706 " to the intermediate particle list.");
707 bool found_ptype =
false;
708 if (event_hadron[i].isHadron()) {
710 new_intermediate_particles);
713 new_non_hadron_particles);
716 log.warn(
"PDG ID ", pythia_id,
717 " does not exist in ParticleType - start over.");
718 hadronize_success =
false;
726 if (!hadronize_success) {
733 NpartFinal_ += nfrag;
735 find_forward_string = !find_forward_string;
738 if (hadronize_success) {
741 data.set_cross_section_scaling_factor(1.);
749 return hadronize_success;
754 std::array<int, 5> &excess_quark,
755 std::array<int, 5> &excess_antiq) {
758 std::array<int, 3> qcontent_actual = pdg_actual.
quark_content();
759 std::array<int, 3> qcontent_mapped = pdg_mapped.
quark_content();
761 excess_quark = {0, 0, 0, 0, 0};
762 excess_antiq = {0, 0, 0, 0, 0};
763 for (
int i = 0; i < 3; i++) {
764 if (qcontent_actual[i] > 0) {
765 int j = qcontent_actual[i] - 1;
766 excess_quark[j] += 1;
769 if (qcontent_mapped[i] > 0) {
770 int j = qcontent_mapped[i] - 1;
771 excess_quark[j] -= 1;
774 if (qcontent_actual[i] < 0) {
775 int j = std::abs(qcontent_actual[i]) - 1;
776 excess_antiq[j] += 1;
779 if (qcontent_mapped[i] < 0) {
780 int j = std::abs(qcontent_mapped[i]) - 1;
781 excess_antiq[j] -= 1;
787 Pythia8::Particle &particle, std::array<int, 5> &excess_constituent) {
788 const auto &log = logger<LogArea::Pythia>();
791 if (!particle.isQuark() && !particle.isDiquark()) {
796 const std::array<int, 5> excess_null = {0, 0, 0, 0, 0};
797 if (excess_constituent == excess_null) {
802 std::array<int, 2> pdgid = {0, 0};
805 if (particle.isQuark()) {
807 pdgid[0] = particle.id();
808 }
else if (particle.isDiquark()) {
813 for (
int iq = 0; iq < nq; iq++) {
814 int jq = std::abs(pdgid[iq]) - 1;
816 std::vector<int> k_found;
819 if (excess_constituent[jq] < 0) {
820 for (
int k = 0; k < 5; k++) {
822 if (k != jq && excess_constituent[k] > 0) {
823 k_found.push_back(k);
829 if (k_found.size() > 0) {
832 k_select = k_found[l];
835 pdgid[iq] = pdgid[iq] > 0 ? k_select + 1 : -(k_select + 1);
836 excess_constituent[jq] += 1;
837 excess_constituent[k_select] -= 1;
842 if (particle.isQuark()) {
843 pdgid_new = pdgid[0];
844 }
else if (particle.isDiquark()) {
845 if (std::abs(pdgid[0]) < std::abs(pdgid[1])) {
846 std::swap(pdgid[0], pdgid[1]);
849 pdgid_new = std::abs(pdgid[0]) * 1000 + std::abs(pdgid[1]) * 100;
850 if (std::abs(pdgid[0]) == std::abs(pdgid[1])) {
853 pdgid_new += spin_deg;
856 if (particle.id() < 0) {
860 log.debug(
" parton id = ", particle.id(),
" is converted to ", pdgid_new);
863 Pythia8::Vec4 pquark = particle.p();
865 double e_new = std::sqrt(mass_new * mass_new + pquark.pAbs() * pquark.pAbs());
867 particle.id(pdgid_new);
869 particle.m(mass_new);
873 Pythia8::Event &event_intermediate, std::array<int, 5> &nquark_total,
874 std::array<int, 5> &nantiq_total) {
875 for (
int iflav = 0; iflav < 5; iflav++) {
876 nquark_total[iflav] = 0;
877 nantiq_total[iflav] = 0;
880 for (
int ip = 1; ip < event_intermediate.size(); ip++) {
881 if (!event_intermediate[ip].isFinal()) {
884 const int pdgid = event_intermediate[ip].id();
887 for (
int iflav = 0; iflav < 5; iflav++) {
888 nquark_total[iflav] +=
893 for (
int iflav = 0; iflav < 5; iflav++) {
894 nantiq_total[iflav] +=
pythia_hadron_->particleData.nQuarksInCode(
895 std::abs(pdgid), iflav + 1);
902 Pythia8::Event &event_intermediate, std::array<int, 5> &nquark_total,
903 std::array<int, 5> &nantiq_total,
bool sign_constituent,
904 std::array<std::array<int, 5>, 2> &excess_constituent) {
905 const auto &log = logger<LogArea::Pythia>();
907 Pythia8::Vec4 pSum = event_intermediate[0].p();
913 for (
int iflav = 0; iflav < 5; iflav++) {
920 excess_constituent[0][iflav] + excess_constituent[1][iflav];
921 if (sign_constituent) {
922 nquark_final += nquark_total[iflav];
924 nquark_final += nantiq_total[iflav];
929 bool enough_quark = nquark_final >= 0;
933 log.debug(
" not enough constituents with flavor ", iflav + 1,
934 " : try to split a gluon to qqbar.");
935 for (
int ic = 0; ic < std::abs(nquark_final); ic++) {
939 if (excess_constituent[0][iflav] < 0) {
948 for (
int ip = 2; ip < event_intermediate.size(); ip++) {
949 if (!event_intermediate[ip].isFinal() ||
950 !event_intermediate[ip].isGluon()) {
954 const double y_gluon_current = event_intermediate[ip].y();
955 const double y_gluon_forward = event_intermediate[iforward].y();
956 if ((ih_mod == 0 && y_gluon_current > y_gluon_forward) ||
957 (ih_mod == 1 && y_gluon_current < y_gluon_forward)) {
962 if (!event_intermediate[iforward].isGluon()) {
963 log.debug(
"There is no gluon to split into qqbar.");
968 Pythia8::Vec4 pgluon = event_intermediate[iforward].p();
970 const int pdgid = iflav + 1;
972 const int status = event_intermediate[iforward].status();
976 const int col = event_intermediate[iforward].col();
977 const int acol = event_intermediate[iforward].acol();
980 std::array<double, 2> px_quark;
981 std::array<double, 2> py_quark;
982 std::array<double, 2> pz_quark;
984 std::array<double, 2> e_quark;
986 std::array<Pythia8::Vec4, 2> pquark;
988 const double sigma_qt_frag =
pythia_hadron_->parm(
"StringPT:sigma");
993 for (
int isign = 0; isign < 2; isign++) {
997 px_quark[isign] = 0.5 * pgluon.px() + (isign == 0 ? 1. : -1.) * qx;
998 py_quark[isign] = 0.5 * pgluon.py() + (isign == 0 ? 1. : -1.) * qy;
999 pz_quark[isign] = 0.5 * pgluon.pz();
1001 std::sqrt(mass * mass + px_quark[isign] * px_quark[isign] +
1002 py_quark[isign] * py_quark[isign] +
1003 pz_quark[isign] * pz_quark[isign]);
1004 pquark[isign] = Pythia8::Vec4(px_quark[isign], py_quark[isign],
1005 pz_quark[isign], e_quark[isign]);
1010 pSum += pquark[0] + pquark[1] - pgluon;
1012 event_intermediate.append(pdgid, status, col, 0, pquark[0], mass);
1013 event_intermediate.append(-pdgid, status, 0, acol, pquark[1], mass);
1015 event_intermediate.remove(iforward, iforward);
1017 log.debug(
" gluon at iforward = ", iforward,
" is splitted into ",
1018 pdgid,
",", -pdgid,
" qqbar pair.");
1021 nquark_total[iflav] += 1;
1022 nantiq_total[iflav] += 1;
1029 event_intermediate[0].p(pSum);
1030 event_intermediate[0].m(pSum.mCalc());
1036 std::array<int, 5> &nquark_total,
1037 std::array<std::array<int, 5>, 2> &excess_quark,
1038 std::array<std::array<int, 5>, 2> &excess_antiq) {
1039 const auto &log = logger<LogArea::Pythia>();
1041 for (
int iflav = 0; iflav < 5; iflav++) {
1048 nquark_total[iflav] + excess_quark[0][iflav] + excess_quark[1][iflav];
1052 bool enough_quark = nquark_final >= 0;
1054 if (!enough_quark) {
1055 log.debug(
" not enough constituents with flavor ", iflav + 1,
1056 " : try to modify excess of constituents.");
1057 for (
int ic = 0; ic < std::abs(nquark_final); ic++) {
1061 if (excess_quark[0][iflav] < 0) {
1069 excess_quark[ih_mod][iflav] += 1;
1070 excess_antiq[ih_mod][iflav] += 1;
1077 for (
int jflav = 0; jflav < 5; jflav++) {
1079 if (jflav != iflav && excess_quark[ih_mod][jflav] > 0) {
1082 excess_quark[ih_mod][jflav] -= 1;
1083 excess_antiq[ih_mod][jflav] -= 1;
1095 Pythia8::Event &event_intermediate,
1096 std::array<std::array<int, 5>, 2> &excess_quark,
1097 std::array<std::array<int, 5>, 2> &excess_antiq) {
1098 const auto &log = logger<LogArea::Pythia>();
1100 Pythia8::Vec4 pSum = event_intermediate[0].p();
1101 const double energy_init = pSum.e();
1102 log.debug(
" initial total energy [GeV] : ", energy_init);
1105 std::array<int, 5> nquark_total;
1106 std::array<int, 5> nantiq_total;
1111 event_intermediate, nquark_total, nantiq_total,
true, excess_quark);
1113 event_intermediate, nquark_total, nantiq_total,
false, excess_antiq);
1117 if (!split_for_quark || !split_for_antiq) {
1123 for (
int iflav = 0; iflav < 5; iflav++) {
1124 if (nquark_total[iflav] + excess_quark[0][iflav] + excess_quark[1][iflav] <
1126 log.debug(
"Not enough quark constituents of flavor ", iflav + 1);
1130 if (nantiq_total[iflav] + excess_antiq[0][iflav] + excess_antiq[1][iflav] <
1132 log.debug(
"Not enough antiquark constituents of flavor ", -(iflav + 1));
1137 for (
int ih = 0; ih < 2; ih++) {
1138 log.debug(
" initial excess_quark[", ih,
"] = (", excess_quark[ih][0],
", ",
1139 excess_quark[ih][1],
", ", excess_quark[ih][2],
", ",
1140 excess_quark[ih][3],
", ", excess_quark[ih][4],
")");
1141 log.debug(
" initial excess_antiq[", ih,
"] = (", excess_antiq[ih][0],
", ",
1142 excess_antiq[ih][1],
", ", excess_antiq[ih][2],
", ",
1143 excess_antiq[ih][3],
", ", excess_antiq[ih][4],
")");
1146 bool recovered_quarks =
false;
1147 while (!recovered_quarks) {
1150 std::array<bool, 2> find_forward = {
true,
false};
1151 const std::array<int, 5> excess_null = {0, 0, 0, 0, 0};
1152 std::array<int, 5> excess_total = excess_null;
1154 for (
int ih = 0; ih < 2; ih++) {
1155 int nfrag = event_intermediate.size();
1156 for (
int np_end = 0; np_end < nfrag - 1; np_end++) {
1163 pSum -= event_intermediate[iforward].p();
1165 if (event_intermediate[iforward].
id() > 0) {
1167 log.debug(
" excess_quark[", ih,
"] = (", excess_quark[ih][0],
", ",
1168 excess_quark[ih][1],
", ", excess_quark[ih][2],
", ",
1169 excess_quark[ih][3],
", ", excess_quark[ih][4],
")");
1172 log.debug(
" excess_antiq[", ih,
"] = (", excess_antiq[ih][0],
", ",
1173 excess_antiq[ih][1],
", ", excess_antiq[ih][2],
", ",
1174 excess_antiq[ih][3],
", ", excess_antiq[ih][4],
")");
1177 const int pdgid = event_intermediate[iforward].id();
1178 Pythia8::Vec4 pquark = event_intermediate[iforward].p();
1181 const int status = event_intermediate[iforward].status();
1182 const int color = event_intermediate[iforward].col();
1183 const int anticolor = event_intermediate[iforward].acol();
1186 event_intermediate.append(pdgid, status, color, anticolor, pquark,
1189 event_intermediate.remove(iforward, iforward);
1195 for (
int j = 0; j < 5; j++) {
1196 excess_total[j] += (excess_quark[ih][j] - excess_antiq[ih][j]);
1202 recovered_quarks = excess_total == excess_null;
1204 log.debug(
" valence quark contents of hadons are recovered.");
1206 log.debug(
" current total energy [GeV] : ", pSum.e());
1210 if (std::abs(pSum.e() - energy_init) <
really_small * energy_init) {
1214 double energy_current = pSum.e();
1216 for (
int i = 1; i < event_intermediate.size(); i++) {
1217 slope += event_intermediate[i].pAbs2() / event_intermediate[i].e();
1220 const double rescale_factor = 1. + (energy_init - energy_current) / slope;
1222 for (
int i = 1; i < event_intermediate.size(); i++) {
1223 const double px = rescale_factor * event_intermediate[i].px();
1224 const double py = rescale_factor * event_intermediate[i].py();
1225 const double pz = rescale_factor * event_intermediate[i].pz();
1226 const double pabs = rescale_factor * event_intermediate[i].pAbs();
1227 const double mass = event_intermediate[i].m();
1229 event_intermediate[i].px(px);
1230 event_intermediate[i].py(py);
1231 event_intermediate[i].pz(pz);
1232 event_intermediate[i].e(std::sqrt(mass * mass + pabs * pabs));
1233 pSum += event_intermediate[i].p();
1235 log.debug(
" parton momenta are rescaled by factor of ", rescale_factor);
1238 log.debug(
" final total energy [GeV] : ", pSum.e());
1241 event_intermediate[0].p(pSum);
1242 event_intermediate[0].m(pSum.mCalc());
1248 Pythia8::Event &event_intermediate,
1249 Pythia8::Event &event_hadronize) {
1250 const auto &log = logger<LogArea::Pythia>();
1252 Pythia8::Vec4 pSum = 0.;
1253 event_hadronize.reset();
1257 log.debug(
"Hard non-diff: iforward = ", iforward,
"(",
1258 event_intermediate[iforward].
id(),
")");
1260 pSum += event_intermediate[iforward].p();
1261 event_hadronize.append(event_intermediate[iforward]);
1263 int col_to_find = event_intermediate[iforward].acol();
1264 int acol_to_find = event_intermediate[iforward].col();
1265 event_intermediate.remove(iforward, iforward);
1266 log.debug(
"Hard non-diff: event_intermediate reduces in size to ",
1267 event_intermediate.size());
1270 while (col_to_find != 0 || acol_to_find != 0) {
1271 log.debug(
" col_to_find = ", col_to_find,
1272 ", acol_to_find = ", acol_to_find);
1275 for (
int i = 1; i < event_intermediate.size(); i++) {
1276 const int pdgid = event_intermediate[i].id();
1278 col_to_find != 0 && col_to_find == event_intermediate[i].col();
1280 acol_to_find != 0 && acol_to_find == event_intermediate[i].acol();
1282 log.debug(
" col_to_find ", col_to_find,
" from i ", i,
"(", pdgid,
1286 log.debug(
" acol_to_find ", acol_to_find,
" from i ", i,
"(", pdgid,
1290 if (found_col && !found_acol) {
1292 col_to_find = event_intermediate[i].acol();
1294 }
else if (!found_col && found_acol) {
1296 acol_to_find = event_intermediate[i].col();
1298 }
else if (found_col && found_acol) {
1307 event_intermediate.list();
1308 event_intermediate.listJunctions();
1309 event_hadronize.list();
1310 event_hadronize.listJunctions();
1311 if (col_to_find != 0) {
1312 log.error(
"No parton with col = ", col_to_find);
1314 if (acol_to_find != 0) {
1315 log.error(
"No parton with acol = ", acol_to_find);
1317 throw std::runtime_error(
"Hard string could not be identified.");
1319 pSum += event_intermediate[ifound].p();
1321 event_hadronize.append(event_intermediate[ifound]);
1323 event_intermediate.remove(ifound, ifound);
1324 log.debug(
"Hard non-diff: event_intermediate reduces in size to ",
1325 event_intermediate.size());
1331 event_hadronize[0].p(pSum);
1332 event_hadronize[0].m(pSum.mCalc());
1336 Pythia8::Event &event_intermediate,
1337 Pythia8::Event &event_hadronize) {
1338 const auto &log = logger<LogArea::Pythia>();
1340 event_hadronize.reset();
1348 const int kind = event_intermediate.kindJunction(0);
1349 bool sign_color = kind % 2 == 1;
1350 std::vector<int> col;
1351 for (
int j = 0; j < 3; j++) {
1352 col.push_back(event_intermediate.colJunction(0, j));
1354 event_hadronize.appendJunction(kind, col[0], col[1], col[2]);
1355 event_intermediate.eraseJunction(0);
1356 log.debug(
"junction (", col[0],
", ", col[1],
", ", col[2],
") with kind ",
1357 kind,
" will be handled.");
1359 bool found_string =
false;
1360 while (!found_string) {
1363 found_string =
true;
1364 for (
unsigned int j = 0; j < col.size(); j++) {
1365 found_string = found_string && col[j] == 0;
1367 if (!found_string) {
1370 log.debug(
" still has leg(s) unfinished.");
1371 sign_color = !sign_color;
1372 std::vector<int> junction_to_move;
1373 for (
int i = 0; i < event_intermediate.sizeJunction(); i++) {
1374 const int kind_new = event_intermediate.kindJunction(i);
1378 if (sign_color != (kind_new % 2 == 1)) {
1382 std::array<int, 3> col_new;
1383 for (
int k = 0; k < 3; k++) {
1384 col_new[k] = event_intermediate.colJunction(i, k);
1387 int n_legs_connected = 0;
1389 for (
unsigned int j = 0; j < col.size(); j++) {
1393 for (
int k = 0; k < 3; k++) {
1394 if (col[j] == col_new[k]) {
1395 n_legs_connected += 1;
1403 if (n_legs_connected > 0) {
1404 for (
int k = 0; k < 3; k++) {
1405 if (col_new[k] != 0) {
1406 col.push_back(col_new[k]);
1409 log.debug(
" junction ", i,
" (",
1410 event_intermediate.colJunction(i, 0),
", ",
1411 event_intermediate.colJunction(i, 1),
", ",
1412 event_intermediate.colJunction(i, 2),
") with kind ",
1413 kind_new,
" will be added.");
1414 junction_to_move.push_back(i);
1420 for (
unsigned int i = 0; i < junction_to_move.size(); i++) {
1421 unsigned int imove = junction_to_move[i] - i;
1422 const int kind_add = event_intermediate.kindJunction(imove);
1423 std::array<int, 3> col_add;
1424 for (
int k = 0; k < 3; k++) {
1425 col_add[k] = event_intermediate.colJunction(imove, k);
1428 event_hadronize.appendJunction(kind_add, col_add[0], col_add[1],
1431 event_intermediate.eraseJunction(imove);
1436 Pythia8::Vec4 pSum = event_hadronize[0].p();
1437 find_forward_string = pSum.pz() > 0.;
1441 Pythia8::Event &event_intermediate,
1442 Pythia8::Event &event_hadronize) {
1443 const auto &log = logger<LogArea::Pythia>();
1445 Pythia8::Vec4 pSum = event_hadronize[0].p();
1446 for (
unsigned int j = 0; j < col.size(); j++) {
1450 bool found_leg =
false;
1451 while (!found_leg) {
1453 for (
int i = 1; i < event_intermediate.size(); i++) {
1454 const int pdgid = event_intermediate[i].id();
1455 if (sign_color && col[j] == event_intermediate[i].col()) {
1456 log.debug(
" col[", j,
"] = ", col[j],
" from i ", i,
"(", pdgid,
1459 col[j] = event_intermediate[i].acol();
1461 }
else if (!sign_color && col[j] == event_intermediate[i].acol()) {
1462 log.debug(
" acol[", j,
"] = ", col[j],
" from i ", i,
"(", pdgid,
1465 col[j] = event_intermediate[i].col();
1472 if (event_intermediate.sizeJunction() == 0) {
1473 event_intermediate.list();
1474 event_intermediate.listJunctions();
1475 event_hadronize.list();
1476 event_hadronize.listJunctions();
1477 log.error(
"No parton with col = ", col[j],
1478 " connected with junction leg ", j);
1479 throw std::runtime_error(
"Hard string could not be identified.");
1482 pSum += event_intermediate[ifound].p();
1484 event_hadronize.append(event_intermediate[ifound]);
1486 event_intermediate.remove(ifound, ifound);
1487 log.debug(
"Hard non-diff: event_intermediate reduces in size to ",
1488 event_intermediate.size());
1498 event_hadronize[0].p(pSum);
1499 event_hadronize[0].m(pSum.mCalc());
1504 const auto &log = logger<LogArea::Pythia>();
1505 const std::array<FourVector, 2> ustrcom = {
FourVector(1., 0., 0., 0.),
1519 std::swap(baryon, antibaryon);
1521 if (baryon.
baryon_number() != 1 || antibaryon.baryon_number() != -1) {
1522 throw std::invalid_argument(
"Expected baryon-antibaryon pair.");
1526 constexpr
int n_q_types = 5;
1527 std::vector<int> qcount_bar, qcount_antibar;
1528 std::vector<int> n_combinations;
1529 bool no_combinations =
true;
1530 for (
int i = 0; i < n_q_types; i++) {
1532 qcount_antibar.push_back(-antibaryon.net_quark_number(i + 1));
1533 const int n_i = qcount_bar[i] * qcount_antibar[i];
1534 n_combinations.push_back(n_i);
1536 no_combinations =
false;
1542 if (no_combinations) {
1543 for (
int i = 0; i < 2; i++) {
1557 const int q_annihilate = discrete_distr() + 1;
1558 qcount_bar[q_annihilate - 1]--;
1559 qcount_antibar[q_annihilate - 1]--;
1562 std::vector<int> remaining_quarks, remaining_antiquarks;
1563 for (
int i = 0; i < n_q_types; i++) {
1564 for (
int j = 0; j < qcount_bar[i]; j++) {
1565 remaining_quarks.push_back(i + 1);
1567 for (
int j = 0; j < qcount_antibar[i]; j++) {
1568 remaining_antiquarks.push_back(-(i + 1));
1571 assert(remaining_quarks.size() == 2);
1572 assert(remaining_antiquarks.size() == 2);
1578 std::swap(remaining_quarks[0], remaining_quarks[1]);
1581 std::swap(remaining_antiquarks[0], remaining_antiquarks[1]);
1584 bool kin_threshold_satisfied =
true;
1585 for (
int i = 0; i < 2; i++) {
1586 const double mstr_min =
1589 if (mstr_min > mstr[i]) {
1590 kin_threshold_satisfied =
false;
1593 if (!kin_threshold_satisfied) {
1597 for (
int i = 0; i < 2; i++) {
1598 ParticleList new_intermediate_particles;
1602 fragment_string(remaining_quarks[i], remaining_antiquarks[i], mstr[i],
1603 evec,
true,
false, new_intermediate_particles);
1616 ThreeVector &evec_polar, std::array<ThreeVector, 3> &evec_basis) {
1619 if (std::abs(evec_polar.
x3()) < (1. - 1.0e-8)) {
1624 evec_basis[0] = evec_polar;
1626 theta = std::acos(evec_basis[0].x3());
1628 ex = evec_basis[0].x1();
1629 ey = evec_basis[0].x2();
1630 et = std::sqrt(ex * ex + ey * ey);
1632 phi = std::acos(ex / et);
1634 phi = -std::acos(ex / et);
1639 evec_basis[1].set_x1(std::cos(theta) * std::cos(phi));
1640 evec_basis[1].set_x2(std::cos(theta) * std::sin(phi));
1641 evec_basis[1].set_x3(-std::sin(theta));
1643 evec_basis[2].set_x1(-std::sin(phi));
1644 evec_basis[2].set_x2(std::cos(phi));
1645 evec_basis[2].set_x3(0.);
1648 if (evec_polar.
x3() > 0.) {
1659 assert(std::fabs(evec_basis[1] * evec_basis[2]) <
really_small);
1660 assert(std::fabs(evec_basis[2] * evec_basis[0]) <
really_small);
1661 assert(std::fabs(evec_basis[0] * evec_basis[1]) <
really_small);
1674 assert((std::abs(diquark) > 1000) && (std::abs(diquark) < 5510) &&
1675 (std::abs(diquark) % 100 < 10));
1678 deg_spin = std::abs(diquark) % 10;
1680 const int sign_anti = diquark > 0 ? 1 : -1;
1683 q1 = sign_anti * (std::abs(diquark) - (std::abs(diquark) % 1000)) / 1000;
1684 q2 = sign_anti * (std::abs(diquark) % 1000 - deg_spin) / 100;
1688 assert((q1 > 0 && q2 > 0) || (q1 < 0 && q2 < 0));
1689 if (std::abs(q1) < std::abs(q2)) {
1692 int diquark = std::abs(q1 * 1000 + q2 * 100);
1697 return (q1 < 0) ? -diquark : diquark;
1744 std::swap(idq1, idq2);
1750 bool separate_fragment_baryon,
1751 ParticleList &intermediate_particles) {
1752 const auto &log = logger<LogArea::Pythia>();
1754 intermediate_particles.clear();
1756 log.debug(
"initial quark content for fragment_string : ", idq1,
", ", idq2);
1757 log.debug(
"initial string mass (GeV) for fragment_string : ", mString);
1759 std::array<int, 2> idqIn;
1765 std::array<double, 2> m_const;
1767 for (
int i = 0; i < 2; i++) {
1769 bstring +=
pythia_hadron_->particleData.baryonNumberType(idqIn[i]);
1773 log.debug(
"baryon number of string times 3 : ", bstring);
1780 evecLong = -evecLong;
1783 if (m_const[0] + m_const[1] > mString) {
1784 throw std::runtime_error(
"String fragmentation: m1 + m2 > mString");
1786 Pythia8::Vec4 pSum = 0.;
1788 int number_of_fragments = 0;
1789 bool do_string_fragmentation =
false;
1793 double ppos_string_new, pneg_string_new;
1796 double QTrx_string_new, QTry_string_new, QTrn_string_new;
1798 double mTrn_string_new;
1800 double mass_string_new;
1804 double QTrx_add_pos, QTry_add_pos;
1807 double QTrx_add_neg, QTry_add_neg;
1819 std::array<ThreeVector, 3> evec_basis;
1822 if (separate_fragment_baryon && (std::abs(bstring) == 3) &&
1823 (mString > m_const[0] + m_const[1] + 1.)) {
1830 std::vector<int> pdgid_frag_prior;
1833 std::vector<FourVector> momentum_frag_prior;
1836 double QTrx_string_pos;
1838 double QTrx_string_neg;
1840 double QTry_string_pos;
1842 double QTry_string_neg;
1845 double QTrn_string_pos;
1848 double QTrn_string_neg;
1850 std::array<double, 2> m_trans;
1853 const int niter_max = 10000;
1854 bool found_leading_baryon =
false;
1855 for (
int iiter = 0; iiter < niter_max; iiter++) {
1857 pdgid_frag_prior.clear();
1858 momentum_frag_prior.clear();
1860 std::vector<int> pdgid_frag;
1861 std::vector<FourVector> momentum_frag;
1863 ppos_string_new = mString * M_SQRT1_2;
1864 pneg_string_new = mString * M_SQRT1_2;
1866 QTrx_string_pos = 0.;
1867 QTrx_string_neg = 0.;
1868 QTrx_string_new = 0.;
1869 QTry_string_pos = 0.;
1870 QTry_string_neg = 0.;
1871 QTry_string_new = 0.;
1873 Pythia8::FlavContainer flav_string_pos =
1874 bstring > 0 ? Pythia8::FlavContainer(idq2)
1875 : Pythia8::FlavContainer(idq1);
1877 Pythia8::FlavContainer flav_string_neg =
1878 bstring > 0 ? Pythia8::FlavContainer(idq1)
1879 : Pythia8::FlavContainer(idq2);
1881 bool found_forward_baryon =
false;
1883 bool done_forward_end =
false;
1886 bool energy_used_up =
false;
1887 while (!found_forward_baryon && !energy_used_up) {
1898 separate_fragment_baryon && from_forward && !done_forward_end,
1899 evec_basis, ppos_string_new, pneg_string_new, QTrx_string_pos,
1900 QTrx_string_neg, QTry_string_pos, QTry_string_neg, flav_string_pos,
1901 flav_string_neg, pdgid_frag, momentum_frag);
1907 QTrx_string_new = QTrx_string_pos + QTrx_string_neg;
1908 QTry_string_new = QTry_string_pos + QTry_string_neg;
1912 idqIn[0] = bstring > 0 ? flav_string_neg.id : flav_string_pos.id;
1913 idqIn[1] = bstring > 0 ? flav_string_pos.id : flav_string_neg.id;
1914 for (
int i = 0; i < 2; i++) {
1917 QTrn_string_pos = std::sqrt(QTrx_string_pos * QTrx_string_pos +
1918 QTry_string_pos * QTry_string_pos);
1919 QTrn_string_neg = std::sqrt(QTrx_string_neg * QTrx_string_neg +
1920 QTry_string_neg * QTry_string_neg);
1925 m_trans[0] = std::sqrt(m_const[0] * m_const[0] +
1926 QTrn_string_neg * QTrn_string_neg);
1930 m_trans[1] = std::sqrt(m_const[1] * m_const[1] +
1931 QTrn_string_pos * QTrn_string_pos);
1936 m_trans[0] = std::sqrt(m_const[0] * m_const[0] +
1937 QTrn_string_pos * QTrn_string_pos);
1941 m_trans[1] = std::sqrt(m_const[1] * m_const[1] +
1942 QTrn_string_neg * QTrn_string_neg);
1944 done_forward_end = done_forward_end || from_forward;
1945 found_forward_baryon =
1946 found_forward_baryon ||
1951 energy_used_up =
true;
1955 n_frag_prior += n_frag;
1956 for (
int i_frag = 0; i_frag < n_frag; i_frag++) {
1957 pdgid_frag_prior.push_back(pdgid_frag[i_frag]);
1958 momentum_frag_prior.push_back(momentum_frag[i_frag]);
1966 double mTsqr_string = 2. * ppos_string_new * pneg_string_new;
1967 mTrn_string_new = std::sqrt(mTsqr_string);
1968 QTrn_string_new = std::sqrt(QTrx_string_new * QTrx_string_new +
1969 QTry_string_new * QTry_string_new);
1970 if (mTrn_string_new < QTrn_string_new) {
1973 found_leading_baryon =
false;
1977 std::sqrt(mTsqr_string - QTrn_string_new * QTrn_string_new);
1981 if (mass_string_new > m_const[0] + m_const[1]) {
1982 do_string_fragmentation =
true;
1983 found_leading_baryon =
true;
1984 QTrx_add_pos = QTrx_string_pos;
1985 QTry_add_pos = QTry_string_pos;
1986 QTrx_add_neg = QTrx_string_neg;
1987 QTry_add_neg = QTry_string_neg;
1989 found_leading_baryon =
false;
1992 }
else if (n_frag == 2) {
1995 do_string_fragmentation =
false;
1996 found_leading_baryon =
true;
2000 if (found_leading_baryon) {
2004 if (found_leading_baryon) {
2007 for (
int i_frag = 0; i_frag < n_frag_prior; i_frag++) {
2008 log.debug(
"appending the the fragmented hadron ",
2009 pdgid_frag_prior[i_frag],
2010 " to the intermediate particle list.");
2013 momentum_frag_prior[i_frag],
2014 intermediate_particles);
2016 log.error(
"PDG ID ", pdgid_frag_prior[i_frag],
2017 " should exist in ParticleType.");
2018 throw std::runtime_error(
"string fragmentation failed.");
2020 number_of_fragments++;
2028 if (do_string_fragmentation) {
2029 mTrn_string_new = std::sqrt(2. * ppos_string_new * pneg_string_new);
2031 std::array<double, 2> ppos_parton;
2033 std::array<double, 2> pneg_parton;
2041 const double pb_const =
2042 (mTrn_string_new * mTrn_string_new + m_trans[0] * m_trans[0] -
2043 m_trans[1] * m_trans[1]) /
2044 (4. * pneg_string_new);
2045 const double pc_const =
2046 0.5 * m_trans[0] * m_trans[0] * ppos_string_new / pneg_string_new;
2047 ppos_parton[0] = pb_const + (bstring > 0 ? -1. : 1.) *
2048 std::sqrt(pb_const * pb_const - pc_const);
2049 ppos_parton[1] = ppos_string_new - ppos_parton[0];
2053 for (
int i = 0; i < 2; i++) {
2054 pneg_parton[i] = 0.5 * m_trans[i] * m_trans[i] / ppos_parton[i];
2057 const int status = 1;
2058 int color, anticolor;
2061 Pythia8::Vec4 pquark;
2081 bstring > 0 ? evec_basis[1] * (QTrx_string_neg - QTrx_add_neg) +
2082 evec_basis[2] * (QTry_string_neg - QTry_add_neg)
2083 : evec_basis[1] * (QTrx_string_pos - QTrx_add_pos) +
2084 evec_basis[2] * (QTry_string_pos - QTry_add_pos);
2086 evec_basis[0] * (ppos_parton[0] - pneg_parton[0]) * M_SQRT1_2 +
2088 const double E_quark =
2089 std::sqrt(m_const[0] * m_const[0] + three_mom.
sqr());
2090 pquark =
set_Vec4(E_quark, three_mom);
2092 pythia_hadron_->event.append(idqIn[0], status, color, anticolor, pquark,
2113 bstring > 0 ? evec_basis[1] * (QTrx_string_pos - QTrx_add_pos) +
2114 evec_basis[2] * (QTry_string_pos - QTry_add_pos)
2115 : evec_basis[1] * (QTrx_string_neg - QTrx_add_neg) +
2116 evec_basis[2] * (QTry_string_neg - QTry_add_neg);
2118 evec_basis[0] * (ppos_parton[1] - pneg_parton[1]) * M_SQRT1_2 +
2120 const double E_antiq =
2121 std::sqrt(m_const[1] * m_const[1] + three_mom.
sqr());
2122 pquark =
set_Vec4(E_antiq, three_mom);
2124 pythia_hadron_->event.append(idqIn[1], status, color, anticolor, pquark,
2128 do_string_fragmentation =
true;
2130 ppos_string_new = mString * M_SQRT1_2;
2131 pneg_string_new = mString * M_SQRT1_2;
2132 QTrx_string_new = 0.;
2133 QTry_string_new = 0.;
2134 QTrn_string_new = 0.;
2135 mTrn_string_new = mString;
2136 mass_string_new = mString;
2141 double sign_direction = 1.;
2142 if (bstring == -3) {
2146 sign_direction = -1;
2150 const double pCMquark =
pCM(mString, m_const[0], m_const[1]);
2151 const double E1 = std::sqrt(m_const[0] * m_const[0] + pCMquark * pCMquark);
2152 const double E2 = std::sqrt(m_const[1] * m_const[1] + pCMquark * pCMquark);
2154 ThreeVector direction = sign_direction * evecLong;
2157 const int status1 = 1, color1 = 1, anticolor1 = 0;
2158 Pythia8::Vec4 pquark =
set_Vec4(E1, -direction * pCMquark);
2160 pythia_hadron_->event.append(idqIn[0], status1, color1, anticolor1, pquark,
2163 const int status2 = 1, color2 = 0, anticolor2 = 1;
2164 pquark =
set_Vec4(E2, direction * pCMquark);
2166 pythia_hadron_->event.append(idqIn[1], status2, color2, anticolor2, pquark,
2170 if (do_string_fragmentation) {
2171 log.debug(
"fragmenting a string with ", idqIn[0],
", ", idqIn[1]);
2176 if (!successful_hadronization) {
2183 pythia_hadron_->event, evec_basis, ppos_string_new, pneg_string_new,
2184 QTrx_string_new, QTry_string_new, QTrx_add_pos, QTry_add_pos,
2185 QTrx_add_neg, QTry_add_neg);
2186 if (!successful_kinematics) {
2190 for (
int ipyth = 0; ipyth <
pythia_hadron_->event.size(); ipyth++) {
2201 log.debug(
"appending the fragmented hadron ", pythia_id,
2202 " to the intermediate particle list.");
2206 log.warn(
"PDG ID ", pythia_id,
2207 " does not exist in ParticleType - start over.");
2208 intermediate_particles.clear();
2212 number_of_fragments++;
2215 return number_of_fragments;
2219 bool from_forward,
bool separate_fragment_baryon,
2220 std::array<ThreeVector, 3> &evec_basis,
double &ppos_string,
2221 double &pneg_string,
double &QTrx_string_pos,
double &QTrx_string_neg,
2222 double &QTry_string_pos,
double &QTry_string_neg,
2223 Pythia8::FlavContainer &flav_string_pos,
2224 Pythia8::FlavContainer &flav_string_neg, std::vector<int> &pdgid_frag,
2225 std::vector<FourVector> &momentum_frag) {
2226 const auto &log = logger<LogArea::Pythia>();
2229 const int n_try = 10;
2231 momentum_frag.clear();
2233 if (ppos_string < 0. || pneg_string < 0.) {
2234 throw std::runtime_error(
"string has a negative lightcone momentum.");
2236 double mTsqr_string = 2. * ppos_string * pneg_string;
2238 double mTrn_string = std::sqrt(mTsqr_string);
2240 double QTrx_string_tot = QTrx_string_pos + QTrx_string_neg;
2241 double QTry_string_tot = QTry_string_pos + QTry_string_neg;
2242 double QTsqr_string_tot = std::fabs(QTrx_string_tot * QTrx_string_tot) +
2243 std::fabs(QTry_string_tot * QTry_string_tot);
2244 double QTrn_string_tot = std::sqrt(QTsqr_string_tot);
2245 if (mTrn_string < QTrn_string_tot) {
2249 double mass_string = std::sqrt(mTsqr_string - QTsqr_string_tot);
2250 log.debug(
" Fragment off one hadron from a string ( ", flav_string_pos.id,
2251 " , ", flav_string_neg.id,
" ) with mass ", mass_string,
" GeV.");
2254 const double sigma_qt_frag =
pythia_hadron_->parm(
"StringPT:sigma");
2255 const double stop_string_mass =
2257 const double stop_string_smear =
2261 const double prob_enhance_qt =
2263 double fac_enhance_qt;
2267 fac_enhance_qt = 1.;
2281 log.debug(
" Transverse momentum (", QTrx_new,
", ", QTry_new,
2282 ") GeV selected for the new qqbar pair.");
2291 double QTrx_had_1st =
2292 from_forward ? QTrx_string_pos + QTrx_new : QTrx_string_neg + QTrx_new;
2293 double QTry_had_1st =
2294 from_forward ? QTry_string_pos + QTry_new : QTry_string_neg + QTry_new;
2295 double QTrn_had_1st =
2296 std::sqrt(QTrx_had_1st * QTrx_had_1st + QTry_had_1st * QTry_had_1st);
2299 int pdgid_had_1st = 0;
2301 double mass_had_1st = 0.;
2304 Pythia8::FlavContainer flav_old =
2305 from_forward ? flav_string_pos : flav_string_neg;
2310 Pythia8::FlavContainer flav_new = Pythia8::FlavContainer(0);
2314 for (
int i_try = 0; i_try < n_try; i_try++) {
2319 if (pdgid_had_1st != 0) {
2322 log.debug(
" number of tries of flavor selection : ", i_try + 1,
2323 " in StringProcess::fragment_off_hadron.");
2327 if (pdgid_had_1st == 0) {
2330 log.debug(
" New flavor ", flav_new.id,
" selected for the string end with ",
2332 log.debug(
" PDG id ", pdgid_had_1st,
2333 " selected for the (first) fragmented hadron.");
2334 bool had_1st_baryon =
pythia_hadron_->particleData.isBaryon(pdgid_had_1st);
2336 double mTrn_had_1st =
2337 std::sqrt(mass_had_1st * mass_had_1st + QTrn_had_1st * QTrn_had_1st);
2338 log.debug(
" Transverse momentum (", QTrx_had_1st,
", ", QTry_had_1st,
2339 ") GeV selected for the (first) fragmented hadron.");
2344 const double mass_min_to_continue =
2345 (stop_string_mass +
pythia_hadron_->particleData.m0(flav_new.id) +
2351 bool string_into_final_two = mass_string < mass_min_to_continue;
2352 if (string_into_final_two) {
2353 log.debug(
" The string mass is below the mass threshold ",
2354 mass_min_to_continue,
" GeV : finishing with two hadrons.");
2358 double ppos_had_1st = 0.;
2359 double pneg_had_1st = 0.;
2363 bool from_diquark_end =
2364 from_forward ?
pythia_hadron_->particleData.isDiquark(flav_string_pos.id)
2367 bool has_diquark_pos =
2371 if (string_into_final_two) {
2375 int pdgid_had_2nd = 0.;
2377 double mass_had_2nd = 0.;
2380 Pythia8::FlavContainer flav_new2 = Pythia8::FlavContainer(0);
2381 flav_new2.anti(flav_new);
2384 if (
pythia_hadron_->particleData.isDiquark(flav_string_neg.id) &&
2385 pythia_hadron_->particleData.isDiquark(flav_new2.id) && from_forward) {
2388 if (
pythia_hadron_->particleData.isDiquark(flav_string_pos.id) &&
2389 pythia_hadron_->particleData.isDiquark(flav_new2.id) && !from_forward) {
2392 for (
int i_try = 0; i_try < n_try; i_try++) {
2397 if (pdgid_had_2nd != 0) {
2403 if (pdgid_had_2nd == 0) {
2406 log.debug(
" PDG id ", pdgid_had_2nd,
2407 " selected for the (second) fragmented hadron.");
2408 bool had_2nd_baryon =
pythia_hadron_->particleData.isBaryon(pdgid_had_2nd);
2416 double QTrx_had_2nd =
2417 from_forward ? QTrx_string_neg - QTrx_new : QTrx_string_pos - QTrx_new;
2418 double QTry_had_2nd =
2419 from_forward ? QTry_string_neg - QTry_new : QTry_string_pos - QTry_new;
2420 double QTrn_had_2nd =
2421 std::sqrt(QTrx_had_2nd * QTrx_had_2nd + QTry_had_2nd * QTry_had_2nd);
2422 double mTrn_had_2nd =
2423 std::sqrt(mass_had_2nd * mass_had_2nd + QTrn_had_2nd * QTrn_had_2nd);
2424 log.debug(
" Transverse momentum (", QTrx_had_2nd,
", ", QTry_had_2nd,
2425 ") GeV selected for the (second) fragmented hadron.");
2427 double ppos_had_2nd = 0.;
2428 double pneg_had_2nd = 0.;
2434 bool found_kinematics =
2437 separate_fragment_baryon && has_diquark_pos && had_1st_baryon,
2438 ppos_string, pneg_string, mTrn_had_1st, mTrn_had_2nd,
2439 ppos_had_1st, ppos_had_2nd, pneg_had_1st, pneg_had_2nd)
2441 separate_fragment_baryon && has_diquark_pos && had_2nd_baryon,
2442 ppos_string, pneg_string, mTrn_had_2nd, mTrn_had_1st,
2443 ppos_had_2nd, ppos_had_1st, pneg_had_2nd, pneg_had_1st);
2444 if (!found_kinematics) {
2451 QTrx_string_pos = 0.;
2452 QTry_string_pos = 0.;
2455 pdgid_frag.push_back(pdgid_had_1st);
2457 (ppos_had_1st + pneg_had_1st) * M_SQRT1_2,
2458 evec_basis[0] * (ppos_had_1st - pneg_had_1st) * M_SQRT1_2 +
2459 evec_basis[1] * QTrx_had_1st + evec_basis[2] * QTry_had_1st);
2460 momentum_frag.push_back(mom_had_1st);
2463 pdgid_frag.push_back(pdgid_had_2nd);
2465 (ppos_had_2nd + pneg_had_2nd) * M_SQRT1_2,
2466 evec_basis[0] * (ppos_had_2nd - pneg_had_2nd) * M_SQRT1_2 +
2467 evec_basis[1] * QTrx_had_2nd + evec_basis[2] * QTry_had_2nd);
2468 momentum_frag.push_back(mom_had_2nd);
2477 double stringz_a_use, stringz_b_use;
2480 if (separate_fragment_baryon && from_diquark_end && had_1st_baryon) {
2490 double xfrac =
sample_zLund(stringz_a_use, stringz_b_use, mTrn_had_1st);
2494 ppos_had_1st = xfrac * ppos_string;
2495 pneg_had_1st = 0.5 * mTrn_had_1st * mTrn_had_1st / ppos_had_1st;
2496 if (pneg_had_1st > pneg_string) {
2502 pneg_had_1st = xfrac * pneg_string;
2503 ppos_had_1st = 0.5 * mTrn_had_1st * mTrn_had_1st / pneg_had_1st;
2504 if (ppos_had_1st > ppos_string) {
2510 pdgid_frag.push_back(pdgid_had_1st);
2512 (ppos_had_1st + pneg_had_1st) * M_SQRT1_2,
2513 evec_basis[0] * (ppos_had_1st - pneg_had_1st) * M_SQRT1_2 +
2514 evec_basis[1] * QTrx_had_1st + evec_basis[2] * QTry_had_1st);
2515 momentum_frag.push_back(mom_had_1st);
2518 ppos_string -= ppos_had_1st;
2519 pneg_string -= pneg_had_1st;
2529 flav_string_pos.anti(flav_new);
2530 QTrx_string_pos = -QTrx_new;
2531 QTry_string_pos = -QTry_new;
2535 flav_string_neg.anti(flav_new);
2536 QTrx_string_neg = -QTrx_new;
2537 QTry_string_neg = -QTry_new;
2547 const auto &log = logger<LogArea::Pythia>();
2549 const int baryon_number =
2553 int pdgid_hadron = 0;
2556 Pythia8::FlavContainer flav1 = Pythia8::FlavContainer(idq1);
2557 Pythia8::FlavContainer flav2 = Pythia8::FlavContainer(idq2);
2558 const int n_try = 10;
2559 for (
int i_try = 0; i_try < n_try; i_try++) {
2561 if (pdgid_hadron != 0) {
2562 return pdgid_hadron;
2570 std::array<int, 5> frag_net_q;
2573 for (
int iq = 0; iq < 5; iq++) {
2575 pythia_hadron_->particleData.nQuarksInCode(std::abs(idq1), iq + 1);
2577 pythia_hadron_->particleData.nQuarksInCode(std::abs(idq2), iq + 1);
2578 nq1 = idq1 > 0 ? nq1 : -nq1;
2579 nq2 = idq2 > 0 ? nq2 : -nq2;
2580 frag_net_q[iq] = nq1 + nq2;
2582 const int frag_iso3 = frag_net_q[1] - frag_net_q[0];
2583 const int frag_strange = -frag_net_q[2];
2584 const int frag_charm = frag_net_q[3];
2585 const int frag_bottom = -frag_net_q[4];
2586 log.debug(
" conserved charges : iso3 = ", frag_iso3,
2587 ", strangeness = ", frag_strange,
", charmness = ", frag_charm,
2588 ", bottomness = ", frag_bottom);
2590 std::vector<int> pdgid_possible;
2591 std::vector<double> weight_possible;
2592 std::vector<double> weight_summed;
2597 if (!ptype.is_hadron()) {
2600 const int pdgid = ptype.pdgcode().get_decimal();
2602 (baryon_number == 3 * ptype.pdgcode().baryon_number()) &&
2603 (frag_iso3 == ptype.pdgcode().isospin3()) &&
2604 (frag_strange == ptype.pdgcode().strangeness()) &&
2605 (frag_charm == ptype.pdgcode().charmness()) &&
2606 (frag_bottom == ptype.pdgcode().bottomness())) {
2607 const int spin_degeneracy = ptype.pdgcode().spin_degeneracy();
2608 const double mass_pole = ptype.mass();
2609 const double weight =
static_cast<double>(spin_degeneracy) / mass_pole;
2610 pdgid_possible.push_back(pdgid);
2611 weight_possible.push_back(weight);
2613 log.debug(
" PDG id ", pdgid,
" is possible with weight ", weight);
2616 const int n_possible = pdgid_possible.size();
2617 weight_summed.push_back(0.);
2618 for (
int i = 0; i < n_possible; i++) {
2619 weight_summed.push_back(weight_summed[i] + weight_possible[i]);
2625 for (
int i = 0; i < n_possible; i++) {
2626 if ((uspc >= weight_summed[i]) && (uspc < weight_summed[i + 1])) {
2627 return pdgid_possible[i];
2635 const auto &log = logger<LogArea::Pythia>();
2646 bool end1_is_quark = idq1 > 0 &&
pythia_hadron_->particleData.isQuark(idq1);
2647 bool end1_is_antidiq =
2650 bool end2_is_antiq = idq2 < 0 &&
pythia_hadron_->particleData.isQuark(idq2);
2651 bool end2_is_diquark =
2655 if (end1_is_quark) {
2656 if (end2_is_antiq) {
2659 }
else if (end2_is_diquark) {
2665 }
else if (end1_is_antidiq) {
2666 if (end2_is_antiq) {
2679 std::array<int, 5> net_qnumber;
2680 for (
int iflav = 0; iflav < 5; iflav++) {
2681 net_qnumber[iflav] = 0;
2684 pythia_hadron_->particleData.nQuarksInCode(std::abs(idq1), iflav + 1);
2687 qnumber1 = -qnumber1;
2689 net_qnumber[iflav] += qnumber1;
2692 pythia_hadron_->particleData.nQuarksInCode(std::abs(idq2), iflav + 1);
2695 qnumber2 = -qnumber2;
2697 net_qnumber[iflav] += qnumber2;
2701 std::vector<int> pdgid_possible;
2703 std::vector<double> mass_diff;
2705 if (!ptype.is_hadron() || ptype.is_stable() ||
2706 ptype.pdgcode().baryon_number() != baryon) {
2710 const int pdgid = ptype.pdgcode().get_decimal();
2711 const double mass_min = ptype.min_mass_spectral();
2712 if (mass < mass_min) {
2717 if (ptype.pdgcode().isospin3() != net_qnumber[1] - net_qnumber[0]) {
2721 if (ptype.pdgcode().strangeness() != -net_qnumber[2]) {
2725 if (ptype.pdgcode().charmness() != net_qnumber[3]) {
2729 if (ptype.pdgcode().bottomness() != -net_qnumber[4]) {
2734 const double mass_pole = ptype.mass();
2736 pdgid_possible.push_back(pdgid);
2737 mass_diff.push_back(mass - mass_pole);
2740 const int n_res = pdgid_possible.size();
2746 int ires_closest = 0;
2747 double mass_diff_min = std::fabs(mass_diff[0]);
2750 for (
int ires = 1; ires < n_res; ires++) {
2751 if (std::fabs(mass_diff[ires]) < mass_diff_min) {
2752 ires_closest = ires;
2753 mass_diff_min = mass_diff[ires];
2756 log.debug(
"Quark constituents ", idq1,
" and ", idq2,
" with mass ", mass,
2757 " (GeV) turned into a resonance ", pdgid_possible[ires_closest]);
2758 return pdgid_possible[ires_closest];
2762 bool separate_fragment_hadron,
double ppos_string,
double pneg_string,
2763 double mTrn_had_forward,
double mTrn_had_backward,
double &ppos_had_forward,
2764 double &ppos_had_backward,
double &pneg_had_forward,
2765 double &pneg_had_backward) {
2766 const double mTsqr_string = 2. * ppos_string * pneg_string;
2767 if (mTsqr_string < 0.) {
2770 const double mTrn_string = std::sqrt(mTsqr_string);
2771 if (mTrn_string < mTrn_had_forward + mTrn_had_backward) {
2776 const double mTsqr_had_forward = mTrn_had_forward * mTrn_had_forward;
2778 const double mTsqr_had_backward = mTrn_had_backward * mTrn_had_backward;
2792 const double xm_diff =
2793 (mTsqr_had_forward - mTsqr_had_backward) / mTsqr_string;
2794 const double xe_pos = 0.5 * (1. + xm_diff);
2795 const double xe_neg = 0.5 * (1. - xm_diff);
2798 const double lambda_sqr =
2799 pow_int(mTsqr_string - mTsqr_had_forward - mTsqr_had_backward, 2) -
2800 4. * mTsqr_had_forward * mTsqr_had_backward;
2801 if (lambda_sqr <= 0.) {
2804 const double lambda = std::sqrt(lambda_sqr);
2805 const double b_lund =
2810 const double prob_reverse =
2811 std::exp(-b_lund * lambda) / (1. + std::exp(-b_lund * lambda));
2812 double xpz_pos = 0.5 * lambda / mTsqr_string;
2817 ppos_had_forward = (xe_pos + xpz_pos) * ppos_string;
2818 ppos_had_backward = (xe_neg - xpz_pos) * ppos_string;
2820 pneg_had_forward = 0.5 * mTsqr_had_forward / ppos_had_forward;
2821 pneg_had_backward = 0.5 * mTsqr_had_backward / ppos_had_backward;
2829 bool xfrac_accepted =
false;
2837 while (!xfrac_accepted) {
2838 const double fac_env = b * mTrn * mTrn;
2842 const double xfrac_inv = 1. - std::log(u_aux) / fac_env;
2843 assert(xfrac_inv >= 1.);
2846 const double xf_ratio = std::pow(1. - 1. / xfrac_inv, a) / xfrac_inv;
2851 xfrac = 1. / xfrac_inv;
2852 xfrac_accepted =
true;
2859 Pythia8::Event &event_fragments, std::array<ThreeVector, 3> &evec_basis,
2860 double ppos_string,
double pneg_string,
double QTrx_string,
2861 double QTry_string,
double QTrx_add_pos,
double QTry_add_pos,
2862 double QTrx_add_neg,
double QTry_add_neg) {
2863 const auto &log = logger<LogArea::Pythia>();
2864 log.debug(
"Correcting the kinematics of fragmented hadrons...");
2866 if (ppos_string < 0. || pneg_string < 0.) {
2867 log.debug(
" wrong lightcone momenta of string : ppos_string (GeV) = ",
2868 ppos_string,
" pneg_string (GeV) = ", pneg_string);
2872 const double yrapid_string = 0.5 * std::log(ppos_string / pneg_string);
2873 log.debug(
"Momentum-space rapidity of the string should be ", yrapid_string);
2876 const double mTrn_string = std::sqrt(2. * ppos_string * pneg_string);
2877 log.debug(
"Transvere mass (GeV) of the string should be ", mTrn_string);
2879 const double QTrn_string =
2880 std::sqrt(QTrx_string * QTrx_string + QTry_string * QTry_string);
2881 if (mTrn_string < QTrn_string) {
2882 log.debug(
" wrong transverse mass of string : mTrn_string (GeV) = ",
2883 mTrn_string,
" QTrn_string (GeV) = ", QTrn_string);
2886 const double msqr_string =
2887 mTrn_string * mTrn_string - QTrn_string * QTrn_string;
2889 const double mass_string = std::sqrt(msqr_string);
2890 log.debug(
"The string mass (GeV) should be ", mass_string);
2894 if (std::fabs(QTrx_add_pos) <
small_number * mass_string &&
2895 std::fabs(QTry_add_pos) <
small_number * mass_string &&
2896 std::fabs(QTrx_add_neg) <
small_number * mass_string &&
2897 std::fabs(QTry_add_neg) <
small_number * mass_string) {
2898 log.debug(
" no need to add transverse momenta - skipping.");
2904 for (
int ipyth = 1; ipyth < event_fragments.size(); ipyth++) {
2905 if (!event_fragments[ipyth].isFinal()) {
2910 FourVector(event_fragments[ipyth].e(), event_fragments[ipyth].px(),
2911 event_fragments[ipyth].py(), event_fragments[ipyth].pz());
2912 ptot_string_ini += p_frag;
2914 const double E_string_ini = ptot_string_ini.
x0();
2915 const double pz_string_ini = ptot_string_ini.
threevec() * evec_basis[0];
2916 const double ppos_string_ini = (E_string_ini + pz_string_ini) * M_SQRT1_2;
2917 const double pneg_string_ini = (E_string_ini - pz_string_ini) * M_SQRT1_2;
2919 const double yrapid_string_ini =
2920 0.5 * std::log(ppos_string_ini / pneg_string_ini);
2926 int ip_backward = 0;
2927 double y_forward = 0.;
2928 double y_backward = 0.;
2929 ptot_string_ini =
FourVector(0., 0., 0., 0.);
2931 for (
int ipyth = 1; ipyth < event_fragments.size(); ipyth++) {
2932 if (!event_fragments[ipyth].isFinal()) {
2937 FourVector(event_fragments[ipyth].e(), event_fragments[ipyth].px(),
2938 event_fragments[ipyth].py(), event_fragments[ipyth].pz());
2939 ptot_string_ini += p_frag;
2941 const double E_frag = p_frag.
x0();
2942 const double pl_frag = p_frag.
threevec() * evec_basis[0];
2943 double y_current = 0.5 * std::log((E_frag + pl_frag) / (E_frag - pl_frag));
2944 if (y_current > y_forward) {
2946 y_forward = y_current;
2948 if (y_current < y_backward) {
2949 ip_backward = ipyth;
2950 y_backward = y_current;
2953 log.debug(
" The most forward hadron is ip_forward = ", ip_forward,
2954 " with rapidity ", y_forward);
2955 log.debug(
" The most backward hadron is ip_backward = ", ip_backward,
2956 " with rapidity ", y_backward);
2958 const double px_string_ini = ptot_string_ini.
threevec() * evec_basis[1];
2959 const double py_string_ini = ptot_string_ini.
threevec() * evec_basis[2];
2963 bool correct_px = std::fabs(px_string_ini + QTrx_add_pos + QTrx_add_neg -
2966 log.debug(
" input transverse momenta in x-axis are not consistent.");
2971 bool correct_py = std::fabs(py_string_ini + QTry_add_pos + QTry_add_neg -
2974 log.debug(
" input transverse momenta in y-axis are not consistent.");
2978 Pythia8::Vec4 pvec_string_now =
2981 log.debug(
" Adding transverse momentum to the most forward hadron.");
2982 pvec_string_now -= event_fragments[ip_forward].p();
2983 const double mass_frag_pos = event_fragments[ip_forward].p().mCalc();
2986 event_fragments[ip_forward].e(), event_fragments[ip_forward].px(),
2987 event_fragments[ip_forward].py(), event_fragments[ip_forward].pz());
2990 QTrx_add_pos * evec_basis[1] +
2991 QTry_add_pos * evec_basis[2];
2993 double E_new_frag_pos =
2994 std::sqrt(mom_new_frag_pos.
sqr() + mass_frag_pos * mass_frag_pos);
2995 Pythia8::Vec4 pvec_new_frag_pos =
set_Vec4(E_new_frag_pos, mom_new_frag_pos);
2996 pvec_string_now += pvec_new_frag_pos;
2998 event_fragments[ip_forward].p(pvec_new_frag_pos);
3000 log.debug(
" Adding transverse momentum to the most backward hadron.");
3001 pvec_string_now -= event_fragments[ip_backward].p();
3002 const double mass_frag_neg = event_fragments[ip_backward].p().mCalc();
3005 event_fragments[ip_backward].e(), event_fragments[ip_backward].px(),
3006 event_fragments[ip_backward].py(), event_fragments[ip_backward].pz());
3009 QTrx_add_neg * evec_basis[1] +
3010 QTry_add_neg * evec_basis[2];
3012 double E_new_frag_neg =
3013 std::sqrt(mom_new_frag_neg.
sqr() + mass_frag_neg * mass_frag_neg);
3014 Pythia8::Vec4 pvec_new_frag_neg =
set_Vec4(E_new_frag_neg, mom_new_frag_neg);
3015 pvec_string_now += pvec_new_frag_neg;
3017 event_fragments[ip_backward].p(pvec_new_frag_neg);
3020 event_fragments[0].p(pvec_string_now);
3021 event_fragments[0].m(pvec_string_now.mCalc());
3025 double mTrn_frag_all = 0.;
3026 for (
int ipyth = 1; ipyth < event_fragments.size(); ipyth++) {
3027 if (!event_fragments[ipyth].isFinal()) {
3033 FourVector(event_fragments[ipyth].e(), event_fragments[ipyth].px(),
3034 event_fragments[ipyth].py(), event_fragments[ipyth].pz());
3035 ptot_string_ini += p_frag;
3037 const double E_frag = p_frag.
x0();
3038 const double pl_frag = p_frag.
threevec() * evec_basis[0];
3039 const double ppos_frag = (E_frag + pl_frag) * M_SQRT1_2;
3040 const double pneg_frag = (E_frag - pl_frag) * M_SQRT1_2;
3041 const double mTrn_frag = std::sqrt(2. * ppos_frag * pneg_frag);
3042 mTrn_frag_all += mTrn_frag;
3044 log.debug(
"Sum of transverse masses (GeV) of all fragmented hadrons : ",
3048 if (mTrn_string < mTrn_frag_all) {
3049 log.debug(
" which is larger than mT of the actual string ", mTrn_string);
3053 double mass_string_now = pvec_string_now.mCalc();
3054 double msqr_string_now = mass_string_now * mass_string_now;
3057 FourVector(pvec_string_now.e(), pvec_string_now.px(),
3058 pvec_string_now.py(), pvec_string_now.pz());
3059 double E_string_now = p_string_now.
x0();
3060 double pz_string_now = p_string_now.
threevec() * evec_basis[0];
3061 log.debug(
"The string mass (GeV) at this point : ", mass_string_now);
3062 double ppos_string_now = (E_string_now + pz_string_now) * M_SQRT1_2;
3063 double pneg_string_now = (E_string_now - pz_string_now) * M_SQRT1_2;
3065 double yrapid_string_now = 0.5 * std::log(ppos_string_now / pneg_string_now);
3066 log.debug(
"The momentum-space rapidity of string at this point : ",
3068 log.debug(
"The momentum-space rapidities of hadrons will be changed.");
3069 const int niter_max = 10000;
3070 bool accepted =
false;
3071 double fac_all_yrapid = 1.;
3076 for (
int iiter = 0; iiter < niter_max; iiter++) {
3077 if (std::fabs(mass_string_now - mass_string) <
really_small * mass_string) {
3081 double E_deriv = 0.;
3082 double pz_deriv = 0.;
3086 for (
int ipyth = 1; ipyth < event_fragments.size(); ipyth++) {
3087 if (!event_fragments[ipyth].isFinal()) {
3092 FourVector(event_fragments[ipyth].e(), event_fragments[ipyth].px(),
3093 event_fragments[ipyth].py(), event_fragments[ipyth].pz());
3094 const double E_frag = p_frag.
x0();
3095 const double pl_frag = p_frag.
threevec() * evec_basis[0];
3096 const double ppos_frag = (E_frag + pl_frag) * M_SQRT1_2;
3097 const double pneg_frag = (E_frag - pl_frag) * M_SQRT1_2;
3098 const double mTrn_frag = std::sqrt(2. * ppos_frag * pneg_frag);
3099 const double y_frag = 0.5 * std::log(ppos_frag / pneg_frag);
3101 E_deriv += mTrn_frag * (y_frag - yrapid_string_now) * std::sinh(y_frag);
3102 pz_deriv += mTrn_frag * (y_frag - yrapid_string_now) * std::cosh(y_frag);
3104 double slope = 2. * (E_string_now * E_deriv - pz_string_now * pz_deriv);
3105 double fac_yrapid = 1. + std::tanh((msqr_string - msqr_string_now) / slope);
3106 fac_all_yrapid *= fac_yrapid;
3110 (1. - fac_yrapid) * yrapid_string_now);
3112 pvec_string_now = event_fragments[0].p();
3113 mass_string_now = pvec_string_now.mCalc();
3114 msqr_string_now = mass_string_now * mass_string_now;
3115 p_string_now =
FourVector(pvec_string_now.e(), pvec_string_now.px(),
3116 pvec_string_now.py(), pvec_string_now.pz());
3117 E_string_now = p_string_now.
x0();
3118 pz_string_now = p_string_now.
threevec() * evec_basis[0];
3119 ppos_string_now = (E_string_now + pz_string_now) * M_SQRT1_2;
3120 pneg_string_now = (E_string_now - pz_string_now) * M_SQRT1_2;
3121 yrapid_string_now = 0.5 * std::log(ppos_string_now / pneg_string_now);
3122 log.debug(
" step ", iiter + 1,
" : fac_yrapid = ", fac_yrapid,
3123 " , string mass (GeV) = ", mass_string_now,
3124 " , string rapidity = ", yrapid_string_now);
3128 log.debug(
" Too many iterations in rapidity rescaling.");
3131 log.debug(
"The overall factor multiplied to the rapidities of hadrons = ",
3133 log.debug(
"The momentum-space rapidity of string at this point : ",
3135 const double y_diff = yrapid_string - yrapid_string_now;
3136 log.debug(
"The hadrons will be boosted by rapidity ", y_diff,
3137 " for the longitudinal momentum conservation.");
3146 double suppression_factor) {
3161 ParticleList &list) {
3162 assert(list.size() >= 2);
3163 int end = list.size() - 1;
3166 i1 <= end && !list[i1].pdgcode().contains_enough_valence_quarks(nq1);
3170 i2 >= 0 && !list[i2].pdgcode().contains_enough_valence_quarks(nq2);
3173 std::pair<int, int> indices(i1, i2);
3178 ParticleList &outgoing_particles,
3180 double suppression_factor) {
3183 data.set_cross_section_scaling_factor(0.0);
3186 std::sort(outgoing_particles.begin(), outgoing_particles.end(),
3189 j.momentum().velocity() * evecLong;
3192 switch (baryon_string) {
3206 throw std::runtime_error(
"string is neither mesonic nor baryonic");
3211 std::pair<int, int> i =
find_leading(nq1, nq2, outgoing_particles);
3212 std::pair<int, int> j =
find_leading(nq2, nq1, outgoing_particles);
3213 if (baryon_string == 0 && i.second - i.first < j.second - j.first) {
3216 suppression_factor);
3220 suppression_factor);
3240 throw std::runtime_error(
"StringProcess::pdg_map_for_pythia failed.");
int charge() const
The charge of the particle.
double sample_zLund(double a, double b, double mTrn)
Sample lightcone momentum fraction according to the LUND fragmentation function.
double additional_xsec_supp_
additional cross-section suppression factor to take coherence effect into account.
PdgCode pdgcode() const
Get the pdgcode of the particle.
bool remake_kinematics_fragments(Pythia8::Event &event_fragments, std::array< ThreeVector, 3 > &evec_basis, double ppos_string, double pneg_string, double QTrx_string, double QTry_string, double QTrx_add_pos, double QTry_add_pos, double QTrx_add_neg, double QTry_add_neg)
std::array< int, 2 > NpartString_
number of particles fragmented from strings
bool next_NDiffSoft()
Soft Non-diffractive process is modelled in accordance with dual-topological approach Capella:1978ig...
The ThreeVector class represents a physical three-vector with the components .
double PPosA_
forward lightcone momentum p^{+} of incoming particle A in CM-frame [GeV]
static FourVector reorient(Pythia8::Particle &particle, std::array< ThreeVector, 3 > &evec_basis)
compute the four-momentum properly oriented in the lab frame.
T beta_a0(T xmin, T b)
Draws a random number from a beta-distribution with a = 0.
constexpr double really_small
Numerical error tolerance.
static Pythia8::Vec4 set_Vec4(double energy, const ThreeVector &mom)
Easy setter of Pythia Vec4 from SMASH.
double pmin_gluon_lightcone_
the minimum lightcone momentum scale carried by a gluon [GeV]
bool make_final_state_2strings(const std::array< std::array< int, 2 >, 2 > &quarks, const std::array< FourVector, 2 > &pstr_com, const std::array< double, 2 > &m_str, const std::array< ThreeVector, 2 > &evec_str, bool flip_string_ends, bool separate_fragment_baryon)
Prepare kinematics of two strings, fragment them and append to final_state.
int net_quark_number(const int quark) const
Returns the net number of quarks with given flavour number For public use, see strangeness(), charmness(), bottomness() and isospin3().
int NpartFinal_
total number of final state particles
static void make_string_ends(const PdgCode &pdgcode_in, int &idq1, int &idq2, double xi)
make a random selection to determine partonic contents at the string ends.
int fragment_string(int idq1, int idq2, double mString, ThreeVector &evecLong, bool flip_string_ends, bool separate_fragment_baryon, ParticleList &intermediate_particles)
perform string fragmentation to determine species and momenta of hadrons by implementing PYTHIA 8...
void replace_constituent(Pythia8::Particle &particle, std::array< int, 5 > &excess_constituent)
Convert a partonic PYTHIA partice into the desired species and update the excess of constituents...
std::unique_ptr< Pythia8::Pythia > pythia_hadron_
PYTHIA object used in fragmentation.
int baryon_number() const
std::array< FourVector, 2 > plab_
momenta of incoming particles in the lab frame [GeV]
int append_final_state(ParticleList &intermediate_particles, const FourVector &uString, const ThreeVector &evecLong)
compute the formation time and fill the arrays with final-state particles as described in Andersson:1...
static int pdg_map_for_pythia(PdgCode &pdg)
Take pdg code and map onto particle specie which can be handled by PYTHIA.
T pCM_sqr(const T sqrts, const T mass_a, const T mass_b) noexcept
std::array< PdgCode, 2 > PDGcodes_
PdgCodes of incoming particles.
double stringz_b_leading_
parameter (StringZ:bLund) for the fragmentation function of leading baryon in soft non-diffractive st...
constexpr T pow_int(const T base, unsigned const exponent)
Efficient template for calculating integer powers using squaring.
void find_total_number_constituent(Pythia8::Event &event_intermediate, std::array< int, 5 > &nquark_total, std::array< int, 5 > &nantiq_total)
Compute how many quarks and antiquarks we have in the system, and update the correspoing arrays with ...
ThreeVector threevec() const
double prob_proton_to_d_uu_
Probability of splitting a nucleon into the quark flavour it has only once and a diquark it has twice...
Pythia8::SigmaTotal pythia_sigmatot_
An object to compute cross-sections.
double PNegB_
backward lightcone momentum p^{-} of incoming particle B in CM-frame [GeV]
std::array< FourVector, 2 > pcom_
momenta of incoming particles in the center of mass frame [GeV]
void set_formation_time(const double &form_time)
Set the absolute formation time.
constexpr double pion_mass
Pion mass in GeV.
std::unique_ptr< Pythia8::Pythia > pythia_parton_
PYTHIA object used in hard string routine.
double sqrtsAB_
sqrt of Mandelstam variable s of collision [GeV]
static const ParticleType & find(PdgCode pdgcode)
Returns the ParticleType object for the given pdgcode.
void rearrange_excess(std::array< int, 5 > &nquark_total, std::array< std::array< int, 5 >, 2 > &excess_quark, std::array< std::array< int, 5 >, 2 > &excess_antiq)
Take total number of quarks and check if the system has enough constitents that need to be converted ...
int get_resonance_from_quark(int idq1, int idq2, double mass)
std::array< int, 3 > quark_content() const
The return is always an array of three numbers, which are pdgcodes of quarks: 1 - d...
static void quarks_from_diquark(int diquark, int &q1, int &q2, int °_spin)
find two quarks from a diquark.
static bool append_intermediate_list(int pdgid, FourVector momentum, ParticleList &intermediate_particles)
append new particle from PYTHIA to a specific particle list
double stringz_b_produce_
parameter (StringZ:bLund) for the fragmentation function of other (produced) hadrons in soft non-diff...
static const ParticleTypeList & list_all()
int get_hadrontype_from_quark(int idq1, int idq2)
Determines hadron type from valence quark constituents.
void init(const ParticleList &incoming, double tcoll)
initialization feed intial particles, time of collision and gamma factor of the center of mass...
static int diquark_from_quarks(int q1, int q2)
Construct diquark from two quarks.
static void make_orthonormal_basis(ThreeVector &evec_polar, std::array< ThreeVector, 3 > &evec_basis)
compute three orthonormal basis vectors from unit vector in the longitudinal direction ...
T uniform_int(T min, T max)
Pythia8::Event event_intermediate_
event record for intermediate partonic state in the hard string routine
double kappa_tension_string_
string tension [GeV/fm]
double pow_fquark_alpha_
parameter for the quark distribution function
static void assign_all_scaling_factors(int baryon_string, ParticleList &outgoing_particles, const ThreeVector &evecLong, double suppression_factor)
Assign a cross section scaling factor to all outgoing particles.
void compute_incoming_lightcone_momenta()
compute the lightcone momenta of incoming particles where the longitudinal direction is set to be sam...
bool next_SDiff(bool is_AB_to_AX)
Single-diffractive process is based on single pomeron exchange described in Ingelman:1984ns.
double stringz_a_produce_
parameter (StringZ:aLund) for the fragmentation function of other (produced) hadrons in soft non-diff...
static void assign_scaling_factor(int nquark, ParticleData &data, double suppression_factor)
Assign a cross section scaling factor to the given particle.
void shift_rapidity_event(Pythia8::Event &event, std::array< ThreeVector, 3 > &evec_basis, double factor_yrapid, double diff_yrapid)
Shift the momentum rapidity of all particles in a given event record.
void compose_string_parton(bool find_forward_string, Pythia8::Event &event_intermediate, Pythia8::Event &event_hadronize)
Identify a set of partons, which are connected to form a color-neutral string, from a given PYTHIA ev...
bool next_DDiff()
Double-diffractive process ( A + B -> X + X ) is similar to the single-diffractive process...
ThreeVector velocity() const
Get the velocity (3-vector divided by zero component).
bool separate_fragment_baryon_
Whether to use a separate fragmentation function for leading baryons.
void set_4momentum(const FourVector &momentum_vector)
Set the particle's 4-momentum directly.
ThreeVector vcomAB_
velocity three vector of the center of mass in the lab frame
ParticleList final_state_
final state array which must be accessed after the collision
bool pythia_parton_initialized_
Remembers if Pythia is initialized or not.
static std::pair< int, int > find_leading(int nq1, int nq2, ParticleList &list)
Find the leading string fragments.
PdgCode stores a Particle Data Group Particle Numbering Scheme particle type number.
FourVector LorentzBoost(const ThreeVector &v) const
Returns the FourVector boosted with velocity v.
void common_setup_pythia(Pythia8::Pythia *pythia_in, double strange_supp, double diquark_supp, double popcorn_rate, double stringz_a, double stringz_b, double string_sigma_T)
Common setup of PYTHIA objects for soft and hard string routines.
double PNegA_
backward lightcone momentum p^{-} of incoming particle A in CM-frame [GeV]
constexpr double kaon_mass
Kaon mass in GeV.
double PPosB_
forward lightcone momentum p^{+} of incoming particle B in CM-frame [GeV]
Pythia8::StringFlav pythia_stringflav_
An object for the flavor selection in string fragmentation in the case of separate fragmentation func...
static void convert_KaonLS(int &pythia_id)
convert Kaon-L or Kaon-S into K0 or Anti-K0
Discrete distribution with weight given by probability vector.
void find_junction_leg(bool sign_color, std::vector< int > &col, Pythia8::Event &event_intermediate, Pythia8::Event &event_hadronize)
Identify partons, which are associated with junction legs, from a given PYTHIA event record...
void compose_string_junction(bool &find_forward_string, Pythia8::Event &event_intermediate, Pythia8::Event &event_hadronize)
Identify a set of partons and junction(s), which are connected to form a color-neutral string...
FourVector ucomAB_
velocity four vector of the center of mass in the lab frame
double time_collision_
time of collision in the computational frame [fm]
bool set_mass_and_direction_2strings(const std::array< std::array< int, 2 >, 2 > &quarks, const std::array< FourVector, 2 > &pstr_com, std::array< double, 2 > &m_str, std::array< ThreeVector, 2 > &evec_str)
Determine string masses and directions in which strings are stretched.
T power(T n, T xMin, T xMax)
Draws a random number according to a power-law distribution ~ x^n.
double soft_t_form_
factor to be multiplied to formation times in soft strings
int fragment_off_hadron(bool from_forward, bool separate_fragment_baryon, std::array< ThreeVector, 3 > &evec_basis, double &ppos_string, double &pneg_string, double &QTrx_string_pos, double &QTrx_string_neg, double &QTry_string_pos, double &QTry_string_neg, Pythia8::FlavContainer &flav_string_pos, Pythia8::FlavContainer &flav_string_neg, std::vector< int > &pdgid_frag, std::vector< FourVector > &momentum_frag)
Fragment one hadron from a given string configuration if the string mass is above threshold (given by...
bool restore_constituent(Pythia8::Event &event_intermediate, std::array< std::array< int, 5 >, 2 > &excess_quark, std::array< std::array< int, 5 >, 2 > &excess_antiq)
Take the intermediate partonic state from PYTHIA event with mapped hadrons and convert constituents i...
double pow_fgluon_beta_
parameter for the gluon distribution function
constexpr int maximum_rndm_seed_in_pythia
The maximum value of the random seed used in PYTHIA.
constexpr double small_number
Physical error tolerance.
bool mass_dependent_formation_times_
Whether the formation time should depend on the mass of the fragment according to Andersson:1983ia eq...
StringProcess(double string_tension, double time_formation, double gluon_beta, double gluon_pmin, double quark_alpha, double quark_beta, double strange_supp, double diquark_supp, double sigma_perp, double stringz_a_leading, double stringz_b_leading, double stringz_a, double stringz_b, double string_sigma_T, double factor_t_form, bool mass_dependent_formation_times, double prob_proton_to_d_uu, bool separate_fragment_baryon, double popcorn_rate)
Constructor, initializes pythia.
std::array< ThreeVector, 3 > evecBasisAB_
Orthonormal basis vectors in the center of mass frame, where the 0th one is parallel to momentum of i...
int get_index_forward(bool find_forward, int np_end, Pythia8::Event &event)
Obtain index of the most forward or backward particle in a given PYTHIA event record.
double normal(const T &mean, const T &sigma)
Returns a random number drawn from a normal distribution.
bool next_BBbarAnn()
Baryon-antibaryon annihilation process Based on what UrQMD Bass:1998ca, Bleicher:1999xi does...
double sigma_qperp_
Transverse momentum spread of the excited strings.
void set_cross_section_scaling_factor(const double &xsec_scal)
Set the particle's initial cross_section_scaling_factor.
T pCM(const T sqrts, const T mass_a, const T mass_b) noexcept
The FourVector class holds relevant values in Minkowski spacetime with (+, −, −, −) metric signature.
static void find_excess_constituent(PdgCode &pdg_actual, PdgCode &pdg_mapped, std::array< int, 5 > &excess_quark, std::array< int, 5 > &excess_antiq)
Compare the valence quark contents of the actual and mapped hadrons and evaluate how many more consti...
int32_t get_decimal() const
bool next_NDiffHard()
Hard Non-diffractive process is based on PYTHIA 8 with partonic showers and interactions.
double stringz_a_leading_
parameter (StringZ:aLund) for the fragmentation function of leading baryon in soft non-diffractive st...
double massB_
mass of incoming particle B [GeV]
ParticleData contains the dynamic information of a certain particle.
T beta(T a, T b)
Draws a random number from a beta-distribution, where probability density of is .
double time_formation_const_
constant proper time in the case of constant formation time [fm]
double massA_
mass of incoming particle A [GeV]
bool splitting_gluon_qqbar(Pythia8::Event &event_intermediate, std::array< int, 5 > &nquark_total, std::array< int, 5 > &nantiq_total, bool sign_constituent, std::array< std::array< int, 5 >, 2 > &excess_constituent)
Take total number of quarks and check if the system has enough constituents that need to be converted...
const FourVector & momentum() const
Get the particle's 4-momentum.
bool make_lightcone_final_two(bool separate_fragment_hadron, double ppos_string, double pneg_string, double mTrn_had_forward, double mTrn_had_backward, double &ppos_had_forward, double &ppos_had_backward, double &pneg_had_forward, double &pneg_had_backward)
Determines lightcone momenta of two final hadrons fragmented from a string in the same way as StringF...
double pow_fquark_beta_
parameter for the quark distribution function