CbmRoot
ThermalModelFit.h
Go to the documentation of this file.
1 #ifndef THERMALMODELFIT_H
2 #define THERMALMODELFIT_H
3 
4 #include "ThermalModelBase.h"
5 #include <cmath>
6 #include <string>
7 
8 struct FitParameter {
9  bool toFit;
10  double value;
11  double error;
12  double xmin, xmax;
13  std::string name;
14  FitParameter(std::string name_ = "",
15  bool toFit_ = true,
16  double val = 1.,
17  double err = 0.,
18  double vmin = -2.,
19  double vmax = 2.)
20  : toFit(toFit_)
21  , value(val)
22  , error(err)
23  , xmin(vmin)
24  , xmax(vmax)
25  , name(name_) {}
26 };
27 
30  double chi2ndf;
33  : T()
34  , muB()
35  , muS()
36  , muQ()
37  , gammaS()
38  , V()
39  , chi2ndf()
40  , nB()
41  , rhoB()
42  , rhoQ()
43  , en()
44  , entropy()
45  , pressure()
46  , eta() {}
48  : T()
49  , muB()
50  , muS()
51  , muQ()
52  , gammaS()
53  , V()
54  , chi2ndf()
55  , nB()
56  , rhoB()
57  , rhoQ()
58  , en()
59  , entropy()
60  , pressure()
61  , eta() {
62  T.value = model->Parameters.T;
63  muB.value = model->Parameters.muB;
64  muS.value = model->Parameters.muS;
65  muQ.value = model->Parameters.muQ;
66  gammaS.value = model->Parameters.gammaS;
67  V.value = model->Parameters.V;
68  nB.value = model->CalculateHadronDensity();
71  en.value = model->CalculateEnergyDensity();
73  pressure.value = model->CalculatePressure();
74  eta.value =
76  }
77 };
78 
81  double chi2ndf;
82  ThermalModelFitParameters(double T_ = 0.12,
83  double muB_ = 0.5,
84  double muS_ = 0.1,
85  double muQ_ = -0.01,
86  double gammaS_ = 1.,
87  double V_ = 4000.,
88  double R_ = 1.)
89  : T(FitParameter("T", true, T_, 0.05, 0.05, 0.18))
90  , muB(FitParameter("muB", true, muB_, 0.05, 0., 1.))
91  , muS(FitParameter("muS", false, muS_))
92  , muQ(FitParameter("muQ", false, muQ_))
93  , gammaS(FitParameter("gammaS", false, gammaS_, 0.2, 0.5, 1.5))
94  , V(FitParameter("V", true, V_, 2000., 1., 20000.))
95  , R(FitParameter("R", false, R_, 0., 0., 100.))
96  , chi2ndf(1.) {
97  // T = FitParameter("T", true, T_, 0.05, 0.05, 0.18);
98  // muB = FitParameter("muB", true, muB_, 0.05, 0., 1.);
99  // muS = FitParameter("muS", false, muS_);
100  // muQ = FitParameter("muQ", false, muQ_);
101  // gammaS = FitParameter("gammaS", false, gammaS_, 0.2, 0.5, 1.5);
102  // V = FitParameter("V", true, V_, 2000., 1., 20000.);
103  // R = FitParameter("R", false, R_, 0., 0., 100.);
104  }
105  FitParameter GetParamater(const std::string& name) const {
106  if (T.name == name) return T;
107  if (muB.name == name) return muB;
108  if (muS.name == name) return muS;
109  if (muQ.name == name) return muQ;
110  if (gammaS.name == name) return gammaS;
111  if (V.name == name) return V;
112  if (R.name == name) return R;
113  return FitParameter();
114  }
115  void SetParameter(const std::string& name, const FitParameter& param) {
116  if (T.name == name) T = param;
117  if (muB.name == name) muB = param;
118  if (muS.name == name) muS = param;
119  if (muQ.name == name) muQ = param;
120  if (gammaS.name == name) gammaS = param;
121  if (V.name == name) V = param;
122  if (R.name == name) R = param;
123  }
124  void SetParameter(const std::string& name,
125  double val,
126  double err,
127  double xmin,
128  double xmax) {
129  if (T.name == name) T = FitParameter(name, true, val, err, xmin, xmax);
130  if (muB.name == name) muB = FitParameter(name, true, val, err, xmin, xmax);
131  if (muS.name == name) muS = FitParameter(name, true, val, err, xmin, xmax);
132  if (muQ.name == name) muQ = FitParameter(name, true, val, err, xmin, xmax);
133  if (gammaS.name == name)
134  gammaS = FitParameter(name, true, val, err, xmin, xmax);
135  if (V.name == name) V = FitParameter(name, true, val, err, xmin, xmax);
136  if (R.name == name) R = FitParameter(name, true, val, err, xmin, xmax);
137  }
138  void SetParameterFitFlag(const std::string& name, bool toFit) {
139  if (T.name == name) T.toFit = toFit;
140  if (muB.name == name) muB.toFit = toFit;
141  if (muS.name == name) muS.toFit = toFit;
142  if (muQ.name == name) muQ.toFit = toFit;
143  if (gammaS.name == name) gammaS.toFit = toFit;
144  if (V.name == name) V.toFit = toFit;
145  if (R.name == name) R.toFit = toFit;
146  }
148  return ThermalModelParameters(
150  }
151 };
152 
154  int fPDGID;
155  double fValue, fError;
156  ExperimentMultiplicity(int PDGID = -211,
157  double value = 300.,
158  double error = 20.)
159  : fPDGID(PDGID), fValue(value), fError(error) {}
160  void addSystematicError(double percent) {
161  fError = sqrt(fError * fError + percent * percent * fValue * fValue);
162  }
163 };
164 
167  double value, error;
168  ExperimentRatio(int PDGID1_ = 211,
169  int PDGID2_ = -211,
170  double value_ = 1.,
171  double error_ = 0.1)
172  : PDGID1(PDGID1_), PDGID2(PDGID2_), value(value_), error(error_) {}
173  ExperimentRatio(int PDGID1_,
174  int PDGID2_,
175  double value1,
176  double error1,
177  double value2,
178  double error2)
179  : PDGID1(PDGID1_)
180  , PDGID2(PDGID2_)
181  , value(value1 / value2)
182  , error(sqrt(error1 * error1 / value2 / value2
183  + value1 * value1 / value2 / value2 / value2 / value2 * error2
184  * error2)) {
185  // value = value1 / value2;
186  // error = sqrt(error1*error1 / value2 / value2 + value1 * value1 / value2 / value2 / value2 / value2 * error2 * error2);
187  //error += value * 0.05;
188  }
189  void addSystematicError(double percent) {
190  error = sqrt(error * error + percent * percent * value * value);
191  }
192 };
193 
195  int type; // 0 - Multiplicity, 1 - Ratio
199  : type(0), mult(ExperimentMultiplicity(-211, 10., 1.)), ratio() {
200  // type = 0;
201  // mult = ExperimentMultiplicity(-211, 10., 1.);
202  }
204  : type(0), mult(op), ratio() {
205  // type = 0;
206  // mult = op;
207  }
208  FittedQuantity(const ExperimentRatio& op) : type(1), mult(), ratio(op) {
209  // type = 1;
210  // ratio = op;
211  }
212 };
213 
214 class ThermalModelBase;
215 
217 public:
221  double QBgoal;
222  std::vector<ExperimentMultiplicity> Multiplicities;
223  std::vector<ExperimentRatio> Ratios;
225  double T = 0.12,
226  double muB = 0.5,
227  double muS = 0.,
228  double muQ = 0.,
229  double gammaS = 1.,
230  double V = 4000.,
231  double R = 1.)
232  : model(model_)
233  , Parameters(T, muB, muS, muQ, gammaS, V, R)
235  , QBgoal(0.4)
236  , Multiplicities()
237  , Ratios() {
238  Multiplicities.resize(0);
239  Ratios.resize(0);
241  }
242  ~ThermalModelFit(void);
243  void SetFitFlag(const std::string& name, bool flag) {
244  Parameters.SetParameterFitFlag(name, flag);
245  QBgoal = 0.4;
246  }
247  void SetQBConstraint(double QB) { QBgoal = QB; }
248  void SetRatios(const std::vector<ExperimentRatio>& Ratios_) {
249  Ratios = Ratios_;
250  }
251  void AddRatios(const std::vector<ExperimentRatio>& Ratios_) {
252  Ratios.insert(Ratios.end(), Ratios_.begin(), Ratios_.end());
253  }
254  void AddRatio(const ExperimentRatio& Ratio_) { Ratios.push_back(Ratio_); }
255  void ClearRatios() { Ratios.resize(0); }
256  void PrintRatios();
257 
259  const std::vector<ExperimentMultiplicity>& Multiplicities_) {
260  Multiplicities = Multiplicities_;
261  }
263  const std::vector<ExperimentMultiplicity>& Multiplicities_) {
264  Multiplicities.insert(
265  Multiplicities.end(), Multiplicities_.begin(), Multiplicities_.end());
266  }
267  void AddMultiplicity(const ExperimentMultiplicity& Multiplicity_) {
268  Multiplicities.push_back(Multiplicity_);
269  }
270  void ClearMultiplicities() { Multiplicities.resize(0); }
271  void PrintMultiplicities();
272  double chi2Ndf(double T, double muB);
273 
275 
278 };
279 
280 std::vector<FittedQuantity> loadExpDataFromFile(const std::string& filename);
281 
282 #endif
ThermalModelParameters::muS
double muS
Definition: ThermalModelBase.h:7
FitParameter::value
double value
Definition: ThermalModelFit.h:10
FittedQuantity::FittedQuantity
FittedQuantity()
Definition: ThermalModelFit.h:198
ThermalModelFit::ClearRatios
void ClearRatios()
Definition: ThermalModelFit.h:255
ThermalModelBase::CalculateShearViscosity
virtual double CalculateShearViscosity()=0
ExperimentRatio::error
double error
Definition: ThermalModelFit.h:167
ThermalModelFit::PerformFit
ThermalModelFitParameters PerformFit()
Definition: ThermalModelFit.cxx:82
ThermalModelFit::PrintMultiplicities
void PrintMultiplicities()
Definition: ThermalModelFit.cxx:284
ExperimentRatio::addSystematicError
void addSystematicError(double percent)
Definition: ThermalModelFit.h:189
ThermalModelFitParameters::GetThermalModelParameters
ThermalModelParameters GetThermalModelParameters()
Definition: ThermalModelFit.h:147
ThermalModelBase::CalculateHadronDensity
virtual double CalculateHadronDensity()=0
ThermalModelFit::Ratios
std::vector< ExperimentRatio > Ratios
Definition: ThermalModelFit.h:223
ThermalModelFit::~ThermalModelFit
~ThermalModelFit(void)
Definition: ThermalModelFit.cxx:80
FitParameter::error
double error
Definition: ThermalModelFit.h:11
ThermalModelFitParameters::SetParameterFitFlag
void SetParameterFitFlag(const std::string &name, bool toFit)
Definition: ThermalModelFit.h:138
ThermalModelFitParameters::SetParameter
void SetParameter(const std::string &name, const FitParameter &param)
Definition: ThermalModelFit.h:115
ExperimentMultiplicity::ExperimentMultiplicity
ExperimentMultiplicity(int PDGID=-211, double value=300., double error=20.)
Definition: ThermalModelFit.h:156
ThermalModelFitParameters::muQ
FitParameter muQ
Definition: ThermalModelFit.h:80
ThermalModelFit::ThermalModelFit
ThermalModelFit(const ThermalModelFit &)
sqrt
friend F32vec4 sqrt(const F32vec4 &a)
Definition: L1/vectors/P4_F32vec4.h:41
ThermalModelFit::SetQBConstraint
void SetQBConstraint(double QB)
Definition: ThermalModelFit.h:247
ExperimentRatio::value
double value
Definition: ThermalModelFit.h:167
ThermalModelFit::chi2Ndf
double chi2Ndf(double T, double muB)
Definition: ThermalModelFit.cxx:340
ThermalModelBase.h
ThermalModelFit::Parameters
ThermalModelFitParameters Parameters
Definition: ThermalModelFit.h:219
FitParameter
Definition: ThermalModelFit.h:8
ThermalModelParameters::V
double V
Definition: ThermalModelBase.h:7
ThermalModelFitParameters::muB
FitParameter muB
Definition: ThermalModelFit.h:80
FittedQuantity::type
int type
Definition: ThermalModelFit.h:195
ThermalModelFitParametersExtended::V
FitParameter V
Definition: ThermalModelFit.h:29
FittedQuantity::ratio
ExperimentRatio ratio
Definition: ThermalModelFit.h:197
FittedQuantity
Definition: ThermalModelFit.h:194
ThermalModelParameters::gammaS
double gammaS
Definition: ThermalModelBase.h:7
ThermalModelFit::ThermalModelFit
ThermalModelFit(ThermalModelBase *model_, double T=0.12, double muB=0.5, double muS=0., double muQ=0., double gammaS=1., double V=4000., double R=1.)
Definition: ThermalModelFit.h:224
ThermalModelFitParameters::chi2ndf
double chi2ndf
Definition: ThermalModelFit.h:81
ThermalModelFitParameters::muS
FitParameter muS
Definition: ThermalModelFit.h:80
ExperimentMultiplicity
Definition: ThermalModelFit.h:153
ExperimentRatio::ExperimentRatio
ExperimentRatio(int PDGID1_, int PDGID2_, double value1, double error1, double value2, double error2)
Definition: ThermalModelFit.h:173
ThermalModelFitParameters::GetParamater
FitParameter GetParamater(const std::string &name) const
Definition: ThermalModelFit.h:105
ThermalModelFit::SetFitFlag
void SetFitFlag(const std::string &name, bool flag)
Definition: ThermalModelFit.h:243
FittedQuantity::mult
ExperimentMultiplicity mult
Definition: ThermalModelFit.h:196
ThermalModelFit::model
ThermalModelBase * model
Definition: ThermalModelFit.h:218
ThermalModelBase::SetParameters
virtual void SetParameters(double T, double muB, double muS, double muQ, double gammaS, double V, double R)
Definition: ThermalModelBase.h:104
ThermalModelBase::CalculateEntropyDensity
virtual double CalculateEntropyDensity()=0
ThermalModelFitParametersExtended::nB
FitParameter nB
Definition: ThermalModelFit.h:31
ThermalModelFit::ExtendedParameters
ThermalModelFitParametersExtended ExtendedParameters
Definition: ThermalModelFit.h:220
ThermalModelBase::CalculateChargeDensity
virtual double CalculateChargeDensity()=0
ExperimentMultiplicity::addSystematicError
void addSystematicError(double percent)
Definition: ThermalModelFit.h:160
ThermalModelFitParameters::V
FitParameter V
Definition: ThermalModelFit.h:80
ExperimentRatio::PDGID2
int PDGID2
Definition: ThermalModelFit.h:166
ThermalModelFitParametersExtended::rhoB
FitParameter rhoB
Definition: ThermalModelFit.h:31
ThermalModelBase
Definition: ThermalModelBase.h:18
ThermalModelFit::SetRatios
void SetRatios(const std::vector< ExperimentRatio > &Ratios_)
Definition: ThermalModelFit.h:248
ThermalModelFitParametersExtended::eta
FitParameter eta
Definition: ThermalModelFit.h:31
ExperimentMultiplicity::fValue
double fValue
Definition: ThermalModelFit.h:155
ThermalModelFit
Definition: ThermalModelFit.h:216
ThermalModelFit::Multiplicities
std::vector< ExperimentMultiplicity > Multiplicities
Definition: ThermalModelFit.h:222
ThermalModelFitParametersExtended::chi2ndf
double chi2ndf
Definition: ThermalModelFit.h:30
ThermalModelFitParametersExtended::rhoQ
FitParameter rhoQ
Definition: ThermalModelFit.h:31
ThermalModelFit::AddMultiplicity
void AddMultiplicity(const ExperimentMultiplicity &Multiplicity_)
Definition: ThermalModelFit.h:267
ThermalModelFit::AddMultiplicities
void AddMultiplicities(const std::vector< ExperimentMultiplicity > &Multiplicities_)
Definition: ThermalModelFit.h:262
FitParameter::name
std::string name
Definition: ThermalModelFit.h:13
FittedQuantity::FittedQuantity
FittedQuantity(const ExperimentRatio &op)
Definition: ThermalModelFit.h:208
ThermalModelParameters::muB
double muB
Definition: ThermalModelBase.h:7
ThermalModelFit::AddRatios
void AddRatios(const std::vector< ExperimentRatio > &Ratios_)
Definition: ThermalModelFit.h:251
ThermalModelFitParameters
Definition: ThermalModelFit.h:79
ThermalModelFit::QBgoal
double QBgoal
Definition: ThermalModelFit.h:221
ExperimentRatio::ExperimentRatio
ExperimentRatio(int PDGID1_=211, int PDGID2_=-211, double value_=1., double error_=0.1)
Definition: ThermalModelFit.h:168
ThermalModelParameters::T
double T
Definition: ThermalModelBase.h:7
ThermalModelFitParametersExtended::ThermalModelFitParametersExtended
ThermalModelFitParametersExtended()
Definition: ThermalModelFit.h:32
ThermalModelFitParameters::ThermalModelFitParameters
ThermalModelFitParameters(double T_=0.12, double muB_=0.5, double muS_=0.1, double muQ_=-0.01, double gammaS_=1., double V_=4000., double R_=1.)
Definition: ThermalModelFit.h:82
ThermalModelBase::CalculateBaryonDensity
virtual double CalculateBaryonDensity()=0
ThermalModelFitParametersExtended::en
FitParameter en
Definition: ThermalModelFit.h:31
ThermalModelBase::CalculatePressure
virtual double CalculatePressure()=0
ThermalModelFit::AddRatio
void AddRatio(const ExperimentRatio &Ratio_)
Definition: ThermalModelFit.h:254
loadExpDataFromFile
std::vector< FittedQuantity > loadExpDataFromFile(const std::string &filename)
Definition: ThermalModelFit.cxx:300
ThermalModelFitParameters::SetParameter
void SetParameter(const std::string &name, double val, double err, double xmin, double xmax)
Definition: ThermalModelFit.h:124
ThermalModelFitParametersExtended::muS
FitParameter muS
Definition: ThermalModelFit.h:29
FitParameter::FitParameter
FitParameter(std::string name_="", bool toFit_=true, double val=1., double err=0., double vmin=-2., double vmax=2.)
Definition: ThermalModelFit.h:14
FitParameter::xmax
double xmax
Definition: ThermalModelFit.h:12
ThermalModelBase::CalculateEnergyDensity
virtual double CalculateEnergyDensity()=0
ExperimentRatio::PDGID1
int PDGID1
Definition: ThermalModelFit.h:166
ExperimentRatio
Definition: ThermalModelFit.h:165
ThermalModelFit::operator=
ThermalModelFit & operator=(const ThermalModelFit &)
FitParameter::toFit
bool toFit
Definition: ThermalModelFit.h:9
ThermalModelFit::PrintRatios
void PrintRatios()
Definition: ThermalModelFit.cxx:269
ThermalModelFitParametersExtended
Definition: ThermalModelFit.h:28
ThermalModelFitParametersExtended::gammaS
FitParameter gammaS
Definition: ThermalModelFit.h:29
ThermalModelFitParametersExtended::entropy
FitParameter entropy
Definition: ThermalModelFit.h:31
ThermalModelParameters
Definition: ThermalModelBase.h:6
ThermalModelFitParametersExtended::muB
FitParameter muB
Definition: ThermalModelFit.h:29
ThermalModelFitParametersExtended::muQ
FitParameter muQ
Definition: ThermalModelFit.h:29
ExperimentMultiplicity::fPDGID
int fPDGID
Definition: ThermalModelFit.h:154
FittedQuantity::FittedQuantity
FittedQuantity(const ExperimentMultiplicity &op)
Definition: ThermalModelFit.h:203
ThermalModelParameters::muQ
double muQ
Definition: ThermalModelBase.h:7
ThermalModelFitParameters::gammaS
FitParameter gammaS
Definition: ThermalModelFit.h:80
ThermalModelFitParametersExtended::T
FitParameter T
Definition: ThermalModelFit.h:29
ThermalModelFitParametersExtended::pressure
FitParameter pressure
Definition: ThermalModelFit.h:31
ThermalModelFitParameters::T
FitParameter T
Definition: ThermalModelFit.h:80
ThermalModelFitParameters::R
FitParameter R
Definition: ThermalModelFit.h:80
ThermalModelBase::Parameters
ThermalModelParameters Parameters
Definition: ThermalModelBase.h:21
ThermalModelFitParametersExtended::ThermalModelFitParametersExtended
ThermalModelFitParametersExtended(ThermalModelBase *model)
Definition: ThermalModelFit.h:47
ThermalModelFit::ClearMultiplicities
void ClearMultiplicities()
Definition: ThermalModelFit.h:270
FitParameter::xmin
double xmin
Definition: ThermalModelFit.h:12
ThermalModelFit::SetMultiplicities
void SetMultiplicities(const std::vector< ExperimentMultiplicity > &Multiplicities_)
Definition: ThermalModelFit.h:258
ExperimentMultiplicity::fError
double fError
Definition: ThermalModelFit.h:155