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"
97 int convertStatusForComponents(
int sta,
int typ) {
98 if (sta == 1 && typ == 0)
100 if (sta == 1 && typ == 1)
102 if (sta == 2 && typ == 0)
104 if (sta == 2 && typ == 1)
111 int convertStatus(
int st) {
133 fAw(
pset.getParameter<double>(
"fAw")),
136 fBmin(
pset.getParameter<double>(
"fBmin")),
137 fBmax(
pset.getParameter<double>(
"fBmax")),
138 fBfix(
pset.getParameter<double>(
"fBfix")),
139 fT(
pset.getParameter<double>(
"fT")),
140 fMuB(
pset.getParameter<double>(
"fMuB")),
141 fMuS(
pset.getParameter<double>(
"fMuS")),
144 fMuI3(
pset.getParameter<double>(
"fMuI3")),
145 fThFO(
pset.getParameter<double>(
"fThFO")),
152 fR(
pset.getParameter<double>(
187 fTau0(
pset.getParameter<double>(
"fTau0")),
194 embedding_(
pset.getParameter<
bool>(
"embeddingMode")),
195 rotate_(
pset.getParameter<
bool>(
"rotateEventPlane")),
237 LogInfo(
"Hydjet2Hadronizer|GenSeed") <<
"Seed for random number generation: "
251 LogInfo(
"Hydjet2Hadronizer|RAScaling") <<
"Nuclear radius(RA) = " << ra;
259 LogError(
"Hydjet2Hadronizer|sqrtS") <<
"SqrtS<2.24 not allowed with fTMuType>0";
278 LogInfo(
"Hydjet2Hadronizer|Strange") <<
"fMuS = " <<
fMuS;
282 LogError(
"Hydjet2Hadronizer|Ylmax") <<
"fYlmax more then TMath::Log(fSqrtS vs 0.94)!!! ";
289 LogInfo(
"Hydjet2Hadronizer|Strange")
290 <<
"The phenomenological f-la F. Becattini et al. PRC73 044905 (2006) for CorrS was used." << endl
291 <<
"Strangeness suppression parameter = " <<
fCorrS;
293 LogInfo(
"Hydjet2Hadronizer|Strange")
294 <<
"The phenomenological f-la J. Cleymans et al. PRC73 034905 (2006) for Tch mu_B was used." << endl
295 <<
"The simulation will be done with the calculated parameters:" << endl
296 <<
"Baryon chemical potential = " <<
fMuB <<
" [GeV]" << endl
297 <<
"Strangeness chemical potential = " <<
fMuS <<
" [GeV]" << endl
298 <<
"Isospin chemical potential = " <<
fMuI3 <<
" [GeV]" << endl
299 <<
"Strangeness suppression parameter = " <<
fCorrS << endl
300 <<
"Eta_max = " <<
fYlmax;
303 LogInfo(
"Hydjet2Hadronizer|Param") <<
"Used eta_max = " <<
fYlmax << endl
304 <<
"maximal allowed eta_max TMath::Log(fSqrtS/0.94)= "
305 << TMath::Log(
fSqrtS / 0.94);
346 LogInfo(
"Hydjet2Hadronizer|Param") <<
"central Effective volume = " <<
fVolEff <<
" [fm^3]";
348 double particleDensity_pi_ch = 0;
349 double particleDensity_pi_th = 0;
362 int encoding = currParticle->
GetPDG();
383 double numb_dens_bolt = particleDensity_pi_th * particleDensity_ch / particleDensity_pi_ch;
384 mu =
fThFO * TMath::Log(numb_dens_bolt / particleDensity_th_0);
385 if (
abs(encoding) == 211 || encoding == 111)
387 particleDensity = numb_dens_bolt;
392 if (
abs(encoding) <= 9) {
396 if (
abs(encoding) > 10 &&
abs(encoding) < 19) {
400 if (
abs(encoding) > 20 &&
abs(encoding) < 30) {
404 if (
abs(encoding) > 80 &&
abs(encoding) < 100) {
409 if (
abs(encoding) > 1000 &&
abs(encoding) < 6000) {
410 int tens = ((
abs(encoding) - (
abs(encoding) % 10)) / 10) % 10;
416 if (
abs(encoding) == 130 ||
abs(encoding) == 310) {
422 NJPsith = particleDensity *
fVolEff / dYl;
433 if (
abs(encoding) == 441 ||
abs(encoding) == 10441 ||
abs(encoding) == 10443 ||
abs(encoding) == 20443 ||
434 abs(encoding) == 445 ||
abs(encoding) == 4232 ||
abs(encoding) == 4322 ||
abs(encoding) == 4132 ||
435 abs(encoding) == 4312 ||
abs(encoding) == 4324 ||
abs(encoding) == 4314 ||
abs(encoding) == 4332 ||
436 abs(encoding) == 4334) {
439 if (
abs(encoding) != 443) {
440 Nocth = Nocth + particleDensity *
fVolEff / dYl;
441 LogInfo(
"Hydjet2Hadronizer|Charam") << encoding <<
" Nochth " << Nocth;
449 if ((
abs(encoding) > 500 &&
abs(encoding) < 600) || (
abs(encoding) > 10500 &&
abs(encoding) < 10600) ||
450 (
abs(encoding) > 20500 &&
abs(encoding) < 20600) || (
abs(encoding) > 100500 &&
abs(encoding) < 100600)) {
454 if (
abs(encoding) > 5000 &&
abs(encoding) < 6000) {
459 if (particleDensity > 0.) {
486 TLorentzVector partJMom, partJPos, zeroVec;
495 const HepMC::HeavyIon*
hi = inev->heavy_ion();
497 fBfix =
hi->impact_parameter();
498 phi0_ =
hi->event_plane_angle();
502 LogWarning(
"EventEmbedding") <<
"Background event does not have heavy ion record!";
521 LogError(
"Hydjet2EmptyEvent") <<
"##### HYDJET2: No Particles generated, Number of tries =" << ntry;
524 std::ostringstream sstr;
525 sstr <<
"Hydjet2HadronizerProducer: No particles generated after " << ntry <<
" tries.\n";
535 int numbJetPart =
HYPART.njp;
537 for (
int i = 0;
i < numbJetPart; ++
i) {
542 double pz =
HYPART.ppart[
i][4];
544 double vx =
HYPART.ppart[
i][6];
545 double vy =
HYPART.ppart[
i][7];
546 double vz =
HYPART.ppart[
i][8];
547 double vt =
HYPART.ppart[
i][9];
549 int mother_index =
int(
HYPART.ppart[
i][10]) - 1;
550 int daughter_index1 =
int(
HYPART.ppart[
i][11]) - 1;
551 int daughter_index2 =
int(
HYPART.ppart[
i][12]) - 1;
557 daughter_index1 = -1;
558 daughter_index2 = -1;
565 int motherPdg =
int(
HYPART.ppart[mother_index][1]);
568 partJMom.SetXYZT(
px,
py, pz,
e);
569 partJPos.SetXYZT(vx, vy, vz, vt);
570 Particle particle(partDef, partJPos, partJMom, 0, 0,
type, motherPdg, zeroVec, zeroVec);
571 int index = particle.SetIndex();
578 particle.SetMother(mother_index);
579 particle.SetFirstDaughterIndex(daughter_index1);
580 particle.SetLastDaughterIndex(daughter_index2);
582 particle.SetDecayed();
586 <<
" PYTHIA particle of specie " <<
pdg <<
" is not in Hydjet2 particle list" << endl
587 <<
" Please define it in particles.data, otherwise the history information will be de-synchronized and "
596 double impactParameter =
HYFPAR.bgen;
600 double e3 = (0.2 / 5.5) * TMath::Power(impactParameter, 1. / 3.);
605 const double weightMax = 2 * TMath::CosH(
fUmax);
606 const int nBins = 100;
607 double probList[
nBins];
610 TLorentzVector partPos, partMom, n1, p0;
612 const TLorentzVector zeroVec;
614 const double eMax = 5.;
622 double Epsilon0 = 0.5 * impactParameter;
623 double coeff = (
HYIPAR.RA /
fR) / 12.;
630 Delta = 0.5 * (TMath::Sqrt(1 + 4 *
A * (
Epsilon +
A)) - 1) /
A;
646 double coeff_RB = TMath::Sqrt(VolEffcent *
HYFPAR.npart /
HYFPAR.npart0 / VolEffnoncent);
648 coeff_R1 = TMath::Power(coeff_R1, 0.333333);
656 double Ncc =
Nbcol * NccNN / dYl;
667 LogInfo(
"Hydjet2Hadronizer|Param") <<
" gammaC = " << gammaC;
680 Mparam = Mparam * gammaC;
681 if (
abs(encoding) == 443)
682 Mparam = Mparam * gammaC;
684 LogInfo(
"Hydjet2Hadronizer|Param") << encoding <<
" " << Mparam / dYl;
686 int multiplicity = CLHEP::RandPoisson::shoot(
hjRandomEngine, Mparam);
688 LogInfo(
"Hydjet2Hadronizer|Param")
689 <<
"specie: " << encoding <<
"; average mult: = " << Mparam <<
"; multiplicity = " << multiplicity;
691 if (multiplicity > 0) {
694 LogError(
"Hydjet2Hadronizer") <<
"No particle with encoding " << encoding;
699 LogInfo(
"Hydjet2Hadronizer|Param") <<
"statistical charmed particle not allowed ! " << encoding;
703 LogInfo(
"Hydjet2Hadronizer|Param") <<
" charm pdg generated " << encoding;
710 const double d = !(
int(2 * partDef->
GetSpin()) & 1) ? -1 : 1;
715 double x =
mass + 0.5 *
h;
719 probList[
i] = x * TMath::Sqrt(x * x -
mass *
mass) / (TMath::Exp((x -
mu) / (
fThFO)) +
d);
721 probList[
i] = x * TMath::Sqrt(x * x -
mass *
mass) / (TMath::Exp((x -
mu) / (
fT)) +
d);
733 probList[
i] = x * TMath::CosH(param * x);
739 double weight = 0.,
yy = 0., px0 = 0., py0 = 0., pz0 = 0.;
740 double e = 0., x0 = 0., y0 = 0.,
z0 = 0.,
t0 = 0., etaF = 0.;
743 RB =
fR * coeff_RB * coeff_R1 * TMath::Sqrt((1 +
e3) / (1 -
e3));
745 for (
int j = 0;
j < multiplicity; ++
j) {
749 n1.SetXYZT(0., 0., TMath::SinH(etaF), TMath::CosH(etaF));
765 double Rx = TMath::Sqrt(1 -
Epsilon) * RB;
766 double Ry = TMath::Sqrt(1 +
Epsilon) * RB;
768 x0 = Rx * rho * TMath::Cos(phi);
769 y0 = Ry * rho * TMath::Sin(phi);
770 r = TMath::Sqrt(x0 * x0 + y0 * y0);
773 if (x0 < 0 && y0 > 0)
775 if (x0 < 0 && y0 < 0)
777 if (x0 > 0 && y0 < 0)
781 if (
r > RB * (1 +
e3 * TMath::Cos(3 * (phiF +
psiforv3))) / (1 +
e3))
787 z0 =
tau * TMath::SinH(etaF);
788 t0 =
tau * TMath::CosH(etaF);
789 double rhou =
fUmax *
r / RB;
790 double rhou3 = 0.063 * TMath::Sqrt((0.5 * impactParameter) / 0.67);
791 double rhou4 = 0.023 * ((0.5 * impactParameter) / 0.67);
792 double rrcoeff = 1. / TMath::Sqrt(1. + Delta * TMath::Cos(2 * phiF));
795 rhou = rhou * (1 + rrcoeff * rhou3 * TMath::Cos(3 * (phiF +
psiforv3)) +
796 rrcoeff * rhou4 * TMath::Cos(4 * phiF));
798 Delta = Delta * (1.0 + delta1 * TMath::Cos(phiF) - delta1 * TMath::Cos(3 * phiF));
800 double uxf = TMath::SinH(rhou) * TMath::Sqrt(1 + Delta) * TMath::Cos(phiF);
801 double uyf = TMath::SinH(rhou) * TMath::Sqrt(1 - Delta) * TMath::Sin(phiF);
802 double utf = TMath::CosH(etaF) * TMath::CosH(rhou) *
803 TMath::Sqrt(1 + Delta * TMath::Cos(2 * phiF) * TMath::TanH(rhou) * TMath::TanH(rhou));
804 double uzf = TMath::SinH(etaF) * TMath::CosH(rhou) *
805 TMath::Sqrt(1 + Delta * TMath::Cos(2 * phiF) * TMath::TanH(rhou) * TMath::TanH(rhou));
807 vec3.SetXYZ(uxf / utf, uyf / utf, uzf / utf);
814 double stp0 = TMath::Sqrt(1. - ctp0 * ctp0);
816 double pp0 = TMath::Sqrt(
e *
e -
mass *
mass);
817 px0 = pp0 * stp0 * TMath::Sin(php0);
818 py0 = pp0 * stp0 * TMath::Cos(php0);
820 p0.SetXYZT(px0, py0, pz0,
e);
827 if (
abs(
z0) > 1000 ||
abs(x0) > 1000)
828 LogInfo(
"Hydjet2Hadronizer|Param") <<
" etaF = " << etaF << std::endl;
830 partMom.SetXYZT(px0, py0, pz0,
e);
831 partPos.SetXYZT(x0, y0,
z0,
t0);
835 Particle particle(partDef, partPos, partMom, 0., 0,
type, -1, zeroVec, zeroVec);
866 TVector3
pos(it->Pos().Vect());
867 TVector3 mom(it->Mom().Vect());
868 float m1 = it->TableMass();
870 Mpdg[
Ntot] = it->GetLastMotherPdg();
874 E[
Ntot] = TMath::Sqrt(mom.Mag2() + m1 * m1);
911 LogError(
"Hydjet2Hadronizer") <<
"Ntot is too large" <<
Ntot;
938 evt->set_signal_process_id(
pypars.msti[0]);
951 std::vector<int>
pdg = _pdg;
952 for (
size_t i = 0;
i <
pdg.size();
i++) {
954 std::ostringstream pyCard;
955 pyCard <<
"MDCY(" << pyCode <<
",1)=0";
977 double rhou =
fUmax * y / RsB;
979 y * TMath::CosH(rhou) * TMath::Sqrt(1 + Delta * TMath::Cos(2 * x) * TMath::TanH(rhou) * TMath::TanH(rhou));
986 LogDebug(
"SimpsonIntegrator") <<
"in SimpsonIntegrator"
987 <<
"delta - " << Delta;
988 int nsubIntervals = 100;
989 double h = (
b -
a) / nsubIntervals;
990 double s =
f2(phi,
a + 0.5 *
h, Delta);
991 double t = 0.5 * (
f2(phi,
a, Delta) +
f2(phi,
b, Delta));
993 double y =
a + 0.5 *
h;
994 for (
int i = 1;
i < nsubIntervals;
i++) {
997 s +=
f2(phi, y, Delta);
998 t +=
f2(phi, x, Delta);
1006 LogInfo(
"SimpsonIntegrator2") <<
"in SimpsonIntegrator2: epsilon - " <<
Epsilon <<
" delta - " << Delta;
1007 int nsubIntervals = 10000;
1008 double h = (
b -
a) / nsubIntervals;
1013 for (
int j = 1;
j < nsubIntervals;
j++) {
1017 double RB = RsB * (TMath::Sqrt(1 -
e *
e) / TMath::Sqrt(1 +
e * TMath::Cos(2 * x)));
1026 int nsubIntervals = 2000;
1027 int nsubIntervals2 = 1;
1028 double h = (
b -
a) / nsubIntervals;
1029 double h2 = (
fR) / nsubIntervals;
1031 double x =
a + 0.5 *
h;
1034 double t =
f2(x, y, Delta);
1038 for (
int j = 1;
j < nsubIntervals;
j++) {
1042 double RB = RsB * (TMath::Sqrt(1 -
e *
e) / TMath::Sqrt(1 +
e * TMath::Cos(2 * x)));
1044 nsubIntervals2 =
int(RB / h2) + 1;
1047 for (
int i = 1;
i < nsubIntervals2;
i++)
1048 t +=
f2(x, (y += h2), Delta);
1055 double gammaC = 100.;
1056 double x1 = gammaC * Ndth;
1058 LogInfo(
"Charam") <<
"gammaC 20"
1059 <<
" var " << var1 << endl;
1061 double x0 = gammaC * Ndth;
1063 LogInfo(
"Charam") <<
"gammaC 1"
1066 for (
int i = 1;
i < 1000;
i++) {
1067 if (var1 * var0 < 0) {
1068 gammaC = gammaC + 0.01 *
i;
1069 double x = gammaC * Ndth;
1072 LogInfo(
"Charam") <<
"gammaC " << gammaC <<
" var0 " << var0;
1076 LogInfo(
"Charam") <<
"gammaC not found ? " << gammaC <<
" var0 " << var0;
1085 const double pi = 3.14159265358979;
1101 LogDebug(
"Hydjet2") <<
"Number of hard events " <<
Njet;
1105 vector<HepMC::GenVertex*> sub_vertices(
nsub_);
1108 for (
int isub = 0; isub <
nsub_; isub++) {
1109 LogDebug(
"SubEvent") <<
"Sub Event ID : " << isub;
1111 int sub_up = (isub + 1) * 150000;
1113 vector<int> mother_ids;
1114 vector<HepMC::GenVertex*> prods;
1116 sub_vertices[isub] =
new HepMC::GenVertex(HepMC::FourVector(0, 0, 0, 0), isub);
1117 evt->add_vertex(sub_vertices[isub]);
1119 if (!
evt->signal_process_vertex())
1120 evt->set_signal_process_vertex(sub_vertices[isub]);
1137 int mid = mother_ids[
i] - isub * 150000 - 1;
1138 LogDebug(
"DecayChain") <<
"Particle " <<
i;
1139 LogDebug(
"DecayChain") <<
"Mother's ID " << mid;
1140 LogDebug(
"DecayChain") <<
"Particle's PDG ID " <<
part->pdg_id();
1143 sub_vertices[isub]->add_particle_out(
part);
1149 LogDebug(
"DecayChain") <<
"Mother's PDG ID " << mother->pdg_id();
1150 HepMC::GenVertex* prod_vertex = mother->end_vertex();
1152 prod_vertex = prods[
i];
1153 prod_vertex->add_particle_in(mother);
1154 evt->add_vertex(prod_vertex);
1158 prod_vertex->add_particle_out(
part);
1163 for (
unsigned int i = 0;
i < prods.size();
i++) {
1191 p->suggest_barcode(barcode);
1206 HepMC::GenVertex*
vertex =
new HepMC::GenVertex(HepMC::FourVector(x, y, z,
t),
id);
1214 int nproj = static_cast<int>(
npart / 2);
1215 int ntarg = static_cast<int>(
npart - nproj);
1217 HepMC::HeavyIon*
hi =
new HepMC::HeavyIon(
nsub_,
1232 evt->set_heavy_ion(*
hi);