Thermal-FIST 1.5
Package for hadron resonance gas model applications
Loading...
Searching...
No Matches
ThermalParticleSystem.h
Go to the documentation of this file.
1/*
2 * Thermal-FIST package
3 *
4 * Copyright (c) 2014-2019 Volodymyr Vovchenko
5 *
6 * GNU General Public License (GPLv3 or later)
7 */
8#ifndef THERMALPARTICLESYSTEM_H
9#define THERMALPARTICLESYSTEM_H
10
11#include <map>
12#include <vector>
13#include <set>
14#include <fstream>
15
17
18namespace thermalfist {
19
30 {
31 public:
32
42 ThermalParticleSystem(const std::string& InputFile = "", bool GenAntiP = true, double mcut = -1.) { Initialize(InputFile, std::string(""), GenAntiP, mcut); }
43
54 ThermalParticleSystem(const std::string& InputFile, const std::string& DecayFile, bool GenAntiP = true, double mcut = -1.) { Initialize(InputFile, DecayFile, GenAntiP, mcut); }
55
56
78 const std::vector<std::string>& ListFiles,
79 const std::vector<std::string>& DecayFiles = std::vector<std::string>(0),
80 const std::set<std::string>& flags = std::set<std::string>(),
81 double mcut = -1.);
82
88
97
103 void ProcessDecays();
104
115 void FillDecayProperties();
116
121 void FillDecayThresholds();
122
130 void FillResonanceDecays();
131
138
139
143 typedef std::pair<double, int> SingleDecayContribution;
144
146 typedef std::vector<SingleDecayContribution> DecayContributionsToParticle;
147
150 typedef std::vector<DecayContributionsToParticle> DecayContributionsToAllParticles;
151
155 typedef std::pair< std::vector<double>, int> SingleDecayCumulantsContribution;
156
158 typedef std::vector<SingleDecayCumulantsContribution> DecayCumulantsContributionsToParticle;
159
162 typedef std::vector<DecayCumulantsContributionsToParticle> DecayCumulantsContributionsToAllParticles;
163
169 typedef std::pair< std::vector<double>, int> SingleDecayProbabilityDistribution;
170
172 typedef std::vector<SingleDecayProbabilityDistribution> DecayProbabilityDistributionsToParticle;
173
176 typedef std::vector<DecayProbabilityDistributionsToParticle> DecayProbabilityDistributionsToAllParticles;
177
183 typedef std::vector< std::pair<double, std::vector<int> > > ResonanceFinalStatesDistribution;
184
191 const std::vector<DecayContributionsToAllParticles>& DecayContributionsByFeeddown() const { return m_DecayContributionsByFeeddown; }
192
201 const DecayCumulantsContributionsToAllParticles& DecayCumulants() const { return m_DecayCumulants; }
202
209 const std::vector<ResonanceFinalStatesDistribution>& ResonanceFinalStatesDistributions() const { return m_ResonanceFinalStatesDistributions; }
210
222 void LoadList(const std::vector<std::string>& ListFiles,
223 const std::vector<std::string>& DecayFiles = std::vector<std::string>(0),
224 const std::set<std::string>& flags = std::set<std::string>(),
225 double mcut = 1.e9);
226
238 void LoadList(const std::string& InputFile, const std::string& DecayFile, bool GenerateAntiParticles = true, double mcut = 1.e9);
239
252 void LoadList(const std::string& InputFile = "", bool GenerateAntiParticles = true, double mcut = -1.) { LoadList(InputFile, std::string(""), GenerateAntiParticles, mcut); }
253
254 void AddParticlesToListFromFile(const std::string& InputFile = "", const std::set<std::string>& flags = std::set<std::string>(), double mcut = -1.);
255
256
262 void LoadTable(const std::string& InputFile = "", bool GenerateAntiParticles = true, double mcut = -1.) { LoadList(InputFile, GenerateAntiParticles, mcut); }
263
271 void SetTableFromVector(const std::vector<ThermalParticle> &part_in, bool GenerateAntiParticles = true);
272
282 void WriteTableToFile(const std::string& OutputFile = "", bool WriteAntiParticles = false);
283
291 void LoadDecays(const std::vector<std::string>& DecayFiles, const std::set<std::string>& flags = std::set<std::string>());
292
300 void LoadDecays(const std::string& DecaysFile = "", bool GenerateAntiParticles = true);
301
308 void WriteDecaysToFile(const std::string& OutputFile = "", bool WriteAntiParticles = false);
309
316
322
324
330 IdealGasFunctions::QStatsCalculationType QStatsCalculationType() const { return m_QStatsCalculationType; }
332
342 void SetClusterExpansionOrder(int order);
343
345
354 ThermalParticle::ResonanceWidthShape ResonanceWidthShape() const { return m_ResonanceWidthShape; }
356
358
365 ThermalParticle::ResonanceWidthIntegration ResonanceWidthIntegrationType() const { return m_ResonanceWidthIntegrationType; }
367
378 std::string GetNameFromPDG(long long pdgid);
379
382 bool hasBaryons() const { return (m_NumBaryons > 0); }
383
386 bool hasCharged() const { return (m_NumCharged > 0); }
387
390 bool hasStrange() const { return (m_NumStrange > 0); }
391
394 bool hasCharmed() const { return (m_NumCharmed > 0); }
395
398 bool hasMultiBaryons() const { return (m_MaxAbsBaryonNumber > 1); }
399
401 int ComponentsNumber() const { return static_cast<int>(m_Particles.size()); }
402
408 const std::vector<ThermalParticle>& Particles() const { return m_Particles; }
409 std::vector<ThermalParticle>& Particles() { return m_Particles; }
410
412
419 const ThermalParticle& Particle(int id) const;
420 ThermalParticle& Particle(int id);
422
433 const ThermalParticle& ParticleByPDG(long long pdgid) const;
434 ThermalParticle& ParticleByPDG(long long pdgid);
435
444 int PdgToId(long long pdgid) const;// { return (m_PDGtoID.count(pdgid) > 0) ? m_PDGtoID[pdgid] : -1; }
445
454 long long IdToPdg(int id) const { return (id >= 0 && id < static_cast<int>(m_Particles.size())) ? m_Particles[id].PdgId() : 0; }
455
463 void AddParticle(const ThermalParticle & part);
464
471 void RemoveParticleAt(int ind);
472
476 bool CheckDecayChargesConservation(int ind) const;
477
482
486 bool CheckAbsoluteQuarkNumbers() const;
487
493 std::vector<int> CheckDecayChargesConservationVector(int ind) const;
494
495 bool operator==(const ThermalParticleSystem &rhs) const;
496 bool operator!=(const ThermalParticleSystem &rhs) const { return !(*this == rhs); }
497
500 void FillPdgMap();
501
508
511 void SetSortMode(SortModeType type) { m_SortMode = type; FinalizeList(); ProcessDecays(); }
512
514 SortModeType SortMode() const { return m_SortMode; }
515
520 void FinalizeList();
521
537
538 static const std::string flag_no_antiparticles;
539 static const std::string flag_nostrangeness;
540 static const std::string flag_nocharm;
541 static const std::string flag_nonuclei;
542 static const std::string flag_noexcitednuclei;
543
549 std::vector<double> GetConservedChargesVector(ConservedCharge::Name charge);
550
551 private:
552 void GoResonance(int ind, int startind, double BR);
553
554 void GoResonanceByFeeddown(int ind, int startind, double BR, Feeddown::Type feeddown);
555
556 std::vector<double> GoResonanceDecayProbs(int ind, int goalind, bool firstdecay = false);
557
558 std::vector<double> GoResonanceDecayProbsCharge(int ind, int nch, bool firstdecay = false);
559
560 ResonanceFinalStatesDistribution GoResonanceDecayDistributions(int ind, bool firstdecay = false);
561
562 bool AcceptParticle(const ThermalParticle& part, const std::set<std::string>& flags, double mcut = -1.) const;
563
564 void LoadTable_OldFormat(std::ifstream& fin, const std::set<std::string>& flags = std::set<std::string>(), double mcut = 1.e9);
565
566 void LoadTable_NewFormat(std::ifstream& fin, const std::set<std::string>& flags = std::set<std::string>(), double mcut = 1.e9);
567
568 void ReadDecays_OldFormat(std::ifstream &fin);
569
570 void ReadDecays_NewFormat(std::ifstream &fin);
571
572 void Initialize(const std::vector<std::string>& ListFiles,
573 const std::vector<std::string>& DecayFiles = std::vector<std::string>(0),
574 const std::set<std::string>& flags = std::set<std::string>(),
575 double mcut = -1.);
576
577 void Initialize(const std::string& InputFile = "", const std::string& DecayFile = "", bool GenAntiP = true, double mcut = -1.);
578
579 void FinalizeListLoad();
580
581 void FinalizeDecaysLoad();
582
584 bool CheckListIsiSS(const std::string &filename);
585
587 void LoadListiSS(const std::string& filename, const std::set<std::string>& flags = std::set<std::string>(), double mcut = 1.e9);
588
589 private:
590 std::vector<ThermalParticle> m_Particles;
591 std::map<long long, int> m_PDGtoID;
592 int m_NumBaryons;
593 int m_NumCharged;
594 int m_NumStrange;
595 int m_NumCharmed;
596 int m_MaxAbsBaryonNumber;
597
598 int m_NumberOfParticles;
599
600 ThermalParticle::ResonanceWidthIntegration m_ResonanceWidthIntegrationType;
601
602 ThermalParticle::ResonanceWidthShape m_ResonanceWidthShape;
603
604 IdealGasFunctions::QStatsCalculationType m_QStatsCalculationType;
605
606 std::vector<DecayContributionsToAllParticles> m_DecayContributionsByFeeddown;
607
609
611
612 std::vector<ResonanceFinalStatesDistribution> m_ResonanceFinalStatesDistributions;
613
614 // Map for DP-based calculations of decay distributions
615 std::vector<ResonanceFinalStatesDistribution> m_DecayDistributionsMap;
616
617 SortModeType m_SortMode;
618 };
619
621 namespace CuteHRGHelper {
622 std::vector<std::string> split(const std::string &s, char delim);
623 void cutDecayDistributionsVector(std::vector<std::pair<double, std::vector<int> > > &vect, int maxsize = 1000);
624 }
625
627 namespace DecayLifetimes {
628 // In units of ctau (fm)
629 double GetLifetime(long long pdg);
630 }
631
632} // namespace thermalfist
633
634#endif
Class containing all information about a particle specie.
std::vector< ParticleDecayChannel > ParticleDecaysVector
Vector of all decay channels of a particle.
ResonanceWidthIntegration
Treatment of finite resonance widths.
ResonanceWidthShape
Relativistic vs non-relativistic Breit-Wigner shape.
Class containing the particle list.
void SetResonanceWidthIntegrationType(ThermalParticle::ResonanceWidthIntegration type)
Set (or get) the ThermalParticle::ResonanceWidthIntegration scheme for all particles.
void SetTableFromVector(const std::vector< ThermalParticle > &part_in, bool GenerateAntiParticles=true)
Sets the particle list from a provided vector of ThermalParticle objects.
IdealGasFunctions::QStatsCalculationType QStatsCalculationType() const
const DecayCumulantsContributionsToAllParticles & DecayCumulants() const
Cumulants of particle number distributions of from decays.
void LoadTable(const std::string &InputFile="", bool GenerateAntiParticles=true, double mcut=-1.)
Same as LoadList()
const std::vector< DecayContributionsToAllParticles > & DecayContributionsByFeeddown() const
std::vector< DecayProbabilityDistributionsToParticle > DecayProbabilityDistributionsToAllParticles
ThermalParticle::ResonanceWidthIntegration ResonanceWidthIntegrationType() const
std::vector< std::pair< double, std::vector< int > > > ResonanceFinalStatesDistribution
ThermalParticleSystem(const std::string &InputFile="", bool GenAntiP=true, double mcut=-1.)
Construct a new ThermalParticleSystem object.
ThermalParticleSystem(const std::string &InputFile, const std::string &DecayFile, bool GenAntiP=true, double mcut=-1.)
Construct a new ThermalParticleSystem object.
static const std::string flag_noexcitednuclei
int PdgToId(long long pdgid) const
Transforms PDG ID to a 0-based particle id number.
std::vector< SingleDecayProbabilityDistribution > DecayProbabilityDistributionsToParticle
A vector of SingleDecayProbabilityDistribution where each element corresponds to a certain resonance ...
SortModeType SortMode() const
Current mode to sort particle species.
void WriteTableToFile(const std::string &OutputFile="", bool WriteAntiParticles=false)
Writes the particle list to file.
void LoadList(const std::string &InputFile="", bool GenerateAntiParticles=true, double mcut=-1.)
Loads the particle list from file.
void ProcessDecays()
Computes the decay contributions of decaying resonances to all particle yields.
std::string GetNameFromPDG(long long pdgid)
Get the name of particle species with the specified PDG ID.
ThermalParticle::ParticleDecaysVector GetDecaysFromAntiParticle(const ThermalParticle::ParticleDecaysVector &Decays)
Generates the decay channels for an antiparticle based on the provided decay channels of a particle.
std::vector< DecayCumulantsContributionsToParticle > DecayCumulantsContributionsToAllParticles
void SetCalculationType(IdealGasFunctions::QStatsCalculationType type)
Sets the CalculationType() method to evaluate quantum statistics.
void NormalizeBranchingRatios()
Normalize branching ratios for all particles such that they add up to 100%.
bool operator==(const ThermalParticleSystem &rhs) const
void SetClusterExpansionOrder(int order)
Set the number of terms in the cluster expansion method.
const std::vector< ThermalParticle > & Particles() const
Returns the vector of all particle species.
std::vector< SingleDecayContribution > DecayContributionsToParticle
A vector of SingleDecayContribution where each element corresponds to a certain resonance species.
void RestoreBranchingRatios()
Restore the original values of all the branching ratios.
void FillDecayProperties()
Computes and fills decay channels of all particles with extra information.
void LoadList(const std::vector< std::string > &ListFiles, const std::vector< std::string > &DecayFiles=std::vector< std::string >(0), const std::set< std::string > &flags=std::set< std::string >(), double mcut=1.e9)
Loads the particle list from file.
static const std::string flag_no_antiparticles
std::pair< double, int > SingleDecayContribution
void FillResonanceDecaysByFeeddown()
Same as FillResonanceDecays() but separately for weak, electromagnetic, and strong decay feeddowns.
std::pair< std::vector< double >, int > SingleDecayCumulantsContribution
void FillDecayThresholds()
Computes mass thresholds of all decay channels of all particles. Obsolete.
void AddParticlesToListFromFile(const std::string &InputFile="", const std::set< std::string > &flags=std::set< std::string >(), double mcut=-1.)
static const std::string flag_nostrangeness
std::vector< int > CheckDecayChargesConservationVector(int ind) const
std::pair< std::vector< double >, int > SingleDecayProbabilityDistribution
static ParticleDecayType::DecayType DecayTypeByParticleType(const ThermalParticle &part)
Determines the decay type of a given particle specie.
const ThermalParticle & Particle(int id) const
ThermalParticle object corresponding to particle species with a provided 0-based index.
void RemoveParticleAt(int ind)
Removes particle specie with specified 0-based particle id number from the list.
long long IdToPdg(int id) const
Transforms 0-based particle id number to a PDG ID.
std::vector< DecayContributionsToParticle > DecayContributionsToAllParticles
const std::vector< ResonanceFinalStatesDistribution > & ResonanceFinalStatesDistributions() const
Final state particle number distributions for resonance decays.
std::vector< ThermalParticle > & Particles()
void AddParticle(const ThermalParticle &part)
Adds a new particle specie to the list.
ThermalParticle::ResonanceWidthShape ResonanceWidthShape() const
void SetResonanceWidthShape(ThermalParticle::ResonanceWidthShape shape)
Set (or get) the ThermalParticle::ResonanceWidthShape for all particles.
void LoadDecays(const std::vector< std::string > &DecayFiles, const std::set< std::string > &flags=std::set< std::string >())
Load the decay channels for all particles from a file.
const ThermalParticle & ParticleByPDG(long long pdgid) const
ThermalParticle object corresponding to particle species with a provided PDG ID.
void FillResonanceDecays()
Computes the decay contributions of decaying resonances to all particle yields.
std::vector< double > GetConservedChargesVector(ConservedCharge::Name charge)
Calculates vector of conserved charges for all particle species.
int ComponentsNumber() const
Number of different particle species in the list.
bool operator!=(const ThermalParticleSystem &rhs) const
void WriteDecaysToFile(const std::string &OutputFile="", bool WriteAntiParticles=false)
Writes the decay channels to a file.
SortModeType
Mode list to sort particles species.
~ThermalParticleSystem(void)
Destroy the ThermalParticleSystem object.
std::vector< SingleDecayCumulantsContribution > DecayCumulantsContributionsToParticle
A vector of SingleDecayCumulantsContribution where each element corresponds to a certain resonance sp...
Contains several helper routines.
void cutDecayDistributionsVector(std::vector< std::pair< double, std::vector< int > > > &vect, int maxsize=1000)
std::vector< std::string > split(const std::string &s, char delim)
Contains decay lifetimes needed for propagation in Monte Carlo.
QStatsCalculationType
Identifies whether quantum statistics are to be computed using the cluster expansion or numerical int...
The main namespace where all classes and functions of the Thermal-FIST library reside.
Definition CosmicEoS.h:9
Name
Set of all conserved charges considered.
DecayType
Type of particle's decay.