Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
eos.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file eos.cpp
1 #include <string>
2 #include <iostream>
3 #include <fstream>
4 #include <cstdlib>
5 #include "eos.h"
6 #include "inc.h"
7 #include <TGraph.h>
8 
9 using namespace std;
10 
11 const double bagp = pow(247.19 / 197.32, 4) / gevtofm;
12 const double bagt = pow(247.19 / 197.32, 4) / gevtofm;
13 const double deg = 16.0 + 3.0 * 12.0 * (7.0 / 8.0);
14 
15 // EoS choise --> MOVED to Makefile
16 //#define TABLE // Laine, etc
17 //#define SIMPLE // p=e/3
18 
19 double EoS::s(double e, double nb, double nq, double ns) {
20  double T, mub, muq, mus, p;
21  eos(e, nb, nq, ns, T, mub, muq, mus, p);
22  if (T > 0.0)
23  return (e + p - mub * nb - muq * nq - mus * ns) / T;
24  else
25  return 0.;
26 }
27 
28 EoSs::EoSs(string fname, int ncols) {
29 #if defined TABLE || defined LAINE_CFO
30 
31  int edat = 10000;
32  double* e = new double[edat];
33  double* pGrid = new double[edat];
34  double* tpGrid = new double[edat];
35  double* muGrid = new double[edat];
36 
37  ifstream finput(fname.c_str(), ios::in);
38  // ofstream fout("debug.txt");
39  if (!finput) {
40  cerr << "can't open input file \"" << fname.c_str() << "\"" << endl;
41  exit(1);
42  }
43  edat = 0;
44  while (!finput.eof()) {
45  if (ncols == 3) {
46  finput >> e[edat] >> pGrid[edat] >> tpGrid[edat];
47  muGrid[edat] = 0.;
48  } else {
49  finput >> e[edat] >> pGrid[edat] >> tpGrid[edat] >> muGrid[edat];
50  }
51  if (pGrid[edat] < 0.) pGrid[edat] = 0.;
52  edat++;
53  }
54  finput.close();
55 
56  gp = new TGraph(edat, e, pGrid);
57  gT = new TGraph(edat, e, tpGrid);
58  gmu = new TGraph(edat, e, muGrid);
59 
60 #elif defined SIMPLE
61 // nothing
62 #endif
63 }
64 
65 EoSs::~EoSs(void) {}
66 
67 double EoSs::p(double e) {
68 #if defined TABLE
69  return gp->Eval(e);
70 #elif defined SIMPLE
71  return e / 3.;
72 #endif
73 }
74 
75 double EoSs::dpe(double e) {
76 #if defined TABLE
77  return (gp->Eval(e * 1.1) - gp->Eval(e)) / (0.1 * e);
78 #elif defined SIMPLE
79  return 1. / 3.;
80 #endif
81 }
82 
83 double EoSs::t(double e) {
84 #if defined TABLE
85  return gT->Eval(e);
86 #elif defined SIMPLE
87  const double cnst =
88  (16 + 0.5 * 21.0 * 2.5) * pow(C_PI, 2) / 30.0 / pow(0.197326968, 3);
89  return e > 0. ? 1.0 * pow(e / cnst, 0.25) : 0.;
90 #endif
91 }
92 
93 double EoSs::mu(double e) {
94 #if defined TABLE
95  return gmu->Eval(e);
96 #elif defined SIMPLE
97  return 0.;
98 #endif
99 }