Thermal-FIST  1.3
Package for hadron resonance gas model applications
cpc2-chi2-vs-T.cpp
Go to the documentation of this file.
1 #include <string.h>
2 #include <fstream>
3 #include <iostream>
4 #include <iomanip>
5 #include <ctime>
6 #include <cstdio>
7 
8 #include "HRGBase.h"
9 #include "HRGEV.h"
10 #include "HRGFit.h"
11 #include "HRGVDW.h"
12 
13 #include "ThermalFISTConfig.h"
14 
15 using namespace std;
16 
17 #ifdef ThermalFIST_USENAMESPACE
18 using namespace thermalfist;
19 #endif
20 
21 
22 // Temperature dependence of the fit to ALICE 2.76 TeV data, 0-5% centrality, as in 1512.08046
23 // Four variants of HRG model:
24 // 1. Ideal HRG: <config> = 0
25 // 2. Diagonal EV-HRG with bag model parametrization r = r_p * (m/m_p)^1/3, where r_p = 0.5 is proton radius parameter (as in 1512.08046): <config> = 1
26 // 3. Diagonal EV-HRG with constant radius parameter r = 0.3 fm for all baryons and r = 0 for all mesons (as in 1201.0693): <config> = 2
27 // 4. QvdW-HRG with a and b for baryons only, fixed to nuclear ground state (as in 1609.03975): <config> = 3
28 // Usage: cpc1HRGTDep <config>
29 int main(int argc, char *argv[])
30 {
31  // Particle list file
32  // Here we will use the list from THERMUS-2.3, for comparing the results with THERMUS-2.3
33  string listname = string(ThermalFIST_INPUT_FOLDER) + "/list/thermus23/list.dat";
34 
35  // Alternative: use the default PDG2014 list
36  //string listname = string(ThermalFIST_INPUT_FOLDER) + "/list/PDG2014/list.dat";
37 
38  // Create the hadron list instance and read the list from file
39  ThermalParticleSystem TPS(listname);
40 
41  // Which variant of the HRG model to use
42  int config = 0;
43 
44  // Read config from command line
45  if (argc > 1)
46  config = atoi(argv[1]);
47 
48 
49  string modeltype; // For output
50 
51 
52  // Pointer to the thermal model instance used in calculations
53  ThermalModelBase *model;
54 
55 
56 
57  if (config == 0) // Ideal HRG
58  {
59  model = new ThermalModelIdeal(&TPS);
60 
61  printf("#Fitting 2.76 TeV ALICE data at \\mu = 0 in Id-HRG model\n");
62 
63  modeltype = "Id-HRG";
64  }
65  else if (config == 1) // EV-HRG, r = 0.3 fm for baryons, r = 0 for mesons, no light nuclei, as in 1512.08046
66  {
67  model = new ThermalModelEVDiagonal(&TPS);
68  double rad = 0.3;
69  for (int i = 0; i < model->TPS()->ComponentsNumber(); ++i) {
70  if (model->TPS()->Particle(i).BaryonCharge() == 0) model->SetRadius(i, 0.);
71  else model->SetRadius(i, rad);
72  }
73 
74  printf("#Fitting 2.76 TeV ALICE data at \\mu = 0 in EV-HRG model with r = %lf fm for baryons, and r = 0 for mesons\n", rad);
75 
76  modeltype = "EV-HRG-TwoComponent";
77  }
78  else if (config == 2) // EV-HRG, Bag Model with r_p = 0.5 fm, as in 1512.08046
79  {
80  model = new ThermalModelEVDiagonal(&TPS);
81  double radProton = 0.5;
82  for (int i = 0; i < model->TPS()->ComponentsNumber(); ++i) {
83  model->SetRadius(i, radProton * pow(model->TPS()->Particle(i).Mass() / 0.938, 1/3.));
84  }
85 
86  printf("#Fitting 2.76 TeV ALICE data at \\mu = 0 in Bag Model EV-HRG model with proton r = %lf fm\n", radProton);
87 
88  modeltype = "EV-HRG-BagModel";
89  }
90  else if (config == 3) // QvdW-HRG, to reproduce 1609.03975
91  {
92  model = new ThermalModelVDWFull(&TPS);
93 
94  // vdW parameters, for baryon-baryon, antibaryon-antibaryon ONLY, otherwise zero
95  double a = 0.329; // In GeV*fm3
96  double b = 3.42; // In fm3
97 
98  // Iterate over all pairs of hadron species and set a and b
99  for (int i = 0; i < model->TPS()->ComponentsNumber(); ++i) {
100  for (int j = 0; j < model->TPS()->ComponentsNumber(); ++j) {
101  int B1 = model->TPS()->Particle(i).BaryonCharge(); // Baryon number of 1st species
102  int B2 = model->TPS()->Particle(j).BaryonCharge(); // Baryon number of 2nd species
103 
104  if ((B1 > 0 && B2 > 0) || (B1 < 0 && B2 < 0)) // baryon-baryon or antibaryon-antibaryon
105  {
106  model->SetAttraction(i, j, a); // Set QvdW repulsion
107  model->SetVirial(i, j, b); // Set QvdW attraction
108  }
109  else // no vdW interactions for meson-meson, meson-baryon or baryon-anitbaryon pairs
110  {
111  model->SetAttraction(i, j, 0.);
112  model->SetVirial(i, j, 0.);
113  }
114  }
115  }
116 
117  printf("#Fitting 2.76 TeV ALICE data at \\mu = 0 in QvdW-HRG model\n");
118 
119  modeltype = "QvdW-HRG";
120  }
121  else // Ideal HRG by default
122  {
123  model = new ThermalModelIdeal(&TPS);
124 
125  modeltype = "Id-HRG";
126  }
127 
128  // Use quantum statistics
129  model->SetStatistics(true);
130  //model->SetStatistics(false);
131 
132  // Use mass integration over Breit-Wigner shapes in +-2Gamma interval, as in THERMUS
133  model->SetUseWidth(ThermalParticle::BWTwoGamma);
134  //model->SetUseWidth(ThermalParticle::ZeroWidth);
135 
136  // Set chemical potentials to zero
137  model->SetBaryonChemicalPotential(0.0);
138  model->SetElectricChemicalPotential(0.0);
140  model->SetCharmChemicalPotential(0.0);
141  model->FillChemicalPotentials();
142 
143  // Prepare fitter
144  ThermalModelFit fitter(model);
145 
146  // By default T, muB, and R parameters are fitted, while others (gammaS etc.) are fixed
147  // Initial parameters values are taken from those currently set in the ThermalModel object
148  // Here we do not fit muB, which is set to zero above
149  fitter.SetParameterFitFlag("muB", false); // Do not fit muB
150 
151 
152 
153  // R is fitted by default
154  // We can still specify the initial value, the initial delta used by minuit,
155  // and the lower and upper limits using the SetParameter function
156  double Rinit = 10.0;
157  double Rdelta = 1.0;
158  double Rmin = 0.0;
159  double Rmax = 30.0;
160  fitter.SetParameter("R", Rinit, Rdelta, Rmin, Rmax);
161 
162  // Load the experimental data
163  vector<FittedQuantity> quantities = ThermalModelFit::loadExpDataFromFile(string(ThermalFIST_INPUT_FOLDER) + "/data/ALICE-PbPb2.76TeV-0-5-1512.08046.dat");
164  fitter.SetQuantities(quantities);
165 
166 
167  printf("%15s%15s%15s%15s\n",
168  "T[MeV]", // Temperature in MeV
169  "R[fm]", // System radius in fm
170  "chi2", // chi_2
171  "chi2_dof" // Reduced chi2
172  );
173 
174 
175  // Prepare for output to file
176  char tmpc[1000];
177  sprintf(tmpc, "cpc2.%s.ALICE2_76.chi2.TDep.out", modeltype.c_str());
178  FILE *fout = fopen(tmpc, "w");
179 
180  fprintf(fout, "%15s%15s%15s%15s\n",
181  "T[MeV]", // Temperature in MeV
182  "R[fm]", // System radius in fm
183  "chi2", // chi_2
184  "chi2_dof" // Reduced chi2
185  );
186 
187  double wt1 = get_wall_time(); // Timing
188 
189  int iters = 0; // Number of data points
190 
191  // Temperature interval, in GeV
192  double Tmin = 0.100;
193  double Tmax = 0.2501;
194  double dT = 0.002;
195 
196  if (config == 0)
197  dT = 0.001;
198 
199  if (config == 2) {
200  dT = 0.005;
201  Tmax = 0.4001;
202  }
203 
204  for (double T = Tmin; T <= Tmax; T += dT) {
205  // We also do not fit T, but fix it at each iteration to a given value
206  fitter.SetParameterFitFlag("T", false);
207  fitter.SetParameterValue("T", T); // Set the temperature
208 
209  ThermalModelFitParameters result = fitter.PerformFit(false); // We still have to fit the radius, the argument suppresses the output during minimization
210 
211  double Rfit = result.R.value;
212  double chi2 = result.chi2;
213  double chi2dof = result.chi2ndf;
214 
215  printf("%15lf%15lf%15lf%15lf\n", T * 1000., Rfit, chi2, chi2 / (result.ndf - 1.));
216 
217  fprintf(fout, "%15lf%15lf%15lf%15lf\n", T * 1000., Rfit, chi2, chi2 / (result.ndf - 1.));
218 
219  iters++;
220 
221  fflush(stdout);
222 
223  }
224 
225  fclose(fout);
226 
227  delete model;
228 
229 
230  double wt2 = get_wall_time();
231 
232  printf("%30s %lf s\n", "Running time:", (wt2 - wt1));
233  printf("%30s %lf s\n", "Time per single calculation:", (wt2 - wt1) / iters);
234 
235  return 0;
236 }
237 
238 
Abstract base class for an HRG model implementation.
int main(int argc, char *argv[])
virtual void SetStrangenessChemicalPotential(double muS)
Set the strangeness chemical potential.
virtual void SetElectricChemicalPotential(double muQ)
Set the electric chemical potential.
virtual void SetBaryonChemicalPotential(double muB)
Set the baryon chemical potential.
const ThermalParticle & Particle(int id) const
ThermalParticle object corresponding to particle species with a provided 0-based index.
virtual void SetStatistics(bool stats)
void SetParameter(const std::string &name, const FitParameter &param)
Sets the fit parameter with a given name.
void SetUseWidth(bool useWidth)
Sets whether finite resonance widths are used. Deprecated.
void SetQuantities(const std::vector< FittedQuantity > &inQuantities)
Same as SetData()
Class implementing the diagonal excluded-volume model.
Class containing the particle list.
int ndf
Number of degrees of freedom.
virtual void SetRadius(double)
Set the same excluded volume radius parameter for all species.
int ComponentsNumber() const
Number of different particle species in the list.
virtual void SetVirial(int, int, double)
Set the excluded volume coefficient .
virtual void FillChemicalPotentials()
Sets the chemical potentials of all particles.
int BaryonCharge() const
Particle&#39;s baryon number.
Class implementing the thermal model fit procedure.
double get_wall_time()
Definition: Utility.cpp:187
virtual void SetCharmChemicalPotential(double muC)
Set the charm chemical potential.
void SetParameterFitFlag(const std::string &name, bool toFit)
Sets whether the fit parameter with a given name is fitted.
double Mass() const
Particle&#39;s mass [GeV].
Structure holding information about parameters of a thermal fit.
virtual void SetAttraction(int, int, double)
Set the vdW mean field attraction coefficient .
Class implementing the Ideal HRG model.
ThermalModelVDW ThermalModelVDWFull
For backward compatibility.
ThermalModelFitParameters PerformFit(bool verbose=true, bool AsymmErrors=false)
The thermal fit procedure.
The main namespace where all classes and functions of the Thermal-FIST library reside.
ThermalParticleSystem * TPS()
void SetParameterValue(const std::string &name, double value)
Sets the (initial) value for the fit parameter with a given name.