PYTHIA  8.311
HadronWidths.h
1 // HadronWidths.h is a part of the PYTHIA event generator.
2 // Copyright (C) 2024 Torbjorn Sjostrand.
3 // PYTHIA is licenced under the GNU GPL v2 or later, see COPYING for details.
4 // Please respect the MCnet Guidelines, see GUIDELINES for details.
5 
6 // Header file for computing mass-dependent widths and branching ratios
7 
8 #ifndef Pythia8_HadronWidths_H
9 #define Pythia8_HadronWidths_H
10 
11 #include "Pythia8/MathTools.h"
12 #include "Pythia8/ParticleData.h"
13 #include "Pythia8/PhysicsBase.h"
14 
15 namespace Pythia8 {
16 
17 //==========================================================================
18 
19 // The HadronWidths class is used to compute mass-dependent widths
20 // and branching ratios of hadrons.
21 
22 class HadronWidths : public PhysicsBase {
23 
24 public:
25 
26  // Load hadron widths data from an xml file.
27  bool init(string path);
28  bool init(istream& stream);
29 
30  // Check whether input data is valid and matches particle data.
31  bool check();
32 
33  // Get whether the specified incoming particles can form a resonance.
34  bool hasResonances(int idA, int idB) const;
35 
36  // Get all implemented resonances.
37  set<int> getResonances() const;
38 
39  // Get resonances that can be formed by the specified incoming particles.
40  set<int> getResonances(int idA, int idB) const;
41 
42  // Returns whether the specified particle is handled by HadronWidths.
43  bool hasData(int id) const {
44  auto iter = entries.find(abs(id));
45  return iter != entries.end();
46  }
47 
48  // Get whether the resonance can decay into the specified products.
49  bool canDecay(int id, int prodA, int prodB) const;
50 
51  // Get the total width of the specified particle at the specified mass.
52  double width(int id, double m) const;
53 
54  // Get the partial width for the specified decay channel of the particle.
55  double partialWidth(int idR, int prodA, int prodB, double m) const;
56 
57  // Get the branching ratio for the specified decay channel of the particle.
58  double br(int idR, int prodA, int prodB, double m) const;
59 
60  // Get the mass distribution density for the particle at the specified mass.
61  double mDistr(int id, double m) const;
62 
63  // Sample masses for the outgoing system with a given eCM.
64  bool pickMasses(int idA, int idB, double eCM,
65  double& mAOut, double& mBOut, int lType = 1);
66 
67  // Pick a decay channel for the specified particle, together with phase
68  // space configuration. Returns whether successful.
69  bool pickDecay(int idDec, double m, int& idAOut, int& idBOut,
70  double& mAOut, double& mBOut);
71 
72  // Calculate the total width of the particle without using interpolation.
73  double widthCalc(int id, double m) const;
74 
75  // Calculate partial width of the particle without using interpolation.
76  double widthCalc(int id, int prodA, int prodB, double m) const;
77 
78  // Regenerate parameterization for particle, using the specified number of
79  // interpolation points. If needed, its decay products are automatically
80  // parameterized as well.
81  bool parameterize(int id, int precision = 50);
82 
83  // Regenerate parameterization for all particles.
84  void parameterizeAll(int precision = 50);
85 
86  // Write all width data to an xml file.
87  bool save(ostream& stream) const;
88  bool save(string file = "HadronWidths.dat") const {
89  ofstream stream(file); return save(stream); }
90 
91 private:
92 
93  // Struct for mass dependent partial width and other decay channel info.
94  struct ResonanceDecayChannel {
96  int prodA, prodB;
97 
98  // 2l+1, where l is the angular momentum of the outgoing two-body system.
99  int lType;
100 
101  // Minimum mass for this channel.
102  double mThreshold;
103  };
104 
105  // Structure for total width parameterization and map to decay channels.
106  struct HadronWidthEntry {
108  map<pair<int, int>, ResonanceDecayChannel> decayChannels;
109  bool isUserDefined;
110  };
111 
112  // Map from particle id to corresponding HadronWidthEntry.
113  map<int, HadronWidthEntry> entries;
114 
115  // Gets key for the decay and flips idR if necessary
116  pair<int, int> getKey(int& idR, int idA, int idB) const;
117 
118  // Map from signatures to candidate resonances. Used for optimization.
119  map<int, vector<int>> signatureToParticles;
120 
121  // Get signature of system based on total baryon number and electric charge.
122  int getSignature(int baryonNumber, int charge) const;
123 
124  // Get total available phase space.
125  double psSize(double eCM, ParticleDataEntryPtr prodA,
126  ParticleDataEntryPtr prodB, double lType) const;
127 
128  // Calculate partial width of the particle without using interpolation.
129  double widthCalc(int id, DecayChannel& channel, double m) const;
130 
131  // Recursive method for parameterization.
132  bool parameterizeRecursive(int id, int precision);
133 
134 };
135 
136 //==========================================================================
137 
138 } // end namespace Pythia8
139 
140 #endif // Pythia8_HadronWidths_H
bool save(ostream &stream) const
Write all width data to an xml file.
Definition: HadronWidths.cc:1117
Definition: PhysicsBase.h:27
bool pickDecay(int idDec, double m, int &idAOut, int &idBOut, double &mAOut, double &mBOut)
Definition: HadronWidths.cc:531
double mDistr(int id, double m) const
Get the mass distribution density for the particle at the specified mass.
Definition: HadronWidths.cc:518
bool init(string path)
Load hadron widths data from an xml file.
Definition: HadronWidths.cc:58
double partialWidth(int idR, int prodA, int prodB, double m) const
Get the partial width for the specified decay channel of the particle.
Definition: HadronWidths.cc:422
double width(int id, double m) const
Get the total width of the specified particle at the specified mass.
Definition: HadronWidths.cc:391
bool canDecay(int id, int prodA, int prodB) const
Get whether the resonance can decay into the specified products.
Definition: HadronWidths.cc:374
This class holds info on a single decay channel.
Definition: ParticleData.h:35
bool parameterize(int id, int precision=50)
Regenerate parameterization for particle and its decay products if needed.
Definition: HadronWidths.cc:866
bool hasData(int id) const
Returns whether the specified particle is handled by HadronWidths.
Definition: HadronWidths.h:43
Definition: HadronWidths.h:22
double widthCalc(int id, double m) const
Calculate the total width of the particle without using interpolation.
Definition: HadronWidths.cc:757
bool hasResonances(int idA, int idB) const
Get whether the specified incoming particles can form a resonance.
Definition: HadronWidths.cc:293
bool check()
Check whether input data is valid and matches particle data.
Definition: HadronWidths.cc:189
void parameterizeAll(int precision=50)
Regenerate parameterization for all particles.
Definition: HadronWidths.cc:1090
set< int > getResonances() const
Get all implemented resonances.
Definition: HadronWidths.cc:325
Header for classes to set beam momentum and interaction vertex spread.
Definition: Analysis.h:20
double m(const Vec4 &v1)
Invariant mass and its square.
Definition: Basics.cc:576
Definition: MathTools.h:65
double br(int idR, int prodA, int prodB, double m) const
Get the branching ratio for the specified decay channel of the particle.
Definition: HadronWidths.cc:462
bool pickMasses(int idA, int idB, double eCM, double &mAOut, double &mBOut, int lType=1)
Sample masses for the outgoing system with a given eCM.
Definition: HadronWidths.cc:630