Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
icGlauber.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file icGlauber.cpp
1 #include <fstream>
2 #include <iomanip>
3 #include <iomanip>
4 #include <TF1.h>
5 #include <TF2.h>
6 #include <TGraph.h>
7 
8 #include "fld.h"
9 #include "eos.h"
10 #include "icGlauber.h"
11 #include "inc.h"
12 
13 using namespace std;
14 
15 // --------------------------------------------
16 // Initial state from optical Glauber model
17 // --------------------------------------------
18 
19 // Au nucleus parameters for optical Glauber
20 const double A = 197.0; // mass number
21 const double Ra = 6.37; // radius
22 const double dlt = 0.54; // diffuseness
23 const double sigma = 4.0; // NN cross section in fm^2
24 
25 const int nphi = 301;
26 
27 ICGlauber::ICGlauber(double e, double impactPar, double _tau0) {
28  epsilon = e;
29  b = impactPar;
30  tau0 = _tau0;
31 }
32 
34 
35 double ICGlauber::eProfile(double x, double y) {
36  prms[0] = sqrt((x + b / 2.0) * (x + b / 2.0) + y * y);
37  iff->SetParameters(prms);
38  const double tpp = iff->Integral(-3.0 * Ra, 3.0 * Ra, 1.0e-9);
39  prms[0] = sqrt((x - b / 2.0) * (x - b / 2.0) + y * y);
40  iff->SetParameters(prms);
41  const double tmm = iff->Integral(-3.0 * Ra, 3.0 * Ra, 1.0e-9);
42  return epsilon *
43  pow(1. / rho0 * (tpp * (1.0 - pow((1.0 - sigma * tmm / A), A)) +
44  tmm * (1.0 - pow((1.0 - sigma * tpp / A), A))),
45  1.0);
46 }
47 
48 void ICGlauber::findRPhi(void) {
49  _rphi = new double[nphi];
50  for (int iphi = 0; iphi < nphi; iphi++) {
51  double phi = iphi * C_PI * 2. / (nphi - 1);
52  double r = 0., r1 = 0., r2 = 2. * Ra;
53  while (fabs((r2 - r1) / r2) > 0.001 && r2 > 0.001) {
54  r = 0.5 * (r1 + r2);
55  if (eProfile(r * cos(phi), r * sin(phi)) > 0.5)
56  r1 = r;
57  else
58  r2 = r;
59  }
60  _rphi[iphi] = r;
61  }
62 }
63 
64 
65 double ICGlauber::rPhi(double phi) {
66  const double cpi = C_PI;
67  phi = phi - 2. * cpi * floor(phi / 2. / cpi);
68  int iphi = (int)(phi / (2. * cpi) * (nphi - 1));
69  int iphi1 = iphi + 1;
70  if (iphi1 == nphi) iphi = nphi - 2;
71  return _rphi[iphi] * (1. - (phi / (2. * cpi) * (nphi - 1) - iphi)) +
72  _rphi[iphi1] * (phi / (2. * cpi) * (nphi - 1) - iphi);
73 }
74 
75 
77  double e, nb, nq, vx = 0., vy = 0., vz = 0.;
78  Cell *c;
79  ofstream fvel("velocity_debug.txt");
80 
81  TF2 *ff = 0;
82  double prms2[2], intgr2;
83  cout << "finding normalization constant\n";
84  ff = new TF2("ThicknessF", this, &ICGlauber::Thickness, -3.0 * Ra, 3.0 * Ra,
85  -3.0 * Ra, 3.0 * Ra, 2, "IC", "Thickness");
86  prms2[0] = Ra;
87  prms2[1] = dlt;
88  ff->SetParameters(prms2);
89  intgr2 = ff->Integral(-3.0 * Ra, 3.0 * Ra, -3.0 * Ra, 3.0 * Ra, 1.0e-9);
90  if (intgr2 == 0.0) {
91  cerr << "IC::setICGlauber Error! ff->Integral == 0; Return -1\n";
92  delete ff;
93  exit(1);
94  }
95  delete ff;
96  cout << "a = " << A / intgr2 << endl;
97  prms[1] = A / intgr2;
98  prms[2] = Ra;
99  prms[3] = dlt;
100  iff = new TF1("WoodSaxonDF", this, &ICGlauber::WoodSaxon, -3.0 * Ra, 3.0 * Ra, 4,
101  "IC", "WoodSaxon");
102  prms[0] = 0.0;
103  iff->SetParameters(prms);
104  const double tpp = iff->Integral(-3.0 * Ra, 3.0 * Ra, 1.0e-9);
105  rho0 = 2.0 * tpp * (1.0 - pow((1.0 - sigma * tpp / A), A));
106 
107  findRPhi(); // fill in R(phi) table
108  cout << "R(phi) = ";
109  for (int jj = 0; jj < 5; jj++) cout << rPhi(jj * C_PI / 2.) << " "; // test
110  cout << endl;
111  //--------------
112  double avv_num = 0., avv_den = 0.;
113  double Etotal = 0.0;
114 
115  for (int ix = 0; ix < f->getNX(); ix++)
116  for (int iy = 0; iy < f->getNY(); iy++)
117  for (int iz = 0; iz < f->getNZ(); iz++) {
118  c = f->getCell(ix, iy, iz);
119  double x = f->getX(ix);
120  double y = f->getY(iy);
121  double eta = f->getZ(iz);
122  double etaFactor;
123  double eta1 = fabs(eta) < 1.3 ? 0.0 : fabs(eta) - 1.3;
124  etaFactor = exp(-eta1 * eta1 / 2.1 / 2.1) * (fabs(eta) < 5.3 ? 1.0 : 0.0);
125  e = eProfile(x, y) * etaFactor;
126  if (e < 0.5) e = 0.0;
127  vx = vy = 0.0;
128  nb = nq = 0.0;
129  vz = 0.0;
130 
131  avv_num += sqrt(vx * vx + vy * vy) * e;
132  avv_den += e;
133 
134  c->setPrimVar(eos, tau0, e, nb, nq, 0., vx, vy, vz);
135  double _p = eos->p(e, nb, nq, 0.);
136  const double gamma2 = 1.0 / (1.0 - vx * vx - vy * vy - vz * vz);
137  Etotal +=
138  ((e + _p) * gamma2 * (cosh(eta) + vz * sinh(eta)) - _p * cosh(eta));
139  c->saveQprev();
140 
141  if (e > 0.) c->setAllM(1.);
142  }
143  fvel.close();
144  cout << "average initial flow = " << avv_num / avv_den << endl;
145  cout << "total energy = " << Etotal *f->getDx() * f->getDy() * f->getDz() *
146  tau0 << endl;
147 }
148 
149 double ICGlauber::Thickness(double *x, double *p) {
150  // p[0]: Ra radius; p[1]: delta = 0.54fm
151  double intgrl, prms[4];
152  TF1 *iff = 0;
153  iff = new TF1("WoodSaxonDF", this, &ICGlauber::WoodSaxon, -3.0 * p[0], 3.0 * p[0], 4,
154  "IC", "WoodSaxon");
155  prms[0] = sqrt(x[0] * x[0] + x[1] * x[1]); //
156  prms[1] = 1.0; // normalization parameter which must be found.
157  prms[2] = p[0];
158  prms[3] = p[1];
159  iff->SetParameters(prms);
160  intgrl = iff->Integral(-3.0 * p[0], 3.0 * p[0], 1.0e-9);
161  if (iff) delete iff;
162  return intgrl;
163 }
164 
165 double ICGlauber::WoodSaxon(double *x, double *p) {
166  return p[1] / (exp((sqrt(x[0] * x[0] + p[0] * p[0]) - p[2]) / p[3]) + 1.0);
167 }