Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-16 09:03:46

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