PYTHIA  8.311
PartonLevel.h
1 // PartonLevel.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 main class for parton-level event generation
7 // PartonLevel: administrates showers, multiparton interactions and remnants.
8 
9 #ifndef Pythia8_PartonLevel_H
10 #define Pythia8_PartonLevel_H
11 
12 #include "Pythia8/Basics.h"
13 #include "Pythia8/BeamParticle.h"
14 #include "Pythia8/BeamRemnants.h"
15 #include "Pythia8/Event.h"
16 #include "Pythia8/HardDiffraction.h"
17 #include "Pythia8/Info.h"
18 #include "Pythia8/JunctionSplitting.h"
19 #include "Pythia8/MergingHooks.h"
20 #include "Pythia8/MultipartonInteractions.h"
21 #include "Pythia8/ParticleData.h"
22 #include "Pythia8/PartonSystems.h"
23 #include "Pythia8/PartonVertex.h"
24 #include "Pythia8/PhysicsBase.h"
25 #include "Pythia8/PythiaStdlib.h"
26 #include "Pythia8/ResonanceDecays.h"
27 #include "Pythia8/RHadrons.h"
28 #include "Pythia8/Settings.h"
29 #include "Pythia8/Settings.h"
30 #include "Pythia8/SharedPointers.h"
31 #include "Pythia8/SigmaTotal.h"
32 #include "Pythia8/SpaceShower.h"
33 #include "Pythia8/StandardModel.h"
34 #include "Pythia8/StringLength.h"
35 #include "Pythia8/TimeShower.h"
36 #include "Pythia8/UserHooks.h"
37 
38 namespace Pythia8 {
39 
40 //==========================================================================
41 
42 // The PartonLevel class contains the top-level routines to generate
43 // the partonic activity of an event.
44 
45 class PartonLevel : public PhysicsBase {
46 
47 public:
48 
49  // Constructor.
50  PartonLevel() = default;
51 
52  // Initialization of all classes at the parton level.
53  bool init( TimeShowerPtr timesDecPtrIn, TimeShowerPtr timesPtrIn,
54  SpaceShowerPtr spacePtrIn, RHadrons* rHadronsPtrIn,
55  MergingHooksPtr mergingHooksPtr, PartonVertexPtr partonVertexPtrIn,
56  StringIntPtr stringInteractionPtrIn,
57  bool useAsTrial);
58 
59  // Special setup to allow switching between beam PDFs for MPI handling.
60  // Not needed when MPI for incoming pomeron, since same for all beams.
61  void initSwitchID( const vector<int>& idAList) {
62  multiMB.initSwitchID( idAList);
63  multiSDA.initSwitchID( idAList);}
64 
65  // Switch to new beam particle identities; for similar hadrons only.
66  void setBeamID(int iPDFA = 0) {multiMB.setBeamID(iPDFA);
67  multiSDA.setBeamID(iPDFA);}
68 
69  // Generate the next parton-level process.
70  bool next( Event& process, Event& event);
71 
72  // Perform showers in resonance decay chains. (For special cases.)
73  void setupShowerSys( Event& process, Event& event);
74  bool resonanceShowers( Event& process, Event& event, bool skipForR);
75 
76  // Perform decays and showers of W and Z emitted in shower.
77  bool wzDecayShowers( Event& event);
78 
79  // Tell whether failure was due to vetoing.
80  bool hasVetoed() const {return doVeto;}
81  bool hasVetoedDiff() const {return doDiffVeto;}
82  bool hasVetoedMerging() const {return doMergingVeto;}
83 
84  // Accumulate, print and reset statistics.
85  void accumulate() {if (isResolved && !isDiff) multiPtr->accumulate();}
86  void statistics(bool reset = false) {
87  if (doMPI) multiMB.statistics(reset);}
88  void resetStatistics() { if (doMPI) multiMB.resetStatistics(); }
89 
90  // Reset PartonLevel object for trial shower usage.
91  void resetTrial();
92  // Provide the pT scale of the last branching in the shower.
93  double pTLastInShower() { return pTLastBranch; }
94  // Provide the type of the last branching in the shower.
95  int typeLastInShower() { return typeLastBranch; }
96 
97  // Check of any trial emissions could have been enhanced.
98  bool canEnhanceTrial() { return doEnhanceTrial; }
99  // Get enhanced trial emission evolution variable.
101  if (canEnhanceTrial()) return infoPtr->weightContainerPtr->
102  weightsSimpleShower.getEnhancedTrialPT();
103  return 0.;
104  }
105  // Get enhanced trial emission weight.
107  if (canEnhanceTrial()) return infoPtr->weightContainerPtr->
108  weightsSimpleShower.getEnhancedTrialWeight();
109  return 1.;
110  }
111 
112  // Spare copies of normal beam pointers.
114  BeamParticle* beamHadBPtr{};
115 
116  // Pointers to timelike showers for resonance decays and the rest.
117  TimeShowerPtr timesDecPtr{};
118  TimeShowerPtr timesPtr{};
119 
120  // Pointer to spacelike showers.
121  SpaceShowerPtr spacePtr{};
122 
123 protected:
124 
125  virtual void onInitInfoPtr() override {
126  registerSubObject(multiMB);
127  registerSubObject(multiSDA);
128  registerSubObject(multiSDB);
129  registerSubObject(multiCD);
130  registerSubObject(multiGmGm);
131  registerSubObject(remnants);
132  registerSubObject(resonanceDecays);
133  registerSubObject(junctionSplitting);
134  registerSubObject(hardDiffraction);
135  }
136 
137 private:
138 
139  // Constants: could only be changed in the code itself.
140  static const int NTRY;
141 
142  // Initialization data, mainly read from Settings.
143  bool doNonDiff{}, doDiffraction{}, doMPI{}, doMPIMB{}, doMPISDA{},
144  doMPISDB{}, doMPICD{}, doMPIinit{}, doISR{}, doFSRduringProcess{},
145  doFSRafterProcess{}, doFSRinResonances{}, doInterleaveResDec{},
146  doRemnants{}, doSecondHard{}, hasOneLeptonBeam{}, hasTwoLeptonBeams{},
147  hasPointLeptons{}, canVetoPT{}, canVetoStep{}, canVetoMPIStep{},
148  canVetoEarly{}, canSetScale{}, allowRH{}, earlyResDec{},
149  vetoWeakJets{}, canReconResSys{}, doReconnect{}, doHardDiff{},
150  forceResonanceCR{}, doNDgamma{}, doMPIgmgm{}, showUnresGamma{};
151  int pTmaxMatchMPI;
152  double mMinDiff{}, mWidthDiff{}, pMaxDiff{}, vetoWeakDeltaR2{};
153 
154  // Event generation strategy. Number of steps. Maximum pT scales.
155  bool doVeto{};
156  int nMPI{}, nISR{}, nFSRinProc{}, nFSRinRes{}, nISRhard{}, nFSRhard{},
157  typeLatest{}, nVetoStep{}, typeVetoStep{}, nVetoMPIStep{}, iSysNow{},
158  reconnectMode{}, hardDiffSide{}, sampleTypeDiff{};
159  double pTsaveMPI{}, pTsaveISR{}, pTsaveFSR{}, pTvetoPT{};
160 
161  // Current event properties.
162  bool isNonDiff{}, isDiffA{}, isDiffB{}, isDiffC{}, isDiff{},
163  isSingleDiff{}, isDoubleDiff{}, isCentralDiff{},
164  isResolved{}, isResolvedA{}, isResolvedB{}, isResolvedC{},
165  isHardDiffA{}, isHardDiffB{}, isHardDiff{}, doDiffVeto{},
166  hardDiffSet{}, isElastic{}, twoHard{};
167  int sizeProcess{}, sizeEvent{}, nHardDone{}, nHardDoneRHad{}, iDS{};
168  double eCMsave;
169  vector<bool> inRHadDecay;
170  vector<int> iPosBefShow;
171 
172  // Variables for photon inside electron.
173  bool hasGammaA{}, hasGammaB{}, beamHasGamma{}, beamAisGamma{},
174  beamBisGamma{}, beamAhasGamma{}, beamBhasGamma{}, beamAhasResGamma{},
175  beamBhasResGamma{}, beamHasResGamma{}, isGammaHadronDir{},
176  sampleQ2gamma{};
177  int gammaMode{}, gammaModeEvent{}, gammaOffset{};
178  double eCMsaveGamma{};
179 
180  // Pointer to assign space-time vertices during parton evolution.
181  PartonVertexPtr partonVertexPtr{};
182 
183  // The generator classes for multiparton interactions.
184  MultipartonInteractions multiMB;
185  MultipartonInteractions multiSDA;
186  MultipartonInteractions multiSDB;
187  MultipartonInteractions multiCD;
188  MultipartonInteractions* multiPtr{};
189  MultipartonInteractions multiGmGm;
190 
191  // The generator class to construct beam-remnant kinematics.
192  BeamRemnants remnants;
193 
194  // The RHadrons class is used to fragment off and decay R-hadrons.
195  RHadrons* rHadronsPtr{};
196 
197  // ResonanceDecay object does sequential resonance decays.
198  ResonanceDecays resonanceDecays;
199 
200  // The Colour reconnection class used to do colour reconnection.
201  ColRecPtr colourReconnectionPtr{};
202 
203  // The Junction splitting class used to split junctions systems.
204  JunctionSplitting junctionSplitting;
205 
206  // The Diffraction class is for hard diffraction selection.
207  HardDiffraction hardDiffraction;
208 
209  // Resolved diffraction: find how many systems should have it.
210  int decideResolvedDiff( Event& process);
211 
212  // Set up an unresolved process, i.e. elastic or diffractive.
213  bool setupUnresolvedSys( Event& process, Event& event);
214 
215  // Set up the hard process, excluding subsequent resonance decays.
216  void setupHardSys( Event& process, Event& event);
217 
218  // Resolved diffraction: pick whether to have it and set up for it.
219  void setupResolvedDiff( Event& process);
220 
221  // Resolved diffraction: restore normal behaviour.
222  void leaveResolvedDiff( int iHardLoop, Event& process, Event& event);
223 
224  // Hard diffraction: set up the process record.
225  void setupHardDiff( Event& process);
226 
227  // Hard diffraction: leave the process record.
228  void leaveHardDiff( Event& process, Event& event, bool physical = true);
229 
230  // Photon beam inside lepton beam: set up the parton level generation.
231  bool setupResolvedLeptonGamma( Event& process);
232 
233  // Photon beam inside lepton beam: recover the whole event and
234  // add scattered leptons.
235  void leaveResolvedLeptonGamma( Event& process, Event& event,
236  bool physical = true);
237 
238  // Set the photon collision mode for the current event.
239  void saveGammaModeEvent( int gammaModeA, int gammaModeB);
240 
241  // Photon beam inside lepton beam: set up the parton level generation.
242  void cleanEventFromGamma( Event& event);
243 
244  // Pointer to MergingHooks object for user interaction with the merging.
245  MergingHooksPtr mergingHooksPtr{};
246  // Parameters to specify trial shower usage.
247  bool doTrial{};
248  bool doEnhanceTrial{};
249  int nTrialEmissions{};
250  // Parameters to store to veto trial showers.
251  double pTLastBranch{};
252  int typeLastBranch{};
253  // Parameters to specify merging usage.
254  bool canRemoveEvent{}, canRemoveEmission{}, doMergingVeto{};
255 
256 };
257 
258 //==========================================================================
259 
260 } // end namespace Pythia8
261 
262 #endif // Pythia8_PartonLevel_H
bool hasVetoed() const
Tell whether failure was due to vetoing.
Definition: PartonLevel.h:80
bool wzDecayShowers(Event &event)
Perform decays and showers of W and Z emitted in shower.
Definition: PartonLevel.cc:2956
bool resonanceShowers(Event &process, Event &event, bool skipForR)
Definition: PartonLevel.cc:2624
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
void statistics(bool resetStat=false)
Print statistics on number of multiparton-interactions processes.
Definition: MultipartonInteractions.cc:2871
The Event class holds all info on the generated event.
Definition: Event.h:453
virtual void onInitInfoPtr() override
Definition: PartonLevel.h:125
Definition: BeamParticle.h:133
double getEnhancedTrialWeight()
Get enhanced trial emission weight.
Definition: PartonLevel.h:106
int typeLastInShower()
Provide the type of the last branching in the shower.
Definition: PartonLevel.h:95
bool next(Event &process, Event &event)
Generate the next parton-level process.
Definition: PartonLevel.cc:335
Definition: JunctionSplitting.h:30
double pTLastInShower()
Provide the pT scale of the last branching in the shower.
Definition: PartonLevel.h:93
SpaceShowerPtr spacePtr
Pointer to spacelike showers.
Definition: PartonLevel.h:121
void accumulate()
Definition: MultipartonInteractions.h:206
Definition: RHadrons.h:29
bool canEnhanceTrial()
Check of any trial emissions could have been enhanced.
Definition: PartonLevel.h:98
double getEnhancedTrialPT()
Get enhanced trial emission evolution variable.
Definition: PartonLevel.h:100
Definition: PartonLevel.h:45
void setBeamID(int iPDFA=0)
Switch to new beam particle identities; for similar hadrons only.
Definition: PartonLevel.h:66
void setupShowerSys(Event &process, Event &event)
Perform showers in resonance decay chains. (For special cases.)
Definition: PartonLevel.cc:1651
void initSwitchID(const vector< int > &idAListIn)
Special setup to allow switching between beam PDFs for MPI handling.
Definition: MultipartonInteractions.h:142
Definition: HardDiffraction.h:31
PartonLevel()=default
Constructor.
BeamParticle * beamHadAPtr
Spare copies of normal beam pointers.
Definition: PartonLevel.h:113
bool init(TimeShowerPtr timesDecPtrIn, TimeShowerPtr timesPtrIn, SpaceShowerPtr spacePtrIn, RHadrons *rHadronsPtrIn, MergingHooksPtr mergingHooksPtr, PartonVertexPtr partonVertexPtrIn, StringIntPtr stringInteractionPtrIn, bool useAsTrial)
Initialization of all classes at the parton level.
Definition: PartonLevel.cc:30
void resetTrial()
Reset PartonLevel object for trial shower usage.
Definition: PartonLevel.cc:310
Header for classes to set beam momentum and interaction vertex spread.
Definition: Analysis.h:20
void accumulate()
Accumulate, print and reset statistics.
Definition: PartonLevel.h:85
Info * infoPtr
Definition: PhysicsBase.h:78
Definition: MultipartonInteractions.h:100
Definition: BeamRemnants.h:35
void initSwitchID(const vector< int > &idAList)
Definition: PartonLevel.h:61
Definition: ResonanceDecays.h:28
TimeShowerPtr timesDecPtr
Pointers to timelike showers for resonance decays and the rest.
Definition: PartonLevel.h:117
void setBeamID(int iPDFAin)
Switch to new beam particle identities, and possibly PDFs.
Definition: MultipartonInteractions.h:147