37 #include <TLorentzVector.h>
55 #include "boost/lexical_cast.hpp"
67 #include "HepMC/PythiaWrapper6_4.h"
68 #include "HepMC/GenEvent.h"
69 #include "HepMC/HeavyIon.h"
70 #include "HepMC/SimpleVector.h"
99 int convertStatusForComponents(
int sta,
int typ) {
100 if (sta == 1 && typ == 0)
102 if (sta == 1 && typ == 1)
104 if (sta == 2 && typ == 0)
106 if (sta == 2 && typ == 1)
113 int convertStatus(
int st) {
135 fAw(
pset.getParameter<double>(
"fAw")),
138 fBmin(
pset.getParameter<double>(
"fBmin")),
139 fBmax(
pset.getParameter<double>(
"fBmax")),
140 fBfix(
pset.getParameter<double>(
"fBfix")),
141 fT(
pset.getParameter<double>(
"fT")),
142 fMuB(
pset.getParameter<double>(
"fMuB")),
143 fMuS(
pset.getParameter<double>(
"fMuS")),
146 fMuI3(
pset.getParameter<double>(
"fMuI3")),
147 fThFO(
pset.getParameter<double>(
"fThFO")),
154 fR(
pset.getParameter<double>(
189 fTau0(
pset.getParameter<double>(
"fTau0")),
196 embedding_(
pset.getParameter<
bool>(
"embeddingMode")),
197 rotate_(
pset.getParameter<
bool>(
"rotateEventPlane")),
239 LogInfo(
"Hydjet2Hadronizer|GenSeed") <<
"Seed for random number generation: "
253 LogInfo(
"Hydjet2Hadronizer|RAScaling") <<
"Nuclear radius(RA) = " << ra;
261 LogError(
"Hydjet2Hadronizer|sqrtS") <<
"SqrtS<2.24 not allowed with fTMuType>0";
280 LogInfo(
"Hydjet2Hadronizer|Strange") <<
"fMuS = " <<
fMuS;
284 LogError(
"Hydjet2Hadronizer|Ylmax") <<
"fYlmax more then TMath::Log(fSqrtS vs 0.94)!!! ";
291 LogInfo(
"Hydjet2Hadronizer|Strange")
292 <<
"The phenomenological f-la F. Becattini et al. PRC73 044905 (2006) for CorrS was used." << endl
293 <<
"Strangeness suppression parameter = " <<
fCorrS;
295 LogInfo(
"Hydjet2Hadronizer|Strange")
296 <<
"The phenomenological f-la J. Cleymans et al. PRC73 034905 (2006) for Tch mu_B was used." << endl
297 <<
"The simulation will be done with the calculated parameters:" << endl
298 <<
"Baryon chemical potential = " <<
fMuB <<
" [GeV]" << endl
299 <<
"Strangeness chemical potential = " <<
fMuS <<
" [GeV]" << endl
300 <<
"Isospin chemical potential = " <<
fMuI3 <<
" [GeV]" << endl
301 <<
"Strangeness suppression parameter = " <<
fCorrS << endl
302 <<
"Eta_max = " <<
fYlmax;
305 LogInfo(
"Hydjet2Hadronizer|Param") <<
"Used eta_max = " <<
fYlmax << endl
306 <<
"maximal allowed eta_max TMath::Log(fSqrtS/0.94)= "
307 << TMath::Log(
fSqrtS / 0.94);
348 LogInfo(
"Hydjet2Hadronizer|Param") <<
"central Effective volume = " <<
fVolEff <<
" [fm^3]";
350 double particleDensity_pi_ch = 0;
351 double particleDensity_pi_th = 0;
364 int encoding = currParticle->
GetPDG();
385 double numb_dens_bolt = particleDensity_pi_th * particleDensity_ch / particleDensity_pi_ch;
386 mu =
fThFO * TMath::Log(numb_dens_bolt / particleDensity_th_0);
387 if (
abs(encoding) == 211 || encoding == 111)
389 particleDensity = numb_dens_bolt;
394 if (
abs(encoding) <= 9) {
398 if (
abs(encoding) > 10 &&
abs(encoding) < 19) {
402 if (
abs(encoding) > 20 &&
abs(encoding) < 30) {
406 if (
abs(encoding) > 80 &&
abs(encoding) < 100) {
411 if (
abs(encoding) > 1000 &&
abs(encoding) < 6000) {
412 int tens = ((
abs(encoding) - (
abs(encoding) % 10)) / 10) % 10;
418 if (
abs(encoding) == 130 ||
abs(encoding) == 310) {
424 NJPsith = particleDensity *
fVolEff / dYl;
435 if (
abs(encoding) == 441 ||
abs(encoding) == 10441 ||
abs(encoding) == 10443 ||
abs(encoding) == 20443 ||
436 abs(encoding) == 445 ||
abs(encoding) == 4232 ||
abs(encoding) == 4322 ||
abs(encoding) == 4132 ||
437 abs(encoding) == 4312 ||
abs(encoding) == 4324 ||
abs(encoding) == 4314 ||
abs(encoding) == 4332 ||
438 abs(encoding) == 4334) {
441 if (
abs(encoding) != 443) {
442 Nocth = Nocth + particleDensity *
fVolEff / dYl;
443 LogInfo(
"Hydjet2Hadronizer|Charam") << encoding <<
" Nochth " << Nocth;
451 if ((
abs(encoding) > 500 &&
abs(encoding) < 600) || (
abs(encoding) > 10500 &&
abs(encoding) < 10600) ||
452 (
abs(encoding) > 20500 &&
abs(encoding) < 20600) || (
abs(encoding) > 100500 &&
abs(encoding) < 100600)) {
456 if (
abs(encoding) > 5000 &&
abs(encoding) < 6000) {
461 if (particleDensity > 0.) {
488 TLorentzVector partJMom, partJPos, zeroVec;
497 const HepMC::HeavyIon*
hi = inev->heavy_ion();
499 fBfix =
hi->impact_parameter();
500 phi0_ =
hi->event_plane_angle();
504 LogWarning(
"EventEmbedding") <<
"Background event does not have heavy ion record!";
523 LogError(
"Hydjet2EmptyEvent") <<
"##### HYDJET2: No Particles generated, Number of tries =" << ntry;
526 std::ostringstream sstr;
527 sstr <<
"Hydjet2HadronizerProducer: No particles generated after " << ntry <<
" tries.\n";
537 int numbJetPart =
HYPART.njp;
539 for (
int i = 0;
i < numbJetPart; ++
i) {
544 double pz =
HYPART.ppart[
i][4];
546 double vx =
HYPART.ppart[
i][6];
547 double vy =
HYPART.ppart[
i][7];
548 double vz =
HYPART.ppart[
i][8];
549 double vt =
HYPART.ppart[
i][9];
551 int mother_index =
int(
HYPART.ppart[
i][10]) - 1;
552 int daughter_index1 =
int(
HYPART.ppart[
i][11]) - 1;
553 int daughter_index2 =
int(
HYPART.ppart[
i][12]) - 1;
559 daughter_index1 = -1;
560 daughter_index2 = -1;
567 int motherPdg =
int(
HYPART.ppart[mother_index][1]);
570 partJMom.SetXYZT(
px,
py, pz,
e);
571 partJPos.SetXYZT(vx, vy, vz, vt);
572 Particle particle(partDef, partJPos, partJMom, 0, 0,
type, motherPdg, zeroVec, zeroVec);
573 int index = particle.SetIndex();
580 particle.SetMother(mother_index);
581 particle.SetFirstDaughterIndex(daughter_index1);
582 particle.SetLastDaughterIndex(daughter_index2);
584 particle.SetDecayed();
588 <<
" PYTHIA particle of specie " <<
pdg <<
" is not in Hydjet2 particle list" << endl
589 <<
" Please define it in particles.data, otherwise the history information will be de-synchronized and "
598 double impactParameter =
HYFPAR.bgen;
602 double e3 = (0.2 / 5.5) * TMath::Power(impactParameter, 1. / 3.);
607 const double weightMax = 2 * TMath::CosH(
fUmax);
608 const int nBins = 100;
609 double probList[
nBins];
612 TLorentzVector partPos, partMom, n1, p0;
614 const TLorentzVector zeroVec;
616 const double eMax = 5.;
624 double Epsilon0 = 0.5 * impactParameter;
625 double coeff = (
HYIPAR.RA /
fR) / 12.;
632 Delta = 0.5 * (TMath::Sqrt(1 + 4 *
A * (
Epsilon +
A)) - 1) /
A;
648 double coeff_RB = TMath::Sqrt(VolEffcent *
HYFPAR.npart /
HYFPAR.npart0 / VolEffnoncent);
650 coeff_R1 = TMath::Power(coeff_R1, 0.333333);
658 double Ncc =
Nbcol * NccNN / dYl;
669 LogInfo(
"Hydjet2Hadronizer|Param") <<
" gammaC = " << gammaC;
682 Mparam = Mparam * gammaC;
683 if (
abs(encoding) == 443)
684 Mparam = Mparam * gammaC;
686 LogInfo(
"Hydjet2Hadronizer|Param") << encoding <<
" " << Mparam / dYl;
688 int multiplicity = CLHEP::RandPoisson::shoot(
hjRandomEngine, Mparam);
690 LogInfo(
"Hydjet2Hadronizer|Param")
691 <<
"specie: " << encoding <<
"; average mult: = " << Mparam <<
"; multiplicity = " << multiplicity;
693 if (multiplicity > 0) {
696 LogError(
"Hydjet2Hadronizer") <<
"No particle with encoding " << encoding;
701 LogInfo(
"Hydjet2Hadronizer|Param") <<
"statistical charmed particle not allowed ! " << encoding;
705 LogInfo(
"Hydjet2Hadronizer|Param") <<
" charm pdg generated " << encoding;
712 const double d = !(
int(2 * partDef->
GetSpin()) & 1) ? -1 : 1;
717 double x =
mass + 0.5 *
h;
721 probList[
i] = x * TMath::Sqrt(x * x -
mass *
mass) / (TMath::Exp((x -
mu) / (
fThFO)) +
d);
723 probList[
i] = x * TMath::Sqrt(x * x -
mass *
mass) / (TMath::Exp((x -
mu) / (
fT)) +
d);
735 probList[
i] = x * TMath::CosH(param * x);
741 double weight = 0.,
yy = 0., px0 = 0., py0 = 0., pz0 = 0.;
742 double e = 0., x0 = 0., y0 = 0.,
z0 = 0.,
t0 = 0., etaF = 0.;
745 RB =
fR * coeff_RB * coeff_R1 * TMath::Sqrt((1 +
e3) / (1 -
e3));
747 for (
int j = 0;
j < multiplicity; ++
j) {
751 n1.SetXYZT(0., 0., TMath::SinH(etaF), TMath::CosH(etaF));
767 double Rx = TMath::Sqrt(1 -
Epsilon) * RB;
768 double Ry = TMath::Sqrt(1 +
Epsilon) * RB;
770 x0 = Rx * rho * TMath::Cos(phi);
771 y0 = Ry * rho * TMath::Sin(phi);
772 r = TMath::Sqrt(x0 * x0 + y0 * y0);
775 if (x0 < 0 && y0 > 0)
777 if (x0 < 0 && y0 < 0)
779 if (x0 > 0 && y0 < 0)
783 if (
r > RB * (1 +
e3 * TMath::Cos(3 * (phiF +
psiforv3))) / (1 +
e3))
789 z0 =
tau * TMath::SinH(etaF);
790 t0 =
tau * TMath::CosH(etaF);
791 double rhou =
fUmax *
r / RB;
792 double rhou3 = 0.063 * TMath::Sqrt((0.5 * impactParameter) / 0.67);
793 double rhou4 = 0.023 * ((0.5 * impactParameter) / 0.67);
794 double rrcoeff = 1. / TMath::Sqrt(1. + Delta * TMath::Cos(2 * phiF));
797 rhou = rhou * (1 + rrcoeff * rhou3 * TMath::Cos(3 * (phiF +
psiforv3)) +
798 rrcoeff * rhou4 * TMath::Cos(4 * phiF));
800 Delta = Delta * (1.0 + delta1 * TMath::Cos(phiF) - delta1 * TMath::Cos(3 * phiF));
802 double uxf = TMath::SinH(rhou) * TMath::Sqrt(1 + Delta) * TMath::Cos(phiF);
803 double uyf = TMath::SinH(rhou) * TMath::Sqrt(1 - Delta) * TMath::Sin(phiF);
804 double utf = TMath::CosH(etaF) * TMath::CosH(rhou) *
805 TMath::Sqrt(1 + Delta * TMath::Cos(2 * phiF) * TMath::TanH(rhou) * TMath::TanH(rhou));
806 double uzf = TMath::SinH(etaF) * TMath::CosH(rhou) *
807 TMath::Sqrt(1 + Delta * TMath::Cos(2 * phiF) * TMath::TanH(rhou) * TMath::TanH(rhou));
809 vec3.SetXYZ(uxf / utf, uyf / utf, uzf / utf);
816 double stp0 = TMath::Sqrt(1. - ctp0 * ctp0);
818 double pp0 = TMath::Sqrt(
e *
e -
mass *
mass);
819 px0 = pp0 * stp0 * TMath::Sin(php0);
820 py0 = pp0 * stp0 * TMath::Cos(php0);
822 p0.SetXYZT(px0, py0, pz0,
e);
829 if (
abs(
z0) > 1000 ||
abs(x0) > 1000)
830 LogInfo(
"Hydjet2Hadronizer|Param") <<
" etaF = " << etaF << std::endl;
832 partMom.SetXYZT(px0, py0, pz0,
e);
833 partPos.SetXYZT(x0, y0,
z0,
t0);
837 Particle particle(partDef, partPos, partMom, 0., 0,
type, -1, zeroVec, zeroVec);
868 TVector3
pos(it->Pos().Vect());
869 TVector3 mom(it->Mom().Vect());
870 float m1 = it->TableMass();
872 Mpdg[
Ntot] = it->GetLastMotherPdg();
876 E[
Ntot] = TMath::Sqrt(mom.Mag2() + m1 * m1);
913 LogError(
"Hydjet2Hadronizer") <<
"Ntot is too large" <<
Ntot;
940 evt->set_signal_process_id(
pypars.msti[0]);
953 std::vector<int>
pdg = _pdg;
954 for (
size_t i = 0;
i <
pdg.size();
i++) {
956 std::ostringstream pyCard;
957 pyCard <<
"MDCY(" << pyCode <<
",1)=0";
979 double rhou =
fUmax * y / RsB;
981 y * TMath::CosH(rhou) * TMath::Sqrt(1 + Delta * TMath::Cos(2 * x) * TMath::TanH(rhou) * TMath::TanH(rhou));
988 LogDebug(
"SimpsonIntegrator") <<
"in SimpsonIntegrator"
989 <<
"delta - " << Delta;
990 int nsubIntervals = 100;
991 double h = (
b -
a) / nsubIntervals;
992 double s =
f2(phi,
a + 0.5 *
h, Delta);
993 double t = 0.5 * (
f2(phi,
a, Delta) +
f2(phi,
b, Delta));
995 double y =
a + 0.5 *
h;
996 for (
int i = 1;
i < nsubIntervals;
i++) {
999 s +=
f2(phi, y, Delta);
1000 t +=
f2(phi, x, Delta);
1008 LogInfo(
"SimpsonIntegrator2") <<
"in SimpsonIntegrator2: epsilon - " <<
Epsilon <<
" delta - " << Delta;
1009 int nsubIntervals = 10000;
1010 double h = (
b -
a) / nsubIntervals;
1015 for (
int j = 1;
j < nsubIntervals;
j++) {
1019 double RB = RsB * (TMath::Sqrt(1 -
e *
e) / TMath::Sqrt(1 +
e * TMath::Cos(2 * x)));
1028 int nsubIntervals = 2000;
1029 int nsubIntervals2 = 1;
1030 double h = (
b -
a) / nsubIntervals;
1031 double h2 = (
fR) / nsubIntervals;
1033 double x =
a + 0.5 *
h;
1036 double t =
f2(x, y, Delta);
1040 for (
int j = 1;
j < nsubIntervals;
j++) {
1044 double RB = RsB * (TMath::Sqrt(1 -
e *
e) / TMath::Sqrt(1 +
e * TMath::Cos(2 * x)));
1046 nsubIntervals2 =
int(RB / h2) + 1;
1049 for (
int i = 1;
i < nsubIntervals2;
i++)
1050 t +=
f2(x, (y += h2), Delta);
1057 double gammaC = 100.;
1058 double x1 = gammaC * Ndth;
1060 LogInfo(
"Charam") <<
"gammaC 20"
1061 <<
" var " << var1 << endl;
1063 double x0 = gammaC * Ndth;
1065 LogInfo(
"Charam") <<
"gammaC 1"
1068 for (
int i = 1;
i < 1000;
i++) {
1069 if (var1 * var0 < 0) {
1070 gammaC = gammaC + 0.01 *
i;
1071 double x = gammaC * Ndth;
1074 LogInfo(
"Charam") <<
"gammaC " << gammaC <<
" var0 " << var0;
1078 LogInfo(
"Charam") <<
"gammaC not found ? " << gammaC <<
" var0 " << var0;
1087 const double pi = 3.14159265358979;
1103 LogDebug(
"Hydjet2") <<
"Number of hard events " <<
Njet;
1107 vector<HepMC::GenVertex*> sub_vertices(
nsub_);
1110 for (
int isub = 0; isub <
nsub_; isub++) {
1111 LogDebug(
"SubEvent") <<
"Sub Event ID : " << isub;
1113 int sub_up = (isub + 1) * 150000;
1115 vector<int> mother_ids;
1116 vector<HepMC::GenVertex*> prods;
1118 sub_vertices[isub] =
new HepMC::GenVertex(HepMC::FourVector(0, 0, 0, 0), isub);
1119 evt->add_vertex(sub_vertices[isub]);
1121 if (!
evt->signal_process_vertex())
1122 evt->set_signal_process_vertex(sub_vertices[isub]);
1139 int mid = mother_ids[
i] - isub * 150000 - 1;
1140 LogDebug(
"DecayChain") <<
"Particle " <<
i;
1141 LogDebug(
"DecayChain") <<
"Mother's ID " << mid;
1142 LogDebug(
"DecayChain") <<
"Particle's PDG ID " <<
part->pdg_id();
1145 sub_vertices[isub]->add_particle_out(
part);
1151 LogDebug(
"DecayChain") <<
"Mother's PDG ID " << mother->pdg_id();
1152 HepMC::GenVertex* prod_vertex = mother->end_vertex();
1154 prod_vertex = prods[
i];
1155 prod_vertex->add_particle_in(mother);
1156 evt->add_vertex(prod_vertex);
1160 prod_vertex->add_particle_out(
part);
1165 for (
unsigned int i = 0;
i < prods.size();
i++) {
1193 p->suggest_barcode(barcode);
1208 HepMC::GenVertex*
vertex =
new HepMC::GenVertex(HepMC::FourVector(x, y, z,
t),
id);
1216 int nproj = static_cast<int>(
npart / 2);
1217 int ntarg = static_cast<int>(
npart - nproj);
1219 HepMC::HeavyIon*
hi =
new HepMC::HeavyIon(
nsub_,
1234 evt->set_heavy_ion(*
hi);