Thermal-FIST 1.5
Package for hadron resonance gas model applications
Loading...
Searching...
No Matches
cpc4-mcHRG.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#include "HRGEventGenerator.h"
13
14#include "ThermalFISTConfig.h"
15
16using namespace std;
17
18#ifdef ThermalFIST_USENAMESPACE
19using namespace thermalfist;
20#endif
21
22double muBss(double ss) {
23 return 1.308 / (1. + 0.273 * ss);
24}
25
26
27double Tss(double ss) {
28 double tmpmuB = muBss(ss);
29 return 0.166 - 0.139 * tmpmuB * tmpmuB - 0.053 * tmpmuB * tmpmuB * tmpmuB * tmpmuB;
30}
31
32
33// Calculates the (mixed) susceptibility using the average decay procedure of 1402.1238
34// by introducing auxiliary chemical potential for all decaying resonances
35// ch1,2 -- vector of charges that all final state hadrons contribute to the observable 1,2
36double CalculateAveragedDecaysChi2(ThermalModelBase *model, const std::vector<double> & ch1, const std::vector<double> & ch2)
37{
38 double ret = 0.;
39 for (int r = 0; r < model->TPS()->ComponentsNumber(); ++r) {
40 //const ThermalParticle &part_r = model->TPS()->Particle(r);
41
42 const ThermalParticleSystem::ResonanceFinalStatesDistribution& decayDistributions = model->TPS()->ResonanceFinalStatesDistributions()[r];
43
44 double mn1 = model->ScaledVariancePrimordial(r) * model->Densities()[r] / pow(model->Parameters().T, 3) / pow(xMath::GeVtoifm(), 3);
45
46 double mn2 = 0., mn3 = 0.;
47 for (int j = 0; j < model->TPS()->ComponentsNumber(); ++j) {
48 //const ThermalParticle &part_j = model->TPS()->Particle(j);
49
50 double njavr = 0.;
51 for (size_t i = 0; i < decayDistributions.size(); ++i) {
52 njavr += decayDistributions[i].first * decayDistributions[i].second[j];
53 }
54
55 mn2 += ch1[j] * njavr;
56 mn3 += ch2[j] * njavr;
57 }
58
59 ret += mn1 * mn2 * mn3;
60 }
61
62 return ret;
63}
64
65// Collision energy dependence of 2nd order susceptibilities of
66// (proxy) conserved charges, computed within the Ideal HRG model
67// along the phenomenological chemical freeze-out curve
68// Comparison of analytic and Monte Carlo calculations
69// Usage: cpc4mcHRG <withMonteCarlo> <nevents>
70// where <withMonteCarlo> flag determines whether Monte Carlo calculations
71// are performed and <nevents> is the number of Monte Carlo events per
72// single collision energy
73int main(int argc, char *argv[])
74{
75 int withMonteCarlo = 1;
76 if (argc > 1)
77 withMonteCarlo = atoi(argv[1]);
78
79 int nevents = 100000;
80 if (argc >2)
81 nevents = atoi(argv[2]);
82
83 string listname = string(ThermalFIST_INPUT_FOLDER) + "/list/PDG2014/list.dat";
84 ThermalParticleSystem parts(listname);
85
86 // Disable K0 and K0bar decays to avoid strangeness non-conservation
87 parts.ParticleByPDG(311).SetStable(true);
88 parts.ParticleByPDG(-311).SetStable(true);
89
90 // Optionally switch off some decays
91 //for (size_t i = 0; i < parts.Particles().size(); ++i) {
92 // ThermalParticle& part = parts.Particle(i);
93 //
94 // // Switch off |S| = 1 hyperon decays
95 // if (abs(part.BaryonCharge()) == 1 && abs(part.Strangeness()) == 1)
96 // part.SetStable(true);
97 //
98 // // Switch off K*0 like decays
99 // if (abs(part.BaryonCharge()) == 0 && abs(part.Strangeness()) == 1 && part.ElectricCharge() == 0)
100 // part.SetStable(true);
101
102 // // Switch off all decays
103 // part.SetStable(true);
104 //}
105
107 params.V = 1000.;
108
109 ThermalModelBase *model;
110
111 model = new ThermalModelIdeal(&parts);
112
113 model->SetParameters(params);
114 model->SetStatistics(false);
115
117 //model->SetUseWidth(ThermalParticle::ZeroWidth);
118
119 // Normalize branching ratios to avoid charge non-conservation in decays
120 model->SetNormBratio(true);
121
122
123 // For calculating net-kaon scaled variance using "average decays"
124 vector<double> coefsk(parts.Particles().size(), 0.);
125 coefsk[parts.PdgToId(321)] = 1.;
126 coefsk[parts.PdgToId(-321)] = -1.;
127
128
129 double smin = 3.;
130 double smax = 3000.;
131 int iterss = 100;
132
133 double wt1 = get_wall_time();
134 int iters = 0;
135
136 double musp = 0., muqp = 0., mucp = 0.;
137
138 // First analytic calculations
139 printf("Analytic\n");
140
141 FILE *f = fopen("cpc4.analyt.dat", "w");
142
143 fprintf(f, "%15s%15s%15s%15s%15s%15s%15s%15s%15s%15s%15s%15s%15s\n",
144 "sqrts[GeV]",
145 "T[MeV]",
146 "muB[MeV]",
147 "muQ[MeV]",
148 "muS[MeV]",
149 "c2k/c1k",
150 "C_B,S",
151 "C_p,k_fd",
152 "C_Q,S",
153 "C_Q,k_fd",
154 "C_B,Q",
155 "C_p,Q_fd",
156 "c2k_av/c1k"
157 );
158
159 vector<double> ens, Ts, muBs, muQs, muSs;
160
161 double logSmin = log(smin);
162 double logSmax = log(smax);
163 double dlogS = (logSmax - logSmin) / iterss;
164 for (int is = 0; is <= iterss; ++is) {
165 double ss = exp(logSmin + is * dlogS);
166 double T = Tss(ss);
167 double muB = muBss(ss);
168
169 model->SetTemperature(T);
170 model->ConstrainMuS(true);
171 model->ConstrainMuQ(true);
172 model->ConstrainMuC(true);
173 model->SetBaryonChemicalPotential(muB);
175 model->SetElectricChemicalPotential(muqp);
176 model->SetCharmChemicalPotential(mucp);
178
179 musp = model->Parameters().muS;
180 muqp = model->Parameters().muQ;
181 mucp = model->Parameters().muC;
182
183 ens.push_back(ss);
184 Ts.push_back(T);
185 muBs.push_back(muB);
186 muQs.push_back(muqp);
187 muSs.push_back(musp);
188
189 model->CalculateFluctuations();
190
191
192 double chi1B = model->CalculateBaryonDensity() / pow(T, 3) / pow(xMath::GeVtoifm(), 3);
193 double chi1Q = model->CalculateChargeDensity() / pow(T, 3) / pow(xMath::GeVtoifm(), 3);
194 double chi1S = model->CalculateStrangenessDensity() / pow(T, 3) / pow(xMath::GeVtoifm(), 3);
195
196 double chi1p = (model->GetDensity(2212, Feeddown::StabilityFlag) - model->GetDensity(-2212, Feeddown::StabilityFlag)) / pow(T, 3) / pow(xMath::GeVtoifm(), 3);
197 double chi1k = (model->GetDensity(321, Feeddown::StabilityFlag) - model->GetDensity(-321, Feeddown::StabilityFlag)) / pow(T, 3) / pow(xMath::GeVtoifm(), 3);
198
205
206 double chi2p = model->ProxySusc(ConservedCharge::BaryonCharge, ConservedCharge::BaryonCharge);
208 double chi11pk = model->ProxySusc(ConservedCharge::BaryonCharge, ConservedCharge::StrangenessCharge);
210 double chi11pQ = model->ProxySusc(ConservedCharge::ElectricCharge, ConservedCharge::BaryonCharge);
211
212 double chi2kav = CalculateAveragedDecaysChi2(model, coefsk, coefsk);
213
214 printf("%15lf%15lf%15lf%15lf%15lf%15lf%15lf\n",
215 ss,
216 chi11BS / chi2S,
217 chi11QS / chi2S,
218 chi11BQ / chi2B,
219 chi11pk / chi2k,
220 chi11Qk / chi2k,
221 chi11pQ / chi2p);
222
223 fprintf(f, "%15lf%15lf%15lf%15lf%15lf%15lf%15lf%15lf%15lf%15lf%15lf%15lf%15lf\n",
224 ss,
225 T * 1.e3,
226 muB * 1.e3,
227 muqp * 1.e3,
228 musp * 1.e3,
229 chi2k / chi1k,
230 chi11BS / chi2S,
231 chi11pk / chi2k,
232 chi11QS / chi2S,
233 chi11Qk / chi2k,
234 chi11BQ / chi2B,
235 chi11pQ / chi2p,
236 chi2kav / chi1k);
237
238 fflush(f);
239
240 iters++;
241 }
242
243 fclose(f);
244
245 double wt2 = get_wall_time();
246
247 printf("%30s %lf s\n", "Running time:", (wt2 - wt1));
248 printf("%30s %lf s\n", "Time per single calculation:", (wt2 - wt1) / iters);
249
250 printf("\n\n");
251
252 if (!withMonteCarlo)
253 return 0;
254
255 printf("Monte Carlo\n");
256
257 f = fopen("cpc4.montecarlo.dat", "w");
258
259 fprintf(f, "%15s%15s%15s%15s%15s%15s%15s%15s%15s%15s%15s%15s\n",
260 "sqrts[GeV]",
261 "T[MeV]",
262 "muB[MeV]",
263 "muQ[MeV]",
264 "muS[MeV]",
265 "c2k/c1k",
266 "C_B,S",
267 "C_p,k_fd",
268 "C_Q,S",
269 "C_Q,k_fd",
270 "C_B,Q",
271 "C_p,Q_fd"
272 );
273
274 // Now Monte Carlo
275 iters = 0;
276 wt1 = get_wall_time();
278
279 for (size_t ind = 0; ind < ens.size(); ind++) {
280 model->SetTemperature(Ts[ind]);
281 model->SetBaryonChemicalPotential(muBs[ind]);
282 model->SetElectricChemicalPotential(muQs[ind]);
283 model->SetStrangenessChemicalPotential(muSs[ind]);
284
285 double mc_B = 0., mc_Q = 0., mc_S = 0., mc_p = 0., mc_k = 0.;
286 double mc_B2 = 0., mc_Q2 = 0., mc_S2 = 0., mc_BQ = 0., mc_QS = 0., mc_BS = 0.;
287 double mc_p2 = 0., mc_k2 = 0., mc_pk = 0., mc_pQ = 0., mc_Qk = 0.;
288
289 // Setup the configuration for event generator
293 config.CFOParameters = model->Parameters();
294
295 SphericalBlastWaveEventGenerator generator(model->TPS(), config, 0.100, 0.5);
296 double wsum = 0.;
297 for (int i = 0; i < nevents; ++i) {
298 SimpleEvent ev = generator.GetEvent();
299 int mcev_B = 0, mcev_Q = 0, mcev_S = 0, mcev_p = 0, mcev_k = 0;
300
301 for (size_t part = 0; part < ev.Particles.size(); ++part) {
302 long long pdgid = ev.Particles[part].PDGID;
303 const ThermalParticle &thermpart = parts.ParticleByPDG(pdgid);
304 mcev_B += thermpart.BaryonCharge();
305 mcev_Q += thermpart.ElectricCharge();
306 mcev_S += thermpart.Strangeness();
307
308 if (pdgid == 2212)
309 mcev_p += 1;
310 else if (pdgid == -2212)
311 mcev_p += (-1);
312
313 if (pdgid == 321)
314 mcev_k += 1;
315 else if (pdgid == -321)
316 mcev_k += (-1);
317 }
318
319 mc_B += ev.weight * mcev_B;
320 mc_Q += ev.weight * mcev_Q;
321 mc_S += ev.weight * mcev_S;
322 mc_p += ev.weight * mcev_p;
323 mc_k += ev.weight * mcev_k;
324
325 mc_B2 += ev.weight * mcev_B * mcev_B;
326 mc_Q2 += ev.weight * mcev_Q * mcev_Q;
327 mc_S2 += ev.weight * mcev_S * mcev_S;
328 mc_p2 += ev.weight * mcev_p * mcev_p;
329 mc_k2 += ev.weight * mcev_k * mcev_k;
330
331 mc_BQ += ev.weight * mcev_B * mcev_Q;
332 mc_QS += ev.weight * mcev_Q * mcev_S;
333 mc_BS += ev.weight * mcev_B * mcev_S;
334 mc_pQ += ev.weight * mcev_p * mcev_Q;
335 mc_pk += ev.weight * mcev_p * mcev_k;
336 mc_Qk += ev.weight * mcev_Q * mcev_k;
337
338 wsum += ev.weight;
339 }
340
341 double chi1B = mc_B / wsum;
342 double chi1Q = mc_Q / wsum;
343 double chi1S = mc_S / wsum;
344
345 double chi1p = mc_p / wsum;
346 double chi1k = mc_k / wsum;
347
348 double chi2B = mc_B2 / wsum - mc_B / wsum * mc_B / wsum;
349 double chi2Q = mc_Q2 / wsum - mc_Q / wsum * mc_Q / wsum;
350 double chi2S = mc_S2 / wsum - mc_S / wsum * mc_S / wsum;
351 double chi11BS = mc_BS / wsum - mc_B / wsum * mc_S / wsum;
352 double chi11QS = mc_QS / wsum - mc_Q / wsum * mc_S / wsum;
353 double chi11BQ = mc_BQ / wsum - mc_B / wsum * mc_Q / wsum;
354
355 double chi2p = mc_p2 / wsum - mc_p / wsum * mc_p / wsum;
356 double chi2k = mc_k2 / wsum - mc_k / wsum * mc_k / wsum;
357 double chi11pk = mc_pk / wsum - mc_p / wsum * mc_k / wsum;
358 double chi11Qk = mc_Qk / wsum - mc_Q / wsum * mc_k / wsum;
359 double chi11pQ = mc_pQ / wsum - mc_p / wsum * mc_Q / wsum;
360
361 printf("%15lf%15lf%15lf%15lf%15lf%15lf%15lf\n", ens[ind], chi11BS / chi2S, chi11QS / chi2S, chi11BQ / chi2B, chi11pk / chi2k, chi11Qk / chi2k, chi11pQ / chi2p);
362
363
364 fprintf(f, "%15lf%15lf%15lf%15lf%15lf%15lf%15lf%15lf%15lf%15lf%15lf%15lf\n",
365 ens[ind],
366 Ts[ind] * 1.e3,
367 muBs[ind] * 1.e3,
368 muQs[ind] * 1.e3,
369 muSs[ind] * 1.e3,
370 chi2k / chi1k,
371 chi11BS / chi2S,
372 chi11pk / chi2k,
373 chi11QS / chi2S,
374 chi11Qk / chi2k,
375 chi11BQ / chi2B,
376 chi11pQ / chi2p);
377
378 fflush(f);
379 iters++;
380 }
381
382 fclose(f);
383
384 wt2 = get_wall_time();
385
386 printf("%30s %lf s\n", "Running time:", (wt2 - wt1));
387 printf("%30s %lf s\n", "Time per single calculation:", (wt2 - wt1) / iters);
388
389 delete model;
390
391 return 0;
392}
393
map< string, double > params
virtual SimpleEvent GetEvent(bool PerformDecays=true) const
Generates a single event.
Class implementing the Thermal Event Generator for the isotropic blast-wave scenario.
Abstract base class for an HRG model implementation.
virtual void SetTemperature(double T)
Set the temperature.
virtual void CalculateFluctuations()
Computes the fluctuation observables.
void ConstrainChemicalPotentials(bool resetInitialValues=true)
Constrains the chemical potentials by the conservation laws imposed.
void SetUseWidth(bool useWidth)
Sets whether finite resonance widths are used. Deprecated.
virtual void SetBaryonChemicalPotential(double muB)
Set the baryon chemical potential.
void SetNormBratio(bool normBratio)
Whether branching ratios are renormalized to 100%.
virtual void SetParameters(const ThermalModelParameters &params)
The thermal parameters.
virtual void SetElectricChemicalPotential(double muQ)
Set the electric chemical potential.
virtual void SetStrangenessChemicalPotential(double muS)
Set the strangeness chemical potential.
const ThermalModelParameters & Parameters() const
virtual void SetCharmChemicalPotential(double muC)
Set the charm chemical potential.
virtual void SetStatistics(bool stats)
Class implementing the Ideal HRG model.
Class containing all information about a particle specie.
int BaryonCharge() const
Particle's baryon number.
int Strangeness() const
Particle's strangeness.
@ BWTwoGamma
Energy-independent Breit-Wigner in +-2\Gamma interval.
void SetStable(bool stable=true)
Sets particle stability flag.
int ElectricCharge() const
Particle's electric charge.
Class containing the particle list.
std::vector< std::pair< double, std::vector< int > > > ResonanceFinalStatesDistribution
int PdgToId(long long pdgid) const
Transforms PDG ID to a 0-based particle id number.
const std::vector< ThermalParticle > & Particles() const
Returns the vector of all particle species.
const ThermalParticle & ParticleByPDG(long long pdgid) const
ThermalParticle object corresponding to particle species with a provided PDG ID.
int main(int argc, char *argv[])
double CalculateAveragedDecaysChi2(ThermalModelBase *model, const std::vector< double > &ch1, const std::vector< double > &ch2)
double Tss(double ss)
double muBss(double ss)
void SetSeed(const unsigned int seed)
Set the seed of the random number generator randgenMT.
constexpr double GeVtoifm()
A constant to transform GeV into fm .
Definition xMath.h:25
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
@ ElectricCharge
Electric charge.
Structure containing the thermal event generator configuration.
Ensemble fEnsemble
The statistical ensemble used.
ThermalModelParameters CFOParameters
The chemical freeze-out parameters.
ModelType fModelType
The type of interaction model.
@ StabilityFlag
Feeddown from all particles marked as unstable.
Structure holding information about a single event in the event generator.
Definition SimpleEvent.h:20
double weight
Event weight factor.
Definition SimpleEvent.h:22
std::vector< SimpleParticle > Particles
Vector of all final particles in the event.
Definition SimpleEvent.h:28
Structure containing all thermal parameters of the model.