]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TUHKMgen/UHKM/GrandCanonical.cxx
Coverity fixes
[u/mrichter/AliRoot.git] / TUHKMgen / UHKM / GrandCanonical.cxx
CommitLineData
03896fc4 1//////////////////////////////////////////////////////////////////////////////////
2// //
3// Nikolai Amelin, Ludmila Malinina, Timur Pocheptsov (C) JINR/Dubna //
4// amelin@sunhe.jinr.ru, malinina@sunhe.jinr.ru, pocheptsov@sunhe.jinr.ru //
5// November. 2, 2005 //
6// //
7//////////////////////////////////////////////////////////////////////////////////
b1c2e580 8#include <iostream>
9
10#include <TError.h>
11#include <TMath.h>
b1c2e580 12#include "GrandCanonical.h"
b1c2e580 13#include "HankelFunction.h"
b1c2e580 14#include "UKUtility.h"
b7d1d891 15#include "ParticlePDG.h"
b7d1d891 16#include "DatabasePDG.h"
b1c2e580 17
03896fc4 18
19//_______________________________________________________________________________
786056a2 20GrandCanonical::GrandCanonical():
21 fTemperature(-1111),
22 fBaryonPotential(-1111),
23 fStrangePotential(-1111),
24 fElectroPotential(-1111),
25 fNMax(-1111),
26 fInitialized(kFALSE)
27{
03896fc4 28 //
29 // default constructor
30 //
b1c2e580 31}
32
03896fc4 33//_______________________________________________________________________________
786056a2 34GrandCanonical::GrandCanonical(Int_t nmax, Double_t temperature, Double_t baryonPotential, Double_t strangePotential, Double_t electroPotential):
35 fTemperature(temperature),
36 fBaryonPotential(baryonPotential),
37 fStrangePotential(strangePotential),
38 fElectroPotential(electroPotential),
39 fNMax(nmax),
40 fInitialized(kTRUE)
41{
03896fc4 42 //
43 // constructor
44 //
b1c2e580 45}
46
03896fc4 47//_______________________________________________________________________________
48GrandCanonical::~GrandCanonical() {
49//
50// destructor
51//
52}
b1c2e580 53
03896fc4 54//_______________________________________________________________________________
b1c2e580 55void GrandCanonical::Temperature(Double_t value) {
03896fc4 56 //
57 // set temperature
58 //
b1c2e580 59 fTemperature = value;
03896fc4 60 if(fNMax!=-1111 && TMath::Abs(fBaryonPotential+1111)>1.e-10 &&
61 TMath::Abs(fStrangePotential+1111)>1.e-10 && TMath::Abs(fElectroPotential+1111)>1.e-10)
b1c2e580 62 fInitialized = kTRUE;
63}
64
03896fc4 65//_______________________________________________________________________________
b1c2e580 66void GrandCanonical::BaryonPotential(Double_t value) {
03896fc4 67 //
68 // set baryo chemical potential
69 //
b1c2e580 70 fBaryonPotential = value;
03896fc4 71 if(fNMax!=-1111 && TMath::Abs(fTemperature+1111)>1.e-10 &&
72 TMath::Abs(fStrangePotential+1111)>1.e-10 && TMath::Abs(fElectroPotential+1111)>1.e-10)
b1c2e580 73 fInitialized = kTRUE;
74}
75
03896fc4 76//_______________________________________________________________________________
b1c2e580 77void GrandCanonical::StrangePotential(Double_t value) {
03896fc4 78 //
79 // set strange potential
80 //
b1c2e580 81 fStrangePotential = value;
03896fc4 82 if(fNMax!=-1111 && TMath::Abs(fTemperature+1111)>1.e-10 &&
83 TMath::Abs(fBaryonPotential+1111)>1.e-10 && TMath::Abs(fElectroPotential+1111)>1.e-10)
b1c2e580 84 fInitialized = kTRUE;
85}
86
03896fc4 87//_______________________________________________________________________________
b1c2e580 88void GrandCanonical::ElectroPotential(Double_t value) {
03896fc4 89 //
90 // set electro chemical potential
91 //
b1c2e580 92 fElectroPotential = value;
03896fc4 93 if(fNMax!=-1111 && TMath::Abs(fTemperature+1111)>1.e-10 &&
94 TMath::Abs(fBaryonPotential+1111)>1.e-10 && TMath::Abs(fStrangePotential+1111)>1.e-10)
b1c2e580 95 fInitialized = kTRUE;
96}
97
03896fc4 98//_______________________________________________________________________________
b1c2e580 99void GrandCanonical::NMax(Int_t value) {
03896fc4 100 //
101 // set the number of iterations
102 //
b1c2e580 103 fNMax = value;
104 if(fTemperature!=-1111 && fBaryonPotential!=-1111 && fStrangePotential!=-1111 && fElectroPotential!=-1111)
03896fc4 105 if(fNMax!=-1111 && TMath::Abs(fBaryonPotential+1111)>1.e-10 &&
106 TMath::Abs(fStrangePotential+1111)>1.e-10 && TMath::Abs(fElectroPotential+1111)>1.e-10)
b1c2e580 107 fInitialized = kTRUE;
108}
109
03896fc4 110//_______________________________________________________________________________
b7d1d891 111Double_t GrandCanonical::ParticleEnergyDensity(ParticlePDG *const particle) {
03896fc4 112 //
113 // compute the energy density for a given particle
114 //
b1c2e580 115 // Check if all the thermodinamic parameters are set
116 if(!fInitialized)
117 Fatal("GrandCanonical::ParticleEnergyDensity", "GrandCanonical object not fully initialized!!");
118
119 // Compute the particle energy density
120 Double_t degFactor = 2.*particle->GetSpin() + 1.; // degeneracy factor
121 Double_t mass = particle->GetMass(); // PDG table mass
122 Double_t d = Int_t(2.*particle->GetSpin()) & 1 ? 1. : -1; // Bose-Einstein/Fermi-Dirac factor
03896fc4 123 Double_t preFactor = (degFactor*mass*mass*fTemperature*fTemperature/kHbarc/kHbarc/kHbarc)/(2.*TMath::Pi()*TMath::Pi());
b1c2e580 124
125 Double_t postFactor = 0.;
126 //compute chemical potential
127 Double_t potential = fBaryonPotential * particle->GetBaryonNumber() +
128 fStrangePotential * particle->GetStrangeness() +
129 fElectroPotential * particle->GetElectricCharge();
130
131 for(Int_t n = 1; n <= fNMax; ++n) {
132 postFactor += TMath::Power(-d, n+1)/(n*n) *
133 TMath::Exp(n*potential/fTemperature) *
134 (3.*HankelKn(2, n*mass/fTemperature) + n*mass/fTemperature*HankelK1(n*mass/fTemperature));
135 }
136 return preFactor * postFactor;
137}
138
03896fc4 139//_______________________________________________________________________________
b7d1d891 140Double_t GrandCanonical::ParticleNumberDensity(ParticlePDG *const particle) {
03896fc4 141 //
142 // compute the particle number density
143 //
b1c2e580 144 // Check if all the thermodinamic parameters are set
145 if(!fInitialized)
146 Fatal("GrandCanonical::ParticleNumberDensity", "GrandCanonical object not fully initialized!!");
147
148 Double_t degFactor = 2.*particle->GetSpin() + 1.;
149 Double_t mass = particle->GetMass();
150 Double_t d = Int_t(2*particle->GetSpin()) & 1 ? 1. : -1.;
03896fc4 151 Double_t preFactor = (degFactor*mass*mass*fTemperature/kHbarc/kHbarc/kHbarc)/(2.*TMath::Pi()*TMath::Pi());
b1c2e580 152
153 Double_t postFactor = 0.;
154 Double_t potential = fBaryonPotential * particle->GetBaryonNumber() +
155 fStrangePotential * particle->GetStrangeness() +
156 fElectroPotential * particle->GetElectricCharge();
157
158 for(Int_t n = 1; n <= fNMax; ++n) {
159 postFactor += TMath::Power(-d, n+1)/n *
160 TMath::Exp(n*potential/fTemperature) *
161 HankelKn(2, n*mass/fTemperature);
162 }
163 return preFactor * postFactor;
164}
165
03896fc4 166//_______________________________________________________________________________
b7d1d891 167Double_t GrandCanonical::EnergyDensity(DatabasePDG *const database) {
03896fc4 168 //
169 // compute the total energy density
170 //
b1c2e580 171 // Check if all the thermodinamic parameters are set
172 if(!fInitialized)
173 Fatal("GrandCanonical::EnergyDensity", "GrandCanonical object not fully initialized!!");
174
175 Double_t meanEnergyDensity = 0.;
176
177 for(Int_t currParticle = 0; currParticle<database->GetNParticles(); currParticle++) {
178 ParticlePDG *particle = database->GetPDGParticleByIndex(currParticle);
179 meanEnergyDensity += ParticleEnergyDensity(particle);
180 }
181
182 return meanEnergyDensity;
183}
184
03896fc4 185//_______________________________________________________________________________
b7d1d891 186Double_t GrandCanonical::BaryonDensity(DatabasePDG *const database) {
03896fc4 187 //
188 // compute the baryon density
189 //
b1c2e580 190 // Check if all the thermodinamic parameters are set
191 if(!fInitialized)
192 Fatal("GrandCanonical::BaryonDensity", "GrandCanonical object not fully initialized!!");
193
194 Double_t meanBaryonDensity = 0.;
195
196 for(Int_t currParticle = 0; currParticle<database->GetNParticles(); currParticle++) {
197 ParticlePDG *particle = database->GetPDGParticleByIndex(currParticle);
198 meanBaryonDensity += ParticleNumberDensity(particle)*particle->GetBaryonNumber();
199 }
200 return meanBaryonDensity;
201}
202
03896fc4 203//_______________________________________________________________________________
b7d1d891 204Double_t GrandCanonical::StrangeDensity(DatabasePDG *const database) {
03896fc4 205 //
206 // compute the strangeness density
207 //
b1c2e580 208 // Check if all the thermodinamic parameters are set
209 if(!fInitialized)
210 Fatal("GrandCanonical::StrangeDensity", "GrandCanonical object not fully initialized!!");
211
212 Double_t meanStrangeDensity = 0.;
213
214 for(Int_t currParticle = 0; currParticle<database->GetNParticles(); currParticle++) {
215 ParticlePDG *particle = database->GetPDGParticleByIndex(currParticle);
216 meanStrangeDensity += ParticleNumberDensity(particle)*particle->GetStrangeness();
217 }
218
219 return meanStrangeDensity;
220}
221
03896fc4 222//_______________________________________________________________________________
b7d1d891 223Double_t GrandCanonical::ElectroDensity(DatabasePDG *const database) {
03896fc4 224 //
225 // compute the electro number density
226 //
b1c2e580 227 // Check if all the thermodinamic parameters are set
228 if(!fInitialized)
229 Fatal("GrandCanonical::ElectroDensity", "GrandCanonical object not fully initialized!!");
230
231 Double_t meanElectroDensity = 0.;
232
233 //hadrons
234 for(Int_t currParticle = 0; currParticle<database->GetNParticles(); currParticle++) {
235 ParticlePDG *particle = database->GetPDGParticleByIndex(currParticle);
236 meanElectroDensity += ParticleNumberDensity(particle)*particle->GetElectricCharge();
237 }
238
239 return meanElectroDensity;
240}