StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Ropewalk.h
1 // Ropewalk.h is a part of the PYTHIA event generator.
2 // Copyright (C) 2018 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 Rope Hadronization. The Ropewalk takes care of setting
7 // up string geometry and calculating overlaps etc. The RopeDipole classes
8 // take care of the dynamics of string shoving. Flavour-composition-changing
9 // ropes are handled by FlavourRope which changes parameters, and RopeFragPars
10 // which calculates parameters for the rope.
11 //
12 // The file contains the following classes: RopeDipoleEnd,
13 // OverlappingRopeDipole, RopeDipole, Ropewalk, RopeFragPars and FlavourRope.
14 
15 #ifndef Pythia8_Ropewalk_H
16 #define Pythia8_Ropewalk_H
17 
18 #include "Pythia8/Basics.h"
19 #include "Pythia8/Event.h"
20 #include "Pythia8/FragmentationSystems.h"
21 #include "Pythia8/Info.h"
22 #include "Pythia8/ParticleData.h"
23 #include "Pythia8/Settings.h"
24 #include "Pythia8/PythiaStdlib.h"
25 
26 namespace Pythia8 {
27 
28 //==================================================================
29 
30 // Define the end of a dipole, containing a pointer to the particle,
31 // and its index in the event record.
32 // Includes some methods for kinematics output.
33 
35 
36 public:
37 
38  // Constructors sets event pointer and event record index.
39  RopeDipoleEnd() : e(NULL), ne(-1) { }
40  RopeDipoleEnd(Event* eIn, int neIn) : e(eIn), ne(neIn) { }
41 
42  // Get a pointer to the particle.
43  Particle* getParticlePtr() { if (!e) return NULL; return &(*e)[ne]; }
44 
45  // Get the particle index in event record.
46  int getNe() {return ne;}
47 
48  // Output methods for (modified) rapidity.
49  double labrap() { return getParticlePtr()->y(); }
50  double rap(double m0){ return getParticlePtr()->y(m0); }
51  double rap(double m0, RotBstMatrix& r) { return getParticlePtr()->y(m0, r); }
52 
53 private:
54 
55  // Pointer to the event and the particle index in event record.
56  Event* e;
57  int ne;
58 
59 };
60 
61 //==================================================================
62 
63 // A dipole has many dipoles overlapping with it. The OverlappingRopeDipole
64 // class does bookkeeping of this. Holds a pointer to the original dipole.
65 
66 // Forward declaration of RopeDipole class.
67 class RopeDipole;
68 
70 
71 public:
72 
73  // Constructor sets up coordinates in the rest frame of other dipole.
75 
76  // Calculate the overlap at given y and b.
77  bool overlap(double y, Vec4 ba, double r0);
78 
79  // Has the dipole been hadronized?
80  bool hadronized();
81 
82 private:
83 
84  // Pointer to the original dipole.
85  RopeDipole* dipole;
86 
87 // Data members are made public rather than making
88 // the RopeDipole class a friend.
89 public:
90 
91  int dir;
92  double y1, y2;
93  Vec4 b1, b2;
94 
95 };
96 
97 //==================================================================
98 
99 // The RopeDipole class holds information about a colour dipole, as well as
100 // functionality to do shoving and to calculate effective string tension.
101 
102 class RopeDipole {
103 
104 public:
105 
106  // The RopeDipole constructor makes sure that d1 is always the colored
107  // end and d2 the anti-colored.
108  RopeDipole(RopeDipoleEnd d1In, RopeDipoleEnd d2In, int iSubIn,
109  Info* infoPtrIn);
110 
111  // Insert an excitation on dipole, if not already there.
112  void addExcitation(double ylab, Particle* ex);
113 
114  // Deep access to the RopeDipoleEnds (needed by OverlappingRopeDipole).
115  RopeDipoleEnd* d1Ptr() { return &d1; }
116  RopeDipoleEnd* d2Ptr() { return &d2; }
117 
118  // Get the rotation matrix to go to dipole rest frame.
119  RotBstMatrix getDipoleRestFrame();
120  RotBstMatrix getDipoleLabFrame();
121 
122  // Get the dipole momentum four-vector.
123  Vec4 dipoleMomentum();
124  // Get the spatial point interpolated to given rapidity.
125  // In the dipole rest frame.
126  Vec4 bInterpolateDip(double y, double m0);
127  // In the lab frame.
128  Vec4 bInterpolateLab(double y, double m0);
129  // Given a Lorentz matrix.
130  Vec4 bInterpolate(double y, RotBstMatrix rb, double m0);
131 
132  // Get the quantum numbers m,n characterizing all dipole overlaps
133  // at a given rapidity value.
134  pair<int, int> getOverlaps(double yfrac, double m0, double r0);
135 
136  // Add an overlapping dipole.
137  void addOverlappingDipole(OverlappingRopeDipole& d) {
138  overlaps.push_back(d); }
139 
140  // Get the maximal and minimal rapidity of the dipole.
141  double maxRapidity(double m0) { return (max(d1.rap(m0), d2.rap(m0))); }
142  double minRapidity(double m0) { return (min(d1.rap(m0), d2.rap(m0))); }
143 
144  // Get the maximal and minimal boosted rapidity of the dipole.
145  double maxRapidity(double m0, RotBstMatrix& r) { return (max(d1.rap(m0,r),
146  d2.rap(m0,r))); }
147  double minRapidity(double m0, RotBstMatrix& r) { return (min(d1.rap(m0,r),
148  d2.rap(m0,r))); }
149 
150  // Propagate the dipole itself.
151  void propagateInit(double deltat);
152 
153  // Propagate both dipole ends as well as all excitations.
154  void propagate(double deltat, double m0);
155 
156  // Redistribute momentum to two particles.
157  void splitMomentum(Vec4 mom, Particle* p1, Particle* p2, double frac = 0.5);
158 
159  // Put gluon excitations on the dipole.
160  void excitationsToString(double m0, Event& event);
161 
162  // Test if the dipole is hadronized.
163  bool hadronized() { return isHadronized; }
164 
165  // Get the (event colconfig) index.
166  int index() { return iSub; }
167 
168  // Recoil the dipole from adding a gluon. If the "dummy" option is set,
169  // the recoil will not be added, but only checked.
170  // Note: the gluon will not actually be added, only the recoil (if possible).
171  bool recoil(Vec4& pg, bool dummy = false);
172 
173  // Set dipole hadronized flag.
174  void hadronized(bool h) { isHadronized = h; }
175 
176  // The number of excitations on the dipole.
177  int nExcitations() { return int(excitations.size()); }
178 
179 private:
180 
181  // The ends (ie. particles) of the dipole.
182  RopeDipoleEnd d1, d2;
183 
184  // The propagated positions in the lab frame.
185  Vec4 b1, b2;
186 
187  // The string index (internal to the event).
188  int iSub;
189 
190  // Lorentz matrices to go to and from dipole rest frame.
191  RotBstMatrix rotFrom, rotTo;
192  bool hasRotFrom, hasRotTo;
193 
194  // The dipoles overlapping with this one.
195  vector<OverlappingRopeDipole> overlaps;
196 
197  // All excitations belonging to this dipole ordered in rapidity in lab frame.
198  map<double, Particle*> excitations;
199 
200  bool isHadronized;
201  Info* infoPtr;
202 
203 };
204 
205 //==================================================================
206 
207 // The Ropewalk class keeps track of all the strings making up ropes
208 // for shoving as well as flavour enhancement.
209 
210 class Ropewalk {
211 
212 public:
213 
214  // Constructor.
215  Ropewalk() {}
216 
217  // The Ropewalk init function sets parameters and pointers.
218  bool init(Info* infoPtrIn, Settings& settings, Rndm* rndmPtrIn);
219 
220  // Extract all dipoles from an event.
221  bool extractDipoles(Event& event, ColConfig& colConfig);
222 
223  // Calculate all overlaps of all dipoles and store as OverlappingRopeDipoles.
224  bool calculateOverlaps();
225 
226  // Calculate the effective string tension a fraction yfrac in on the dipole
227  // given by indices e1 and e2.
228  double getKappaHere(int e1, int e2, double yfrac);
229 
230  // The multiplicity of a colour state given its quantum numbers.
231  double multiplicity(double p, double q) {
232  return ( p < 0 || q < 0 || p + q == 0 )
233  ? 0.0 : 0.5 * (p + 1) * (q + 1) * (p + q + 2);
234  }
235 
236  // Calculate the average string tension of the event, in units of the default
237  // string tension (ie. 1 GeV/fm), using random walk in colour space.
238  double averageKappa();
239 
240  // Invoke the random walk and select a state.
241  pair<int, int> select(int m, int n, Rndm* rndm);
242 
243  // Shove all dipoles in the event.
244  void shoveTheDipoles(Event& event);
245 
246 private:
247 
248  // Parameters of the ropewalk.
249  double r0, m0, pTcut;
250  // Do shoving flag.
251  bool doShoving;
252  // Include junction strings in shoving.
253  bool shoveJunctionStrings;
254  // Include ministrings in shoving.
255  bool shoveMiniStrings;
256  // Include gluon loops in shoving.
257  bool shoveGluonLoops;
258  // Limit between string frag and ministring.
259  double mStringMin;
260  // Limit participating dipoles by their momentum.
261  bool limitMom;
262  // Radius cutoff in multiples of r0.
263  double rCutOff;
264  // Parameters of the shoving.
265  double gAmplitude, gExponent;
266  // Rapidity slicing.
267  double deltay;
268  // Time steps.
269  double deltat;
270  // Shove time.
271  double tShove;
272  // Intial propagation time.
273  double tInit;
274  // Final state shower cut-off.
275  double showerCut;
276  // Assume we are always in highest multiplet.
277  bool alwaysHighest;
278 
279  // Info pointer.
280  Info* infoPtr;
281 
282  // Pointer the the random number generator.
283  Rndm* rndmPtr;
284 
285  // All dipoles in the event sorted by event record.
286  // Index of the two partons.
287  typedef multimap<pair<int,int>, RopeDipole> DMap;
288  DMap dipoles;
289 
290  // All excitations.
291  vector< vector<Particle> > eParticles;
292 
293  // Random walk states and their weights.
294  vector<pair<int, int> > states;
295  vector<double> weights;
296 
297  // Private assignment operator.
298  Ropewalk& operator=(const Ropewalk);
299 
300 };
301 
302 //==================================================================
303 
304 // RopeFragPars recalculates fragmentation parameters according to a
305 // changed string tension. Helper class to FlavourRope.
306 
308 
309 public:
310 
311  // Constructor.
312  RopeFragPars() {}
313 
314  // The init function sets up initial parameters from settings.
315  void init(Info* infoPtrIn, Settings& settings);
316 
317  // Return parameters at given string tension, ordered by their
318  // name for easy insertion in settings.
319  map<string,double> getEffectiveParameters(double h);
320 
321 private:
322 
323  // Constants: can only be changed in the code itself.
324  static const double DELTAA, ACONV, ZCUT;
325 
326  // Get the Fragmentation function a parameter from cache or calculate it.
327  double getEffectiveA(double thisb, double mT2, bool isDiquark);
328 
329  // Calculate the effective parameters.
330  bool calculateEffectiveParameters(double h);
331 
332  // Insert calculated parameters in cache for later (re-)use.
333  bool insertEffectiveParameters(double h);
334 
335  // Calculate the a parameter.
336  double aEffective(double aOrig, double thisb, double mT2);
337 
338  // The Lund fragmentation function.
339  double fragf(double z, double a, double b, double mT2);
340 
341  // Integral of the Lund fragmentation function with given parameter values.
342  double integrateFragFun(double a, double b, double mT2);
343 
344  // Helper function for integration.
345  double trapIntegrate(double a, double b, double mT2, double sOld, int n);
346 
347  // The info pointer.
348  Info* infoPtr;
349 
350  // Parameter caches to re-use calculations. Sets of parameters, ordered in h.
351  map<double, map<string, double> > parameters;
352 
353  // Values of the a-parameter ordered in b*mT2 grid.
354  map<double, double> aMap;
355 
356  // The same for aDiquark.
357  map<double, double> aDiqMap;
358 
359  // Initial values of parameters.
360  double aIn, adiqIn, bIn, rhoIn, xIn, yIn, xiIn, sigmaIn, kappaIn;
361 
362  // Effective values of parameters.
363  double aEff, adiqEff, bEff, rhoEff, xEff, yEff, xiEff, sigmaEff, kappaEff;
364 
365  // Junction parameter.
366  double beta;
367 
368 };
369 
370 //==================================================================
371 
372 // The FlavourRope class takes care of placing a string breakup in
373 // the event, and assigning the string breakup effective parameters.
374 // It is a UserHooks derived class, and one must make sure to add it
375 // to the UserHooksVector in the main program or somewhere else.
376 
377 class FlavourRope {
378 
379 public:
380 
381  // Constructor.
382  FlavourRope() {}
383 
384  // Initialize. Set pointers.
385  void init(Settings* settingsPtrIn, Rndm* rndmPtrIn, ParticleData*
386  particleDataPtrIn, Info* infoPtrIn, Ropewalk* rwPtrIn) {
387  settingsPtr = settingsPtrIn, rndmPtr = rndmPtrIn,
388  particleDataPtr = particleDataPtrIn, infoPtr = infoPtrIn,
389  rwPtr = rwPtrIn;
390  // Initialize event pointer such that it can be tested.
391  ePtr = NULL;
392  h = settingsPtr->parm("Ropewalk:presetKappa");
393  fixedKappa = settingsPtr->flag("Ropewalk:setFixedKappa");
394  doBuffon = settingsPtr->flag("Ropewalk:doBuffon");
395  rapiditySpan = settingsPtr->parm("Ropewalk:rapiditySpan");
396  stringProtonRatio = settingsPtr->parm("Ropewalk:stringProtonRatio");
397  // Initialize FragPar.
398  fp.init(infoPtr, *settingsPtr);
399  }
400 
401  // Change the fragmentation parameters.
402  bool doChangeFragPar(StringFlav* flavPtr, StringZ* zPtr,
403  StringPT * pTPtr, double m2Had, vector<int> iParton, int endId);
404 
405  // Set enhancement manually.
406  void setEnhancement(double hIn) { h = hIn;}
407 
408  // Set pointer to the event.
409  void setEventPtr(Event& event) { ePtr = &event;}
410 
411 private:
412 
413  // Find breakup placement and fetch effective parameters.
414  // For model depending on vertex information.
415  map<string, double> fetchParameters(double m2Had, vector<int> iParton,
416  int endId);
417  // For simple Buffon model.
418  map<string, double> fetchParametersBuffon(double m2Had, vector<int> iParton,
419  int endId);
420 
421  // Pointer to settings.
422  Settings* settingsPtr;
423 
424  // Random number generator needed for reinitialization.
425  Rndm* rndmPtr;
426 
427  // Particle data object needed for reinitialization.
428  ParticleData* particleDataPtr;
429 
430  // Pythia info pointer.
431  Info* infoPtr;
432 
433  // Pointer to the ropewalk object.
434  Ropewalk* rwPtr;
435 
436  // Pointer to the event.
437  Event* ePtr;
438 
439  // The object which handles change in parameters.
440  RopeFragPars fp;
441 
442  // Use Buffon prescription without vertex information.
443  bool doBuffon;
444 
445  // Parameters of Buffon prescription
446  double rapiditySpan, stringProtonRatio;
447 
448  // Keep track of hadronized dipoles in Buffon prescription.
449  vector<int> hadronized;
450 
451  // Use preset kappa from settings.
452  bool fixedKappa;
453 
454  // Locally stored string tension.
455  double h;
456 
457 };
458 
459 //==========================================================================
460 
461 } // end namespace Pythia8
462 
463 #endif // Pythia8_Ropewalk_H
Definition: rb.hh:21