Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:06:26

0001 // MiniStringFragmentation.h is a part of the PYTHIA event generator.
0002 // Copyright (C) 2024 Torbjorn Sjostrand.
0003 // PYTHIA is licenced under the GNU GPL v2 or later, see COPYING for details.
0004 // Please respect the MCnet Guidelines, see GUIDELINES for details.
0005 
0006 // This file contains the class for "cluster" fragmentation.
0007 // MiniStringFragmentation: handle the fragmentation of low-mass systems.
0008 
0009 #ifndef Pythia8_MiniStringFragmentation_H
0010 #define Pythia8_MiniStringFragmentation_H
0011 
0012 #include "Pythia8/Basics.h"
0013 #include "Pythia8/Event.h"
0014 #include "Pythia8/FragmentationFlavZpT.h"
0015 #include "Pythia8/FragmentationSystems.h"
0016 #include "Pythia8/Info.h"
0017 #include "Pythia8/ParticleData.h"
0018 #include "Pythia8/PythiaStdlib.h"
0019 #include "Pythia8/PhysicsBase.h"
0020 #include "Pythia8/Settings.h"
0021 
0022 namespace Pythia8 {
0023 
0024 //==========================================================================
0025 
0026 // The MiniStringFragmentation class contains the routines to fragment
0027 // occasional low-mass colour singlet partonic systems, where the string
0028 // approach is not directly applicable (for technical reasons).
0029 
0030 class MiniStringFragmentation : public PhysicsBase {
0031 
0032 public:
0033 
0034   // Constructor.
0035   MiniStringFragmentation() : flavSelPtr(), pTSelPtr(), zSelPtr(),
0036     setVertices(), constantTau(), smearOn(), nTryMass(), hadronVertex(),
0037     bLund(), xySmear(), kappaVtx(), mc(), mb(), isClosed(), mSum(), m2Sum() {}
0038 
0039   // Initialize and save pointers.
0040   void init(StringFlav* flavSelPtrIn, StringPT* pTSelPtrIn,
0041     StringZ* zSelPtrIn);
0042 
0043   // Do the fragmentation: driver routine.
0044   bool fragment( int iSub, ColConfig& colConfig, Event& event,
0045     bool isDiff = false, bool systemRecoil = true);
0046 
0047 private:
0048 
0049   // Constants: could only be changed in the code itself.
0050   static const int    NTRYDIFFRACTIVE, NTRYLASTRESORT, NTRYFLAV;
0051 
0052   // Pointers to classes for flavour, pT and z generation.
0053   StringFlav*   flavSelPtr;
0054   StringPT*     pTSelPtr;
0055   StringZ*      zSelPtr;
0056 
0057   // Initialization data, read from Settings.
0058   bool   setVertices, constantTau, smearOn;
0059   int    nTryMass, hadronVertex;
0060   double bLund, xySmear, kappaVtx, mc, mb;
0061 
0062   // Data members.
0063   bool   isClosed, isJunctionSystem;
0064   double mSum, m2Sum;
0065   Vec4   pSum;
0066   vector<int> iParton;
0067   FlavContainer flav1, flav2, flavj3;
0068 
0069   // Information from the fragmentation process.
0070   vector<StringVertex> ministringVertices;
0071 
0072   // Reduce the junction size by absorbing gluons into the quarks/diquarks.
0073   bool reduce2SimpleJunction(Event& event); // HS
0074 
0075   // Reduce the junction to a string by merging q + q -> qq diquark.
0076   void reduce2SimpleString(Event& event); // HS
0077 
0078   // Attempt to produce two hadrons from a mini-junction.
0079   bool minijunction2two(int nTry, Event& event);
0080 
0081   // Attempt to produce two particles from a cluster.
0082   bool ministring2two( int nTry, Event& event, bool findLowMass = false);
0083 
0084   // Attempt to produce one particle from a cluster.
0085   bool ministring2one( int iSub, ColConfig& colConfig, Event& event,
0086     bool findLowMass = false, bool systemRecoil = true);
0087 
0088   // Set hadron production points in space-time picture.
0089   void setHadronVertices(Event& event, StringRegion& region,
0090     int iFirst, int iLast);
0091 
0092   // Internal class to make sure that junction-handling-related changes
0093   // in iParton and in the event record are reset when the job is done.
0094   // Advantage: many return true/false clauses do destructor commands.
0095   struct SaveJunctionState {
0096 
0097     // Empty constructor.
0098     SaveJunctionState(MiniStringFragmentation& msfIn, Event& eventIn)
0099       : msf(msfIn), iParton(msfIn.iParton), event(eventIn),
0100         oldSize(eventIn.size()) {}
0101 
0102     void saveMomenta() {
0103       for (int i = 1; i < int(iParton.size()); ++i) {
0104         // First two partons from two legs.
0105         if (iParton[i] < 0) {
0106           savedMomenta[iParton[i-1]] = event[iParton[i-1]].p();
0107         }
0108       }
0109       // The last parton from the third leg.
0110       savedMomenta[iParton[iParton.size()-1]] =
0111         event[iParton[iParton.size()-1]].p();
0112     }
0113 
0114     // Destructor restoring the old state of the event record and iParton.
0115     ~SaveJunctionState() {
0116       if ( savedMomenta.empty() || event.size() <= oldSize ) return;
0117 
0118       // Restore the junction edge partons' original momenta
0119       for ( auto & mom : savedMomenta ) event[mom.first].p(mom.second);
0120       int iFirst = oldSize;
0121       int iLast = event.size() - 1;
0122       int imother = iParton.size() -1;
0123       // Mark original partons as hadronized and set their daughter range.
0124       for (int ip : iParton ) {
0125         if (ip >= 0) {
0126           event[ip].statusNeg();
0127           event[ip].daughters(iFirst, iLast);
0128         }
0129       }
0130       event[iFirst].mothers(iParton[1], iParton[imother]);
0131       event[iLast].mothers(iParton[1], iParton[imother]);
0132     }
0133 
0134     MiniStringFragmentation & msf;
0135     vector<int> iParton;
0136     Event & event;
0137     int np{}, oldSize{};
0138     map<int,Vec4> savedMomenta{};
0139 
0140   };
0141 
0142 };
0143 
0144 //==========================================================================
0145 
0146 } // end namespace Pythia8
0147 
0148 #endif // Pythia8_MiniStringFragmentation_H