StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
HadronLevel.cc
1 // HadronLevel.cc is a part of the PYTHIA event generator.
2 // Copyright (C) 2014 Torbjorn Sjostrand.
3 // PYTHIA is licenced under the GNU GPL version 2, see COPYING for details.
4 // Please respect the MCnet Guidelines, see GUIDELINES for details.
5 
6 // Function definitions (not found in the header) for the HadronLevel class.
7 
8 #include "Pythia8/HadronLevel.h"
9 
10 namespace Pythia8 {
11 
12 //==========================================================================
13 
14 // The HadronLevel class.
15 
16 //--------------------------------------------------------------------------
17 
18 // Constants: could be changed here if desired, but normally should not.
19 // These are of technical nature, as described for each.
20 
21 // For breaking J-J string, pick a Gamma by taking a step with fictitious mass.
22 const double HadronLevel::JJSTRINGM2MAX = 25.;
23 const double HadronLevel::JJSTRINGM2FRAC = 0.1;
24 
25 // Iterate junction rest frame boost until convergence or too many tries.
26 const double HadronLevel::CONVJNREST = 1e-5;
27 const int HadronLevel::NTRYJNREST = 20;
28 
29 // Typical average transvere primary hadron mass <mThad>.
30 const double HadronLevel::MTHAD = 0.9;
31 
32 //--------------------------------------------------------------------------
33 
34 // Find settings. Initialize HadronLevel classes as required.
35 
36 bool HadronLevel::init(Info* infoPtrIn, Settings& settings,
37  ParticleData* particleDataPtrIn, Rndm* rndmPtrIn,
38  Couplings* couplingsPtrIn, TimeShower* timesDecPtr,
39  RHadrons* rHadronsPtrIn, DecayHandler* decayHandlePtr,
40  vector<int> handledParticles) {
41 
42  // Save pointers.
43  infoPtr = infoPtrIn;
44  particleDataPtr = particleDataPtrIn;
45  rndmPtr = rndmPtrIn;
46  couplingsPtr = couplingsPtrIn;
47  rHadronsPtr = rHadronsPtrIn;
48 
49  // Main flags.
50  doHadronize = settings.flag("HadronLevel:Hadronize");
51  doDecay = settings.flag("HadronLevel:Decay");
52  doBoseEinstein = settings.flag("HadronLevel:BoseEinstein");
53 
54  // Boundary mass between string and ministring handling.
55  mStringMin = settings.parm("HadronLevel:mStringMin");
56 
57  // For junction processing.
58  eNormJunction = settings.parm("StringFragmentation:eNormJunction");
59 
60  // Allow R-hadron formation.
61  allowRH = settings.flag("RHadrons:allow");
62 
63  // Particles that should decay or not before Bose-Einstein stage.
64  widthSepBE = settings.parm("BoseEinstein:widthSep");
65 
66  // Hadron scattering --rjc
67  doHadronScatter = settings.flag("HadronScatter:scatter");
68  hsAfterDecay = settings.flag("HadronScatter:afterDecay");
69 
70  // Initialize auxiliary fragmentation classes.
71  flavSel.init(settings, rndmPtr);
72  pTSel.init(settings, *particleDataPtr, rndmPtr);
73  zSel.init(settings, *particleDataPtr, rndmPtr);
74 
75  // Initialize auxiliary administrative class.
76  colConfig.init(infoPtr, settings, &flavSel);
77 
78  // Initialize string and ministring fragmentation.
79  stringFrag.init(infoPtr, settings, particleDataPtr, rndmPtr,
80  &flavSel, &pTSel, &zSel);
81  ministringFrag.init(infoPtr, settings, particleDataPtr, rndmPtr,
82  &flavSel, &pTSel, &zSel);
83 
84  // Initialize particle decays.
85  decays.init(infoPtr, settings, particleDataPtr, rndmPtr, couplingsPtr,
86  timesDecPtr, &flavSel, decayHandlePtr, handledParticles);
87 
88  // Initialize BoseEinstein.
89  boseEinstein.init(infoPtr, settings, *particleDataPtr);
90 
91  // Initialize HadronScatter --rjc
92  if (doHadronScatter)
93  hadronScatter.init(infoPtr, settings, rndmPtr, particleDataPtr);
94 
95  // Initialize Hidden-Valley fragmentation, if necessary.
96  useHiddenValley = hiddenvalleyFrag.init(infoPtr, settings,
97  particleDataPtr, rndmPtr);
98 
99  // Send flavour and z selection pointers to R-hadron machinery.
100  rHadronsPtr->fragPtrs( &flavSel, &zSel);
101 
102  // Done.
103  return true;
104 
105 }
106 
107 //--------------------------------------------------------------------------
108 
109 // Hadronize and decay the next parton-level.
110 
111 bool HadronLevel::next( Event& event) {
112 
113  // Do Hidden-Valley fragmentation, if necessary.
114  if (useHiddenValley) hiddenvalleyFrag.fragment(event);
115 
116  // Colour-octet onia states must be decayed to singlet + gluon.
117  if (!decayOctetOnia(event)) return false;
118 
119  // Possibility of hadronization inside decay, but then no BE second time.
120  // Hadron scattering, first pass only --rjc
121  bool moreToDo, firstPass = true;
122  bool doBoseEinsteinNow = doBoseEinstein;
123  do {
124  moreToDo = false;
125 
126  // First part: string fragmentation.
127  if (doHadronize) {
128 
129  // Find the complete colour singlet configuration of the event.
130  if (!findSinglets( event)) return false;
131 
132  // Fragment off R-hadrons, if necessary.
133  if (allowRH && !rHadronsPtr->produce( colConfig, event))
134  return false;
135 
136  // Process all colour singlet (sub)systems.
137  for (int iSub = 0; iSub < colConfig.size(); ++iSub) {
138 
139  // Collect sequentially all partons in a colour singlet subsystem.
140  colConfig.collect(iSub, event);
141 
142  // String fragmentation of each colour singlet (sub)system.
143  if ( colConfig[iSub].massExcess > mStringMin ) {
144  if (!stringFrag.fragment( iSub, colConfig, event)) return false;
145 
146  // Low-mass string treated separately. Tell if diffractive system.
147  } else {
148  bool isDiff = infoPtr->isDiffractiveA()
149  || infoPtr->isDiffractiveB();
150  if (!ministringFrag.fragment( iSub, colConfig, event, isDiff))
151  return false;
152  }
153  }
154  }
155 
156  // Hadron scattering --rjc
157  if (doHadronScatter && !hsAfterDecay && firstPass)
158  hadronScatter.scatter(event);
159 
160  // Second part: sequential decays of short-lived particles (incl. K0).
161  if (doDecay) {
162 
163  // Loop through all entries to find those that should decay.
164  int iDec = 0;
165  do {
166  Particle& decayer = event[iDec];
167  if ( decayer.isFinal() && decayer.canDecay() && decayer.mayDecay()
168  && (decayer.mWidth() > widthSepBE || decayer.idAbs() == 311) ) {
169  decays.decay( iDec, event);
170  if (decays.moreToDo()) moreToDo = true;
171  }
172  } while (++iDec < event.size());
173  }
174 
175  // Hadron scattering --rjc
176  if (doHadronScatter && hsAfterDecay && firstPass)
177  hadronScatter.scatter(event);
178 
179  // Third part: include Bose-Einstein effects among current particles.
180  if (doBoseEinsteinNow) {
181  if (!boseEinstein.shiftEvent(event)) return false;
182  doBoseEinsteinNow = false;
183  }
184 
185  // Fourth part: sequential decays also of long-lived particles.
186  if (doDecay) {
187 
188  // Loop through all entries to find those that should decay.
189  int iDec = 0;
190  do {
191  Particle& decayer = event[iDec];
192  if ( decayer.isFinal() && decayer.canDecay() && decayer.mayDecay() ) {
193  decays.decay( iDec, event);
194  if (decays.moreToDo()) moreToDo = true;
195  }
196  } while (++iDec < event.size());
197  }
198 
199  // Normally done first time around, but sometimes not (e.g. Upsilon).
200  } while (moreToDo);
201 
202  // Done.
203  return true;
204 
205 }
206 
207 //--------------------------------------------------------------------------
208 
209 // Allow more decays if on/off switches changed.
210 // Note: does not do sequential hadronization, e.g. for Upsilon.
211 
212 bool HadronLevel::moreDecays( Event& event) {
213 
214  // Colour-octet onia states must be decayed to singlet + gluon.
215  if (!decayOctetOnia(event)) return false;
216 
217  // Loop through all entries to find those that should decay.
218  int iDec = 0;
219  do {
220  if ( event[iDec].isFinal() && event[iDec].canDecay()
221  && event[iDec].mayDecay() ) decays.decay( iDec, event);
222  } while (++iDec < event.size());
223 
224  // Done.
225  return true;
226 
227 }
228 
229 //--------------------------------------------------------------------------
230 
231 // Decay colour-octet onium states.
232 
233 bool HadronLevel::decayOctetOnia(Event& event) {
234 
235  // Loop over particles and decay any onia encountered.
236  for (int iDec = 0; iDec < event.size(); ++iDec)
237  if (event[iDec].isFinal()
238  && particleDataPtr->isOctetHadron(event[iDec].id())) {
239  if (!decays.decay( iDec, event)) return false;
240 
241  // Set colour flow by hand: gluon inherits octet-onium state.
242  int iGlu = event.size() - 1;
243  event[iGlu].cols( event[iDec].col(), event[iDec].acol() );
244  }
245 
246  // Done.
247  return true;
248 
249 }
250 
251 //--------------------------------------------------------------------------
252 
253 // Trace colour flow in the event to form colour singlet subsystems.
254 
255 bool HadronLevel::findSinglets(Event& event) {
256 
257  // Find a list of final partons and of all colour ends and gluons.
258  iColEnd.resize(0);
259  iAcolEnd.resize(0);
260  iColAndAcol.resize(0);
261  for (int i = 0; i < event.size(); ++i) if (event[i].isFinal()) {
262  if (event[i].col() > 0 && event[i].acol() > 0) iColAndAcol.push_back(i);
263  else if (event[i].col() > 0) iColEnd.push_back(i);
264  else if (event[i].acol() > 0) iAcolEnd.push_back(i);
265  }
266 
267  // Begin arrange the partons into separate colour singlets.
268  colConfig.clear();
269  iPartonJun.resize(0);
270  iPartonAntiJun.resize(0);
271 
272  // No need to do anything if no final partons.
273  if (iColEnd.size() == 0 && iAcolEnd.size() == 0
274  && iColAndAcol.size() == 0) return true;
275 
276  // Junctions: loop over them, and identify kind.
277  for (int iJun = 0; iJun < event.sizeJunction(); ++iJun)
278  if (event.remainsJunction(iJun)) {
279  event.remainsJunction(iJun, false);
280  int kindJun = event.kindJunction(iJun);
281  iParton.resize(0);
282 
283  // Loop over junction legs.
284  for (int iCol = 0; iCol < 3; ++iCol) {
285  int indxCol = event.colJunction(iJun, iCol);
286  iParton.push_back( -(10 + 10 * iJun + iCol) );
287  // Junctions: find color ends.
288  if (kindJun % 2 == 1 && !traceFromAcol(indxCol, event, iJun, iCol))
289  return false;
290  // Antijunctions: find anticolor ends.
291  if (kindJun % 2 == 0 && !traceFromCol(indxCol, event, iJun, iCol))
292  return false;
293  }
294 
295  // Reject triple- and higher-junction systems (physics not implemented).
296  int otherJun = 0;
297  for (int i = 0; i < int(iParton.size()); ++i)
298  if (iParton[i] < 0 && abs(iParton[i]) / 10 != iJun + 1) {
299  if (otherJun == 0) otherJun = abs(iParton[i]) / 10;
300  else if (abs(iParton[i]) / 10 != otherJun) {
301  infoPtr->errorMsg("Error in HadronLevel::findSinglets: "
302  "too many junction-junction connections");
303  return false;
304  }
305  }
306 
307  // Keep in memory a junction hooked up with an antijunction,
308  // else store found single-junction system.
309  int nNeg = 0;
310  for (int i = 0; i < int(iParton.size()); ++i) if (iParton[i] < 0)
311  ++nNeg;
312  if (nNeg > 3 && kindJun % 2 == 1) {
313  iPartonJun.push_back(iParton);
314  } else if (nNeg > 3 && kindJun % 2 == 0) {
315  iPartonAntiJun.push_back(iParton);
316  } else {
317  // A junction may be eliminated by insert if two quarks are nearby.
318  int nJunOld = event.sizeJunction();
319  if (!colConfig.insert(iParton, event)) return false;
320  if (event.sizeJunction() < nJunOld) {
321 
322  // Update previously stored numbers.
323  for (int i = 0;i < int(iPartonJun.size());++i)
324  for (int j = 0;j < int(iPartonJun[i].size()); ++j)
325  if (iPartonJun[i][j] < -(10 + 10 * iJun)) iPartonJun[i][j] += 10;
326  for (int i = 0;i < int(iPartonAntiJun.size());++i)
327  for (int j = 0;j < int(iPartonAntiJun[i].size()); ++j)
328  if (iPartonAntiJun[i][j] < -(10 + 10 * iJun))
329  iPartonAntiJun[i][j] += 10;
330 
331  // One junction was removed.
332  --iJun;
333  }
334  }
335  }
336 
337  // Split junction-antijunction system into two, and store those.
338  // (Only one system in extreme cases, and then second empty.)
339  if (iPartonJun.size() > 0 && iPartonAntiJun.size() > 0) {
340  if (!splitJunctionPair(event)) return false;
341  for (int i = 0; i < int(iPartonJun.size()); ++i)
342  if (iPartonJun[i].size() > 0)
343  if (!colConfig.insert(iPartonJun[i], event)) return false;
344 
345  for (int i = 0; i < int(iPartonAntiJun.size()); ++i)
346  if (iPartonAntiJun[i].size() > 0)
347  if (!colConfig.insert(iPartonAntiJun[i], event)) return false;
348  }
349 
350  // Error if not same number of junctions and antijuctions left here.
351  if ( iPartonJun.size() != iPartonAntiJun.size() ) {
352  infoPtr->errorMsg("Error in HadronLevel::findSinglets: "
353  "unmatched (anti)junction");
354  return false;
355  }
356 
357  // Open strings: pick up each colour end and trace to its anticolor end.
358  for (int iEnd = 0; iEnd < int(iColEnd.size()); ++iEnd) {
359  iParton.resize(0);
360  iParton.push_back( iColEnd[iEnd] );
361  int indxCol = event[ iColEnd[iEnd] ].col();
362  if (!traceFromCol(indxCol, event)) return false;
363 
364  // Store found open string system. Analyze its properties.
365  if (!colConfig.insert(iParton, event)) return false;
366  }
367 
368  // Closed strings : begin at any gluon and trace until back at it.
369  while (iColAndAcol.size() > 0) {
370  iParton.resize(0);
371  iParton.push_back( iColAndAcol[0] );
372  int indxCol = event[ iColAndAcol[0] ].col();
373  int indxAcol = event[ iColAndAcol[0] ].acol();
374  iColAndAcol[0] = iColAndAcol.back();
375  iColAndAcol.pop_back();
376  if (!traceInLoop(indxCol, indxAcol, event)) return false;
377 
378  // Store found closed string system. Analyze its properties.
379  if (!colConfig.insert(iParton, event)) return false;
380  }
381 
382  // Done.
383  return true;
384 
385 }
386 
387 //--------------------------------------------------------------------------
388 
389 // Trace a colour line, from a colour to an anticolour.
390 
391 bool HadronLevel::traceFromCol(int indxCol, Event& event, int iJun,
392  int iCol) {
393 
394  // Junction kind, if any.
395  int kindJun = (iJun >= 0) ? event.kindJunction(iJun) : 0;
396 
397  // Begin to look for a matching anticolour.
398  int loop = 0;
399  int loopMax = iColAndAcol.size() + 2;
400  bool hasFound = false;
401  do {
402  ++loop;
403  hasFound= false;
404 
405  // First check list of matching anticolour ends.
406  for (int i = 0; i < int(iAcolEnd.size()); ++i)
407  if (event[ iAcolEnd[i] ].acol() == indxCol) {
408  iParton.push_back( iAcolEnd[i] );
409  indxCol = 0;
410  iAcolEnd[i] = iAcolEnd.back();
411  iAcolEnd.pop_back();
412  hasFound = true;
413  break;
414  }
415 
416  // Then check list of intermediate gluons.
417  if (!hasFound)
418  for (int i = 0; i < int(iColAndAcol.size()); ++i)
419  if (event[ iColAndAcol[i] ].acol() == indxCol) {
420  iParton.push_back( iColAndAcol[i] );
421 
422  // Update to new colour. Remove gluon.
423  indxCol = event[ iColAndAcol[i] ].col();
424  if (kindJun > 0) event.endColJunction(iJun, iCol, indxCol);
425  iColAndAcol[i] = iColAndAcol.back();
426  iColAndAcol.pop_back();
427  hasFound = true;
428  break;
429  }
430 
431  // Check opposite-sign junction colours.
432  if (!hasFound)
433  for (int iAntiJun = 0; iAntiJun < event.sizeJunction(); ++iAntiJun)
434  if (iAntiJun != iJun && event.kindJunction(iAntiJun) %2 == 1)
435  for (int iColAnti = 0; iColAnti < 3; ++iColAnti)
436  if (event.colJunction(iAntiJun, iColAnti) == indxCol) {
437  iParton.push_back( -(10 + 10 * iAntiJun + iColAnti) );
438  indxCol = 0;
439  hasFound = true;
440  break;
441  }
442 
443  // In a pinch, check list of opposite-sign junction end colours.
444  // Store in iParton list as -(10 + 10 * iAntiJun + iAntiLeg).
445  if (!hasFound && kindJun % 2 == 0 && event.sizeJunction() > 1)
446  for (int iAntiJun = 0; iAntiJun < event.sizeJunction(); ++iAntiJun)
447  if (iAntiJun != iJun && event.kindJunction(iAntiJun) %2 == 1)
448  for (int iColAnti = 0; iColAnti < 3; ++iColAnti)
449  if (event.endColJunction(iAntiJun, iColAnti) == indxCol) {
450  iParton.push_back( -(10 + 10 * iAntiJun + iColAnti) );
451  indxCol = 0;
452  hasFound = true;
453  break;
454  }
455 
456  // Keep on tracing via gluons until reached end of leg.
457  } while (hasFound && indxCol > 0 && loop < loopMax);
458 
459  // Something went wrong in colour tracing.
460  if (!hasFound || loop == loopMax) {
461  infoPtr->errorMsg("Error in HadronLevel::traceFromCol: "
462  "colour tracing failed");
463  return false;
464  }
465 
466  // Done.
467  return true;
468 
469 }
470 
471 //--------------------------------------------------------------------------
472 
473 // Trace a colour line, from an anticolour to a colour.
474 
475 bool HadronLevel::traceFromAcol(int indxCol, Event& event, int iJun,
476  int iCol) {
477 
478  // Junction kind, if any.
479  int kindJun = (iJun >= 0) ? event.kindJunction(iJun) : 0;
480 
481  // Begin to look for a matching colour.
482  int loop = 0;
483  int loopMax = iColAndAcol.size() + 2;
484  bool hasFound = false;
485  do {
486  ++loop;
487  hasFound= false;
488 
489  // First check list of matching colour ends.
490  for (int i = 0; i < int(iColEnd.size()); ++i)
491  if (event[ iColEnd[i] ].col() == indxCol) {
492  iParton.push_back( iColEnd[i] );
493  indxCol = 0;
494  iColEnd[i] = iColEnd.back();
495  iColEnd.pop_back();
496  hasFound = true;
497  break;
498  }
499 
500  // Then check list of intermediate gluons.
501  if (!hasFound)
502  for (int i = 0; i < int(iColAndAcol.size()); ++i)
503  if (event[ iColAndAcol[i] ].col() == indxCol) {
504  iParton.push_back( iColAndAcol[i] );
505  // Update to new colour. Remove gluon.
506  indxCol = event[ iColAndAcol[i] ].acol();
507  if (kindJun > 0) event.endColJunction(iJun, iCol, indxCol);
508  iColAndAcol[i] = iColAndAcol.back();
509  iColAndAcol.pop_back();
510  hasFound = true;
511  break;
512  }
513 
514  // Check opposite-sign junction colours.
515  if (!hasFound)
516  for (int iAntiJun = 0; iAntiJun < event.sizeJunction(); ++iAntiJun)
517  if (iAntiJun != iJun && event.kindJunction(iAntiJun) % 2 == 0)
518  for (int iColAnti = 0; iColAnti < 3; ++iColAnti)
519  if (event.colJunction(iAntiJun, iColAnti) == indxCol) {
520  iParton.push_back( -(10 + 10 * iAntiJun + iColAnti) );
521  indxCol = 0;
522  hasFound = true;
523  break;
524  }
525 
526  // In a pinch, check list of opposite-sign junction end colours.
527  // Store in iParton list as -(10 + 10 * iAntiJun + iLeg).
528  if (!hasFound && kindJun % 2 == 1 && event.sizeJunction() > 1)
529  for (int iAntiJun = 0; iAntiJun < event.sizeJunction(); ++iAntiJun)
530  if (iAntiJun != iJun && event.kindJunction(iAntiJun) % 2 == 0)
531  for (int iColAnti = 0; iColAnti < 3; ++iColAnti)
532  if (event.endColJunction(iAntiJun, iColAnti) == indxCol) {
533  iParton.push_back( -(10 + 10 * iAntiJun + iColAnti) );
534  indxCol = 0;
535  hasFound = true;
536  break;
537  }
538 
539  // Keep on tracing via gluons until reached end of leg.
540  } while (hasFound && indxCol > 0 && loop < loopMax);
541 
542  // Something went wrong in colour tracing.
543  if (!hasFound || loop == loopMax) {
544  infoPtr->errorMsg("Error in HadronLevel::traceFromAcol: "
545  "colour tracing failed");
546  return false;
547  }
548 
549  // Done.
550  return true;
551 
552 }
553 
554 //--------------------------------------------------------------------------
555 
556 // Trace a colour loop, from a colour back to the anticolour of the same.
557 
558 bool HadronLevel::traceInLoop(int indxCol, int indxAcol, Event& event) {
559 
560  // Move around until back where begun.
561  int loop = 0;
562  int loopMax = iColAndAcol.size() + 2;
563  bool hasFound = false;
564  do {
565  ++loop;
566  hasFound= false;
567 
568  // Check list of gluons.
569  for (int i = 0; i < int(iColAndAcol.size()); ++i)
570  if (event[ iColAndAcol[i] ].acol() == indxCol) {
571  iParton.push_back( iColAndAcol[i] );
572  indxCol = event[ iColAndAcol[i] ].col();
573  iColAndAcol[i] = iColAndAcol.back();
574  iColAndAcol.pop_back();
575  hasFound = true;
576  break;
577  }
578  } while (hasFound && indxCol != indxAcol && loop < loopMax);
579 
580  // Something went wrong in colour tracing.
581  if (!hasFound || loop == loopMax) {
582  infoPtr->errorMsg("Error in HadronLevel::traceInLoop: "
583  "colour tracing failed");
584  return false;
585  }
586 
587  // Done.
588  return true;
589 
590 }
591 
592 //--------------------------------------------------------------------------
593 
594 // Split junction-antijunction system into two, or simplify other way.
595 
596 bool HadronLevel::splitJunctionPair(Event& event) {
597 
598  for(int iJun = 0;iJun < int(iPartonJun.size());++iJun) {
599  int identJun = (-iPartonJun[iJun][0])/10;
600 
601  // Find the connected anti junctions.
602  int identAntiJun = 500;
603  for (int i = 0;i < int(iPartonJun[iJun].size()); ++i) {
604  if (iPartonJun[iJun][i] < 0 && (-iPartonJun[iJun][i])/10 != identJun) {
605  identAntiJun = (-iPartonJun[iJun][i])/10;
606  break;
607  }
608  }
609  int iAntiJun = -1;
610  for (int i = 0; i < int(iPartonAntiJun.size());i++)
611  if ( (-iPartonAntiJun[i][0])/10 == identAntiJun) {
612  iAntiJun = i;
613  break;
614  }
615  // If no anti junction found, something went wrong earlier.
616  if(iAntiJun == -1)
617  return false;
618 
619  // Construct separate index arrays for the three junction legs.
620  iJunLegA.resize(0);
621  iJunLegB.resize(0);
622  iJunLegC.resize(0);
623  int leg = -1;
624  for (int i = 0; i < int(iPartonJun[iJun].size()); ++ i) {
625  if ( (-iPartonJun[iJun][i])/10 == identJun) ++leg;
626  if (leg == 0) iJunLegA.push_back( iPartonJun[iJun][i] );
627  else if (leg == 1) iJunLegB.push_back( iPartonJun[iJun][i] );
628  else iJunLegC.push_back( iPartonJun[iJun][i] );
629  }
630 
631  // Construct separate index arrays for the three antijunction legs.
632  int identAnti = (-iPartonAntiJun[iAntiJun][0])/10;
633  iAntiLegA.resize(0);
634  iAntiLegB.resize(0);
635  iAntiLegC.resize(0);
636  leg = -1;
637  for (int i = 0; i < int(iPartonAntiJun[iAntiJun].size()); ++ i) {
638  if ( (-iPartonAntiJun[iAntiJun][i])/10 == identAnti) ++leg;
639  if (leg == 0) iAntiLegA.push_back( iPartonAntiJun[iAntiJun][i] );
640  else if (leg == 1) iAntiLegB.push_back( iPartonAntiJun[iAntiJun][i] );
641  else iAntiLegC.push_back( iPartonAntiJun[iAntiJun][i] );
642  }
643 
644  // Find interjunction legs, i.e. between junction and antijunction.
645  int nMatch = 0;
646  int legJun[3], legAnti[3], nGluLeg[3];
647  if (iJunLegA.back() < 0) { legJun[nMatch] = 0;
648  legAnti[nMatch] = (-iJunLegA.back())%10; ++nMatch;}
649  if (iJunLegB.back() < 0) { legJun[nMatch] = 1;
650  legAnti[nMatch] = (-iJunLegB.back())%10; ++nMatch;}
651  if (iJunLegC.back() < 0) { legJun[nMatch] = 2;
652  legAnti[nMatch] = (-iJunLegC.back())%10; ++nMatch;}
653 
654  // Loop over interjunction legs.
655  for (int iMatch = 0; iMatch < nMatch; ++iMatch) {
656  vector<int>& iJunLeg = (legJun[iMatch] == 0) ? iJunLegA
657  : ( (legJun[iMatch] == 1) ? iJunLegB : iJunLegC );
658  vector<int>& iAntiLeg = (legAnti[iMatch] == 0) ? iAntiLegA
659  : ( (legAnti[iMatch] == 1) ? iAntiLegB : iAntiLegC );
660 
661  // Find number of gluons on each. Do nothing for now if none.
662  nGluLeg[iMatch] = iJunLeg.size() + iAntiLeg.size() - 4;
663  if (nGluLeg[iMatch] == 0) continue;
664 
665  // Else pick up the gluons on the interjunction leg in order.
666  iGluLeg.resize(0);
667  for (int i = 1; i < int(iJunLeg.size()) - 1; ++i)
668  iGluLeg.push_back( iJunLeg[i] );
669  for (int i = int(iAntiLeg.size()) - 2; i > 0; --i)
670  iGluLeg.push_back( iAntiLeg[i] );
671 
672  // Remove those gluons from the junction/antijunction leg lists.
673  iJunLeg.resize(1);
674  iAntiLeg.resize(1);
675 
676  // Pick a new quark at random; for simplicity no diquarks.
677  int idQ = flavSel.pickLightQ();
678  int colQ, acolQ;
679 
680  // If one gluon on leg, split it into a collinear q-qbar pair.
681  if (iGluLeg.size() == 1) {
682 
683  // Store the new q qbar pair, sharing gluon colour and momentum.
684  colQ = event[ iGluLeg[0] ].col();
685  acolQ = event[ iGluLeg[0] ].acol();
686  Vec4 pQ = 0.5 * event[ iGluLeg[0] ].p();
687  double mQ = 0.5 * event[ iGluLeg[0] ].m();
688  int iQ = event.append( idQ, 75, iGluLeg[0], 0, 0, 0, colQ, 0, pQ, mQ );
689  int iQbar = event.append( -idQ, 75, iGluLeg[0], 0, 0, 0, 0, acolQ,
690  pQ, mQ );
691 
692  // Mark split gluon and update junction and antijunction legs.
693  event[ iGluLeg[0] ].statusNeg();
694  event[ iGluLeg[0] ].daughters( iQ, iQbar);
695  iJunLeg.push_back(iQ);
696  iAntiLeg.push_back(iQbar);
697 
698  // If several gluons on the string, decide which g-g region to split up.
699  } else {
700 
701  // Evaluate mass-squared for all adjacent gluon pairs.
702  m2Pair.resize(0);
703  double m2Sum = 0.;
704  for (int i = 0; i < int(iGluLeg.size()) - 1; ++i) {
705  double m2Now = 0.5 * event[ iGluLeg[i] ].p()
706  * event[ iGluLeg[i + 1] ].p();
707  m2Pair.push_back(m2Now);
708  m2Sum += m2Now;
709  }
710 
711  // Pick breakup region with probability proportional to mass-squared.
712  double m2Reg = m2Sum * rndmPtr->flat();
713  int iReg = -1;
714  do m2Reg -= m2Pair[++iReg];
715  while (m2Reg > 0. && iReg < int(iGluLeg.size()) - 1);
716  m2Reg = m2Pair[iReg];
717 
718  // Pick breaking point of string in chosen region (symmetrically).
719  double m2Temp = min( JJSTRINGM2MAX, JJSTRINGM2FRAC * m2Reg);
720  double xPos = 0.5;
721  double xNeg = 0.5;
722  do {
723  double zTemp = zSel.zFrag( idQ, 0, m2Temp);
724  xPos = 1. - zTemp;
725  xNeg = m2Temp / (zTemp * m2Reg);
726  } while (xNeg > 1.);
727  if (rndmPtr->flat() > 0.5) swap(xPos, xNeg);
728 
729  // Pick up two "mother" gluons of breakup. Mark them decayed.
730  Particle& gJun = event[ iGluLeg[iReg] ];
731  Particle& gAnti = event[ iGluLeg[iReg + 1] ];
732  gJun.statusNeg();
733  gAnti.statusNeg();
734  int dau1 = event.size();
735  gJun.daughters(dau1, dau1 + 3);
736  gAnti.daughters(dau1, dau1 + 3);
737  int mother1 = min( iGluLeg[iReg], iGluLeg[iReg + 1]);
738  int mother2 = max( iGluLeg[iReg], iGluLeg[iReg + 1]);
739 
740  // Need to store variables, since it is not safe to use references
741  // with append.
742  int gJunCol = gJun.col();
743  int gJunAcol = gJun.acol();
744  int gAntiAcol = gAnti.acol();
745  Vec4 gJunP = gJun.p();
746  Vec4 gAntiP = gAnti.p();
747  double gJunM = gJun.m();
748  double gAntiM = gAnti.m();
749 
750  // Can keep one of old colours but need one new so unambiguous.
751  colQ = gJun.acol();
752  acolQ = event.nextColTag();
753 
754  // Store copied gluons with reduced momenta.
755  int iGjun = event.append( 21, 75, mother1, mother2, 0, 0,
756  gJunCol, gJunAcol, (1. - 0.5 * xPos) * gJunP,
757  (1. - 0.5 * xPos) * gJunM);
758  int iGanti = event.append( 21, 75, mother1, mother2, 0, 0,
759  acolQ, gAntiAcol, (1. - 0.5 * xNeg) * gAntiP,
760  (1. - 0.5 * xNeg) * gAntiM);
761 
762  // Store the new q qbar pair with remaining momenta.
763  int iQ = event.append( idQ, 75, mother1, mother2, 0, 0,
764  colQ, 0, 0.5 * xNeg * gAntiP, 0.5 * xNeg * gAntiM );
765  int iQbar = event.append( -idQ, 75, mother1, mother2, 0, 0,
766  0, acolQ, 0.5 * xPos * gJunP, 0.5 * xPos * gJunM );
767 
768  // Update junction and antijunction legs with gluons and quarks.
769  for (int i = 0; i < iReg; ++i)
770  iJunLeg.push_back( iGluLeg[i] );
771  iJunLeg.push_back(iGjun);
772  iJunLeg.push_back(iQ);
773  for (int i = int(iGluLeg.size()) - 1; i > iReg + 1; --i)
774  iAntiLeg.push_back( iGluLeg[i] );
775  iAntiLeg.push_back(iGanti);
776  iAntiLeg.push_back(iQbar);
777  }
778 
779  // Update end colours for both g -> q qbar and g g -> g g q qbar.
780  event.endColJunction(identJun - 1, legJun[iMatch], colQ);
781  event.endColJunction(identAnti - 1, legAnti[iMatch], acolQ);
782  }
783 
784  // Update list of interjunction legs after splittings above.
785  int iMatchUp = 0;
786  while (iMatchUp < nMatch) {
787  if (nGluLeg[iMatchUp] > 0) {
788  for (int i = iMatchUp; i < nMatch - 1; ++i) {
789  legJun[i] = legJun[i + 1];
790  legAnti[i] = legAnti[i + 1];
791  nGluLeg[i] = nGluLeg[i + 1];
792  } --nMatch;
793  } else ++iMatchUp;
794  }
795 
796  // Should not ever have three empty interjunction legs.
797  if (nMatch == 3) {
798  infoPtr->errorMsg("Error in HadronLevel::splitJunctionPair: "
799  "three empty junction-junction legs");
800  return false;
801  }
802 
803  // If two legs are empty, then collapse system to a single string.
804  if (nMatch == 2) {
805  int legJunLeft = 3 - legJun[0] - legJun[1];
806  int legAntiLeft = 3 - legAnti[0] - legAnti[1];
807  vector<int>& iJunLeg = (legJunLeft == 0) ? iJunLegA
808  : ( (legJunLeft == 1) ? iJunLegB : iJunLegC );
809  vector<int>& iAntiLeg = (legAntiLeft == 0) ? iAntiLegA
810  : ( (legAntiLeft == 1) ? iAntiLegB : iAntiLegC );
811  iPartonJun[iJun].resize(0);
812  for (int i = int(iJunLeg.size()) - 1; i > 0; --i)
813  iPartonJun[iJun].push_back( iJunLeg[i] );
814  for (int i = 1; i < int(iAntiLeg.size()); ++i)
815  iPartonJun[iJun].push_back( iAntiLeg[i] );
816 
817  // Match up the colours where the strings are joined.
818  int iColJoin = iJunLeg[1];
819  int iAcolJoin = iAntiLeg[1];
820  event[iAcolJoin].acol( event[iColJoin].col() );
821 
822  // Other string system empty. Remove junctions from their list. Done.
823  iPartonAntiJun[iAntiJun].resize(0);
824  event.eraseJunction( max(identJun, identAnti) - 1);
825  event.eraseJunction( min(identJun, identAnti) - 1);
826  continue;
827  }
828 
829  // If one leg is empty then, depending on string length, either
830  // (a) annihilate junction and antijunction into two simple strings, or
831  // (b) split the empty leg by borrowing energy from nearby legs.
832  if (nMatch == 1) {
833 
834  // Identify the two external legs of either junction.
835  vector<int>& iJunLeg0 = (legJun[0] == 0) ? iJunLegB : iJunLegA;
836  vector<int>& iJunLeg1 = (legJun[0] == 2) ? iJunLegB : iJunLegC;
837  vector<int>& iAntiLeg0 = (legAnti[0] == 0) ? iAntiLegB : iAntiLegA;
838  vector<int>& iAntiLeg1 = (legAnti[0] == 2) ? iAntiLegB : iAntiLegC;
839 
840  // Simplified procedure: mainly study first parton on each leg.
841  Vec4 pJunLeg0 = event[ iJunLeg0[1] ].p();
842  Vec4 pJunLeg1 = event[ iJunLeg1[1] ].p();
843  Vec4 pAntiLeg0 = event[ iAntiLeg0[1] ].p();
844  Vec4 pAntiLeg1 = event[ iAntiLeg1[1] ].p();
845 
846  // Starting frame hopefully intermediate to two junction directions.
847  Vec4 pStart = pJunLeg0 / pJunLeg0.e() + pJunLeg1 / pJunLeg1.e()
848  + pAntiLeg0 / pAntiLeg0.e() + pAntiLeg1 / pAntiLeg1.e();
849 
850  // Loop over iteration to junction/antijunction rest frames (JRF/ARF).
851  RotBstMatrix MtoJRF, MtoARF;
852  Vec4 pInJRF[3], pInARF[3];
853  for (int iJunLocal = 0; iJunLocal < 2; ++iJunLocal) {
854  int offset = (iJunLocal == 0) ? 0 : 2;
855 
856  // Iterate from system rest frame towards the junction rest frame.
857  RotBstMatrix MtoRF, Mstep;
858  MtoRF.bstback(pStart);
859  Vec4 pInRF[4];
860  int iter = 0;
861  do {
862  ++iter;
863 
864  // Find rest-frame momenta on the three sides of the junction.
865  // Only consider first parton on each leg, for simplicity.
866  pInRF[0 + offset] = pJunLeg0;
867  pInRF[1 + offset] = pJunLeg1;
868  pInRF[2 - offset] = pAntiLeg0;
869  pInRF[3 - offset] = pAntiLeg1;
870  for (int i = 0; i < 4; ++i) pInRF[i].rotbst(MtoRF);
871 
872  // For third side add both legs beyond other junction, weighted.
873  double wt2 = 1. - exp( -pInRF[2].e() / eNormJunction);
874  double wt3 = 1. - exp( -pInRF[3].e() / eNormJunction);
875  pInRF[2] = wt2 * pInRF[2] + wt3 * pInRF[3];
876 
877  // Find new junction rest frame from the set of momenta.
878  Mstep = stringFrag.junctionRestFrame( pInRF[0], pInRF[1], pInRF[2]);
879  MtoRF.rotbst( Mstep );
880  } while (iter < 3 || (Mstep.deviation() > CONVJNREST
881  && iter < NTRYJNREST) );
882 
883  // Store final boost and rest-frame (weighted) momenta.
884  if (iJunLocal == 0) {
885  MtoJRF = MtoRF;
886  for (int i = 0; i < 3; ++i) pInJRF[i] = pInRF[i];
887  } else {
888  MtoARF = MtoRF;
889  for (int i = 0; i < 3; ++i) pInARF[i] = pInRF[i];
890  }
891  }
892 
893  // Opposite operations: boost from JRF/ARF to original system.
894  RotBstMatrix MfromJRF = MtoJRF;
895  MfromJRF.invert();
896  RotBstMatrix MfromARF = MtoARF;
897  MfromARF.invert();
898 
899  // Velocity vectors of junctions and momentum of legs in lab frame.
900  Vec4 vJun(0., 0., 0., 1.);
901  vJun.rotbst(MfromJRF);
902  Vec4 vAnti(0., 0., 0., 1.);
903  vAnti.rotbst(MfromARF);
904  Vec4 pLabJ[3], pLabA[3];
905  for (int i = 0; i < 3; ++i) {
906  pLabJ[i] = pInJRF[i];
907  pLabJ[i].rotbst(MfromJRF);
908  pLabA[i] = pInARF[i];
909  pLabA[i].rotbst(MfromARF);
910  }
911 
912  // Calculate Lambda-measure length of three possible topologies.
913  double vJvA = vJun * vAnti;
914  double vJvAe2y = vJvA + sqrt(vJvA*vJvA - 1.);
915  double LambdaJA = (2. * pInJRF[0].e()) * (2. * pInJRF[1].e())
916  * (2. * pInARF[0].e()) * (2. * pInARF[1].e()) * vJvAe2y;
917  double Lambda00 = (2. * pLabJ[0] * pLabA[0])
918  * (2. * pLabJ[1] * pLabA[1]);
919  double Lambda01 = (2. * pLabJ[0] * pLabA[1])
920  * (2. * pLabJ[1] * pLabA[0]);
921 
922  // Case when either topology without junctions is the shorter one.
923  if (LambdaJA > min( Lambda00, Lambda01)) {
924  vector<int>& iAntiMatch0 = (Lambda00 < Lambda01)
925  ? iAntiLeg0 : iAntiLeg1;
926  vector<int>& iAntiMatch1 = (Lambda00 < Lambda01)
927  ? iAntiLeg1 : iAntiLeg0;
928 
929  // Define two quark-antiquark strings.
930  iPartonJun[iJun].resize(0);
931  for (int i = int(iJunLeg0.size()) - 1; i > 0; --i)
932  iPartonJun[iJun].push_back( iJunLeg0[i] );
933  for (int i = 1; i < int(iAntiMatch0.size()); ++i)
934  iPartonJun[iJun].push_back( iAntiMatch0[i] );
935  iPartonAntiJun[iAntiJun].resize(0);
936  for (int i = int(iJunLeg1.size()) - 1; i > 0; --i)
937  iPartonAntiJun[iAntiJun].push_back( iJunLeg1[i] );
938  for (int i = 1; i < int(iAntiMatch1.size()); ++i)
939  iPartonAntiJun[iAntiJun].push_back( iAntiMatch1[i] );
940 
941  // Match up the colours where the strings are joined.
942  int iColJoin = iJunLeg0[1];
943  int iAcolJoin = iAntiMatch0[1];
944  event[iAcolJoin].acol( event[iColJoin].col() );
945  iColJoin = iJunLeg1[1];
946  iAcolJoin = iAntiMatch1[1];
947  event[iAcolJoin].acol( event[iColJoin].col() );
948 
949  // Remove junctions from their list. Done.
950  event.eraseJunction( max(identJun, identAnti) - 1);
951  event.eraseJunction( min(identJun, identAnti) - 1);
952 
953  continue;
954  }
955 
956  // Case where junction and antijunction to be separated.
957  // Shuffle (p+/p-) momentum of order <mThad> between systems,
958  // times 2/3 for 120 degree in JRF, times 1/2 for two legs,
959  // but not more than half of what nearest parton carries.
960  double eShift = MTHAD / (3. * sqrt(vJvAe2y));
961  double fracJ0 = min(0.5, eShift / pInJRF[0].e());
962  double fracJ1 = min(0.5, eShift / pInJRF[0].e());
963  Vec4 pFromJun = fracJ0 * pJunLeg0 + fracJ1 * pJunLeg1;
964  double fracA0 = min(0.5, eShift / pInARF[0].e());
965  double fracA1 = min(0.5, eShift / pInARF[0].e());
966  Vec4 pFromAnti = fracA0 * pAntiLeg0 + fracA1 * pAntiLeg1;
967 
968  // Pick a new quark at random; for simplicity no diquarks.
969  int idQ = flavSel.pickLightQ();
970 
971  // Copy junction partons with scaled-down momenta and update legs.
972  int mother1 = min(iJunLeg0[1], iJunLeg1[1]);
973  int mother2 = max(iJunLeg0[1], iJunLeg1[1]);
974  int iNew1 = event.copy(iJunLeg0[1], 76);
975  event[iNew1].rescale5(1. - fracJ0);
976  iJunLeg0[1] = iNew1;
977  int iNew2 = event.copy(iJunLeg1[1], 76);
978  event[iNew2].rescale5(1. - fracJ1);
979  iJunLeg1[1] = iNew2;
980 
981  // Update junction colour and store quark with antijunction momentum.
982  // Store history as 2 -> 3 step for consistency.
983  int colQ = event.nextColTag();
984  event.endColJunction(identJun - 1, legJun[0], colQ);
985  int iNewJ = event.append( idQ, 76, mother1, mother2, 0, 0,
986  colQ, 0, pFromAnti, pFromAnti.mCalc() );
987  event[mother1].daughters( iNew1, iNewJ);
988  event[mother2].daughters( iNew1, iNewJ);
989  event[iNew1].mothers( mother1, mother2);
990  event[iNew2].mothers( mother1, mother2);
991 
992  // Copy anti junction partons with scaled-down momenta and update legs.
993  mother1 = min(iAntiLeg0[1], iAntiLeg1[1]);
994  mother2 = max(iAntiLeg0[1], iAntiLeg1[1]);
995  iNew1 = event.copy(iAntiLeg0[1], 76);
996  event[iNew1].rescale5(1. - fracA0);
997  iAntiLeg0[1] = iNew1;
998  iNew2 = event.copy(iAntiLeg1[1], 76);
999  event[iNew2].rescale5(1. - fracA1);
1000  iAntiLeg1[1] = iNew2;
1001 
1002  // Update antijunction anticolour and store antiquark with junction
1003  // momentum. Store history as 2 -> 3 step for consistency.
1004  int acolQ = event.nextColTag();
1005  event.endColJunction(identAnti - 1, legAnti[0], acolQ);
1006  int iNewA = event.append( -idQ, 76, mother1, mother2, 0, 0,
1007  0, acolQ, pFromJun, pFromJun.mCalc() );
1008  event[mother1].daughters( iNew1, iNewA);
1009  event[mother2].daughters( iNew1, iNewA);
1010  event[iNew1].mothers( mother1, mother2);
1011  event[iNew2].mothers( mother1, mother2);
1012 
1013  // Bookkeep new quark and antiquark on third legs.
1014  if (legJun[0] == 0) iJunLegA[1] = iNewJ;
1015  else if (legJun[0] == 1) iJunLegB[1] = iNewJ;
1016  else iJunLegC[1] = iNewJ;
1017  if (legAnti[0] == 0) iAntiLegA[1] = iNewA;
1018  else if (legAnti[0] == 1) iAntiLegB[1] = iNewA;
1019  else iAntiLegC[1] = iNewA;
1020 
1021  // Done with splitting junction from antijunction.
1022  }
1023 
1024  // Put together new junction parton list.
1025  iPartonJun[iJun].resize(0);
1026  for (int i = 0; i < int(iJunLegA.size()); ++i)
1027  iPartonJun[iJun].push_back( iJunLegA[i] );
1028  for (int i = 0; i < int(iJunLegB.size()); ++i)
1029  iPartonJun[iJun].push_back( iJunLegB[i] );
1030  for (int i = 0; i < int(iJunLegC.size()); ++i)
1031  iPartonJun[iJun].push_back( iJunLegC[i] );
1032 
1033  // Put together new antijunction parton list.
1034  iPartonAntiJun[iAntiJun].resize(0);
1035  for (int i = 0; i < int(iAntiLegA.size()); ++i)
1036  iPartonAntiJun[iAntiJun].push_back( iAntiLegA[i] );
1037  for (int i = 0; i < int(iAntiLegB.size()); ++i)
1038  iPartonAntiJun[iAntiJun].push_back( iAntiLegB[i] );
1039  for (int i = 0; i < int(iAntiLegC.size()); ++i)
1040  iPartonAntiJun[iAntiJun].push_back( iAntiLegC[i] );
1041 
1042  }
1043  // Now all the two junction systems are separated and can be stored.
1044  return true;
1045 
1046 
1047 }
1048 
1049 //==========================================================================
1050 
1051 } // end namespace Pythia8
Definition: AgUStep.h:26