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