Thermal-FIST 1.5
Package for hadron resonance gas model applications
Loading...
Searching...
No Matches
cpc3-chi2NEQ.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
15using namespace std;
16
17#ifdef ThermalFIST_USENAMESPACE
18using namespace thermalfist;
19#endif
20
21
22// Thermal fits to NA49 and LHC data within the Ideal HRG model in
23// 1. Chemical equilibrium scenario (<config> = 0);
24// 2. Chemical non-equilibrium scenario (<config> = 1).
25//
26// Usage: cpc3chi2NEQ <config>
27int main(int argc, char *argv[])
28{
29 // Particle list file
30 // Here we will use the list from THERMUS-2.3, for comparing the results with THERMUS-2.3
31 //string listname = string(ThermalFIST_INPUT_FOLDER) + "/list/thermus23/list.dat";
32
33 // Alternative: use the default PDG2014 list
34 string listname = string(ThermalFIST_INPUT_FOLDER) + "/list/PDG2014/list.dat";
35 //string listname = string(ThermalFIST_INPUT_FOLDER) + "/../../input/list/PDG2014update/list.dat";
36
37 // Create the hadron list instance and read the list from file
38 ThermalParticleSystem TPS(listname);
39
40 // Which variant of the HRG model to use
41 int config = 0;
42
43 // Read config from command line
44 if (argc > 1)
45 config = atoi(argv[1]);
46
47
48 string fittype; // For output
49 if (config == 1)
50 fittype = "NEQ";
51 else
52 fittype = "EQ";
53
54 // Pointer to the thermal model instance used in calculations
55 ThermalModelBase *model;
56
57 model = new ThermalModelIdeal(&TPS);
58
59
60 // Use quantum statistics
61 model->SetStatistics(true);
62 model->SetCalculationType(IdealGasFunctions::Quadratures); // Use quadratures for better accuracy, needed due to Bose-Einstein condensation effects for pions
63 //model->SetStatistics(false);
64
65 // Use mass integration over Breit-Wigner shapes in +-2Gamma interval, as in THERMUS
67 //model->SetUseWidth(ThermalParticle::ZeroWidth);
68
69 // Prepare for output
70 char tmpc[1000];
71 sprintf(tmpc, "cpc3.%s.chi2.out", fittype.c_str());
72 FILE *fout = fopen(tmpc, "w");
73
74
75 // Prepare fitter
76 ThermalModelFit fitter(model);
77
78
79
80
81
82 printf("%15s%15s%15s%15s%15s%15s%15s%15s%15s%15s%15s%15s%15s\n",
83 "Dataset", // What data are fitted
84 "T[MeV]", // Temperature in MeV
85 "T_err[MeV]", // Temperature error in MeV
86 "muB[MeV]", // Baryon chemical potential in MeV
87 "muB_err[MeV]", // Baryon chemical potential error in MeV
88 "R[fm]", // System radius in fm
89 "R_err[fm]", // System radius error in fm
90 "gammaq", // gamma_q
91 "gammaq_err", // gamma_q
92 "gammaS", // gamma_S
93 "gammaS_err", // gamma_S
94 "chi2", // chi_2
95 "chi2/dof" // Reduced chi2
96 );
97
98 fprintf(fout, "%15s%15s%15s%15s%15s%15s%15s%15s%15s%15s\n",
99 "Dataset", // What data are fitted
100 "T[MeV]", // Temperature in MeV
101 "muB[MeV]", // Baryon chemical potential in MeV
102 "R[fm]", // System radius in fm
103 "gammaq", // gamma_q
104 "gammaS", // gamma_S
105 "chi2", // chi_2
106 "chi2/dof", // Reduced chi2
107 "Q/B", // Electric-to-baryon charge ratio, must be 0.4
108 "S/|S|" // Strangeness-to-absolutestrangeness ratio, must be very close to 0
109 );
110
111
112 // Experimental data sets
113 vector<string> names;
114 vector<string> filenames;
115
116 names.push_back("NA49-30GeV-4pi");
117 filenames.push_back(string(ThermalFIST_INPUT_FOLDER) + "/data/NA49/NA49-PbPb30AGeV-4pi.dat");
118
119 names.push_back("NA49-40GeV-4pi");
120 filenames.push_back(string(ThermalFIST_INPUT_FOLDER) + "/data/NA49/NA49-PbPb40AGeV-4pi.dat");
121
122 names.push_back("NA49-80GeV-4pi");
123 filenames.push_back(string(ThermalFIST_INPUT_FOLDER) + "/data/NA49/NA49-PbPb80AGeV-4pi.dat");
124
125 names.push_back("NA49-158GeV-4pi");
126 filenames.push_back(string(ThermalFIST_INPUT_FOLDER) + "/data/NA49/NA49-PbPb158AGeV-4pi.dat");
127
128 names.push_back("ALICE-2_76-0-5");
129 filenames.push_back(string(ThermalFIST_INPUT_FOLDER) + "/data/ALICE-PbPb2.76TeV-0-5-1512.08046.dat");
130
131
132
133
134
135 double wt1 = get_wall_time(); // Timing
136
137 int iters = 0; // Number of data sets
138
139 for(size_t ind = 0; ind < names.size(); ++ind)
140 {
141 // Load the data to be fitted
142 vector<FittedQuantity> quantities = ThermalModelFit::loadExpDataFromFile(filenames[ind]);
143 fitter.SetQuantities(quantities);
144
145 // Temperature is fitted by default
146 // We can specify initial guess, as well as the bounds
147 double Tinit = 0.140;
148 double Tdelta = 0.030;
149 double Tmin = 0.050;
150 double Tmax = 0.170; // If Tmax is larger, than fit converges to a local minimum with higher chi2 for NA49-158 GeV
151 fitter.SetParameter("T", Tinit, Tdelta, Tmin, Tmax);
152
153 // muB is fitted by default
154 // We can specify initial guess, as well as the bounds
155 double muBinit = 0.250;
156 double muBdelta = 0.150;
157 double muBmin = -0.050;
158 double muBmax = 1.000;
159 fitter.SetParameter("muB", muBinit, muBdelta, muBmin, muBmax);
160
161
162 // R is fitted by default
163 // We can specify initial guess, as well as the bounds
164 double Rinit = 10.0;
165 double Rdelta = 1.0;
166 double Rmin = 0.0;
167 double Rmax = 30.0;
168 fitter.SetParameter("R", Rinit, Rdelta, Rmin, Rmax);
169
170
171 // gammaq is NOT fitted by default
172 // We can specify initial guess, as well as the bounds
173 double gqinit = 1.0;
174 double gqdelta = 0.6;
175 double gqmin = 0.001;
176 double gqmax = 1.800;
177 if (config != 0) {
178 fitter.SetParameterFitFlag("gammaq", true);
179 fitter.SetParameter("gammaq", gqinit, gqdelta, gqmin, gqmax);
180 }
181
182
183 // gammaS is NOT fitted by default, the default value is 1
184 // We can specify initial guess, as well as the bounds
185 if (config != 0) {
186 double gSinit = 1.0;
187 double gSdelta = 0.6;
188 double gSmin = 0.001;
189 double gSmax = 3.000;
190 fitter.SetParameterFitFlag("gammaS", true);
191 fitter.SetParameter("gammaS", gSinit, gSdelta, gSmin, gSmax);
192 }
193
194
195 ThermalModelFitParameters result = fitter.PerformFit(true); // The argument is set to show additional (verbose) output during minimization
196
197 double Tfit = result.T.value;
198 double Terr = result.T.error;
199 double muBfit = result.muB.value;
200 double muBerr = result.muB.error;
201 double Rfit = result.R.value;
202 double Rerr = result.R.error;
203 double gqfit = result.gammaq.value;
204 double gqerr = result.gammaq.error;
205 double gSfit = result.gammaS.value;
206 double gSerr = result.gammaS.error;
207 double chi2 = result.chi2;
208 double chi2dof = result.chi2ndf;
209
210 printf("%15s%15lf%15lf%15lf%15lf%15lf%15lf%15lf%15lf%15lf%15lf%15lf%15lf",
211 names[ind].c_str(),
212 Tfit * 1000.,
213 Terr * 1000.,
214 muBfit * 1000.,
215 muBerr * 1000.,
216 Rfit,
217 Rerr,
218 gqfit,
219 gqerr,
220 gSfit,
221 gSerr,
222 chi2,
223 chi2dof);
224
225 printf("\n");
226
227
228 fprintf(fout, "%15s%15lf%15lf%15lf%15lf%15lf%15lf%15lf%15E%15E\n",
229 names[ind].c_str(),
230 Tfit * 1000.,
231 muBfit * 1000.,
232 Rfit,
233 gqfit,
234 gSfit,
235 chi2,
236 chi2dof,
237 model->CalculateChargeDensity() / model->CalculateBaryonDensity(),
238 model->CalculateStrangenessDensity() / model->CalculateAbsoluteStrangenessDensity());
239
240 fflush(fout);
241
242 iters++;
243
244 }
245
246 delete model;
247
248
249 double wt2 = get_wall_time();
250
251 printf("%30s %lf s\n", "Running time:", (wt2 - wt1));
252 printf("%30s %lf s\n", "Time per single calculation:", (wt2 - wt1) / iters);
253
254 return 0;
255}
256
Abstract base class for an HRG model implementation.
void SetUseWidth(bool useWidth)
Sets whether finite resonance widths are used. Deprecated.
virtual void SetCalculationType(IdealGasFunctions::QStatsCalculationType type)
Sets the CalculationType() method to evaluate quantum statistics. Calls the corresponding method in T...
virtual void SetStatistics(bool stats)
Class implementing the thermal model fit procedure.
void SetParameter(const std::string &name, const FitParameter &param)
Sets the fit parameter with a given name.
void SetParameterFitFlag(const std::string &name, bool toFit)
Sets whether the fit parameter with a given name is fitted.
void SetQuantities(const std::vector< FittedQuantity > &inQuantities)
Same as SetData()
static std::vector< FittedQuantity > loadExpDataFromFile(const std::string &filename)
Load the experimental data from a file.
ThermalModelFitParameters PerformFit(bool verbose=true, bool AsymmErrors=false)
The thermal fit procedure.
Class implementing the Ideal HRG model.
@ BWTwoGamma
Energy-independent Breit-Wigner in +-2\Gamma interval.
Class containing the particle list.
int main(int argc, char *argv[])
The main namespace where all classes and functions of the Thermal-FIST library reside.
Definition CosmicEoS.h:9
double get_wall_time()
Definition Utility.cpp:191
double error
Parameter error (symmetric)
Structure holding information about parameters of a thermal fit.
FitParameter T
All the fit parameters.