32 #include <TLorentzVector.h>
50 #include "boost/lexical_cast.hpp"
62 #include "HepMC/PythiaWrapper6_4.h"
63 #include "HepMC/GenEvent.h"
64 #include "HepMC/HeavyIon.h"
65 #include "HepMC/SimpleVector.h"
106 fSqrtS(pset.getParameter<double>(
"fSqrtS")),
107 fAw(pset.getParameter<double>(
"fAw")),
108 fIfb(pset.getParameter<int>(
"fIfb")),
109 fBmin(pset.getParameter<double>(
"fBmin")),
110 fBmax(pset.getParameter<double>(
"fBmax")),
111 fBfix(pset.getParameter<double>(
"fBfix")),
112 fT(pset.getParameter<double>(
"fT")),
113 fMuB(pset.getParameter<double>(
"fMuB")),
114 fMuS(pset.getParameter<double>(
"fMuS")),
115 fMuC(pset.getParameter<double>(
"fMuC")),
116 fMuI3(pset.getParameter<double>(
"fMuI3")),
117 fThFO(pset.getParameter<double>(
"fThFO")),
118 fMu_th_pip(pset.getParameter<double>(
"fMu_th_pip")),
119 fTau(pset.getParameter<double>(
"fTau")),
120 fSigmaTau(pset.getParameter<double>(
"fSigmaTau")),
121 fR(pset.getParameter<double>(
"fR")),
122 fYlmax(pset.getParameter<double>(
"fYlmax")),
123 fUmax(pset.getParameter<double>(
"fUmax")),
124 fDelta(pset.getParameter<double>(
"fDelta")),
125 fEpsilon(pset.getParameter<double>(
"fEpsilon")),
126 fIfDeltaEpsilon(pset.getParameter<double>(
"fIfDeltaEpsilon")),
127 fDecay(pset.getParameter<int>(
"fDecay")),
128 fWeakDecay(pset.getParameter<double>(
"fWeakDecay")),
129 fEtaType(pset.getParameter<double>(
"fEtaType")),
130 fTMuType(pset.getParameter<double>(
"fTMuType")),
131 fCorrS(pset.getParameter<double>(
"fCorrS")),
132 fCharmProd(pset.getParameter<int>(
"fCharmProd")),
133 fCorrC(pset.getParameter<double>(
"fCorrC")),
134 fNhsel(pset.getParameter<int>(
"fNhsel")),
135 fPyhist(pset.getParameter<int>(
"fPyhist")),
136 fIshad(pset.getParameter<int>(
"fIshad")),
137 fPtmin(pset.getParameter<double>(
"fPtmin")),
138 fT0(pset.getParameter<double>(
"fT0")),
139 fTau0(pset.getParameter<double>(
"fTau0")),
140 fNf(pset.getParameter<int>(
"fNf")),
141 fIenglu(pset.getParameter<int>(
"fIenglu")),
142 fIanglu(pset.getParameter<int>(
"fIanglu")),
144 embedding_(pset.getParameter<bool>(
"embeddingMode")),
145 rotate_(pset.getParameter<bool>(
"rotateEventPlane")),
189 LogInfo(
"Hydjet2Hadronizer|GenSeed") <<
"Seed for random number generation: "<<
hjRandomEngine->CLHEP::HepRandomEngine::getSeed();
203 LogInfo(
"Hydjet2Hadronizer|RAScaling")<<
"Nuclear radius(RA) = "<<ra;
212 LogError(
"Hydjet2Hadronizer|sqrtS") <<
"SqrtS<2.24 not allowed with fTMuType>0";
230 LogInfo(
"Hydjet2Hadronizer|Strange") <<
"fMuS = " <<
fMuS;
234 LogError(
"Hydjet2Hadronizer|Ylmax") <<
"fYlmax more then TMath::Log(fSqrtS vs 0.94)!!! ";
240 fCorrS = 1. - 0.386* TMath::Exp(-1.23*
fT/fMuB);
241 LogInfo(
"Hydjet2Hadronizer|Strange") <<
"The phenomenological f-la F. Becattini et al. PRC73 044905 (2006) for CorrS was used."<<endl
242 <<
"Strangeness suppression parameter = "<<
fCorrS;
244 LogInfo(
"Hydjet2Hadronizer|Strange") <<
"The phenomenological f-la J. Cleymans et al. PRC73 034905 (2006) for Tch mu_B was used." << endl
245 <<
"The simulation will be done with the calculated parameters:" << endl
246 <<
"Baryon chemical potential = "<<fMuB<<
" [GeV]" << endl
247 <<
"Strangeness chemical potential = "<<
fMuS<<
" [GeV]" << endl
248 <<
"Isospin chemical potential = "<<
fMuI3<<
" [GeV]" << endl
249 <<
"Strangeness suppression parameter = "<<
fCorrS << endl
253 LogInfo(
"Hydjet2Hadronizer|Param") <<
"Used eta_max = "<<
fYlmax<< endl
254 <<
"maximal allowed eta_max TMath::Log(fSqrtS/0.94)= "<<TMath::Log(
fSqrtS/0.94);
294 LogInfo(
"Hydjet2Hadronizer|Param") <<
"central Effective volume = " <<
fVolEff <<
" [fm^3]";
296 double particleDensity_pi_ch=0;
297 double particleDensity_pi_th=0;
310 int encoding = currParticle->
GetPDG();
315 if(encoding == 333)S = 2;
332 double numb_dens_bolt = particleDensity_pi_th*particleDensity_ch/particleDensity_pi_ch;
333 mu =
fThFO*TMath::Log(numb_dens_bolt/particleDensity_th_0);
335 particleDensity = numb_dens_bolt;
340 if(
abs(encoding)<=9) {
344 if(
abs(encoding)>10 &&
abs(encoding)<19) {
348 if(
abs(encoding)>20 &&
abs(encoding)<30) {
352 if(
abs(encoding)>80 &&
abs(encoding)<100) {
357 if(
abs(encoding)>1000 &&
abs(encoding)<6000) {
358 int tens = ((
abs(encoding)-(
abs(encoding)%10))/10)%10;
364 if(
abs(encoding)==130 ||
abs(encoding)==310) {
369 if(encoding==443)NJPsith=particleDensity*fVolEff/dYl;
380 if(
abs(encoding)==441 ||
381 abs(encoding)==10441 ||
abs(encoding)==10443 ||
382 abs(encoding)==20443 ||
abs(encoding)==445 ||
abs(encoding)==4232 ||
abs(encoding)==4322 ||
383 abs(encoding)==4132 ||
abs(encoding)==4312 ||
abs(encoding)==4324 ||
abs(encoding)==4314 ||
384 abs(encoding)==4332 ||
abs(encoding)==4334
389 if(
abs(encoding)!=443){
390 Nocth=Nocth+particleDensity*fVolEff/dYl;
391 LogInfo(
"Hydjet2Hadronizer|Charam") << encoding<<
" Nochth "<<Nocth;
401 if((
abs(encoding)>500 &&
abs(encoding)<600) ||
402 (
abs(encoding)>10500 &&
abs(encoding)<10600) ||
403 (
abs(encoding)>20500 &&
abs(encoding)<20600) ||
404 (
abs(encoding)>100500 &&
abs(encoding)<100600)) {
408 if(
abs(encoding)>5000 &&
abs(encoding)<6000) {
414 if(particleDensity > 0.) {
446 TLorentzVector partJMom, partJPos, zeroVec;
454 const HepMC::GenEvent * inev = input->GetEvent();
455 const HepMC::HeavyIon* hi = inev->heavy_ion();
457 fBfix = hi->impact_parameter();
458 phi0_ = hi->event_plane_angle();
462 LogWarning(
"EventEmbedding")<<
"Background event does not have heavy ion record!";
480 LogError(
"Hydjet2EmptyEvent") <<
"##### HYDJET2: No Particles generated, Number of tries ="<<ntry;
483 std::ostringstream sstr;
484 sstr <<
"Hydjet2HadronizerProducer: No particles generated after " << ntry <<
" tries.\n";
496 int numbJetPart = HYPART.
njp;
498 for(
int i = 0;
i <numbJetPart; ++
i) {
501 double px = HYPART.
ppart[
i][2];
502 double py = HYPART.
ppart[
i][3];
503 double pz = HYPART.
ppart[
i][4];
505 double vx = HYPART.
ppart[
i][6];
506 double vy = HYPART.
ppart[
i][7];
507 double vz = HYPART.
ppart[
i][8];
508 double vt = HYPART.
ppart[
i][9];
510 int mother_index = int(HYPART.
ppart[
i][10])-1;
511 int daughter_index1 = int(HYPART.
ppart[
i][11])-1;
512 int daughter_index2 = int(HYPART.
ppart[
i][12])-1;
518 daughter_index1 = -1;
519 daughter_index2 = -1;
526 int motherPdg = int(HYPART.
ppart[mother_index][1]);
527 if(motherPdg==0) motherPdg = -1;
528 partJMom.SetXYZT(px, py, pz, e);
529 partJPos.SetXYZT(vx, vy, vz, vt);
530 Particle particle(partDef, partJPos, partJMom, 0, 0, type, motherPdg, zeroVec, zeroVec);
533 LogWarning(
"Hydjet2Hadronizer") <<
" Allocated HYDJET++ index is not synchronized with the PYTHIA index!" << endl
534 <<
" Collision history information is destroyed! It happens when a PYTHIA code is not" << endl
535 <<
" implemented in HYDJET++ particle list particles.data! Check it out!";
545 LogWarning(
"Hydjet2Hadronizer") <<
" PYTHIA particle of specie " << pdg <<
" is not in HYDJET++ particle list" << endl
546 <<
" Please define it in particles.data, otherwise the history information will be de-synchronized and lost!";
555 double impactParameter = HYFPAR.
bgen;
558 double psiforv3 = 0.;
559 double e3 = (0.2/5.5)*TMath::Power(impactParameter,1./3.);
564 const double weightMax = 2*TMath::CosH(
fUmax);
565 const int nBins = 100;
566 double probList[nBins];
569 TLorentzVector partPos, partMom, n1, p0;
571 const TLorentzVector zeroVec;
573 const double eMax = 5.;
581 double Epsilon0 = 0.5*impactParameter;
582 double coeff = (HYIPAR.
RA/
fR)/12.;
583 Epsilon = Epsilon0 * coeff;
585 double A = C*Epsilon*(1-Epsilon*Epsilon);
587 if(
TMath::Abs(Epsilon)>0.0001 &&
TMath::Abs(A)>0.0001)Delta = 0.5*(TMath::Sqrt(1+4*A*(Epsilon+A))-1)/A;
602 double coeff_RB = TMath::Sqrt(VolEffcent * HYFPAR.
npart/HYFPAR.
npart0/VolEffnoncent);
604 coeff_R1 = TMath::Power(coeff_R1, 0.333333);
612 double Ncc = Nbcol * NccNN/dYl;
623 LogInfo(
"Hydjet2Hadronizer|Param") <<
" gammaC = " <<gammaC;
636 if(
abs(encoding)==443)Mparam = Mparam * gammaC;
638 LogInfo(
"Hydjet2Hadronizer|Param") <<encoding<<
" "<<Mparam/dYl;
640 int multiplicity = CLHEP::RandPoisson::shoot(
hjRandomEngine, Mparam);
642 LogInfo(
"Hydjet2Hadronizer|Param") <<
"specie: " << encoding <<
"; average mult: = " << Mparam <<
"; multiplicity = " << multiplicity;
644 if (multiplicity > 0) {
647 LogError(
"Hydjet2Hadronizer") <<
"No particle with encoding "<< encoding;
653 LogInfo(
"Hydjet2Hadronizer|Param") <<
"statistical charmed particle not allowed ! "<<encoding;
657 LogInfo(
"Hydjet2Hadronizer|Param") <<
" charm pdg generated "<< encoding;
665 const double d = !(int(2*partDef->
GetSpin()) & 1) ? -1 : 1;
666 const double mass = partDef->
GetMass();
669 double h = (eMax - mass) / nBins;
670 double x = mass + 0.5 *
h;
672 for(i = 0; i < nBins; ++
i) {
673 if(x>=mu &&
fThFO>0)probList[
i] = x * TMath::Sqrt(x * x - mass * mass) / (TMath::Exp((x - mu) / (
fThFO)) + d);
674 if(x>=mu &&
fThFO<=0)probList[
i] = x * TMath::Sqrt(x * x - mass * mass) / (TMath::Exp((x - mu) / (
fT)) + d);
675 if(x<mu)probList[
i] = 0.;
684 for (i = 0; i < nBins; ++
i) {
685 probList[
i] = x * TMath::CosH(param*x);
691 double weight = 0., yy = 0., px0 = 0., py0 = 0., pz0 = 0.;
692 double e = 0., x0 = 0., y0 = 0., z0 = 0., t0 = 0., etaF = 0.;
695 RB =
fR * coeff_RB * coeff_R1 * TMath::Sqrt((1+e3)/(1-e3));
697 for(
int j = 0;
j < multiplicity; ++
j) {
700 n1.SetXYZT(0.,0.,TMath::SinH(etaF),TMath::CosH(etaF));
715 double Rx = TMath::Sqrt(1-Epsilon)*RB;
716 double Ry = TMath::Sqrt(1+Epsilon)*RB;
718 x0 = Rx * rho * TMath::Cos(phi);
719 y0 = Ry * rho * TMath::Sin(phi);
720 r = TMath::Sqrt(x0*x0+y0*y0);
725 if(x0>0&&y0<0)phiF = 2.*
TMath::Pi()-phiF;
728 if(r>RB*(1+e3*TMath::Cos(3*(phiF+psiforv3)))/(1+e3))
continue;
732 z0 = tau * TMath::SinH(etaF);
733 t0 = tau * TMath::CosH(etaF);
734 double rhou =
fUmax * r / RB;
735 double rhou3 = 0.063*TMath::Sqrt((0.5*impactParameter)/0.67);
736 double rhou4 = 0.023*((0.5*impactParameter)/0.67);
737 double rrcoeff = 1./TMath::Sqrt(1. + Delta*TMath::Cos(2*phiF));
743 rhou = rhou * (1 + rrcoeff*rhou3*TMath::Cos(3*(phiF+psiforv3)) + rrcoeff*rhou4*TMath::Cos(4*phiF) );
747 Delta = Delta * (1.0 + delta1 * TMath::Cos(phiF) - delta1 * TMath::Cos(3*phiF));
749 double uxf = TMath::SinH(rhou)*TMath::Sqrt(1+Delta)*TMath::Cos(phiF);
750 double uyf = TMath::SinH(rhou)*TMath::Sqrt(1-Delta)*TMath::Sin(phiF);
751 double utf = TMath::CosH(etaF) * TMath::CosH(rhou) *
752 TMath::Sqrt(1+Delta*TMath::Cos(2*phiF)*TMath::TanH(rhou)*TMath::TanH(rhou));
753 double uzf = TMath::SinH(etaF) * TMath::CosH(rhou) *
754 TMath::Sqrt(1+Delta*TMath::Cos(2*phiF)*TMath::TanH(rhou)*TMath::TanH(rhou));
756 vec3.SetXYZ(uxf / utf, uyf / utf, uzf / utf);
763 double stp0 = TMath::Sqrt(1. - ctp0 * ctp0);
764 e = mass + (eMax - mass) * arrayFunctDistE();
765 double pp0 = TMath::Sqrt(e * e - mass * mass);
766 px0 = pp0 * stp0 * TMath::Sin(php0);
767 py0 = pp0 * stp0 * TMath::Cos(php0);
769 p0.SetXYZT(px0, py0, pz0, e);
772 weight = (n1 * p0) /e;
774 }
while(yy >= weight);
776 if(
abs(z0)>1000 ||
abs(x0)>1000)
LogInfo(
"Hydjet2Hadronizer|Param") <<
" etaF = "<<etaF<<std::endl;
778 partMom.SetXYZT(px0, py0, pz0, e);
779 partPos.SetXYZT(x0, y0, z0, t0);
783 Particle particle(partDef, partPos, partMom, 0., 0, type, -1, zeroVec, zeroVec);
799 LogError(
"Hydjet2Hadronizer") <<
"Source is not initialized!!";
811 TVector3 pos(it->Pos().Vect());
812 TVector3 mom(it->Mom().Vect());
813 float m1 = it->TableMass();
815 Mpdg[
Ntot] = it->GetLastMotherPdg();
819 E[
Ntot] = TMath::Sqrt(mom.Mag2() + m1*m1);
852 LogError(
"Hydjet2Hadronizer") <<
"Ntot is too large" <<
Ntot;
874 HepMC::GenEvent *
evt =
new HepMC::GenEvent();
877 evt->set_signal_process_id(
pypars.msti[0]);
878 evt->set_event_scale(
pypars.pari[16]);
893 std::vector<int>
pdg = _pdg;
894 for (
size_t i=0;
i < pdg.size();
i++ ) {
896 std::ostringstream pyCard ;
897 pyCard <<
"MDCY(" << pyCode <<
",1)=0";
924 return "gen::Hydjet2Hadronizer";
932 LogDebug(
"f2") <<
"in f2: "<<
"delta"<<Delta;
934 double rhou =
fUmax * y / RsB;
935 double ff = y*TMath::CosH(rhou)*
936 TMath::Sqrt(1+Delta*TMath::Cos(2*x)*TMath::TanH(rhou)*TMath::TanH(rhou));
943 LogDebug(
"SimpsonIntegrator") <<
"in SimpsonIntegrator"<<
"delta - "<<Delta;
944 int nsubIntervals=100;
945 double h = (b -
a)/nsubIntervals;
946 double s =
f2(phi,a + 0.5*h,Delta);
947 double t = 0.5*(
f2(phi,a,Delta) +
f2(phi,b,Delta));
949 double y = a + 0.5*
h;
950 for(
int i = 1;
i < nsubIntervals;
i++) {
953 s +=
f2(phi,y,Delta);
954 t +=
f2(phi,x,Delta);
963 LogInfo(
"SimpsonIntegrator2") <<
"in SimpsonIntegrator2: epsilon - "<<Epsilon<<
" delta - "<<Delta;
964 int nsubIntervals=10000;
965 double h = (b -
a)/nsubIntervals;
970 for(
int j = 1;
j < nsubIntervals;
j++) {
974 double RB = RsB *(TMath::Sqrt(1-e*e)/TMath::Sqrt(1+e*TMath::Cos(2*x)));
985 int nsubIntervals=2000;
986 int nsubIntervals2=1;
987 double h = (b -
a)/nsubIntervals;
988 double h2 = (
fR)/nsubIntervals;
990 double x = a + 0.5*
h;
993 double t =
f2(x,y,Delta);
997 for(
int j = 1;
j < nsubIntervals;
j++) {
1001 double RB = RsB *(TMath::Sqrt(1-e*e)/TMath::Sqrt(1+e*TMath::Cos(2*x)));
1003 nsubIntervals2 = int(RB / h2)+1;
1006 for(
int i = 1;
i < nsubIntervals2;
i++)
1007 t +=
f2(x,(y += h2),Delta);
1016 double x1 = gammaC*Ndth;
1018 LogInfo(
"Charam") <<
"gammaC 20"<<
" var "<<var1<<endl;
1020 double x0 = gammaC*Ndth;
1022 LogInfo(
"Charam") <<
"gammaC 1"<<
" var "<<var0;
1024 for(
int i=1;
i<1000;
i++){
1026 gammaC=gammaC+0.01*
i;
1027 double x = gammaC*Ndth;
1032 LogInfo(
"Charam") <<
"gammaC "<<gammaC<<
" var0 "<<var0;
1037 LogInfo(
"Charam") <<
"gammaC not found ? "<<gammaC<<
" var0 "<<var0;
1052 const double pi = 3.14159265358979;
1073 vector<HepMC::GenVertex*> sub_vertices(
nsub_);
1076 for(
int isub=0;isub<
nsub_;isub++){
1077 LogDebug(
"SubEvent") <<
"Sub Event ID : "<<isub;
1079 int sub_up = (isub+1)*50000;
1080 vector<HepMC::GenParticle*> particles;
1081 vector<int> mother_ids;
1082 vector<HepMC::GenVertex*> prods;
1084 sub_vertices[isub] =
new HepMC::GenVertex(HepMC::FourVector(0,0,0,0),isub);
1085 evt->add_vertex(sub_vertices[isub]);
1087 if(!evt->signal_process_vertex()) evt->set_signal_process_vertex(sub_vertices[isub]);
1098 LogDebug(
"Hydjet2")<<
"Number of particles in vector "<<particles.size();
1100 for (
unsigned int i = 0;
i<particles.size();
i++) {
1105 int mid = mother_ids[
i]-isub*50000-1;
1107 LogDebug(
"DecayChain")<<
"Mother's ID "<<mid;
1108 LogDebug(
"DecayChain")<<
"Particle's PDG ID "<<part->pdg_id();
1112 sub_vertices[isub]->add_particle_out(part);
1118 LogDebug(
"DecayChain")<<
"Mother's PDG ID "<<mother->pdg_id();
1119 HepMC::GenVertex* prod_vertex = mother->end_vertex();
1121 prod_vertex = prods[
i];
1122 prod_vertex->add_particle_in(mother);
1123 evt->add_vertex(prod_vertex);
1127 prod_vertex->add_particle_out(part);
1133 for (
unsigned int i = 0;
i<prods.size();
i++) {
1134 if(prods[
i])
delete prods[
i];
1164 p->suggest_barcode(barcode);
1180 HepMC::GenVertex* vertex =
new HepMC::GenVertex(HepMC::FourVector(x,y,z,t),
id);
1189 int nproj =
static_cast<int>(npart / 2);
1190 int ntarg =
static_cast<int>(npart - nproj);
1192 HepMC::HeavyIon* hi =
new HepMC::HeavyIon(
1208 evt->set_heavy_ion(*hi);
void SetLastDaughterIndex(int index)
T getParameter(std::string const &) const
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)
void SetPythiaStatusCode(int code)
ParticleAllocator allocator
unsigned int maxEventsToPrint_
TString RunInputHYDJETstr
void add_heavy_ion_rec(HepMC::GenEvent *evt)
unsigned int pythiaPylistVerbosity_
void SetMother(int value)
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)
virtual double GetWeakDecayLimit()
double f2(double, double, double)
std::auto_ptr< HepMC::GenEvent > & event()
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()
bool initializeForInternalPartons()
Cos< T >::type cos(const T &t)
Abs< T >::type abs(const T &t)
double CharmEnhancementFactor(double, double, double, double)
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
virtual void doSetRandomEngine(CLHEP::HepRandomEngine *v) override
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
static const std::string kFortranInstance
double S(const TLorentzVector &, const TLorentzVector &)
HepMC::GenParticle * build_hyjet2(int index, int barcode)
void setRandomEngine(CLHEP::HepRandomEngine *v)
void SetTemperature(double value)
double BesselI1(double x)
void AddParticle(const Particle &particle, List_t &list)
std::list< Particle >::iterator LPIT_t
int FirstDaughterIndex[500000]
void SetFirstDaughterIndex(int index)
edm::Event & getEDMEvent() const
bool generatePartonsAndHadronize()
int LastDaughterIndex[500000]