PYTHIA  8.315
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(), mVecRatio(1.), 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  // Set the vector mass ratio.
40  void setMVecRatio(double mVecRatioIn) {mVecRatio = mVecRatioIn;}
41 
42 private:
43 
44  // Constants: could only be changed in the code itself.
45  static const int NTRYDIFFRACTIVE, NTRYLASTRESORT, NTRYFLAV;
46 
47  // Initialization data, read from Settings.
48  bool setVertices, constantTau, smearOn;
49  int nTryMass, hadronVertex;
50  double bLund, xySmear, kappaVtx, mc, mb, mVecRatio;
51 
52  // Data members.
53  bool isClosed, isJunctionSystem;
54  double mSum, m2Sum;
55  Vec4 pSum;
56  vector<int> iParton;
57  FlavContainer flav1, flav2, flavj3;
58 
59  // Information from the fragmentation process.
60  vector<StringVertex> ministringVertices;
61 
62  // Reduce the junction size by absorbing gluons into the quarks/diquarks.
63  bool reduce2SimpleJunction(Event& event); // HS
64 
65  // Reduce the junction to a string by merging q + q -> qq diquark.
66  void reduce2SimpleString(Event& event); // HS
67 
68  // Attempt to produce two hadrons from a mini-junction.
69  bool minijunction2two(int nTry, Event& event);
70 
71  // Attempt to produce two particles from a cluster.
72  bool ministring2two( int nTry, Event& event, bool findLowMass = false);
73 
74  // Attempt to produce one particle from a cluster.
75  bool ministring2one( int iSub, ColConfig& colConfig, Event& event,
76  bool findLowMass = false, bool systemRecoil = true);
77 
78  // Set hadron production points in space-time picture.
79  void setHadronVertices(Event& event, StringRegion& region,
80  int iFirst, int iLast);
81 
82  // Internal class to make sure that junction-handling-related changes
83  // in iParton and in the event record are reset when the job is done.
84  // Advantage: many return true/false clauses do destructor commands.
85  struct SaveJunctionState {
86 
87  // Empty constructor.
88  SaveJunctionState(MiniStringFragmentation& msfIn, Event& eventIn)
89  : msf(msfIn), iParton(msfIn.iParton), event(eventIn),
90  oldSize(eventIn.size()) {}
91 
92  void saveMomenta() {
93  for (int i = 1; i < int(iParton.size()); ++i) {
94  // First two partons from two legs.
95  if (iParton[i] < 0) {
96  savedMomenta[iParton[i-1]] = event[iParton[i-1]].p();
97  }
98  }
99  // The last parton from the third leg.
100  savedMomenta[iParton[iParton.size()-1]] =
101  event[iParton[iParton.size()-1]].p();
102  }
103 
104  // Destructor restoring the old state of the event record and iParton.
105  ~SaveJunctionState() {
106  if ( savedMomenta.empty() || event.size() <= oldSize ) return;
107 
108  // Restore the junction edge partons' original momenta
109  for ( auto & mom : savedMomenta ) event[mom.first].p(mom.second);
110  int iFirst = oldSize;
111  int iLast = event.size() - 1;
112  int imother = iParton.size() -1;
113  // Mark original partons as hadronized and set their daughter range.
114  for (int ip : iParton ) {
115  if (ip >= 0) {
116  event[ip].statusNeg();
117  event[ip].daughters(iFirst, iLast);
118  }
119  }
120  event[iFirst].mothers(iParton[1], iParton[imother]);
121  event[iLast].mothers(iParton[1], iParton[imother]);
122  }
123 
125  vector<int> iParton;
126  Event & event;
127  int np{}, oldSize{};
128  map<int,Vec4> savedMomenta{};
129 
130  };
131 
132 };
133 
134 //==========================================================================
135 
136 } // end namespace Pythia8
137 
138 #endif // Pythia8_MiniStringFragmentation_H
void setMVecRatio(double mVecRatioIn)
Set the vector mass ratio.
Definition: MiniStringFragmentation.h:40
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:333
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:268
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:33
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:76
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