PYTHIA  8.316
StringFragmentation.h
1 // StringFragmentation.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 the classes for string fragmentation.
7 // StringEnd: keeps track of the fragmentation step.
8 // StringFragmentation: is the top-level class.
9 
10 #ifndef Pythia8_StringFragmentation_H
11 #define Pythia8_StringFragmentation_H
12 
13 #include "Pythia8/FragmentationModel.h"
14 
15 namespace Pythia8 {
16 
17 //==========================================================================
18 
19 // The StringEnd class contains the information related to
20 // one of the current endpoints of the string system.
21 // Only to be used inside StringFragmentation, so no private members.
22 
23 class StringEnd {
24 
25 public:
26 
27  // Constructor.
28  StringEnd() : particleDataPtr(), flavSelPtr(), pTSelPtr(), zSelPtr(),
29  doFlavBeforePT(), fromPos(), iEnd(), iMax(), idHad(), iPosOld(),
30  iNegOld(), iPosNew(), iNegNew(), iPosNewTmp(), iNegNewTmp(),
31  hadSoFar(), colOld(), colNew(),
32  pxOld(), pyOld(), pxNew(), pyNew(), pxHad(), pyHad(), mHad(),
33  mT2Had(), zHad(), GammaOld(), GammaNew(), xPosOld(), xPosNew(),
34  xPosHad(), xNegOld(), xNegNew(), xNegHad(), aLund(), bLund(),
35  iPosOldPrev(), iNegOldPrev(), colOldPrev(), pxOldPrev(),
36  pyOldPrev(), GammaOldPrev(), xPosOldPrev(), xNegOldPrev(),
37  mVecRatio(1.), tinyEq(), pT2tiny() {}
38 
39  // Save pointers.
40  void init( ParticleData* particleDataPtrIn, StringFlav* flavSelPtrIn,
41  StringPT* pTSelPtrIn, StringZ* zSelPtrIn, Settings& settings,
42  bool doFlavBeforePTin = true) { particleDataPtr = particleDataPtrIn;
43  flavSelPtr = flavSelPtrIn; flavSelNow = *flavSelPtr; pTSelPtr = pTSelPtrIn;
44  zSelPtr = zSelPtrIn; doFlavBeforePT = doFlavBeforePTin;
45  bLund = zSelPtr->bAreaLund(); aLund = zSelPtr->aAreaLund();
46  closePacking = settings.flag("ClosePacking:doClosePacking"); }
47 
48  // Set up initial endpoint values from input.
49  void setUp(bool fromPosIn, int iEndIn, int idOldIn, int iMaxIn,
50  double pxIn, double pyIn, double GammaIn, double xPosIn,
51  double xNegIn, int colIn, double mVecRatioIn);
52 
53  // Fragment off one hadron from the string system, in flavour and pT.
54  void newHadron(double kappaModifier, bool forbidPopcornNow = false,
55  double strangeJunc = 0., double probQQmod = 1.);
56 
57  // Fragment off one hadron from the string system, in momentum space,
58  // by taking steps either from positive or from negative end.
59  Vec4 kinematicsHadron(StringSystem& system, StringVertex& newVertex,
60  double zHadIn);
61 
62  // Generate momentum for some possible next hadron, based on mean values
63  // to get an estimate for rapidity and pT.
64  Vec4 kinematicsHadronTmp(StringSystem system, Vec4 pRem, double phi,
65  double mult);
66 
67  // Update string end information after a hadron has been removed.
68  void update();
69  void storePrev();
70  void updateToPrev();
71 
72  // Constants: could only be changed in the code itself.
73  static const double TINY, PT2SAME, MEANMMIN, MEANM, MEANPT;
74 
75  // Pointer to the particle data table.
77 
78  // Pointers to classes for flavour, pT and z generation.
80  StringPT* pTSelPtr;
81  StringZ* zSelPtr;
82 
83  // Local copy of flavSelPtr for modified flavour selection.
85 
86  // Data members.
87  bool doFlavBeforePT, fromPos, closePacking;
88  int iEnd, iMax, idHad, iPosOld, iNegOld, iPosNew, iNegNew, iPosNewTmp,
89  iNegNewTmp, hadSoFar, colOld, colNew;
90  double pxOld, pyOld, pxNew, pyNew, pxHad, pyHad, mHad, mT2Had, zHad,
91  GammaOld, GammaNew, xPosOld, xPosNew, xPosHad, xNegOld, xNegNew,
92  xNegHad, aLund, bLund;
93  int iPosOldPrev, iNegOldPrev, colOldPrev;
94  double pxOldPrev, pyOldPrev, GammaOldPrev, xPosOldPrev, xNegOldPrev,
95  mVecRatio, tinyEq, pT2tiny;
96  FlavContainer flavOld, flavNew, flavOldPrev;
97  Vec4 pHad, pSoFar;
98 
99 };
100 
101 //==========================================================================
102 
103 // The StringFragmentation class contains the top-level routines
104 // to fragment a colour singlet partonic system.
105 
107 
108 public:
109 
110  // Constructor.
112  FragmentationModel(), flavRopePtr(), doFlavBeforePT(true),
113  closePacking(), setVertices(), constantTau(), smearOn(),
114  traceColours(false), hadronVertex(), stopMass(), stopNewFlav(),
115  stopSmear(), pNormJunction(), pMaxJunction(), eJunctionCutoff(),
116  mJunctionCutoff(), eBothLeftJunction(),
117  eMaxLeftJunction(), eMinLeftJunction(), mJoin(), bLund(),
118  closePackingFluxRatio(1.), closePackingPT20(1.), pT20(),
119  xySmear(), maxSmear(), maxTau(), kappaVtx(), mc(), mb(),
120  hasJunction(), isClosed(), iPos(), iNeg(), nExtraJoin(),
121  w2Rem(), stopMassNow(), mVecRatio(1.),
122  idDiquark(), legMin(), legMid() {}
123 
124  // Set order of flavour and pT selection in StringEnd.
125  void setFlavBeforePT( bool doFlavBeforePTin) {
126  doFlavBeforePT = doFlavBeforePTin; }
127 
128  // Initialize and save pointers.
129  bool init(StringFlav* flavSelPtrIn = nullptr, StringPT* pTSelPtrIn = nullptr,
130  StringZ* zSelPtrIn = nullptr, FragModPtr fragModPtrIn = nullptr) override;
131 
132  // Do the fragmentation: driver routine.
133  bool fragment(int iSub, ColConfig& colConfig, Event& event,
134  bool isDiff = false, bool systemRecoil = true) override;
135 
136  // Local copy of flavSelPtr for modified flavour selection.
138 
139  // Find the boost matrix to the rest frame of a junction.
140  Vec4 junctionRestFrame(const Vec4& p0, const Vec4& p1, const Vec4& p2,
141  const bool angleCheck = true) const;
142 
143  // Set the vector mass ratio.
144  void setMVecRatio(double mVecRatioIn) {mVecRatio = mVecRatioIn;}
145 
146 private:
147 
148  // Constants: could only be changed in the code itself.
149  static const int NTRYFLAV, NTRYJOIN, NSTOPMASS,
150  NTRYJNMATCH, NTRYJRFEQ, NTRYSMEAR, MAXVETOFINTWO;
151  static const double FACSTOPMASS, CLOSEDM2MAX, CLOSEDM2FRAC, EXPMAX,
152  MATCHPOSNEG, M2MINJRF, EMINJRF, EEXTRAJNMATCH,
153  MDIQUARKMIN, CONVJRFEQ, CHECKPOS;
154 
155  // Pointer to flavour-composition-changing ropes.
156  FragModPtr flavRopePtr;
157 
158  // Initialization data, read from Settings.
159  bool doFlavBeforePT, closePacking, setVertices, constantTau, smearOn,
160  traceColours, hardRemn, doStrangeJunc;
161  int hadronVertex;
162  double stopMass, stopNewFlav, stopSmear, pNormJunction, pMaxJunction,
163  eJunctionCutoff, mJunctionCutoff,
164  eBothLeftJunction, eMaxLeftJunction, eMinLeftJunction,
165  mJoin, bLund, closePackingFluxRatio, closePackingPT20,
166  qqSupPar, qqSupAnti, pT20, xySmear, maxSmear, maxTau,
167  kappaVtx, mc, mb, dampPopcorn, aRemn, bRemn, strangeJuncParm;
168 
169  // Data members.
170  bool hasJunction, isClosed;
171  int iPos, iNeg, nExtraJoin;
172  double w2Rem, stopMassNow, kappaModifier, probQQmod, mVecRatio;
173  Vec4 pSum, pRem, pJunctionHadrons;
174 
175  // UserHooks flags.
176  bool doChangeFragPar = false, doVetoFrag = false;
177 
178  // List of partons in string system.
179  vector<int> iParton, iPartonMinLeg, iPartonMidLeg, iPartonMax;
180 
181  // Vertex information from the fragmentation process.
182  vector<StringVertex> stringVertices, legMinVertices, legMidVertices;
183  StringVertex newVertex;
184 
185  // Variables used for JRF finding.
186  vector<Vec4> listJRF;
187  vector<double> weightJRF;
188  int iLeg[3], idLeg[3], legEnd[3];
189  double weightSum, pSumJRF, m2Leg[3];
190  Vec4 pLeg[3];
191  bool lastJRF, endpoint[3];
192 
193  // Boost from/to rest frame of a junction to original frame.
194  RotBstMatrix MfromJRF, MtoJRF;
195 
196  // Information on diquark created at the junction.
197  int idDiquark;
198 
199  // Fictitious opposing partons in JRF: string ends for vertex location.
200  Vec4 pMinEnd, pMidEnd;
201 
202  // Temporary event record for the produced particles.
203  Event hadrons;
204 
205  // Information on the system of string regions.
206  StringSystem system, systemMin, systemMid;
207 
208  // Information on the two current endpoints of the fragmenting
209  // system, with backup copies if there is a veto.
210  StringEnd posEnd, negEnd, posEndSave, negEndSave;
211 
212  // Find region where to put first string break for closed gluon loop.
213  vector<int> findFirstRegion(int iSub, const ColConfig& colConfig,
214  const Event& event) const;
215 
216  // Set flavours and momentum position for initial string endpoints.
217  void setStartEnds(int idPos, int idNeg, const StringSystem& systemNow,
218  int legNow = 3);
219 
220  // Check remaining energy-momentum whether it is OK to continue.
221  bool energyUsedUp(bool fromPos);
222 
223  // Produce the final two partons to complete the system.
224  bool finalTwo(bool fromPos, const Event& event, bool usedPosJun,
225  bool usedNegJun);
226 
227  // Final region information.
228  Vec4 pPosFinalReg, pNegFinalReg, eXFinalReg, eYFinalReg;
229 
230  // Set hadron production points in space-time picture.
231  bool setHadronVertices(Event& event);
232 
233  // Construct a special joining region for the final two hadrons.
234  StringRegion finalRegion();
235 
236  // Store the hadrons in the normal event record, ordered from one end.
237  void store(Event& event);
238 
239  // Fragment off two of the string legs in to a junction.
240  bool fragmentToJunction(Event& event,
241  vector< vector< pair<double,double> > >& rapPairs);
242 
243  // Initially considered legs from the junction.
244  int legMin, legMid;
245 
246  // Functions used in JRF iterative procedure.
247  bool collinearPair(Event& event);
248  bool perturbedJRF(Event& event);
249  int updateLegs(Event& event, Vec4 vJunIn, bool juncCoM = false);
250  double updateWeights(double pSmall, Vec4 vJunIn);
251  void nextParton(Event& event, int leg);
252 
253  // Join extra nearby partons when stuck.
254  int extraJoin(double facExtra, Event& event);
255 
256  // Get the number of nearby strings given the energies.
257  void kappaEffModifier(StringSystem& systemNow,
258  StringEnd end, vector<int> partonList,
259  vector< vector< pair<double,double> > >& rapPairs,
260  Vec4 pRemNow, Event& event);
261 
262  double yMax(Particle pIn, double mTiny) {
263  double temp = log( ( pIn.e() + abs(pIn.pz()) ) / max( mTiny, pIn.mT()) );
264  return (pIn.pz() > 0) ? temp : -temp; }
265 
266  double yMax(Vec4 pIn, double mTiny) {
267  double mTemp = pIn.m2Calc() + pIn.pT2();
268  mTemp = (mTemp >= 0.) ? sqrt(mTemp) : -sqrt(-mTemp);
269  double temp = log( ( pIn.e() + abs(pIn.pz()) ) / max( mTiny, mTemp) );
270  return (pIn.pz() > 0) ? temp : -temp; }
271 
272 };
273 
274 //==========================================================================
275 
276 } // end namespace Pythia8
277 
278 #endif // Pythia8_StringFragmentation_H
Definition: FragmentationSystems.h:225
void setFlavBeforePT(bool doFlavBeforePTin)
Set order of flavour and pT selection in StringEnd.
Definition: StringFragmentation.h:125
bool flag(string keyIn)
Give back current value, with check that key exists.
Definition: Settings.cc:1613
virtual double aAreaLund()
a and b fragmentation parameters needed in some operations.
Definition: FragmentationFlavZpT.h:254
The Event class holds all info on the generated event.
Definition: Event.h:408
void init(ParticleData *particleDataPtrIn, StringFlav *flavSelPtrIn, StringPT *pTSelPtrIn, StringZ *zSelPtrIn, Settings &settings, bool doFlavBeforePTin=true)
Save pointers.
Definition: StringFragmentation.h:40
Vec4 kinematicsHadron(StringSystem &system, StringVertex &newVertex, double zHadIn)
Definition: StringFragmentation.cc:131
void newHadron(double kappaModifier, bool forbidPopcornNow=false, double strangeJunc=0., double probQQmod=1.)
Fragment off one hadron from the string system, in flavour and pT.
Definition: StringFragmentation.cc:67
void setUp(bool fromPosIn, int iEndIn, int idOldIn, int iMaxIn, double pxIn, double pyIn, double GammaIn, double xPosIn, double xNegIn, int colIn, double mVecRatioIn)
Set up initial endpoint values from input.
Definition: StringFragmentation.cc:39
The StringPT class is used to select select transverse momenta.
Definition: FragmentationFlavZpT.h:284
static const double PT2SAME
Assume two (eX, eY) regions are related if pT2 differs by less.
Definition: StringFragmentation.h:73
StringFlav * flavSelPtr
Pointers to classes for flavour, pT and z generation.
Definition: StringFragmentation.h:79
ParticleData * particleDataPtr
Pointer to the particle data table.
Definition: StringFragmentation.h:76
Definition: StringFragmentation.h:106
Definition: FragmentationSystems.h:186
StringFragmentation()
Constructor.
Definition: StringFragmentation.h:111
Definition: FragmentationSystems.h:136
bool doFlavBeforePT
Data members.
Definition: StringFragmentation.h:87
StringEnd()
Constructor.
Definition: StringFragmentation.h:28
The StringZ class is used to sample the fragmentation function f(z).
Definition: FragmentationFlavZpT.h:219
void updateToPrev()
Update string end information to previous string break.
Definition: StringFragmentation.cc:567
Definition: StringFragmentation.h:23
Vec4 kinematicsHadronTmp(StringSystem system, Vec4 pRem, double phi, double mult)
Definition: StringFragmentation.cc:320
void storePrev()
Store old string end information.
Definition: StringFragmentation.cc:549
Definition: Event.h:32
StringFlav flavSelNow
Local copy of flavSelPtr for modified flavour selection.
Definition: StringFragmentation.h:84
The ColConfig class describes the colour configuration of the whole event.
Definition: FragmentationSystems.h:60
void update()
Update string end information after a hadron has been removed.
Definition: StringFragmentation.cc:531
void setMVecRatio(double mVecRatioIn)
Set the vector mass ratio.
Definition: StringFragmentation.h:144
Definition: Basics.h:254
Definition: FragmentationFlavZpT.h:33
FragmentationModel is the base class for handling fragmentation algorithms.
Definition: FragmentationModel.h:28
double phi(const Vec4 &v1, const Vec4 &v2)
phi is azimuthal angle between v1 and v2 around z axis.
Definition: Basics.cc:703
Header for classes to set beam momentum and interaction vertex spread.
Definition: Analysis.h:20
The StringFlav class is used to select quark and hadron flavours.
Definition: FragmentationFlavZpT.h:76
StringFlav flavSelNow
Local copy of flavSelPtr for modified flavour selection.
Definition: StringFragmentation.h:137
static const double MEANMMIN
Definition: StringFragmentation.h:73
This class holds a map of all ParticleDataEntries.
Definition: ParticleData.h:423
static const double TINY
Constants: could only be changed in the code itself.
Definition: StringFragmentation.h:73
Definition: Basics.h:32
Definition: Settings.h:196