Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-18 09:25:29

0001 // HadronLevel.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 main class for hadron-level generation.
0007 // HadronLevel: handles administration of fragmentation and decay.
0008 
0009 #ifndef Pythia8_HadronLevel_H
0010 #define Pythia8_HadronLevel_H
0011 
0012 #include "Pythia8/Basics.h"
0013 #include "Pythia8/BoseEinstein.h"
0014 #include "Pythia8/ColourTracing.h"
0015 #include "Pythia8/DeuteronProduction.h"
0016 #include "Pythia8/Event.h"
0017 #include "Pythia8/FragmentationFlavZpT.h"
0018 #include "Pythia8/FragmentationSystems.h"
0019 #include "Pythia8/HadronWidths.h"
0020 #include "Pythia8/HiddenValleyFragmentation.h"
0021 #include "Pythia8/Info.h"
0022 #include "Pythia8/JunctionSplitting.h"
0023 #include "Pythia8/LowEnergyProcess.h"
0024 #include "Pythia8/SigmaLowEnergy.h"
0025 #include "Pythia8/NucleonExcitations.h"
0026 #include "Pythia8/ParticleData.h"
0027 #include "Pythia8/ParticleDecays.h"
0028 #include "Pythia8/PartonVertex.h"
0029 #include "Pythia8/PhysicsBase.h"
0030 #include "Pythia8/PythiaStdlib.h"
0031 #include "Pythia8/RHadrons.h"
0032 #include "Pythia8/Settings.h"
0033 #include "Pythia8/StringFragmentation.h"
0034 #include "Pythia8/TimeShower.h"
0035 #include "Pythia8/UserHooks.h"
0036 
0037 namespace Pythia8 {
0038 
0039 //==========================================================================
0040 
0041 // The HadronLevel class contains the top-level routines to generate
0042 // the transition from the partonic to the hadronic stage of an event.
0043 
0044 class HadronLevel : public PhysicsBase {
0045 
0046 public:
0047 
0048   // Constructor.
0049   HadronLevel() = default;
0050 
0051   // Initialize HadronLevel classes as required.
0052   bool init( TimeShowerPtr timesDecPtrIn, RHadronsPtr rHadronsPtrIn,
0053     LundFragmentationPtr fragPtrIn, vector<FragmentationModelPtr>* fragPtrsIn,
0054     DecayHandlerPtr decayHandlePtr, vector<int> handledParticles,
0055     StringIntPtr stringInteractionsPtrIn, PartonVertexPtr partonVertexPtrIn,
0056     SigmaLowEnergy& sigmaLowEnergyIn,
0057     NucleonExcitations& nucleonExcitationsIn);
0058 
0059   // Get pointer to StringFlav instance (needed by BeamParticle).
0060   StringFlav* getStringFlavPtr() {return &flavSel;}
0061 
0062   // Generate the next event.
0063   bool next(Event& event);
0064 
0065   // Try to decay the specified particle. Returns false if decay failed.
0066   bool decay( int iDec, Event& event) { return
0067     (event[iDec].isFinal() && event[iDec].canDecay() && event[iDec].mayDecay())
0068     ? decays.decay( iDec, event) : true;}
0069 
0070   // Special routine to allow more decays if on/off switches changed.
0071   bool moreDecays(Event& event);
0072 
0073   // Perform rescattering. Return true if new strings must be hadronized.
0074   bool rescatter(Event& event);
0075 
0076   // Prepare and pick process for a low-energy hadron-hadron scattering.
0077   bool initLowEnergyProcesses();
0078   int pickLowEnergyProcess(int idA, int idB, double eCM, double mA, double mB);
0079 
0080   // Special routine to do a low-energy hadron-hadron scattering.
0081   bool doLowEnergyProcess(int i1, int i2, int procTypeIn, Event& event) {
0082     if (!lowEnergyProcess.collide( i1, i2, procTypeIn, event)) {
0083       loggerPtr->ERROR_MSG("low energy collision failed");
0084       return false;
0085     }
0086     return true;
0087   }
0088 
0089   // Tell if we did an early user-defined veto of the event.
0090   bool hasVetoedHadronize() const {return doHadronizeVeto; }
0091 
0092 protected:
0093 
0094   virtual void onInitInfoPtr() override{
0095     registerSubObject(flavSel);
0096     registerSubObject(pTSel);
0097     registerSubObject(zSel);
0098     registerSubObject(decays);
0099     registerSubObject(lowEnergyProcess);
0100     registerSubObject(boseEinstein);
0101     registerSubObject(junctionSplitting);
0102     registerSubObject(deuteronProd);
0103   }
0104 
0105 private:
0106 
0107   // Constants: could only be changed in the code itself.
0108   static const double MTINY;
0109 
0110   // Initialization data, read from Settings.
0111   bool doHadronize{}, doDecay{}, doPartonVertex{}, doBoseEinstein{},
0112     doDeuteronProd{}, allowRH{}, closePacking{}, doNonPertAll{},
0113     doQED;
0114   double pNormJunction{}, widthSepBE{}, widthSepRescatter{};
0115   vector<int> nonPertProc{};
0116 
0117   // Configuration of colour-singlet systems.
0118   ColConfig      colConfig;
0119 
0120   // Colour and mass information.
0121   vector<int>    iParton{}, iJunLegA{}, iJunLegB{}, iJunLegC{},
0122                  iAntiLegA{}, iAntiLegB{}, iAntiLegC{}, iGluLeg{};
0123   vector<double> m2Pair{};
0124 
0125   // The generator class for normal decays.
0126   ParticleDecays decays;
0127 
0128   // Pointer to TimeShower for interleaved QED in hadron decays.
0129   TimeShowerPtr timesDecPtr;
0130 
0131   // The generator class for Bose-Einstein effects.
0132   BoseEinstein boseEinstein;
0133 
0134   // The generator class for deuteron production.
0135   DeuteronProduction deuteronProd;
0136 
0137   // Classes for flavour, pT and z generation.
0138   StringFlav flavSel;
0139   StringPT   pTSel;
0140   StringZ    zSel;
0141 
0142   // Class for colour tracing.
0143   ColourTracing colTrace;
0144 
0145   // Junction splitting class.
0146   JunctionSplitting junctionSplitting;
0147 
0148   // The RHadrons class is used to fragment off and decay R-hadrons.
0149   RHadronsPtr rHadronsPtr{};
0150 
0151   // The LundFragmentation class is used for fragmentation and low
0152   // energy processes.
0153   LundFragmentationPtr fragPtr{};
0154 
0155   // The fragmentation model pointer vector allows multiple
0156   // fragmentation models to be used sequentially.
0157   vector<FragmentationModelPtr>* fragPtrs{};
0158 
0159   // Special case: colour-octet onium decays, to be done initially.
0160   bool decayOctetOnia(Event& event);
0161 
0162   // Trace colour flow in the event to form colour singlet subsystems.
0163   // Option to keep junctions, needed for rope hadronization.
0164   bool findSinglets(Event& event, bool keepJunctions = false);
0165 
0166   // Class to displace hadron vertices from parton impact-parameter picture.
0167   PartonVertexPtr partonVertexPtr;
0168 
0169   // Hadronic rescattering.
0170   class PriorityNode;
0171   bool doRescatter{}, scatterManyTimes{}, scatterQuickCheck{},
0172     scatterNeighbours{}, delayRegeneration{};
0173   double b2Max, tauRegeneration{};
0174   void queueDecResc(Event& event, int iStart,
0175     priority_queue<HadronLevel::PriorityNode>& queue);
0176   int boostDir;
0177   double boost;
0178   bool doBoost;
0179   bool useVelocityFrame;
0180 
0181   // User veto performed right after string hadronization.
0182   bool doHadronizeVeto;
0183 
0184   // The generator class for low-energy hadron-hadron collisions.
0185   LowEnergyProcess lowEnergyProcess;
0186   int    impactModel{};
0187   double impactOpacity{};
0188 
0189   // Cross sections for low-energy processes.
0190   SigmaLowEnergy* sigmaLowEnergyPtr = {};
0191 
0192   // Nucleon excitations data.
0193   NucleonExcitations* nucleonExcitationsPtr = {};
0194 
0195   // Class for event geometry for Rope Hadronization. Production vertices.
0196   StringRepPtr stringRepulsionPtr;
0197   FragModPtr fragmentationModifierPtr;
0198 
0199   // Extract rapidity pairs.
0200   vector< vector< pair<double,double> > > rapidityPairs(Event& event);
0201 
0202   // Calculate the rapidity for string ends, protected against too large y.
0203   double yMax(Particle pIn, double mTiny) {
0204     double temp = log( ( pIn.e() + abs(pIn.pz()) ) / max( mTiny, pIn.mT()) );
0205     return (pIn.pz() > 0) ? temp : -temp; }
0206   double yMax(Vec4 pIn, double mTiny) {
0207     double mTemp = pIn.m2Calc() + pIn.pT2();
0208     mTemp = (mTemp >= 0.) ? sqrt(mTemp) : -sqrt(-mTemp);
0209     double temp = log( ( pIn.e() + abs(pIn.pz()) ) / max( mTiny, mTemp) );
0210     return (pIn.pz() > 0) ? temp : -temp; }
0211 
0212   // Fragmentation weights container.
0213   WeightsFragmentation* wgtsPtr{};
0214 
0215 };
0216 
0217 //==========================================================================
0218 
0219 } // end namespace Pythia8
0220 
0221 #endif // Pythia8_HadronLevel_H