4 #include "Minuit2/FCNBase.h"
5 #include "Minuit2/FunctionMinimum.h"
6 #include "Minuit2/MnHesse.h"
7 #include "Minuit2/MnMigrad.h"
8 #include "Minuit2/MnMinos.h"
9 #include "Minuit2/MnPrint.h"
10 #include "Minuit2/MnUserParameterState.h"
11 #include "Minuit2/SimplexMinimizer.h"
19 using namespace ROOT::Minuit2;
31 double operator()(
const std::vector<double>& par)
const {
35 THMFit->model->Parameters.T = par[0];
36 THMFit->model->Parameters.muB = par[1];
37 THMFit->model->Parameters.gammaS = par[2];
38 THMFit->model->Parameters.V = par[3];
39 THMFit->model->Parameters.muQ = -par[1] / 50.;
40 THMFit->model->Parameters.muS = par[1] / 5.;
41 THMFit->model->SetQBgoal(THMFit->QBgoal);
42 THMFit->model->FixParameters();
43 THMFit->Parameters.muQ.value = THMFit->model->Parameters.muQ;
44 THMFit->Parameters.muS.value = THMFit->model->Parameters.muS;
45 THMFit->model->CalculateDensities();
46 for (
unsigned int i = 0;
i < THMFit->Ratios.size(); ++
i) {
47 int id1 = THMFit->model->TPS->PDGtoID[THMFit->Ratios[
i].PDGID1];
48 int id2 = THMFit->model->TPS->PDGtoID[THMFit->Ratios[
i].PDGID2];
49 double ModelRatio = THMFit->model->densitiestotal[id1]
50 / THMFit->model->densitiestotal[id2];
51 chi2 += (ModelRatio - THMFit->Ratios[
i].value)
52 * (ModelRatio - THMFit->Ratios[
i].value)
53 / THMFit->Ratios[
i].error / THMFit->Ratios[
i].error;
55 for (
unsigned int i = 0;
i < THMFit->Multiplicities.size(); ++
i) {
56 int id1 = THMFit->model->TPS->PDGtoID[THMFit->Multiplicities[
i].fPDGID];
58 THMFit->model->densitiestotal[id1] * THMFit->model->Parameters.V;
59 chi2 += (ModelMult - THMFit->Multiplicities[
i].fValue)
60 * (ModelMult - THMFit->Multiplicities[
i].fValue)
61 / THMFit->Multiplicities[
i].fError
62 / THMFit->Multiplicities[
i].fError;
67 double Up()
const {
return 1.; }
84 std::vector<double> params(4, 0.);
85 params[0] = Parameters.T.value;
86 params[1] = Parameters.muB.value;
87 params[2] = Parameters.gammaS.value;
88 params[3] = Parameters.V.value;
89 MnUserParameters upar;
101 Parameters.gammaS.value,
102 Parameters.gammaS.error,
103 Parameters.gammaS.xmin,
104 Parameters.gammaS.xmax);
111 if (!Parameters.gammaS.toFit) {
115 if (!Parameters.V.toFit || Multiplicities.size() == 0) {
121 if (model->fUseWidth) {
123 model->SetUseWidth(
false);
126 MnMigrad migrad(mfunc, upar);
127 FunctionMinimum
min = migrad();
131 ret.
T.
value = (
min.UserParameters()).Params()[0];
132 ret.
T.
error = (
min.UserParameters()).Errors()[0];
133 ret.
muB.
value = (
min.UserParameters()).Params()[1];
134 ret.
muB.
error = (
min.UserParameters()).Errors()[1];
137 ret.
V.
value = (
min.UserParameters()).Params()[3];
138 ret.
V.
error = (
min.UserParameters()).Errors()[3];
141 model->SetUseWidth(
true);
143 upar.SetValue(
"T", (
min.UserParameters()).Params()[0]);
144 upar.SetValue(
"muB", (
min.UserParameters()).Params()[1]);
145 upar.SetValue(
"gammaS", (
min.UserParameters()).Params()[2]);
146 upar.SetValue(
"V", (
min.UserParameters()).Params()[3]);
148 MnMigrad migradd(mfunc, upar);
152 ret.
T.
value = (
min.UserParameters()).Params()[0];
153 ret.
T.
error = (
min.UserParameters()).Errors()[0];
154 ret.
muB.
value = (
min.UserParameters()).Params()[1];
155 ret.
muB.
error = (
min.UserParameters()).Errors()[1];
158 ret.
V.
value = (
min.UserParameters()).Params()[3];
159 ret.
V.
error = (
min.UserParameters()).Errors()[3];
163 model->SetQBgoal(QBgoal);
164 model->FixParameters();
165 ret.
muQ.
value = model->Parameters.muQ;
166 ret.
muS.
value = model->Parameters.muS;
172 std::cout <<
"T= " << params[0] * 1000. <<
" MeV "
173 <<
"muB= " << params[1] * 1000. <<
" MeV "
174 <<
" gammaS = " << params[2] <<
" V = " << params[3] <<
" fm^3"
176 << mfunc(params) / (Multiplicities.size() + Ratios.size() - nparams)
180 mfunc(params) / (Multiplicities.size() + Ratios.size() - nparams);
184 ExtendedParameters.T.error = ret.
T.
error;
185 ExtendedParameters.muB.error = ret.
muB.
error;
186 ExtendedParameters.gammaS.error = ret.
gammaS.
error;
187 ExtendedParameters.V.error = ret.
V.
error;
189 double Tinit = model->Parameters.T;
190 double muBinit = model->Parameters.muB;
192 double dT = 0.0005, dmu = 0.0005;
193 model->Parameters.T = Tinit + dT;
194 model->Parameters.muB = muBinit;
195 model->fCalculated =
false;
196 model->FixParameters();
197 model->CalculateDensities();
200 model->Parameters.T = Tinit;
201 model->Parameters.muB = muBinit + dmu;
202 model->fCalculated =
false;
203 model->FixParameters();
204 model->CalculateDensities();
207 model->Parameters.T = Tinit;
208 model->Parameters.muB = muBinit;
209 model->FixParameters();
210 model->CalculateDensities();
213 double err1 = (
min.UserCovariance()).
operator()(0, 0);
214 double err2 = (
min.UserCovariance()).
operator()(1, 1);
215 double cov = (
min.UserCovariance()).
operator()(0, 1);
216 double deriv1 = (ParametersdT.
muQ.
value - ExtendedParameters.muQ.value) / dT;
218 (ParametersdMu.
muQ.
value - ExtendedParameters.muQ.value) / dmu;
219 ExtendedParameters.muQ.error =
220 sqrt(deriv1 * deriv1 * err1 + deriv2 * deriv2 * err2
221 + 2. * deriv1 * deriv2 * cov);
222 deriv1 = (ParametersdT.
muS.
value - ExtendedParameters.muS.value) / dT;
223 deriv2 = (ParametersdMu.
muS.
value - ExtendedParameters.muS.value) / dmu;
224 ExtendedParameters.muS.error =
225 sqrt(deriv1 * deriv1 * err1 + deriv2 * deriv2 * err2
226 + 2. * deriv1 * deriv2 * cov);
227 deriv1 = (ParametersdT.
nB.
value - ExtendedParameters.nB.value) / dT;
228 deriv2 = (ParametersdMu.
nB.
value - ExtendedParameters.nB.value) / dmu;
229 ExtendedParameters.nB.error =
230 sqrt(deriv1 * deriv1 * err1 + deriv2 * deriv2 * err2
231 + 2. * deriv1 * deriv2 * cov);
232 deriv1 = (ParametersdT.
rhoB.
value - ExtendedParameters.rhoB.value) / dT;
233 deriv2 = (ParametersdMu.
rhoB.
value - ExtendedParameters.rhoB.value) / dmu;
234 ExtendedParameters.rhoB.error =
235 sqrt(deriv1 * deriv1 * err1 + deriv2 * deriv2 * err2
236 + 2. * deriv1 * deriv2 * cov);
237 deriv1 = (ParametersdT.
rhoQ.
value - ExtendedParameters.rhoQ.value) / dT;
238 deriv2 = (ParametersdMu.
rhoQ.
value - ExtendedParameters.rhoQ.value) / dmu;
239 ExtendedParameters.rhoQ.error =
240 sqrt(deriv1 * deriv1 * err1 + deriv2 * deriv2 * err2
241 + 2. * deriv1 * deriv2 * cov);
242 deriv1 = (ParametersdT.
en.
value - ExtendedParameters.en.value) / dT;
243 deriv2 = (ParametersdMu.
en.
value - ExtendedParameters.en.value) / dmu;
244 ExtendedParameters.en.error =
245 sqrt(deriv1 * deriv1 * err1 + deriv2 * deriv2 * err2
246 + 2. * deriv1 * deriv2 * cov);
247 deriv1 = (ParametersdT.
entropy.
value - ExtendedParameters.entropy.value) / dT;
249 (ParametersdMu.
entropy.
value - ExtendedParameters.entropy.value) / dmu;
250 ExtendedParameters.entropy.error =
251 sqrt(deriv1 * deriv1 * err1 + deriv2 * deriv2 * err2
252 + 2. * deriv1 * deriv2 * cov);
254 (ParametersdT.
pressure.
value - ExtendedParameters.pressure.value) / dT;
256 (ParametersdMu.
pressure.
value - ExtendedParameters.pressure.value) / dmu;
257 ExtendedParameters.pressure.error =
258 sqrt(deriv1 * deriv1 * err1 + deriv2 * deriv2 * err2
259 + 2. * deriv1 * deriv2 * cov);
260 deriv1 = (ParametersdT.
eta.
value - ExtendedParameters.eta.value) / dT;
261 deriv2 = (ParametersdMu.
eta.
value - ExtendedParameters.eta.value) / dmu;
262 ExtendedParameters.eta.error =
263 sqrt(deriv1 * deriv1 * err1 + deriv2 * deriv2 * err2
264 + 2. * deriv1 * deriv2 * cov);
270 model->SetParameters(Parameters.GetThermalModelParameters());
271 model->SetQBgoal(QBgoal);
272 model->FixParameters();
273 model->CalculateDensities();
274 for (
unsigned int i = 0;
i < Ratios.size(); ++
i) {
275 int ind1 = model->TPS->PDGtoID[Ratios[
i].PDGID1];
276 int ind2 = model->TPS->PDGtoID[Ratios[
i].PDGID2];
277 std::cout << model->TPS->fParticles[ind1].fName <<
"/"
278 << model->TPS->fParticles[ind2].fName <<
" = "
279 << model->densitiestotal[ind1] / model->densitiestotal[ind2]
280 <<
" " << Ratios[
i].value <<
" " << Ratios[
i].error <<
"\n";
285 model->SetParameters(Parameters.GetThermalModelParameters());
286 model->SetQBgoal(QBgoal);
287 model->FixParameters();
288 model->CalculateDensities();
289 for (
unsigned int i = 0;
i < Multiplicities.size(); ++
i) {
290 int ind1 = model->TPS->PDGtoID[Multiplicities[
i].fPDGID];
291 std::cout <<
"<" << model->TPS->fParticles[ind1].fName
292 <<
"> = " << model->densitiestotal[ind1] * model->Parameters.V
293 <<
" " << Multiplicities[
i].fValue <<
" "
294 << Multiplicities[
i].fError <<
"\n";
301 std::vector<FittedQuantity> ret(0);
302 ifstream fin(filename.c_str());
307 fin.getline(tmpc, 500);
310 vector<string> fields =
split(tmp,
';');
311 if (fields.size() < 4)
break;
312 int type = atoi(fields[0].c_str());
313 int pdgid1 = atoi(fields[1].c_str()), pdgid2 = 0;
316 pdgid2 = atoi(fields[2].c_str());
317 value = atof(fields[3].c_str());
319 if (fields.size() >= 4) error = atof(fields[4].c_str());
321 value = atof(fields[2].c_str());
322 error = atof(fields[3].c_str());
332 fin.getline(tmpc, 500);
341 double Tinit = T, muBinit = muB;
344 if (!Parameters.gammaS.toFit) nparams--;
345 if (!Parameters.V.toFit || Multiplicities.size() == 0) nparams--;
346 std::vector<double> params(4, 0.);
349 params[2] = model->Parameters.gammaS;
350 params[3] = model->Parameters.V;
351 model->Parameters.muS = muB / 5.;
352 model->Parameters.muQ = -muB / 50.;
353 double ret = mfunc(params);
354 model->Parameters.T = Tinit;
355 model->Parameters.muB = muBinit;
356 return ret / (Multiplicities.size() + Ratios.size() - nparams);