37 #include <TLorentzVector.h>
66 #include "HepMC/PythiaWrapper6_4.h"
67 #include "HepMC/GenEvent.h"
68 #include "HepMC/HeavyIon.h"
69 #include "HepMC/SimpleVector.h"
98 int convertStatusForComponents(
int sta,
int typ) {
99 if (sta == 1 && typ == 0)
101 if (sta == 1 && typ == 1)
103 if (sta == 2 && typ == 0)
105 if (sta == 2 && typ == 1)
112 int convertStatus(
int st) {
133 fSqrtS(pset.getParameter<double>(
"fSqrtS")),
134 fAw(pset.getParameter<double>(
"fAw")),
135 fIfb(pset.getParameter<int>(
137 fBmin(pset.getParameter<double>(
"fBmin")),
138 fBmax(pset.getParameter<double>(
"fBmax")),
139 fBfix(pset.getParameter<double>(
"fBfix")),
140 fT(pset.getParameter<double>(
"fT")),
141 fMuB(pset.getParameter<double>(
"fMuB")),
142 fMuS(pset.getParameter<double>(
"fMuS")),
143 fMuC(pset.getParameter<double>(
145 fMuI3(pset.getParameter<double>(
"fMuI3")),
146 fThFO(pset.getParameter<double>(
"fThFO")),
147 fMu_th_pip(pset.getParameter<double>(
149 fTau(pset.getParameter<double>(
151 fSigmaTau(pset.getParameter<double>(
153 fR(pset.getParameter<double>(
155 fYlmax(pset.getParameter<double>(
"fYlmax")),
156 fUmax(pset.getParameter<double>(
158 fDelta(pset.getParameter<double>(
160 fEpsilon(pset.getParameter<double>(
162 fIfDeltaEpsilon(pset.getParameter<double>(
164 fDecay(pset.getParameter<int>(
166 fWeakDecay(pset.getParameter<double>(
168 fEtaType(pset.getParameter<double>(
170 fTMuType(pset.getParameter<double>(
172 fCorrS(pset.getParameter<double>(
174 fCharmProd(pset.getParameter<int>(
176 fCorrC(pset.getParameter<double>(
178 fNhsel(pset.getParameter<int>(
180 fPyhist(pset.getParameter<int>(
182 fIshad(pset.getParameter<int>(
184 fPtmin(pset.getParameter<double>(
186 fT0(pset.getParameter<double>(
188 fTau0(pset.getParameter<double>(
"fTau0")),
189 fNf(pset.getParameter<int>(
"fNf")),
190 fIenglu(pset.getParameter<int>(
192 fIanglu(pset.getParameter<int>(
195 embedding_(pset.getParameter<bool>(
"embeddingMode")),
196 rotate_(pset.getParameter<bool>(
"rotateEventPlane")),
238 LogInfo(
"Hydjet2Hadronizer|GenSeed") <<
"Seed for random number generation: "
252 LogInfo(
"Hydjet2Hadronizer|RAScaling") <<
"Nuclear radius(RA) = " << ra;
260 LogError(
"Hydjet2Hadronizer|sqrtS") <<
"SqrtS<2.24 not allowed with fTMuType>0";
279 LogInfo(
"Hydjet2Hadronizer|Strange") <<
"fMuS = " <<
fMuS;
283 LogError(
"Hydjet2Hadronizer|Ylmax") <<
"fYlmax more then TMath::Log(fSqrtS vs 0.94)!!! ";
289 fCorrS = 1. - 0.386 * TMath::Exp(-1.23 *
fT / fMuB);
290 LogInfo(
"Hydjet2Hadronizer|Strange")
291 <<
"The phenomenological f-la F. Becattini et al. PRC73 044905 (2006) for CorrS was used." << endl
292 <<
"Strangeness suppression parameter = " <<
fCorrS;
294 LogInfo(
"Hydjet2Hadronizer|Strange")
295 <<
"The phenomenological f-la J. Cleymans et al. PRC73 034905 (2006) for Tch mu_B was used." << endl
296 <<
"The simulation will be done with the calculated parameters:" << endl
297 <<
"Baryon chemical potential = " << fMuB <<
" [GeV]" << endl
298 <<
"Strangeness chemical potential = " <<
fMuS <<
" [GeV]" << endl
299 <<
"Isospin chemical potential = " <<
fMuI3 <<
" [GeV]" << endl
300 <<
"Strangeness suppression parameter = " <<
fCorrS << endl
301 <<
"Eta_max = " <<
fYlmax;
304 LogInfo(
"Hydjet2Hadronizer|Param") <<
"Used eta_max = " <<
fYlmax << endl
305 <<
"maximal allowed eta_max TMath::Log(fSqrtS/0.94)= "
306 << TMath::Log(
fSqrtS / 0.94);
347 LogInfo(
"Hydjet2Hadronizer|Param") <<
"central Effective volume = " <<
fVolEff <<
" [fm^3]";
349 double particleDensity_pi_ch = 0;
350 double particleDensity_pi_th = 0;
363 int encoding = currParticle->
GetPDG();
370 if (
fCorrS < 1. && S != 0)
384 double numb_dens_bolt = particleDensity_pi_th * particleDensity_ch / particleDensity_pi_ch;
385 mu =
fThFO * TMath::Log(numb_dens_bolt / particleDensity_th_0);
386 if (
abs(encoding) == 211 || encoding == 111)
388 particleDensity = numb_dens_bolt;
393 if (
abs(encoding) <= 9) {
397 if (
abs(encoding) > 10 &&
abs(encoding) < 19) {
401 if (
abs(encoding) > 20 &&
abs(encoding) < 30) {
405 if (
abs(encoding) > 80 &&
abs(encoding) < 100) {
410 if (
abs(encoding) > 1000 &&
abs(encoding) < 6000) {
411 int tens = ((
abs(encoding) - (
abs(encoding) % 10)) / 10) % 10;
417 if (
abs(encoding) == 130 ||
abs(encoding) == 310) {
423 NJPsith = particleDensity * fVolEff / dYl;
434 if (
abs(encoding) == 441 ||
abs(encoding) == 10441 ||
abs(encoding) == 10443 ||
abs(encoding) == 20443 ||
435 abs(encoding) == 445 ||
abs(encoding) == 4232 ||
abs(encoding) == 4322 ||
abs(encoding) == 4132 ||
436 abs(encoding) == 4312 ||
abs(encoding) == 4324 ||
abs(encoding) == 4314 ||
abs(encoding) == 4332 ||
437 abs(encoding) == 4334) {
440 if (
abs(encoding) != 443) {
441 Nocth = Nocth + particleDensity * fVolEff / dYl;
442 LogInfo(
"Hydjet2Hadronizer|Charam") << encoding <<
" Nochth " << Nocth;
450 if ((
abs(encoding) > 500 &&
abs(encoding) < 600) || (
abs(encoding) > 10500 &&
abs(encoding) < 10600) ||
451 (
abs(encoding) > 20500 &&
abs(encoding) < 20600) || (
abs(encoding) > 100500 &&
abs(encoding) < 100600)) {
455 if (
abs(encoding) > 5000 &&
abs(encoding) < 6000) {
460 if (particleDensity > 0.) {
487 TLorentzVector partJMom, partJPos, zeroVec;
496 const HepMC::HeavyIon* hi = inev->heavy_ion();
498 fBfix = hi->impact_parameter();
499 phi0_ = hi->event_plane_angle();
503 LogWarning(
"EventEmbedding") <<
"Background event does not have heavy ion record!";
522 LogError(
"Hydjet2EmptyEvent") <<
"##### HYDJET2: No Particles generated, Number of tries =" << ntry;
525 std::ostringstream sstr;
526 sstr <<
"Hydjet2HadronizerProducer: No particles generated after " << ntry <<
" tries.\n";
536 int numbJetPart = HYPART.
njp;
538 for (
int i = 0;
i < numbJetPart; ++
i) {
541 double px = HYPART.
ppart[
i][2];
542 double py = HYPART.
ppart[
i][3];
543 double pz = HYPART.
ppart[
i][4];
545 double vx = HYPART.
ppart[
i][6];
546 double vy = HYPART.
ppart[
i][7];
547 double vz = HYPART.
ppart[
i][8];
548 double vt = HYPART.
ppart[
i][9];
550 int mother_index = int(HYPART.
ppart[
i][10]) - 1;
551 int daughter_index1 = int(HYPART.
ppart[
i][11]) - 1;
552 int daughter_index2 = int(HYPART.
ppart[
i][12]) - 1;
558 daughter_index1 = -1;
559 daughter_index2 = -1;
566 int motherPdg = int(HYPART.
ppart[mother_index][1]);
569 partJMom.SetXYZT(px, py, pz, e);
570 partJPos.SetXYZT(vx, vy, vz, vt);
571 Particle particle(partDef, partJPos, partJMom, 0, 0, type, motherPdg, zeroVec, zeroVec);
572 int index = particle.SetIndex();
578 particle.SetPythiaStatusCode(pythiaStatus);
579 particle.SetMother(mother_index);
580 particle.SetFirstDaughterIndex(daughter_index1);
581 particle.SetLastDaughterIndex(daughter_index2);
582 if (pythiaStatus != 1)
583 particle.SetDecayed();
587 <<
" PYTHIA particle of specie " << pdg <<
" is not in Hydjet2 particle list" << endl
588 <<
" Please define it in particles.data, otherwise the history information will be de-synchronized and "
597 double impactParameter = HYFPAR.
bgen;
601 double e3 = (0.2 / 5.5) * TMath::Power(impactParameter, 1. / 3.);
606 const double weightMax = 2 * TMath::CosH(
fUmax);
607 const int nBins = 100;
608 double probList[nBins];
611 TLorentzVector partPos, partMom, n1, p0;
613 const TLorentzVector zeroVec;
615 const double eMax = 5.;
623 double Epsilon0 = 0.5 * impactParameter;
624 double coeff = (HYIPAR.
RA /
fR) / 12.;
625 Epsilon = Epsilon0 * coeff;
627 double A = C * Epsilon * (1 - Epsilon *
Epsilon);
631 Delta = 0.5 * (TMath::Sqrt(1 + 4 * A * (Epsilon + A)) - 1) / A;
647 double coeff_RB = TMath::Sqrt(VolEffcent * HYFPAR.
npart / HYFPAR.
npart0 / VolEffnoncent);
649 coeff_R1 = TMath::Power(coeff_R1, 0.333333);
657 double Ncc = Nbcol * NccNN / dYl;
668 LogInfo(
"Hydjet2Hadronizer|Param") <<
" gammaC = " << gammaC;
681 Mparam = Mparam * gammaC;
682 if (
abs(encoding) == 443)
683 Mparam = Mparam * gammaC;
685 LogInfo(
"Hydjet2Hadronizer|Param") << encoding <<
" " << Mparam / dYl;
687 int multiplicity = CLHEP::RandPoisson::shoot(
hjRandomEngine, Mparam);
689 LogInfo(
"Hydjet2Hadronizer|Param")
690 <<
"specie: " << encoding <<
"; average mult: = " << Mparam <<
"; multiplicity = " << multiplicity;
692 if (multiplicity > 0) {
695 LogError(
"Hydjet2Hadronizer") <<
"No particle with encoding " << encoding;
700 LogInfo(
"Hydjet2Hadronizer|Param") <<
"statistical charmed particle not allowed ! " << encoding;
704 LogInfo(
"Hydjet2Hadronizer|Param") <<
" charm pdg generated " << encoding;
711 const double d = !(int(2 * partDef->
GetSpin()) & 1) ? -1 : 1;
715 double h = (eMax -
mass) / nBins;
716 double x = mass + 0.5 *
h;
718 for (i = 0; i < nBins; ++
i) {
719 if (x >= mu &&
fThFO > 0)
720 probList[
i] = x * TMath::Sqrt(x * x - mass * mass) / (TMath::Exp((x - mu) / (
fThFO)) +
d);
721 if (x >= mu &&
fThFO <= 0)
722 probList[
i] = x * TMath::Sqrt(x * x - mass * mass) / (TMath::Exp((x - mu) / (
fT)) +
d);
733 for (i = 0; i < nBins; ++
i) {
734 probList[
i] = x * TMath::CosH(param * x);
740 double weight = 0., yy = 0., px0 = 0., py0 = 0., pz0 = 0.;
741 double e = 0., x0 = 0., y0 = 0., z0 = 0.,
t0 = 0., etaF = 0.;
744 RB =
fR * coeff_RB * coeff_R1 * TMath::Sqrt((1 + e3) / (1 - e3));
746 for (
int j = 0;
j < multiplicity; ++
j) {
750 n1.SetXYZT(0., 0., TMath::SinH(etaF), TMath::CosH(etaF));
766 double Rx = TMath::Sqrt(1 - Epsilon) * RB;
767 double Ry = TMath::Sqrt(1 + Epsilon) * RB;
769 x0 = Rx * rho * TMath::Cos(phi);
770 y0 = Ry * rho * TMath::Sin(phi);
771 r = TMath::Sqrt(x0 * x0 + y0 * y0);
774 if (x0 < 0 && y0 > 0)
776 if (x0 < 0 && y0 < 0)
778 if (x0 > 0 && y0 < 0)
782 if (r > RB * (1 + e3 * TMath::Cos(3 * (phiF +
psiforv3))) / (1 + e3))
788 z0 = tau * TMath::SinH(etaF);
789 t0 = tau * TMath::CosH(etaF);
790 double rhou =
fUmax * r / RB;
791 double rhou3 = 0.063 * TMath::Sqrt((0.5 * impactParameter) / 0.67);
792 double rhou4 = 0.023 * ((0.5 * impactParameter) / 0.67);
793 double rrcoeff = 1. / TMath::Sqrt(1. + Delta * TMath::Cos(2 * phiF));
796 rhou = rhou * (1 + rrcoeff * rhou3 * TMath::Cos(3 * (phiF +
psiforv3)) +
797 rrcoeff * rhou4 * TMath::Cos(4 * phiF));
799 Delta = Delta * (1.0 + delta1 * TMath::Cos(phiF) - delta1 * TMath::Cos(3 * phiF));
801 double uxf = TMath::SinH(rhou) * TMath::Sqrt(1 + Delta) * TMath::Cos(phiF);
802 double uyf = TMath::SinH(rhou) * TMath::Sqrt(1 - Delta) * TMath::Sin(phiF);
803 double utf = TMath::CosH(etaF) * TMath::CosH(rhou) *
804 TMath::Sqrt(1 + Delta * TMath::Cos(2 * phiF) * TMath::TanH(rhou) * TMath::TanH(rhou));
805 double uzf = TMath::SinH(etaF) * TMath::CosH(rhou) *
806 TMath::Sqrt(1 + Delta * TMath::Cos(2 * phiF) * TMath::TanH(rhou) * TMath::TanH(rhou));
808 vec3.SetXYZ(uxf / utf, uyf / utf, uzf / utf);
815 double stp0 = TMath::Sqrt(1. - ctp0 * ctp0);
816 e = mass + (eMax -
mass) * arrayFunctDistE();
817 double pp0 = TMath::Sqrt(e * e - mass * mass);
818 px0 = pp0 * stp0 * TMath::Sin(php0);
819 py0 = pp0 * stp0 * TMath::Cos(php0);
821 p0.SetXYZT(px0, py0, pz0, e);
824 weight = (n1 * p0) / e;
826 }
while (yy >= weight);
828 if (
abs(z0) > 1000 ||
abs(x0) > 1000)
829 LogInfo(
"Hydjet2Hadronizer|Param") <<
" etaF = " << etaF << std::endl;
831 partMom.SetXYZT(px0, py0, pz0, e);
832 partPos.SetXYZT(x0, y0, z0,
t0);
836 Particle particle(partDef, partPos, partMom, 0., 0, type, -1, zeroVec, zeroVec);
867 TVector3 pos(it->Pos().Vect());
868 TVector3 mom(it->Mom().Vect());
869 float m1 = it->TableMass();
871 Mpdg[
Ntot] = it->GetLastMotherPdg();
875 E[
Ntot] = TMath::Sqrt(mom.Mag2() + m1 * m1);
912 LogError(
"Hydjet2Hadronizer") <<
"Ntot is too large" <<
Ntot;
939 evt->set_signal_process_id(
pypars.msti[0]);
940 evt->set_event_scale(
pypars.pari[16]);
952 std::vector<int>
pdg = _pdg;
953 for (
size_t i = 0;
i < pdg.size();
i++) {
955 std::ostringstream pyCard;
956 pyCard <<
"MDCY(" << pyCode <<
",1)=0";
978 double rhou =
fUmax * y / RsB;
980 y * TMath::CosH(rhou) * TMath::Sqrt(1 + Delta * TMath::Cos(2 * x) * TMath::TanH(rhou) * TMath::TanH(rhou));
987 LogDebug(
"SimpsonIntegrator") <<
"in SimpsonIntegrator"
988 <<
"delta - " << Delta;
989 int nsubIntervals = 100;
990 double h = (b -
a) / nsubIntervals;
991 double s =
f2(phi, a + 0.5 * h, Delta);
992 double t = 0.5 * (
f2(phi, a, Delta) +
f2(phi, b, Delta));
994 double y = a + 0.5 *
h;
995 for (
int i = 1;
i < nsubIntervals;
i++) {
998 s +=
f2(phi, y, Delta);
999 t +=
f2(phi, x, Delta);
1007 LogInfo(
"SimpsonIntegrator2") <<
"in SimpsonIntegrator2: epsilon - " << Epsilon <<
" delta - " << Delta;
1008 int nsubIntervals = 10000;
1009 double h = (b -
a) / nsubIntervals;
1014 for (
int j = 1;
j < nsubIntervals;
j++) {
1018 double RB = RsB * (TMath::Sqrt(1 - e * e) / TMath::Sqrt(1 + e * TMath::Cos(2 * x)));
1027 int nsubIntervals = 2000;
1028 int nsubIntervals2 = 1;
1029 double h = (b -
a) / nsubIntervals;
1030 double h2 = (
fR) / nsubIntervals;
1032 double x = a + 0.5 *
h;
1035 double t =
f2(x, y, Delta);
1039 for (
int j = 1;
j < nsubIntervals;
j++) {
1043 double RB = RsB * (TMath::Sqrt(1 - e * e) / TMath::Sqrt(1 + e * TMath::Cos(2 * x)));
1045 nsubIntervals2 = int(RB / h2) + 1;
1048 for (
int i = 1;
i < nsubIntervals2;
i++)
1049 t +=
f2(x, (y += h2), Delta);
1056 double gammaC = 100.;
1057 double x1 = gammaC * Ndth;
1059 LogInfo(
"Charam") <<
"gammaC 20"
1060 <<
" var " << var1 << endl;
1062 double x0 = gammaC * Ndth;
1064 LogInfo(
"Charam") <<
"gammaC 1"
1067 for (
int i = 1;
i < 1000;
i++) {
1068 if (var1 * var0 < 0) {
1069 gammaC = gammaC + 0.01 *
i;
1070 double x = gammaC * Ndth;
1073 LogInfo(
"Charam") <<
"gammaC " << gammaC <<
" var0 " << var0;
1077 LogInfo(
"Charam") <<
"gammaC not found ? " << gammaC <<
" var0 " << var0;
1086 const double pi = 3.14159265358979;
1102 LogDebug(
"Hydjet2") <<
"Number of hard events " <<
Njet;
1106 vector<HepMC::GenVertex*> sub_vertices(
nsub_);
1109 for (
int isub = 0; isub <
nsub_; isub++) {
1110 LogDebug(
"SubEvent") <<
"Sub Event ID : " << isub;
1112 int sub_up = (isub + 1) * 150000;
1113 vector<HepMC::GenParticle*> particles;
1114 vector<int> mother_ids;
1115 vector<HepMC::GenVertex*> prods;
1117 sub_vertices[isub] =
new HepMC::GenVertex(HepMC::FourVector(0, 0, 0, 0), isub);
1118 evt->add_vertex(sub_vertices[isub]);
1120 if (!evt->signal_process_vertex())
1121 evt->set_signal_process_vertex(sub_vertices[isub]);
1132 LogDebug(
"Hydjet2") <<
"Number of particles in vector " << particles.size();
1134 for (
unsigned int i = 0;
i < particles.size();
i++) {
1138 int mid = mother_ids[
i] - isub * 150000 - 1;
1139 LogDebug(
"DecayChain") <<
"Particle " <<
i;
1140 LogDebug(
"DecayChain") <<
"Mother's ID " << mid;
1141 LogDebug(
"DecayChain") <<
"Particle's PDG ID " << part->pdg_id();
1144 sub_vertices[isub]->add_particle_out(part);
1150 LogDebug(
"DecayChain") <<
"Mother's PDG ID " << mother->pdg_id();
1151 HepMC::GenVertex* prod_vertex = mother->end_vertex();
1153 prod_vertex = prods[
i];
1154 prod_vertex->add_particle_in(mother);
1155 evt->add_vertex(prod_vertex);
1159 prod_vertex->add_particle_out(part);
1164 for (
unsigned int i = 0;
i < prods.size();
i++) {
1188 convertStatusForComponents(
final[index],
type[index])
1192 p->suggest_barcode(barcode);
1207 HepMC::GenVertex* vertex =
new HepMC::GenVertex(HepMC::FourVector(x, y, z, t),
id);
1215 int nproj =
static_cast<int>(npart / 2);
1216 int ntarg =
static_cast<int>(npart - nproj);
1218 HepMC::HeavyIon* hi =
new HepMC::HeavyIon(
nsub_,
1233 evt->set_heavy_ion(*hi);
T getUntrackedParameter(std::string const &, T const &) const
void SetBaryonPotential(double value)
bool declareStableParticles(const std::vector< int > &)
ParticlePDG * GetPDGParticle(int pdg)
int GetNParticles(bool all=kFALSE)
double ParticleNumberDensity(ParticlePDG *particle)
ParticleAllocator allocator
unsigned int maxEventsToPrint_
TString RunInputHYDJETstr
void add_heavy_ion_rec(HepMC::GenEvent *evt)
unsigned int pythiaPylistVerbosity_
double SimpsonIntegrator2(double, double, double, double)
Sin< T >::type sin(const T &t)
double BesselI0(double x)
bool call_pygive(const std::string &line)
double CalculateStrangePotential()
double MidpointIntegrator2(double, double, double, double)
double SimpsonIntegrator(double, double, double, double)
Log< level::Error, false > LogError
double f2(double, double, double)
double GetCharmAQNumber()
static std::string const input
double nuclear_radius() const
static const std::string kPythia6
HepMC::GenVertex * build_hyjet2_vertex(int i, int id)
void PrepareTable(const double *aProbFunc)
Pythia6Service * pythia6Service_
ParticlePDG * GetPDGParticleByIndex(int index)
void FreeList(List_t &list)
bool get_particles(HepMC::GenEvent *evt)
double GetElectricCharge()
if(conf_.getParameter< bool >("UseStripCablingDB"))
bool initializeForInternalPartons()
Cos< T >::type cos(const T &t)
Abs< T >::type abs(const T &t)
double CharmEnhancementFactor(double, double, double, double)
void doSetRandomEngine(CLHEP::HepRandomEngine *v) override
std::unique_ptr< HepMC::GenEvent > & event()
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
CLHEP::HepRandomEngine * hjRandomEngine
virtual void Evolve(List_t &secondaries, ParticleAllocator &allocator, double weakDecayLimit)
static void InitIndexing()
const char * classname() const
Log< level::Info, false > LogInfo
static const std::string kFortranInstance
~Hydjet2Hadronizer() override
T getParameter(std::string const &) const
HepMC::GenParticle * build_hyjet2(int index, int barcode)
void setRandomEngine(CLHEP::HepRandomEngine *v)
bool RunDecays() override
double GetWeakDecayLimit() override
void SetTemperature(double value)
double BesselI1(double x)
void AddParticle(const Particle &particle, List_t &list)
Log< level::Warning, false > LogWarning
std::list< Particle >::iterator LPIT_t
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
int FirstDaughterIndex[500000]
edm::Event & getEDMEvent() const
bool generatePartonsAndHadronize()
int LastDaughterIndex[500000]