PYTHIA  8.313
FragmentationFlavZpT.h
1 // FragmentationFlavZpT.h is a part of the PYTHIA event generator.
2 // Copyright (C) 2025 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 // This file contains helper classes for fragmentation.
7 // StringFlav is used to select quark and hadron flavours.
8 // StringPT is used to select transverse momenta.
9 // StringZ is used to sample the fragmentation function f(z).
10 
11 #ifndef Pythia8_FragmentationFlavZpT_H
12 #define Pythia8_FragmentationFlavZpT_H
13 
14 #include "Pythia8/Basics.h"
15 #include "Pythia8/MathTools.h"
16 #include "Pythia8/ParticleData.h"
17 #include "Pythia8/PhysicsBase.h"
18 #include "Pythia8/PythiaStdlib.h"
19 #include "Pythia8/Settings.h"
20 
21 namespace Pythia8 {
22 
23 //==========================================================================
24 
25 // Functions for unnormalised and average Lund FF.
26 
27 double LundFFRaw(double z, double a, double b, double c, double mT2);
28 
29 double LundFFAvg(double a, double b, double c, double mT2, double tol);
30 
31 //==========================================================================
32 
33 // The FlavContainer class is a simple container for flavour,
34 // including the extra properties needed for popcorn baryon handling.
35 // id = current flavour.
36 // rank = current rank; 0 for endpoint flavour and then increase by 1.
37 // nPop = number of popcorn mesons yet to be produced (1 or 0).
38 // idPop = (absolute sign of) popcorn quark, shared between B and Bbar.
39 // idVtx = (absolute sign of) vertex (= non-shared) quark in diquark.
40 
42 
43 public:
44 
45  // Constructor.
46  FlavContainer(int idIn = 0, int rankIn = 0, int nPopIn = 0,
47  int idPopIn = 0, int idVtxIn = 0) : id(idIn), rank(rankIn),
48  nPop(nPopIn), idPop(idPopIn), idVtx(idVtxIn) {}
49 
50  // Copy constructor.
52  id = flav.id; rank = flav.rank; nPop = flav.nPop; idPop = flav.idPop;
53  idVtx = flav.idVtx;}
54 
55  // Overloaded equal operator.
56  FlavContainer& operator=(const FlavContainer& flav) { if (this != &flav) {
57  id = flav.id; rank = flav.rank; nPop = flav.nPop; idPop = flav.idPop;
58  idVtx = flav.idVtx; } return *this; }
59 
60  // Invert flavour.
61  FlavContainer& anti() {id = -id; return *this;}
62 
63  // Read in a container into another, without/with id sign flip.
64  FlavContainer& copy(const FlavContainer& flav) { if (this != &flav) {
65  id = flav.id; rank = flav.rank; nPop = flav.nPop; idPop = flav.idPop;
66  idVtx = flav.idVtx; } return *this; }
67  FlavContainer& anti(const FlavContainer& flav) { if (this != &flav) {
68  id = -flav.id; rank = flav.rank; nPop = flav.nPop; idPop = flav.idPop;
69  idVtx = flav.idVtx; } return *this; }
70 
71  // Check whether is diquark.
72  bool isDiquark() {int idAbs = abs(id);
73  return (idAbs > 1000 && idAbs < 10000 && (idAbs/10)%10 == 0);}
74 
75  // Stored properties.
76  int id, rank, nPop, idPop, idVtx;
77 
78 };
79 
80 //==========================================================================
81 
82 // The StringFlav class is used to select quark and hadron flavours.
83 
84 class StringFlav : public PhysicsBase {
85 
86 public:
87 
88  // Constructor.
90  suppressLeadingB(),
91  mT2suppression(), useWidthPre(), probQQtoQ(), probStoUD(), probSQtoQQ(),
92  probQQ1toQQ0(), probQandQQ(), probQandS(), probQandSinQQ(), probQQ1corr(),
93  probQQ1corrInv(), probQQ1norm(), probQQ1join(), mesonRate(),
94  mesonRateSum(), mesonMix1(), mesonMix2(), etaSup(), etaPrimeSup(),
95  decupletSup(), baryonCGSum(), baryonCGMax(), popcornRate(), popcornSpair(),
96  popcornSmeson(), barCGMax(), scbBM(), popFrac(), popS(), dWT(),
97  lightLeadingBSup(), heavyLeadingBSup(), probStoUDSav(), probQQtoQSav(),
98  probSQtoQQSav(), probQQ1toQQ0Sav(), alphaQQSav(), sigmaHad(),
99  widthPreStrange(), widthPreDiquark(), thermalModel(), mesonNonetL1(),
100  temperature(), tempPreFactor(), nNewQuark(), mesMixRate1(), mesMixRate2(),
101  mesMixRate3(), baryonOctWeight(), baryonDecWeight(), closePacking(),
102  doEnhanceDiquark(), enhanceStrange(), enhancePT(), enhanceDiquark(),
103  exponentMPI(), exponentNSP(), hadronIDwin(0), idNewWin(0),
104  hadronMassWin(-1.0) {}
105 
106  // Destructor.
107  virtual ~StringFlav() {}
108 
109  // Initialize data members.
110  virtual void init();
111 
112  // Initialise parameters when using close packing.
113  virtual void init(double kappaModifier, double strangeJunc,
114  double probQQmod);
115 
116  // Pick a light d, u or s quark according to fixed ratios.
117  int pickLightQ() { double rndmFlav = probQandS * rndmPtr->flat();
118  if (rndmFlav < 1.) return 1;
119  if (rndmFlav < 2.) return 2;
120  return 3; }
121 
122  // Pick a new flavour (including diquarks) given an incoming one,
123  // either by old standard Gaussian or new alternative exponential.
124  virtual FlavContainer pick(FlavContainer& flavOld, double pT = -1.0,
125  double kappaModifier = -1.0, bool allowPop = true) {
126  hadronIDwin = 0; idNewWin = 0; hadronMassWin = -1.0;
127  if ( (thermalModel || mT2suppression) && (pT >= 0.0) )
128  return pickThermal(flavOld, pT, kappaModifier);
129  return pickGauss(flavOld, allowPop); }
130  virtual FlavContainer pickGauss(FlavContainer& flavOld,
131  bool allowPop = true);
132  virtual FlavContainer pickThermal(FlavContainer& flavOld,
133  double pT, double kappaModifier);
134 
135  // Combine two flavours (including diquarks) to produce a hadron.
136  virtual int combine(FlavContainer& flav1, FlavContainer& flav2);
137 
138  // Ditto, simplified input argument for simple configurations.
139  virtual int combineId( int id1, int id2, bool keepTrying = true) {
140  FlavContainer flag1(id1); FlavContainer flag2(id2);
141  for (int i = 0; i < 100; ++i) { int idNew = combine( flag1, flag2);
142  if (idNew != 0 || !keepTrying) return idNew;} return 0;}
143 
144  // Combine three (di-) quark flavours into two hadrons.
145  virtual pair<int,int> combineDiquarkJunction(int id1, int id2, int id3);
146 
147  // Combine two flavours to produce a hadron with lowest possible mass.
148  virtual int combineToLightest( int id1, int id2);
149 
150  // Lightest flavour-neutral meson.
151  virtual int idLightestNeutralMeson() { return 111; }
152 
153  // Return chosen hadron in case of thermal model.
154  virtual int getHadronIDwin() { return hadronIDwin; }
155 
156  // Combine two flavours into hadron for last two remaining flavours
157  // for thermal model.
158  virtual int combineLastThermal(FlavContainer& flav1, FlavContainer& flav2,
159  double pT, double kappaModifier);
160 
161  // General function, decides whether to just return the hadron id
162  // if thermal model was use or whether to combine the two flavours.
163  virtual int getHadronID(FlavContainer& flav1, FlavContainer& flav2,
164  double pT = -1.0, double kappaModifier = -1.0, bool finalTwo = false) {
165  if (finalTwo) return ((thermalModel || mT2suppression) ?
166  combineLastThermal(flav1, flav2, pT, kappaModifier)
167  : combine(flav1, flav2));
168  if ((thermalModel || mT2suppression)&& (hadronIDwin != 0)
169  && (idNewWin != 0)) return getHadronIDwin();
170  return combine(flav1, flav2); }
171 
172  // Return hadron mass. Used one if present, pick otherwise.
173  virtual double getHadronMassWin(int idHad) { return
174  ((hadronMassWin < 0.0) ? particleDataPtr->mSel(idHad) : hadronMassWin); }
175 
176  // Assign popcorn quark inside an original (= rank 0) diquark.
177  void assignPopQ(FlavContainer& flav);
178 
179  // Combine two quarks to produce a diquark.
180  int makeDiquark(int id1, int id2, int idHad = 0);
181 
182  // Check if quark-diquark combination should be added. If so add.
183  void addQuarkDiquark(vector< pair<int,int> >& quarkCombis,
184  int qID, int diqID, int hadronID) {
185  bool allowed = true;
186  for (int iCombi = 0; iCombi < int(quarkCombis.size()); iCombi++)
187  if ( (qID == quarkCombis[iCombi].first ) &&
188  (diqID == quarkCombis[iCombi].second) ) allowed = false;
189  if (allowed) quarkCombis.push_back( (hadronID > 0) ?
190  make_pair( qID, diqID) : make_pair(-qID, -diqID) ); }
191 
192  // Get spin counter for mesons.
193  int getMesonSpinCounter(int hadronID) { hadronID = abs(hadronID);
194  int j = (hadronID % 10);
195  if (hadronID < 1000) return ((j==1) ? 0 : ( (j==3) ? 1 : 5 ));
196  if (hadronID < 20000) return ((j==1) ? 3 : 2);
197  if (hadronID > 20000) return 4;
198  return -1; }
199 
200  // Get the flavour and spin ratios calculated from the diquark weights.
201  // i: (0) q -> B B, (1) q -> B M B, (2) qq -> M B
202  // j: (0) s/u popcorn ratio, (1/2) s/u ratio for vertex quark if popcorn
203  // quark is u/d or s, (3) q/q' vertex quark ratio if popcorn quark is
204  // light and = q, (4/5/6) (spin 1)/(spin 0) ratio for su, us and ud
205  double getFlavourSpinRatios(int i, int j) {
206  return (i < 3 && j < 7) ? dWT[i][j] : -1.0;}
207 
208 protected:
209 
210  // Initialise derived parameters.
211  virtual void initDerived();
212 
213  // Constants: could only be changed in the code itself.
214  static const int mesonMultipletCode[6];
215  static const double baryonCGOct[6], baryonCGDec[6];
216 
217  // Settings for Gaussian model.
218  bool suppressLeadingB, mT2suppression, useWidthPre;
219  double probQQtoQ, probStoUD, probSQtoQQ, probQQ1toQQ0, probQandQQ,
220  probQandS, probQandSinQQ, probQQ1corr, probQQ1corrInv, probQQ1norm,
221  probQQ1join[4], mesonRate[4][6], mesonRateSum[4], mesonMix1[2][6],
222  mesonMix2[2][6], etaSup, etaPrimeSup, decupletSup, baryonCGSum[6],
223  baryonCGMax[6], popcornRate, popcornSpair, popcornSmeson, barCGMax[8],
224  scbBM[3], popFrac, popS[3], dWT[3][7], lightLeadingBSup,
225  heavyLeadingBSup;
226  bool qqKappa;
227  double probStoUDSav, probQQtoQSav, probSQtoQQSav, probQQ1toQQ0Sav,
228  alphaQQSav, sigmaHad, widthPreStrange, widthPreDiquark;
229 
230  // Settings for thermal model.
231  bool thermalModel, mesonNonetL1;
232  double temperature, tempPreFactor;
233  int nNewQuark;
234  double mesMixRate1[2][6], mesMixRate2[2][6], mesMixRate3[2][6];
235  double baryonOctWeight[6][6][6][2], baryonDecWeight[6][6][6][2];
236 
237  // Settings used by both models.
238  bool closePacking, doEnhanceDiquark;
239  double enhanceStrange, enhancePT, enhanceDiquark, exponentMPI, exponentNSP;
240 
241  // Key = hadron id, value = list of constituent ids.
242  map< int, vector< pair<int,int> > > hadronConstIDs;
243  // Key = initial (di)quark id, value = list of possible hadron ids
244  // + nr in hadronConstIDs.
245  map< int, vector< pair<int,int> > > possibleHadrons;
246  // Key = initial (di)quark id, value = prefactor to multiply rate.
247  map< int, vector<double> > possibleRatePrefacs;
248  // Similar, but for combining the last two (di)quarks. Key = (di)quark pair.
249  map< pair<int,int>, vector< pair<int,int> > > possibleHadronsLast;
250  map< pair<int,int>, vector<double> > possibleRatePrefacsLast;
251 
252  // Selection in thermal model.
253  int hadronIDwin, idNewWin;
254  double hadronMassWin;
255 
256  // Fragmentation weights container.
258 
259 };
260 
261 //==========================================================================
262 
263 // The StringZ class is used to sample the fragmentation function f(z).
264 
265 class StringZ : public PhysicsBase {
266 
267 public:
268 
269  // Constructor.
270  StringZ() : useNonStandC(), useNonStandB(), useNonStandH(), usePetersonC(),
271  usePetersonB(), usePetersonH(), mc2(), mb2(), aLund(), bLund(),
272  aExtraSQuark(), aExtraDiquark(), rFactC(), rFactB(), rFactH(), aNonC(),
273  aNonB(), aNonH(), bNonC(), bNonB(), bNonH(), epsilonC(), epsilonB(),
274  epsilonH(), stopM(), stopNF(), stopS() {}
275 
276  // Destructor.
277  virtual ~StringZ() {}
278 
279  // Initialize data members.
280  virtual void init();
281 
282  // Fragmentation function: top-level to determine parameters.
283  virtual double zFrag( int idOld, int idNew = 0, double mT2 = 1.);
284 
285  // Fragmentation function: select z according to provided parameters.
286  virtual double zLund( double a, double b, double c = 1.,
287  double head = 1., double bNow = 0., int idFrag = 0,
288  bool isOldSQuark = false, bool isNewSQuark = false,
289  bool isOldDiquark = false, bool isNewDiquark = false);
290  virtual double zPeterson( double epsilon);
291  virtual double zLundMax( double a, double b, double c = 1.);
292 
293  // Parameters for stopping in the middle; overloaded for Hidden Valley.
294  virtual double stopMass() {return stopM;}
295  virtual double stopNewFlav() {return stopNF;}
296  virtual double stopSmear() {return stopS;}
297 
298  // a and b fragmentation parameters needed in some operations.
299  virtual double aAreaLund() {return aLund;}
300  virtual double bAreaLund() {return bLund;}
301 
302  // Method to derive bLund from <z> (for fixed a and reference mT2).
303  bool deriveBLund();
304 
305 protected:
306 
307  // Constants: could only be changed in the code itself.
308  static const double CFROMUNITY, AFROMZERO, AFROMC, EXPMAX;
309 
310  // Initialization data, to be read from Settings.
311  bool useNonStandC, useNonStandB, useNonStandH,
312  usePetersonC, usePetersonB, usePetersonH;
313  double mc2, mb2, aLund, bLund, aExtraSQuark, aExtraDiquark, rFactC,
314  rFactB, rFactH, aNonC, aNonB, aNonH, bNonC, bNonB, bNonH,
315  epsilonC, epsilonB, epsilonH, stopM, stopNF, stopS;
316 
317  // Fragmentation weights container.
319 
320 };
321 
322 //==========================================================================
323 
324 // The StringPT class is used to select select transverse momenta.
325 
326 class StringPT : public PhysicsBase {
327 
328 public:
329 
330  // Constructor.
331  StringPT() : useWidthPre(), sigmaQ(), enhancedFraction(), enhancedWidth(),
332  sigma2Had(), widthPreStrange(), widthPreDiquark(),
333  thermalModel(), temperature(), tempPreFactor(), fracSmallX(),
334  closePacking(), enhancePT(), exponentMPI(), exponentNSP() {}
335 
336  // Destructor.
337  virtual ~StringPT() {}
338 
339  // Initialize data members.
340  virtual void init();
341 
342  // General function, return px and py as a pair in the same call
343  // in either model.
344  pair<double, double> pxy(int idIn, double kappaModifier = -1.0) {
345  return (thermalModel ? pxyThermal(idIn, kappaModifier) :
346  pxyGauss(idIn, kappaModifier)); }
347  pair<double, double> pxyGauss(int idIn = 0, double kappaModifier = -1.0);
348  pair<double, double> pxyThermal(int idIn, double kappaModifier = -1.0);
349 
350  // Gaussian suppression of given pT2; used in MiniStringFragmentation.
351  double suppressPT2(double pT2) { return (thermalModel ?
352  exp(-sqrt(pT2)/temperature) : exp(-pT2/sigma2Had)); }
353 
354 protected:
355 
356  // Constants: could only be changed in the code itself.
357  static const double SIGMAMIN;
358 
359  // Initialization data, to be read from Settings.
360  // Gaussian model.
362  double sigmaQ, enhancedFraction, enhancedWidth, sigma2Had,
363  widthPreStrange, widthPreDiquark;
364  // Thermal model.
366  double temperature, tempPreFactor, fracSmallX;
367  // Both.
369  double enhancePT, exponentMPI, exponentNSP;
370 
371 private:
372 
373  // Evaluate Bessel function K_{1/4}(x).
374  double BesselK14(double x);
375 
376  // Fragmentation weights container.
377  WeightsFragmentation* wgtsPtr{};
378 
379 };
380 
381 //==========================================================================
382 
383 } // end namespace Pythia8
384 
385 #endif // Pythia8_FragmentationFlavZpT_H
int hadronIDwin
Selection in thermal model.
Definition: FragmentationFlavZpT.h:253
pair< double, double > pxy(int idIn, double kappaModifier=-1.0)
Definition: FragmentationFlavZpT.h:344
FlavContainer & operator=(const FlavContainer &flav)
Overloaded equal operator.
Definition: FragmentationFlavZpT.h:56
virtual double aAreaLund()
a and b fragmentation parameters needed in some operations.
Definition: FragmentationFlavZpT.h:299
Definition: PhysicsBase.h:27
virtual double getHadronMassWin(int idHad)
Return hadron mass. Used one if present, pick otherwise.
Definition: FragmentationFlavZpT.h:173
int getMesonSpinCounter(int hadronID)
Get spin counter for mesons.
Definition: FragmentationFlavZpT.h:193
map< int, vector< pair< int, int > > > possibleHadrons
Definition: FragmentationFlavZpT.h:245
static const double SIGMAMIN
Constants: could only be changed in the code itself.
Definition: FragmentationFlavZpT.h:357
bool thermalModel
Settings for thermal model.
Definition: FragmentationFlavZpT.h:231
The StringPT class is used to select select transverse momenta.
Definition: FragmentationFlavZpT.h:326
virtual ~StringPT()
Destructor.
Definition: FragmentationFlavZpT.h:337
bool thermalModel
Thermal model.
Definition: FragmentationFlavZpT.h:365
bool isDiquark()
Check whether is diquark.
Definition: FragmentationFlavZpT.h:72
Wave4 epsilon(Wave4 w1, Wave4 w2, Wave4 w3)
Permutation operator.
Definition: HelicityBasics.cc:56
virtual ~StringZ()
Destructor.
Definition: FragmentationFlavZpT.h:277
virtual ~StringFlav()
Destructor.
Definition: FragmentationFlavZpT.h:107
void addQuarkDiquark(vector< pair< int, int > > &quarkCombis, int qID, int diqID, int hadronID)
Check if quark-diquark combination should be added. If so add.
Definition: FragmentationFlavZpT.h:183
virtual int getHadronID(FlavContainer &flav1, FlavContainer &flav2, double pT=-1.0, double kappaModifier=-1.0, bool finalTwo=false)
Definition: FragmentationFlavZpT.h:163
The StringZ class is used to sample the fragmentation function f(z).
Definition: FragmentationFlavZpT.h:265
FlavContainer & anti()
Invert flavour.
Definition: FragmentationFlavZpT.h:61
FlavContainer(int idIn=0, int rankIn=0, int nPopIn=0, int idPopIn=0, int idVtxIn=0)
Constructor.
Definition: FragmentationFlavZpT.h:46
int id
Stored properties.
Definition: FragmentationFlavZpT.h:76
double getFlavourSpinRatios(int i, int j)
Definition: FragmentationFlavZpT.h:205
bool suppressLeadingB
Settings for Gaussian model.
Definition: FragmentationFlavZpT.h:218
bool useWidthPre
Definition: FragmentationFlavZpT.h:361
virtual int combineId(int id1, int id2, bool keepTrying=true)
Ditto, simplified input argument for simple configurations.
Definition: FragmentationFlavZpT.h:139
double suppressPT2(double pT2)
Gaussian suppression of given pT2; used in MiniStringFragmentation.
Definition: FragmentationFlavZpT.h:351
FlavContainer & copy(const FlavContainer &flav)
Read in a container into another, without/with id sign flip.
Definition: FragmentationFlavZpT.h:64
virtual int idLightestNeutralMeson()
Lightest flavour-neutral meson.
Definition: FragmentationFlavZpT.h:151
FlavContainer(const FlavContainer &flav)
Copy constructor.
Definition: FragmentationFlavZpT.h:51
double LundFFRaw(double z, double a, double b, double c, double mT2)
Functions for unnormalised and average Lund FF.
Definition: FragmentationFlavZpT.cc:21
StringZ()
Constructor.
Definition: FragmentationFlavZpT.h:270
map< int, vector< pair< int, int > > > hadronConstIDs
Key = hadron id, value = list of constituent ids.
Definition: FragmentationFlavZpT.h:242
virtual double stopMass()
Parameters for stopping in the middle; overloaded for Hidden Valley.
Definition: FragmentationFlavZpT.h:294
Definition: FragmentationFlavZpT.h:41
Definition: Weights.h:354
map< pair< int, int >, vector< pair< int, int > > > possibleHadronsLast
Similar, but for combining the last two (di)quarks. Key = (di)quark pair.
Definition: FragmentationFlavZpT.h:249
static const double EXPMAX
Do not take exponent of too large or small number.
Definition: FragmentationFlavZpT.h:308
Header for classes to set beam momentum and interaction vertex spread.
Definition: Analysis.h:20
bool closePacking
Both.
Definition: FragmentationFlavZpT.h:368
The StringFlav class is used to select quark and hadron flavours.
Definition: FragmentationFlavZpT.h:84
double LundFFAvg(double a, double b, double c, double mT2, double tol)
Average, <z>, of Lund FF.
Definition: FragmentationFlavZpT.cc:30
virtual FlavContainer pick(FlavContainer &flavOld, double pT=-1.0, double kappaModifier=-1.0, bool allowPop=true)
Definition: FragmentationFlavZpT.h:124
bool closePacking
Settings used by both models.
Definition: FragmentationFlavZpT.h:238
bool useNonStandC
Initialization data, to be read from Settings.
Definition: FragmentationFlavZpT.h:311
int pickLightQ()
Pick a light d, u or s quark according to fixed ratios.
Definition: FragmentationFlavZpT.h:117
StringPT()
Constructor.
Definition: FragmentationFlavZpT.h:331
StringFlav()
Constructor.
Definition: FragmentationFlavZpT.h:89
map< int, vector< double > > possibleRatePrefacs
Key = initial (di)quark id, value = prefactor to multiply rate.
Definition: FragmentationFlavZpT.h:247
virtual int getHadronIDwin()
Return chosen hadron in case of thermal model.
Definition: FragmentationFlavZpT.h:154