PYTHIA  8.313
MiniStringFragmentation.h
1 // MiniStringFragmentation.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 class for "cluster" fragmentation.
7 // MiniStringFragmentation: handle the fragmentation of low-mass systems.
8 
9 #ifndef Pythia8_MiniStringFragmentation_H
10 #define Pythia8_MiniStringFragmentation_H
11 
12 #include "Pythia8/FragmentationModel.h"
13 
14 namespace Pythia8 {
15 
16 //==========================================================================
17 
18 // The MiniStringFragmentation class contains the routines to fragment
19 // occasional low-mass colour singlet partonic systems, where the string
20 // approach is not directly applicable (for technical reasons).
21 
23 
24 public:
25 
26  // Constructor.
28  constantTau(), smearOn(), nTryMass(), hadronVertex(), bLund(), xySmear(),
29  kappaVtx(), mc(), mb(), isClosed(), mSum(), m2Sum() {}
30 
31  // Initialize and save pointers.
32  bool init(StringFlav* flavSelPtrIn = nullptr, StringPT* pTSelPtrIn = nullptr,
33  StringZ* zSelPtrIn = nullptr, FragModPtr fragModPtrIn = nullptr) override;
34 
35  // Do the fragmentation: driver routine.
36  bool fragment(int iSub, ColConfig& colConfig, Event& event,
37  bool isDiff = false, bool systemRecoil = true) override;
38 
39 private:
40 
41  // Constants: could only be changed in the code itself.
42  static const int NTRYDIFFRACTIVE, NTRYLASTRESORT, NTRYFLAV;
43 
44  // Initialization data, read from Settings.
45  bool setVertices, constantTau, smearOn;
46  int nTryMass, hadronVertex;
47  double bLund, xySmear, kappaVtx, mc, mb;
48 
49  // Data members.
50  bool isClosed, isJunctionSystem;
51  double mSum, m2Sum;
52  Vec4 pSum;
53  vector<int> iParton;
54  FlavContainer flav1, flav2, flavj3;
55 
56  // Information from the fragmentation process.
57  vector<StringVertex> ministringVertices;
58 
59  // Reduce the junction size by absorbing gluons into the quarks/diquarks.
60  bool reduce2SimpleJunction(Event& event); // HS
61 
62  // Reduce the junction to a string by merging q + q -> qq diquark.
63  void reduce2SimpleString(Event& event); // HS
64 
65  // Attempt to produce two hadrons from a mini-junction.
66  bool minijunction2two(int nTry, Event& event);
67 
68  // Attempt to produce two particles from a cluster.
69  bool ministring2two( int nTry, Event& event, bool findLowMass = false);
70 
71  // Attempt to produce one particle from a cluster.
72  bool ministring2one( int iSub, ColConfig& colConfig, Event& event,
73  bool findLowMass = false, bool systemRecoil = true);
74 
75  // Set hadron production points in space-time picture.
76  void setHadronVertices(Event& event, StringRegion& region,
77  int iFirst, int iLast);
78 
79  // Internal class to make sure that junction-handling-related changes
80  // in iParton and in the event record are reset when the job is done.
81  // Advantage: many return true/false clauses do destructor commands.
82  struct SaveJunctionState {
83 
84  // Empty constructor.
85  SaveJunctionState(MiniStringFragmentation& msfIn, Event& eventIn)
86  : msf(msfIn), iParton(msfIn.iParton), event(eventIn),
87  oldSize(eventIn.size()) {}
88 
89  void saveMomenta() {
90  for (int i = 1; i < int(iParton.size()); ++i) {
91  // First two partons from two legs.
92  if (iParton[i] < 0) {
93  savedMomenta[iParton[i-1]] = event[iParton[i-1]].p();
94  }
95  }
96  // The last parton from the third leg.
97  savedMomenta[iParton[iParton.size()-1]] =
98  event[iParton[iParton.size()-1]].p();
99  }
100 
101  // Destructor restoring the old state of the event record and iParton.
102  ~SaveJunctionState() {
103  if ( savedMomenta.empty() || event.size() <= oldSize ) return;
104 
105  // Restore the junction edge partons' original momenta
106  for ( auto & mom : savedMomenta ) event[mom.first].p(mom.second);
107  int iFirst = oldSize;
108  int iLast = event.size() - 1;
109  int imother = iParton.size() -1;
110  // Mark original partons as hadronized and set their daughter range.
111  for (int ip : iParton ) {
112  if (ip >= 0) {
113  event[ip].statusNeg();
114  event[ip].daughters(iFirst, iLast);
115  }
116  }
117  event[iFirst].mothers(iParton[1], iParton[imother]);
118  event[iLast].mothers(iParton[1], iParton[imother]);
119  }
120 
122  vector<int> iParton;
123  Event & event;
124  int np{}, oldSize{};
125  map<int,Vec4> savedMomenta{};
126 
127  };
128 
129 };
130 
131 //==========================================================================
132 
133 } // end namespace Pythia8
134 
135 #endif // Pythia8_MiniStringFragmentation_H
The Event class holds all info on the generated event.
Definition: Event.h:408
MiniStringFragmentation()
Constructor.
Definition: MiniStringFragmentation.h:27
The StringPT class is used to select select transverse momenta.
Definition: FragmentationFlavZpT.h:326
Definition: FragmentationSystems.h:136
bool init(StringFlav *flavSelPtrIn=nullptr, StringPT *pTSelPtrIn=nullptr, StringZ *zSelPtrIn=nullptr, FragModPtr fragModPtrIn=nullptr) override
Initialize and save pointers.
Definition: MiniStringFragmentation.cc:35
The StringZ class is used to sample the fragmentation function f(z).
Definition: FragmentationFlavZpT.h:265
int size() const
Event record size.
Definition: Event.h:459
The ColConfig class describes the colour configuration of the whole event.
Definition: FragmentationSystems.h:60
Definition: FragmentationFlavZpT.h:41
FragmentationModel is the base class for handling fragmentation algorithms.
Definition: FragmentationModel.h:28
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
Definition: MiniStringFragmentation.h:22
bool fragment(int iSub, ColConfig &colConfig, Event &event, bool isDiff=false, bool systemRecoil=true) override
Do the fragmentation: driver routine.
Definition: MiniStringFragmentation.cc:73
Definition: Basics.h:32