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