PYTHIA  8.313
HadronLevel.h
1 // HadronLevel.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 main class for hadron-level generation.
7 // HadronLevel: handles administration of fragmentation and decay.
8 
9 #ifndef Pythia8_HadronLevel_H
10 #define Pythia8_HadronLevel_H
11 
12 #include "Pythia8/Basics.h"
13 #include "Pythia8/BoseEinstein.h"
14 #include "Pythia8/ColourTracing.h"
15 #include "Pythia8/DeuteronProduction.h"
16 #include "Pythia8/Event.h"
17 #include "Pythia8/FragmentationFlavZpT.h"
18 #include "Pythia8/FragmentationSystems.h"
19 #include "Pythia8/HadronWidths.h"
20 #include "Pythia8/HiddenValleyFragmentation.h"
21 #include "Pythia8/Info.h"
22 #include "Pythia8/JunctionSplitting.h"
23 #include "Pythia8/LowEnergyProcess.h"
24 #include "Pythia8/SigmaLowEnergy.h"
25 #include "Pythia8/NucleonExcitations.h"
26 #include "Pythia8/ParticleData.h"
27 #include "Pythia8/ParticleDecays.h"
28 #include "Pythia8/PartonVertex.h"
29 #include "Pythia8/PhysicsBase.h"
30 #include "Pythia8/PythiaStdlib.h"
31 #include "Pythia8/RHadrons.h"
32 #include "Pythia8/Settings.h"
33 #include "Pythia8/StringFragmentation.h"
34 #include "Pythia8/TimeShower.h"
35 #include "Pythia8/UserHooks.h"
36 
37 namespace Pythia8 {
38 
39 //==========================================================================
40 
41 // The HadronLevel class contains the top-level routines to generate
42 // the transition from the partonic to the hadronic stage of an event.
43 
44 class HadronLevel : public PhysicsBase {
45 
46 public:
47 
48  // Constructor.
49  HadronLevel() = default;
50 
51  // Initialize HadronLevel classes as required.
52  bool init( TimeShowerPtr timesDecPtrIn, RHadronsPtr rHadronsPtrIn,
53  LundFragmentationPtr fragPtrIn, vector<FragmentationModelPtr>* fragPtrsIn,
54  DecayHandlerPtr decayHandlePtr, vector<int> handledParticles,
55  StringIntPtr stringInteractionsPtrIn, PartonVertexPtr partonVertexPtrIn,
56  SigmaLowEnergy& sigmaLowEnergyIn,
57  NucleonExcitations& nucleonExcitationsIn);
58 
59  // Get pointer to StringFlav instance (needed by BeamParticle).
60  StringFlav* getStringFlavPtr() {return &flavSel;}
61 
62  // Generate the next event.
63  bool next(Event& event);
64 
65  // Try to decay the specified particle. Returns false if decay failed.
66  bool decay( int iDec, Event& event) { return
67  (event[iDec].isFinal() && event[iDec].canDecay() && event[iDec].mayDecay())
68  ? decays.decay( iDec, event) : true;}
69 
70  // Special routine to allow more decays if on/off switches changed.
71  bool moreDecays(Event& event);
72 
73  // Perform rescattering. Return true if new strings must be hadronized.
74  bool rescatter(Event& event);
75 
76  // Prepare and pick process for a low-energy hadron-hadron scattering.
78  int pickLowEnergyProcess(int idA, int idB, double eCM, double mA, double mB);
79 
80  // Special routine to do a low-energy hadron-hadron scattering.
81  bool doLowEnergyProcess(int i1, int i2, int procTypeIn, Event& event) {
82  if (!lowEnergyProcess.collide( i1, i2, procTypeIn, event)) {
83  loggerPtr->ERROR_MSG("low energy collision failed");
84  return false;
85  }
86  return true;
87  }
88 
89  // Tell if we did an early user-defined veto of the event.
90  bool hasVetoedHadronize() const {return doHadronizeVeto; }
91 
92 protected:
93 
94  virtual void onInitInfoPtr() override{
95  registerSubObject(flavSel);
96  registerSubObject(pTSel);
97  registerSubObject(zSel);
98  registerSubObject(decays);
99  registerSubObject(lowEnergyProcess);
100  registerSubObject(boseEinstein);
101  registerSubObject(junctionSplitting);
102  registerSubObject(deuteronProd);
103  }
104 
105 private:
106 
107  // Constants: could only be changed in the code itself.
108  static const double MTINY;
109 
110  // Initialization data, read from Settings.
111  bool doHadronize{}, doDecay{}, doPartonVertex{}, doBoseEinstein{},
112  doDeuteronProd{}, allowRH{}, closePacking{}, doNonPertAll{},
113  doQED;
114  double pNormJunction{}, widthSepBE{}, widthSepRescatter{};
115  vector<int> nonPertProc{};
116 
117  // Configuration of colour-singlet systems.
118  ColConfig colConfig;
119 
120  // Colour and mass information.
121  vector<int> iParton{}, iJunLegA{}, iJunLegB{}, iJunLegC{},
122  iAntiLegA{}, iAntiLegB{}, iAntiLegC{}, iGluLeg{};
123  vector<double> m2Pair{};
124 
125  // The generator class for normal decays.
126  ParticleDecays decays;
127 
128  // Pointer to TimeShower for interleaved QED in hadron decays.
129  TimeShowerPtr timesDecPtr;
130 
131  // The generator class for Bose-Einstein effects.
132  BoseEinstein boseEinstein;
133 
134  // The generator class for deuteron production.
135  DeuteronProduction deuteronProd;
136 
137  // Classes for flavour, pT and z generation.
138  StringFlav flavSel;
139  StringPT pTSel;
140  StringZ zSel;
141 
142  // Class for colour tracing.
143  ColourTracing colTrace;
144 
145  // Junction splitting class.
146  JunctionSplitting junctionSplitting;
147 
148  // The RHadrons class is used to fragment off and decay R-hadrons.
149  RHadronsPtr rHadronsPtr{};
150 
151  // The LundFragmentation class is used for fragmentation and low
152  // energy processes.
153  LundFragmentationPtr fragPtr{};
154 
155  // The fragmentation model pointer vector allows multiple
156  // fragmentation models to be used sequentially.
157  vector<FragmentationModelPtr>* fragPtrs{};
158 
159  // Special case: colour-octet onium decays, to be done initially.
160  bool decayOctetOnia(Event& event);
161 
162  // Trace colour flow in the event to form colour singlet subsystems.
163  // Option to keep junctions, needed for rope hadronization.
164  bool findSinglets(Event& event, bool keepJunctions = false);
165 
166  // Class to displace hadron vertices from parton impact-parameter picture.
167  PartonVertexPtr partonVertexPtr;
168 
169  // Hadronic rescattering.
170  class PriorityNode;
171  bool doRescatter{}, scatterManyTimes{}, scatterQuickCheck{},
172  scatterNeighbours{}, delayRegeneration{};
173  double b2Max, tauRegeneration{};
174  void queueDecResc(Event& event, int iStart,
175  priority_queue<HadronLevel::PriorityNode>& queue);
176  int boostDir;
177  double boost;
178  bool doBoost;
179  bool useVelocityFrame;
180 
181  // User veto performed right after string hadronization.
182  bool doHadronizeVeto;
183 
184  // The generator class for low-energy hadron-hadron collisions.
185  LowEnergyProcess lowEnergyProcess;
186  int impactModel{};
187  double impactOpacity{};
188 
189  // Cross sections for low-energy processes.
190  SigmaLowEnergy* sigmaLowEnergyPtr = {};
191 
192  // Nucleon excitations data.
193  NucleonExcitations* nucleonExcitationsPtr = {};
194 
195  // Class for event geometry for Rope Hadronization. Production vertices.
196  StringRepPtr stringRepulsionPtr;
197  FragModPtr fragmentationModifierPtr;
198 
199  // Extract rapidity pairs.
200  vector< vector< pair<double,double> > > rapidityPairs(Event& event);
201 
202  // Calculate the rapidity for string ends, protected against too large y.
203  double yMax(Particle pIn, double mTiny) {
204  double temp = log( ( pIn.e() + abs(pIn.pz()) ) / max( mTiny, pIn.mT()) );
205  return (pIn.pz() > 0) ? temp : -temp; }
206  double yMax(Vec4 pIn, double mTiny) {
207  double mTemp = pIn.m2Calc() + pIn.pT2();
208  mTemp = (mTemp >= 0.) ? sqrt(mTemp) : -sqrt(-mTemp);
209  double temp = log( ( pIn.e() + abs(pIn.pz()) ) / max( mTiny, mTemp) );
210  return (pIn.pz() > 0) ? temp : -temp; }
211 
212  // Fragmentation weights container.
213  WeightsFragmentation* wgtsPtr{};
214 
215 };
216 
217 //==========================================================================
218 
219 } // end namespace Pythia8
220 
221 #endif // Pythia8_HadronLevel_H
Definition: LowEnergyProcess.h:28
bool collide(int i1, int i2, int typeIn, Event &event, Vec4 vtx=Vec4(), Vec4 vtx1=Vec4(), Vec4 vtx2=Vec4())
Produce outgoing primary hadrons from collision of incoming pair.
Definition: LowEnergyProcess.cc:105
bool moreDecays(Event &event)
Special routine to allow more decays if on/off switches changed.
Definition: HadronLevel.cc:339
Definition: NucleonExcitations.h:23
Definition: PhysicsBase.h:27
void registerSubObject(PhysicsBase &pb)
Register a sub object that should have its information in sync with this.
Definition: PhysicsBase.cc:56
The ParticleDecays class contains the routines to decay a particle.
Definition: ParticleDecays.h:57
The Event class holds all info on the generated event.
Definition: Event.h:408
Definition: HadronLevel.cc:20
Definition: JunctionSplitting.h:30
The StringPT class is used to select select transverse momenta.
Definition: FragmentationFlavZpT.h:326
Gets cross sections for hadron-hadron collisions at low energies.
Definition: SigmaLowEnergy.h:22
StringFlav * getStringFlavPtr()
Get pointer to StringFlav instance (needed by BeamParticle).
Definition: HadronLevel.h:60
int pickLowEnergyProcess(int idA, int idB, double eCM, double mA, double mB)
Pick process for a low-energy hadron-hadron scattering.
Definition: HadronLevel.cc:383
HadronLevel()=default
Constructor.
The StringZ class is used to sample the fragmentation function f(z).
Definition: FragmentationFlavZpT.h:265
Definition: HadronLevel.h:44
bool next(Event &event)
Generate the next event.
Definition: HadronLevel.cc:175
bool rescatter(Event &event)
Perform rescattering. Return true if new strings must be hadronized.
Definition: HadronLevel.cc:620
bool doLowEnergyProcess(int i1, int i2, int procTypeIn, Event &event)
Special routine to do a low-energy hadron-hadron scattering.
Definition: HadronLevel.h:81
bool hasVetoedHadronize() const
Tell if we did an early user-defined veto of the event.
Definition: HadronLevel.h:90
ColourTracing class. It is used to trace colours within the event record.
Definition: ColourTracing.h:22
bool initLowEnergyProcesses()
Prepare and pick process for a low-energy hadron-hadron scattering.
Definition: HadronLevel.cc:359
Definition: Event.h:32
The ColConfig class describes the colour configuration of the whole event.
Definition: FragmentationSystems.h:60
Definition: BoseEinstein.h:48
bool init(TimeShowerPtr timesDecPtrIn, RHadronsPtr rHadronsPtrIn, LundFragmentationPtr fragPtrIn, vector< FragmentationModelPtr > *fragPtrsIn, DecayHandlerPtr decayHandlePtr, vector< int > handledParticles, StringIntPtr stringInteractionsPtrIn, PartonVertexPtr partonVertexPtrIn, SigmaLowEnergy &sigmaLowEnergyIn, NucleonExcitations &nucleonExcitationsIn)
Initialize HadronLevel classes as required.
Definition: HadronLevel.cc:58
Logger * loggerPtr
Pointer to logger.
Definition: PhysicsBase.h:87
bool decay(int iDec, Event &event)
Perform a decay of a single particle.
Definition: ParticleDecays.cc:118
virtual void onInitInfoPtr() override
Definition: HadronLevel.h:94
Definition: Weights.h:354
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
The DeuteronProduction class.
Definition: DeuteronProduction.h:22
bool decay(int iDec, Event &event)
Try to decay the specified particle. Returns false if decay failed.
Definition: HadronLevel.h:66
Definition: Basics.h:32