PYTHIA  8.312
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(const Vec4& p0, const Vec4& p1, const Vec4& p2,
148  const bool angleCheck = true) const;
149 
150 private:
151 
152  // Constants: could only be changed in the code itself.
153  static const int NTRYFLAV, NTRYJOIN, NSTOPMASS,
154  NTRYJNMATCH, NTRYJRFEQ, NTRYSMEAR;
155  static const double FACSTOPMASS, CLOSEDM2MAX, CLOSEDM2FRAC, EXPMAX,
156  MATCHPOSNEG, M2MINJRF, EMINJRF, EEXTRAJNMATCH,
157  MDIQUARKMIN, CONVJRFEQ, CHECKPOS;
158 
159  // Pointers to classes for flavour, pT and z generation.
161  StringPT* pTSelPtr;
162  StringZ* zSelPtr;
163 
164  // Pointer to flavour-composition-changing ropes.
165  FragModPtr flavRopePtr;
166 
167  // Initialization data, read from Settings.
168  bool closePacking, setVertices, constantTau, smearOn,
169  traceColours, hardRemn, gluonPearl, strangeJunc;
170  int hadronVertex;
171  double stopMass, stopNewFlav, stopSmear, pNormJunction, pMaxJunction,
172  eBothLeftJunction, eMaxLeftJunction, eMinLeftJunction,
173  mJoin, bLund, closePackingTension, closePackingTensionRatio,
174  closePackingPT20, qqFacP, qqFacQ, pT20, xySmear, maxSmear, maxTau,
175  kappaVtx, mc, mb, dampPopcorn, aRemn, bRemn, pearlFac,
176  strangeParm, strangePearl;
177 
178  // Data members.
179  bool hasJunction, isClosed;
180  int iPos, iNeg, nExtraJoin;
181  double w2Rem, stopMassNow, kappaRatio, probQQmod;
182  Vec4 pSum, pRem, pJunctionHadrons;
183 
184  // List of partons in string system.
185  vector<int> iParton, iPartonMinLeg, iPartonMidLeg, iPartonMax;
186 
187  // Vertex information from the fragmentation process.
188  vector<StringVertex> stringVertices, legMinVertices, legMidVertices;
189  StringVertex newVertex;
190 
191  // Variables used for JRF finding.
192  vector<Vec4> listJRF;
193  vector<double> weightJRF;
194  int iLeg[3], idLeg[3], legEnd[3];
195  double weightSum, pSumJRF, m2Leg[3];
196  Vec4 pLeg[3];
197  bool lastJRF, endpoint[3];
198 
199  // Variables used for pearl fragmentation.
200  bool pearlFrag;
201  Vec4 gPearl, pPearl;
202  int idPearl, legPearl;
203  double vPearl, eCutoff;
204 
205  // Boost from/to rest frame of a junction to original frame.
206  RotBstMatrix MfromJRF, MtoJRF;
207 
208  // Information on diquark created at the junction.
209  int idDiquark;
210 
211  // Fictitious opposing partons in JRF: string ends for vertex location.
212  Vec4 pMinEnd, pMidEnd;
213 
214  // Temporary event record for the produced particles.
215  Event hadrons;
216 
217  // Information on the system of string regions.
218  StringSystem system, systemMin, systemMid;
219 
220  // Information on the two current endpoints of the fragmenting system.
221  StringEnd posEnd, negEnd;
222 
223  // Find region where to put first string break for closed gluon loop.
224  vector<int> findFirstRegion(int iSub, const ColConfig& colConfig,
225  const Event& event) const;
226 
227  // Set flavours and momentum position for initial string endpoints.
228  void setStartEnds(int idPos, int idNeg, const StringSystem& systemNow,
229  int legNow = 3);
230 
231  // Check remaining energy-momentum whether it is OK to continue.
232  bool energyUsedUp(bool fromPos);
233 
234  // Produce the final two partons to complete the system.
235  bool finalTwo(bool fromPos, const Event& event, bool usedPosJun,
236  bool usedNegJun, bool usedPearlIn, Vec4 pPearlIn);
237 
238  // Final region information.
239  Vec4 pPosFinalReg, pNegFinalReg, eXFinalReg, eYFinalReg;
240 
241  // Set hadron production points in space-time picture.
242  bool setHadronVertices(Event& event);
243 
244  // Construct a special joining region for the final two hadrons.
245  StringRegion finalRegion();
246 
247  // Store the hadrons in the normal event record, ordered from one end.
248  void store(Event& event);
249 
250  // Fragment off two of the string legs in to a junction.
251  bool fragmentToJunction(Event& event,
252  vector< vector< pair<double,double> > >& rapPairs);
253 
254  // Initially considered legs from the junction.
255  int legMin, legMid;
256 
257  // Functions used in JRF iterative procedure.
258  bool collinearPair(Event& event);
259  bool perturbedJRF(Event& event);
260  int updateLegs(Event& event, Vec4 vJunIn, bool juncCoM = false);
261  double updateWeights(double pSmall, Vec4 vJunIn);
262  bool pearlOnAString(Event& event, int iMin);
263  void nextParton(Event& event, int leg);
264 
265  // Join extra nearby partons when stuck.
266  int extraJoin(double facExtra, Event& event);
267 
268  // Get the number of nearby strings given the energies.
269  void kappaEffRatio(StringSystem& systemNow,
270  StringEnd end, bool fromPos, vector<int> partonList,
271  vector< vector< pair<double,double> > >& rapPairs,
272  double mRem, Event& event);
273 
274  double yMax(Particle pIn, double mTiny) {
275  double temp = log( ( pIn.e() + abs(pIn.pz()) ) / max( mTiny, pIn.mT()) );
276  return (pIn.pz() > 0) ? temp : -temp; }
277 
278 };
279 
280 //==========================================================================
281 
282 } // end namespace Pythia8
283 
284 #endif // Pythia8_StringFragmentation_H
Definition: FragmentationSystems.h:223
bool flag(string keyIn)
Give back current value, with check that key exists.
Definition: Settings.cc:1478
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:252
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:693
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