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){
99 if(sta== 1 && typ==0)
return 6;
100 if(sta== 1 && typ==1)
return 7;
101 if(sta== 2 && typ==0)
return 16;
102 if(sta== 2 && typ==1)
return 17;
123 fSqrtS(pset.getParameter<double>(
"fSqrtS")),
124 fAw(pset.getParameter<double>(
"fAw")),
125 fIfb(pset.getParameter<
int>(
"fIfb")),
126 fBmin(pset.getParameter<double>(
"fBmin")),
127 fBmax(pset.getParameter<double>(
"fBmax")),
128 fBfix(pset.getParameter<double>(
"fBfix")),
129 fT(pset.getParameter<double>(
"fT")),
130 fMuB(pset.getParameter<double>(
"fMuB")),
131 fMuS(pset.getParameter<double>(
"fMuS")),
132 fMuC(pset.getParameter<double>(
"fMuC")),
133 fMuI3(pset.getParameter<double>(
"fMuI3")),
134 fThFO(pset.getParameter<double>(
"fThFO")),
135 fMu_th_pip(pset.getParameter<double>(
"fMu_th_pip")),
136 fTau(pset.getParameter<double>(
"fTau")),
137 fSigmaTau(pset.getParameter<double>(
"fSigmaTau")),
138 fR(pset.getParameter<double>(
"fR")),
139 fYlmax(pset.getParameter<double>(
"fYlmax")),
140 fUmax(pset.getParameter<double>(
"fUmax")),
141 fDelta(pset.getParameter<double>(
"fDelta")),
142 fEpsilon(pset.getParameter<double>(
"fEpsilon")),
143 fIfDeltaEpsilon(pset.getParameter<double>(
"fIfDeltaEpsilon")),
144 fDecay(pset.getParameter<
int>(
"fDecay")),
145 fWeakDecay(pset.getParameter<double>(
"fWeakDecay")),
146 fEtaType(pset.getParameter<double>(
"fEtaType")),
147 fTMuType(pset.getParameter<double>(
"fTMuType")),
148 fCorrS(pset.getParameter<double>(
"fCorrS")),
149 fCharmProd(pset.getParameter<
int>(
"fCharmProd")),
150 fCorrC(pset.getParameter<double>(
"fCorrC")),
151 fNhsel(pset.getParameter<
int>(
"fNhsel")),
152 fPyhist(pset.getParameter<
int>(
"fPyhist")),
153 fIshad(pset.getParameter<
int>(
"fIshad")),
154 fPtmin(pset.getParameter<double>(
"fPtmin")),
155 fT0(pset.getParameter<double>(
"fT0")),
156 fTau0(pset.getParameter<double>(
"fTau0")),
157 fNf(pset.getParameter<
int>(
"fNf")),
158 fIenglu(pset.getParameter<
int>(
"fIenglu")),
159 fIanglu(pset.getParameter<
int>(
"fIanglu")),
161 embedding_(pset.getParameter<bool>(
"embeddingMode")),
162 rotate_(pset.getParameter<bool>(
"rotateEventPlane")),
206 LogInfo(
"Hydjet2Hadronizer|GenSeed") <<
"Seed for random number generation: "<<
hjRandomEngine->CLHEP::HepRandomEngine::getSeed();
220 LogInfo(
"Hydjet2Hadronizer|RAScaling")<<
"Nuclear radius(RA) = "<<ra;
229 LogError(
"Hydjet2Hadronizer|sqrtS") <<
"SqrtS<2.24 not allowed with fTMuType>0";
247 LogInfo(
"Hydjet2Hadronizer|Strange") <<
"fMuS = " <<
fMuS;
251 LogError(
"Hydjet2Hadronizer|Ylmax") <<
"fYlmax more then TMath::Log(fSqrtS vs 0.94)!!! ";
257 fCorrS = 1. - 0.386* TMath::Exp(-1.23*
fT/fMuB);
258 LogInfo(
"Hydjet2Hadronizer|Strange") <<
"The phenomenological f-la F. Becattini et al. PRC73 044905 (2006) for CorrS was used."<<endl
259 <<
"Strangeness suppression parameter = "<<
fCorrS;
261 LogInfo(
"Hydjet2Hadronizer|Strange") <<
"The phenomenological f-la J. Cleymans et al. PRC73 034905 (2006) for Tch mu_B was used." << endl
262 <<
"The simulation will be done with the calculated parameters:" << endl
263 <<
"Baryon chemical potential = "<<fMuB<<
" [GeV]" << endl
264 <<
"Strangeness chemical potential = "<<
fMuS<<
" [GeV]" << endl
265 <<
"Isospin chemical potential = "<<
fMuI3<<
" [GeV]" << endl
266 <<
"Strangeness suppression parameter = "<<
fCorrS << endl
270 LogInfo(
"Hydjet2Hadronizer|Param") <<
"Used eta_max = "<<
fYlmax<< endl
271 <<
"maximal allowed eta_max TMath::Log(fSqrtS/0.94)= "<<TMath::Log(
fSqrtS/0.94);
311 LogInfo(
"Hydjet2Hadronizer|Param") <<
"central Effective volume = " <<
fVolEff <<
" [fm^3]";
313 double particleDensity_pi_ch=0;
314 double particleDensity_pi_th=0;
327 int encoding = currParticle->
GetPDG();
332 if(encoding == 333)S = 2;
349 double numb_dens_bolt = particleDensity_pi_th*particleDensity_ch/particleDensity_pi_ch;
350 mu =
fThFO*TMath::Log(numb_dens_bolt/particleDensity_th_0);
352 particleDensity = numb_dens_bolt;
357 if(
abs(encoding)<=9) {
361 if(
abs(encoding)>10 &&
abs(encoding)<19) {
365 if(
abs(encoding)>20 &&
abs(encoding)<30) {
369 if(
abs(encoding)>80 &&
abs(encoding)<100) {
374 if(
abs(encoding)>1000 &&
abs(encoding)<6000) {
375 int tens = ((
abs(encoding)-(
abs(encoding)%10))/10)%10;
381 if(
abs(encoding)==130 ||
abs(encoding)==310) {
386 if(encoding==443)NJPsith=particleDensity*fVolEff/dYl;
397 if(
abs(encoding)==441 ||
398 abs(encoding)==10441 ||
abs(encoding)==10443 ||
399 abs(encoding)==20443 ||
abs(encoding)==445 ||
abs(encoding)==4232 ||
abs(encoding)==4322 ||
400 abs(encoding)==4132 ||
abs(encoding)==4312 ||
abs(encoding)==4324 ||
abs(encoding)==4314 ||
401 abs(encoding)==4332 ||
abs(encoding)==4334
406 if(
abs(encoding)!=443){
407 Nocth=Nocth+particleDensity*fVolEff/dYl;
408 LogInfo(
"Hydjet2Hadronizer|Charam") << encoding<<
" Nochth "<<Nocth;
418 if((
abs(encoding)>500 &&
abs(encoding)<600) ||
419 (
abs(encoding)>10500 &&
abs(encoding)<10600) ||
420 (
abs(encoding)>20500 &&
abs(encoding)<20600) ||
421 (
abs(encoding)>100500 &&
abs(encoding)<100600)) {
425 if(
abs(encoding)>5000 &&
abs(encoding)<6000) {
431 if(particleDensity > 0.) {
463 TLorentzVector partJMom, partJPos, zeroVec;
471 const HepMC::GenEvent * inev = input->
GetEvent();
472 const HepMC::HeavyIon*
hi = inev->heavy_ion();
474 fBfix = hi->impact_parameter();
475 phi0_ = hi->event_plane_angle();
479 LogWarning(
"EventEmbedding")<<
"Background event does not have heavy ion record!";
497 LogError(
"Hydjet2EmptyEvent") <<
"##### HYDJET2: No Particles generated, Number of tries ="<<ntry;
500 std::ostringstream sstr;
501 sstr <<
"Hydjet2HadronizerProducer: No particles generated after " << ntry <<
" tries.\n";
513 int numbJetPart = HYPART.
njp;
515 for(
int i = 0;
i <numbJetPart; ++
i) {
518 double px = HYPART.
ppart[
i][2];
519 double py = HYPART.
ppart[
i][3];
520 double pz = HYPART.
ppart[
i][4];
522 double vx = HYPART.
ppart[
i][6];
523 double vy = HYPART.
ppart[
i][7];
524 double vz = HYPART.
ppart[
i][8];
525 double vt = HYPART.
ppart[
i][9];
527 int mother_index =
int(HYPART.
ppart[
i][10])-1;
528 int daughter_index1 =
int(HYPART.
ppart[
i][11])-1;
529 int daughter_index2 =
int(HYPART.
ppart[
i][12])-1;
535 daughter_index1 = -1;
536 daughter_index2 = -1;
543 int motherPdg =
int(HYPART.
ppart[mother_index][1]);
544 if(motherPdg==0) motherPdg = -1;
545 partJMom.SetXYZT(px, py, pz, e);
546 partJPos.SetXYZT(vx, vy, vz, vt);
547 Particle particle(partDef, partJPos, partJMom, 0, 0, type, motherPdg, zeroVec, zeroVec);
548 int index = particle.SetIndex();
554 particle.SetPythiaStatusCode(pythiaStatus);
555 particle.SetMother(mother_index);
556 particle.SetFirstDaughterIndex(daughter_index1);
557 particle.SetLastDaughterIndex(daughter_index2);
558 if(pythiaStatus!=1) particle.SetDecayed();
562 LogWarning(
"Hydjet2Hadronizer") <<
" PYTHIA particle of specie " << pdg <<
" is not in Hydjet2 particle list" << endl
563 <<
" Please define it in particles.data, otherwise the history information will be de-synchronized and lost!";
572 double impactParameter = HYFPAR.
bgen;
576 double e3 = (0.2/5.5)*TMath::Power(impactParameter,1./3.);
581 const double weightMax = 2*TMath::CosH(
fUmax);
582 const int nBins = 100;
583 double probList[nBins];
586 TLorentzVector partPos, partMom, n1, p0;
588 const TLorentzVector zeroVec;
590 const double eMax = 5.;
598 double Epsilon0 = 0.5*impactParameter;
599 double coeff = (HYIPAR.
RA/
fR)/12.;
600 Epsilon = Epsilon0 * coeff;
602 double A = C*Epsilon*(1-Epsilon*
Epsilon);
604 if(
TMath::Abs(Epsilon)>0.0001 &&
TMath::Abs(A)>0.0001)Delta = 0.5*(TMath::Sqrt(1+4*A*(Epsilon+A))-1)/A;
619 double coeff_RB = TMath::Sqrt(VolEffcent * HYFPAR.
npart/HYFPAR.
npart0/VolEffnoncent);
621 coeff_R1 = TMath::Power(coeff_R1, 0.333333);
629 double Ncc = Nbcol * NccNN/dYl;
640 LogInfo(
"Hydjet2Hadronizer|Param") <<
" gammaC = " <<gammaC;
653 if(
abs(encoding)==443)Mparam = Mparam * gammaC;
655 LogInfo(
"Hydjet2Hadronizer|Param") <<encoding<<
" "<<Mparam/dYl;
657 int multiplicity = CLHEP::RandPoisson::shoot(
hjRandomEngine, Mparam);
659 LogInfo(
"Hydjet2Hadronizer|Param") <<
"specie: " << encoding <<
"; average mult: = " << Mparam <<
"; multiplicity = " << multiplicity;
661 if (multiplicity > 0) {
664 LogError(
"Hydjet2Hadronizer") <<
"No particle with encoding "<< encoding;
670 LogInfo(
"Hydjet2Hadronizer|Param") <<
"statistical charmed particle not allowed ! "<<encoding;
674 LogInfo(
"Hydjet2Hadronizer|Param") <<
" charm pdg generated "<< encoding;
682 const double d = !(
int(2*partDef->
GetSpin()) & 1) ? -1 : 1;
686 double h = (eMax -
mass) / nBins;
687 double x = mass + 0.5 *
h;
689 for(i = 0; i < nBins; ++
i) {
690 if(x>=mu &&
fThFO>0)probList[
i] = x * TMath::Sqrt(x * x - mass * mass) / (TMath::Exp((x - mu) / (
fThFO)) +
d);
691 if(x>=mu &&
fThFO<=0)probList[
i] = x * TMath::Sqrt(x * x - mass * mass) / (TMath::Exp((x - mu) / (
fT)) +
d);
692 if(x<mu)probList[
i] = 0.;
701 for (i = 0; i < nBins; ++
i) {
702 probList[
i] = x * TMath::CosH(param*x);
708 double weight = 0.,
yy = 0., px0 = 0., py0 = 0., pz0 = 0.;
709 double e = 0., x0 = 0., y0 = 0., z0 = 0.,
t0 = 0., etaF = 0.;
712 RB =
fR * coeff_RB * coeff_R1 * TMath::Sqrt((1+e3)/(1-e3));
714 for(
int j = 0; j < multiplicity; ++j) {
717 n1.SetXYZT(0.,0.,TMath::SinH(etaF),TMath::CosH(etaF));
732 double Rx = TMath::Sqrt(1-Epsilon)*RB;
733 double Ry = TMath::Sqrt(1+Epsilon)*RB;
735 x0 = Rx * rho * TMath::Cos(phi);
736 y0 = Ry * rho * TMath::Sin(phi);
737 r = TMath::Sqrt(x0*x0+y0*y0);
742 if(x0>0&&y0<0)phiF = 2.*
TMath::Pi()-phiF;
745 if(r>RB*(1+e3*TMath::Cos(3*(phiF+
psiforv3)))/(1+e3))
continue;
749 z0 = tau * TMath::SinH(etaF);
750 t0 = tau * TMath::CosH(etaF);
751 double rhou =
fUmax * r / RB;
752 double rhou3 = 0.063*TMath::Sqrt((0.5*impactParameter)/0.67);
753 double rhou4 = 0.023*((0.5*impactParameter)/0.67);
754 double rrcoeff = 1./TMath::Sqrt(1. + Delta*TMath::Cos(2*phiF));
760 rhou = rhou * (1 + rrcoeff*rhou3*TMath::Cos(3*(phiF+
psiforv3)) + rrcoeff*rhou4*TMath::Cos(4*phiF) );
764 Delta = Delta * (1.0 + delta1 * TMath::Cos(phiF) - delta1 * TMath::Cos(3*phiF));
766 double uxf = TMath::SinH(rhou)*TMath::Sqrt(1+Delta)*TMath::Cos(phiF);
767 double uyf = TMath::SinH(rhou)*TMath::Sqrt(1-Delta)*TMath::Sin(phiF);
768 double utf = TMath::CosH(etaF) * TMath::CosH(rhou) *
769 TMath::Sqrt(1+Delta*TMath::Cos(2*phiF)*TMath::TanH(rhou)*TMath::TanH(rhou));
770 double uzf = TMath::SinH(etaF) * TMath::CosH(rhou) *
771 TMath::Sqrt(1+Delta*TMath::Cos(2*phiF)*TMath::TanH(rhou)*TMath::TanH(rhou));
773 vec3.SetXYZ(uxf / utf, uyf / utf, uzf / utf);
780 double stp0 = TMath::Sqrt(1. - ctp0 * ctp0);
781 e = mass + (eMax -
mass) * arrayFunctDistE();
782 double pp0 = TMath::Sqrt(e * e - mass * mass);
783 px0 = pp0 * stp0 * TMath::Sin(php0);
784 py0 = pp0 * stp0 * TMath::Cos(php0);
786 p0.SetXYZT(px0, py0, pz0, e);
789 weight = (n1 * p0) /e;
791 }
while(
yy >= weight);
793 if(
abs(z0)>1000 ||
abs(x0)>1000)
LogInfo(
"Hydjet2Hadronizer|Param") <<
" etaF = "<<etaF<<std::endl;
795 partMom.SetXYZT(px0, py0, pz0, e);
796 partPos.SetXYZT(x0, y0, z0,
t0);
800 Particle particle(partDef, partPos, partMom, 0., 0, type, -1, zeroVec, zeroVec);
828 TVector3
pos(it->Pos().Vect());
829 TVector3 mom(it->Mom().Vect());
830 float m1 = it->TableMass();
832 Mpdg[
Ntot] = it->GetLastMotherPdg();
836 E[
Ntot] = TMath::Sqrt(mom.Mag2() + m1*m1);
870 LogError(
"Hydjet2Hadronizer") <<
"Ntot is too large" <<
Ntot;
892 HepMC::GenEvent *
evt =
new HepMC::GenEvent();
895 evt->set_signal_process_id(
pypars.msti[0]);
896 evt->set_event_scale(
pypars.pari[16]);
911 std::vector<int>
pdg = _pdg;
912 for (
size_t i=0;
i < pdg.size();
i++ ) {
914 std::ostringstream pyCard ;
915 pyCard <<
"MDCY(" << pyCode <<
",1)=0";
942 return "gen::Hydjet2Hadronizer";
950 LogDebug(
"f2") <<
"in f2: "<<
"delta"<<Delta;
952 double rhou =
fUmax * y / RsB;
953 double ff = y*TMath::CosH(rhou)*
954 TMath::Sqrt(1+Delta*TMath::Cos(2*x)*TMath::TanH(rhou)*TMath::TanH(rhou));
961 LogDebug(
"SimpsonIntegrator") <<
"in SimpsonIntegrator"<<
"delta - "<<Delta;
962 int nsubIntervals=100;
963 double h = (b -
a)/nsubIntervals;
964 double s =
f2(phi,a + 0.5*h,Delta);
965 double t = 0.5*(
f2(phi,a,Delta) +
f2(phi,b,Delta));
967 double y = a + 0.5*
h;
968 for(
int i = 1;
i < nsubIntervals;
i++) {
971 s +=
f2(phi,y,Delta);
972 t +=
f2(phi,x,Delta);
981 LogInfo(
"SimpsonIntegrator2") <<
"in SimpsonIntegrator2: epsilon - "<<Epsilon<<
" delta - "<<Delta;
982 int nsubIntervals=10000;
983 double h = (b -
a)/nsubIntervals;
988 for(
int j = 1; j < nsubIntervals; j++) {
992 double RB = RsB *(TMath::Sqrt(1-e*e)/TMath::Sqrt(1+e*TMath::Cos(2*x)));
1003 int nsubIntervals=2000;
1004 int nsubIntervals2=1;
1005 double h = (b -
a)/nsubIntervals;
1006 double h2 = (
fR)/nsubIntervals;
1008 double x = a + 0.5*
h;
1011 double t =
f2(x,y,Delta);
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)));
1021 nsubIntervals2 =
int(RB / h2)+1;
1024 for(
int i = 1;
i < nsubIntervals2;
i++)
1025 t +=
f2(x,(y += h2),Delta);
1034 double x1 = gammaC*Ndth;
1036 LogInfo(
"Charam") <<
"gammaC 20"<<
" var "<<var1<<endl;
1038 double x0 = gammaC*Ndth;
1040 LogInfo(
"Charam") <<
"gammaC 1"<<
" var "<<var0;
1042 for(
int i=1;
i<1000;
i++){
1044 gammaC=gammaC+0.01*
i;
1045 double x = gammaC*Ndth;
1050 LogInfo(
"Charam") <<
"gammaC "<<gammaC<<
" var0 "<<var0;
1055 LogInfo(
"Charam") <<
"gammaC not found ? "<<gammaC<<
" var0 "<<var0;
1070 const double pi = 3.14159265358979;
1091 vector<HepMC::GenVertex*> sub_vertices(
nsub_);
1094 for(
int isub=0;isub<
nsub_;isub++){
1095 LogDebug(
"SubEvent") <<
"Sub Event ID : "<<isub;
1097 int sub_up = (isub+1)*150000;
1099 vector<int> mother_ids;
1100 vector<HepMC::GenVertex*> prods;
1102 sub_vertices[isub] =
new HepMC::GenVertex(HepMC::FourVector(0,0,0,0),isub);
1103 evt->add_vertex(sub_vertices[isub]);
1105 if(!evt->signal_process_vertex()) evt->set_signal_process_vertex(sub_vertices[isub]);
1116 LogDebug(
"Hydjet2")<<
"Number of particles in vector "<<particles.size();
1118 for (
unsigned int i = 0;
i<particles.size();
i++) {
1123 int mid = mother_ids[
i]-isub*150000-1;
1125 LogDebug(
"DecayChain")<<
"Mother's ID "<<mid;
1126 LogDebug(
"DecayChain")<<
"Particle's PDG ID "<<part->pdg_id();
1130 sub_vertices[isub]->add_particle_out(part);
1136 LogDebug(
"DecayChain")<<
"Mother's PDG ID "<<mother->pdg_id();
1137 HepMC::GenVertex* prod_vertex = mother->end_vertex();
1139 prod_vertex = prods[
i];
1140 prod_vertex->add_particle_in(mother);
1141 evt->add_vertex(prod_vertex);
1145 prod_vertex->add_particle_out(part);
1151 for (
unsigned int i = 0;
i<prods.size();
i++) {
1152 if(prods[
i])
delete prods[
i];
1178 convertStatusForComponents(
final[index],
type[index])
1182 p->suggest_barcode(barcode);
1198 HepMC::GenVertex* vertex =
new HepMC::GenVertex(HepMC::FourVector(x,y,z,t),
id);
1206 double npart =
Npart;
1207 int nproj =
static_cast<int>(npart / 2);
1208 int ntarg =
static_cast<int>(npart - nproj);
1210 HepMC::HeavyIon*
hi =
new HepMC::HeavyIon(
1226 evt->set_heavy_ion(*hi);
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)
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
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)
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
virtual double GetWeakDecayLimit() override
HepMC::GenVertex * build_hyjet2_vertex(int i, int id)
T x() const
Cartesian x coordinate.
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)
virtual bool RunDecays() override
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
const HepMC::GenEvent * GetEvent() const
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)
def convertStatus(status)
std::list< Particle >::iterator LPIT_t
int FirstDaughterIndex[500000]
edm::Event & getEDMEvent() const
bool generatePartonsAndHadronize()
int LastDaughterIndex[500000]