Thermal-FIST  1.3
Package for hadron resonance gas model applications
BagModelFit.cpp
Go to the documentation of this file.
1 /*
2  * Thermal-FIST package
3  *
4  * Copyright (c) 2014-2018 Volodymyr Vovchenko
5  *
6  * GNU General Public License (GPLv3 or later)
7  */
8 #include <string.h>
9 #include <fstream>
10 #include <iostream>
11 #include <iomanip>
12 #include <ctime>
13 #include <cstdio>
14 
15 #include "HRGBase.h"
16 #include "HRGEV.h"
17 #include "HRGFit.h"
18 
19 #include "ThermalFISTConfig.h"
20 
21 using namespace std;
22 
23 #ifdef ThermalFIST_USENAMESPACE
24 using namespace thermalfist;
25 #endif
26 
27 // Fits within the excluded-volume HRG in a bag model scaling, as in 1512.08046
28 // First does the global fit
29 // Then computes the chi2 profile
30 // Usage: BagModelFit <rp> <Tmin> <Tmax> <dT>
31 int main(int argc, char *argv[])
32 {
33  // Proton radius
34  double radProton = 0.50;
35  if (argc>1)
36  radProton = atof(argv[1]);
37 
38  // Minimum temperature for chi2 profile calculation [GeV]
39  double Tmin = 0.100;
40  if (argc>2)
41  Tmin = atof(argv[2]);
42 
43  // Maximum temperature for chi2 profile calculation [GeV]
44  double Tmax = 0.301;
45  if (argc>3)
46  Tmax = atof(argv[3]);
47 
48  // Step in temperature for chi2 profile calculation [GeV]
49  double dT = 0.001;
50  if (argc>4)
51  dT = atof(argv[4]);
52 
53  // Create the hadron list instance and read the list from file
54  ThermalParticleSystem TPS(string(ThermalFIST_INPUT_FOLDER) + "/list/thermus23/list.dat");
55  //ThermalParticleSystem TPS(string(ThermalFIST_INPUT_FOLDER) + "/list/PDG2014/list.dat");
56 
57  // Create the EV-HRG ThermalModel instance
58  ThermalModelEVDiagonal model(&TPS);
59 
60  // Use finite resonance widths (energy-independent Breit-Wigner)
61  model.SetUseWidth(ThermalParticle::BWTwoGamma);
62 
63  // Include quantum statistics
64  model.SetStatistics(true);
65 
66  // All chemical potentials are zero
70  model.SetCharmChemicalPotential(0.);
71 
72  // Loop over all particles and set their EV parameters in accordance with the bag model
73  for (int i = 0; i < model.TPS()->Particles().size(); ++i) {
74  const ThermalParticle &part = model.TPS()->Particles()[i];
75  double mass = part.Mass(); // Mass of particle i
76  double rad = radProton * pow(mass / xMath::mnucleon(), 1. / 3.); // Radius parameter of particle i
77  model.SetRadius(i, rad); // Sets the radius
78  }
79 
80  // Load the experimental data
81  vector<FittedQuantity> quantities = ThermalModelFit::loadExpDataFromFile(string(ThermalFIST_INPUT_FOLDER) + "/data/ALICE-PbPb2.76TeV-0-5-1512.08046.dat");
82 
83 
84  // Global fit
85  ThermalModelFit pfit(&model);
86 
87  // By default T, muB, and R parameters are fitted, while others (gammaS etc.) are fixed
88  // Initial parameters values are taken from those currently set in a ThermalModel object
89  // Here we do not fit muB, which is set to zero
90  pfit.SetParameterFitFlag("muB", false); // Do not fit muB
91 
92  // R is fitted by default
93  // We can still specify the initial value, the initial delta used by minuit,
94  // and the lower and upper limits using the SetParameter function
95  double Rinit = 10.0;
96  double Rdelta = 1.0;
97  double Rmin = 0.0;
98  double Rmax = 30.0;
99  pfit.SetParameter("R", Rinit, Rdelta, Rmin, Rmax);
100 
101  pfit.SetQuantities(quantities); // Provide the data to be fitted
102 
103  pfit.PerformFit(); // Performs the fit
104  pfit.PrintFitLog(); // Print the fit result
105 
106 
107  // Now perform the chi-square profile scan
108  printf("%15s%15s%15s\n", "T [GeV]", "R [fm]", "chi2");
109  pfit.SetParameterFitFlag("T", false); // We are not fitting T anymore
110 
111  // Iterate over all the T values
112  for (double T = Tmin; T <= Tmax; T += dT) {
113  pfit.SetParameterValue("T", T); // Set the temperature
114  ThermalModelFitParameters result = pfit.PerformFit(false); // We still have to fit the radius, the argument suppresses the output during minimization
115  printf("%15lf%15lf%15lf\n", T, result.R.value, result.chi2);
116  }
117 
118  return 0;
119 }
120 
121 
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.
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 main(int argc, char *argv[])
Definition: BagModelFit.cpp:31
Class implementing the thermal model fit procedure.
void PrintFitLog(std::string filename="", std::string comment="Thermal fit", bool asymm=false)
Prints the result of the fitting procedure to a file.
Class containing all information about a particle specie.
const std::vector< ThermalParticle > & Particles() const
Returns the vector of all particle species.
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.
ThermalModelFitParameters PerformFit(bool verbose=true, bool AsymmErrors=false)
The thermal fit procedure.
double mnucleon()
Nucleon&#39;s mass. Value as in UrQMD.
Definition: xMath.h:36
The main namespace where all classes and functions of the Thermal-FIST library reside.
void SetRadius(double rad)
Set the same excluded volume radius parameter for all species.
ThermalParticleSystem * TPS()
void SetParameterValue(const std::string &name, double value)
Sets the (initial) value for the fit parameter with a given name.