PYTHIA  8.313
TimeShower.h
1 // TimeShower.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 // Header file for the base class of timelike final-state showers.
7 // TimeShower: handles the showering description.
8 
9 #ifndef Pythia8_TimeShower_H
10 #define Pythia8_TimeShower_H
11 
12 #include "Pythia8/Basics.h"
13 #include "Pythia8/BeamParticle.h"
14 #include "Pythia8/Event.h"
15 #include "Pythia8/Info.h"
16 #include "Pythia8/ParticleData.h"
17 #include "Pythia8/PartonSystems.h"
18 #include "Pythia8/PhysicsBase.h"
19 #include "Pythia8/PythiaStdlib.h"
20 #include "Pythia8/PartonVertex.h"
21 #include "Pythia8/Settings.h"
22 #include "Pythia8/StandardModel.h"
23 #include "Pythia8/UserHooks.h"
24 #include "Pythia8/MergingHooks.h"
25 #include "Pythia8/Weights.h"
26 
27 namespace Pythia8 {
28 
29 //==========================================================================
30 
31 // The TimeShower class does timelike showers.
32 
33 class TimeShower : public PhysicsBase {
34 
35 public:
36 
37  // Constructor.
38  TimeShower() = default;
39 
40  // Destructor.
41  virtual ~TimeShower() {}
42 
43  // Initialize various pointers.
44  // (Separated from rest of init since not virtual.)
45  void initPtrs(MergingHooksPtr mergingHooksPtrIn,
46  PartonVertexPtr partonVertexPtrIn,
47  WeightContainer* weightContainerPtrIn) {
49  mergingHooksPtr = mergingHooksPtrIn;
50  partonVertexPtr = partonVertexPtrIn;
51  weightContainerPtr = weightContainerPtrIn;
52  }
53 
54  // New beams possible for handling of hard diffraction. (Not virtual.)
55  void reassignBeamPtrs( BeamParticle* beamAPtrIn, BeamParticle* beamBPtrIn,
56  int beamOffsetIn = 0) {beamAPtr = beamAPtrIn; beamBPtr = beamBPtrIn;
57  beamOffset = beamOffsetIn;}
58 
59  // Initialize alphaStrong and related pTmin parameters.
60  // Usage: init( beamAPtr, beamBPtr).
61  virtual void init( BeamParticle* = 0, BeamParticle* = 0) {}
62 
63  // Find whether to limit maximum scale of emissions, and whether to dampen.
64  // Usage: limitPTmax( event, Q2Fac, double Q2Ren).
65  virtual bool limitPTmax( Event& , double = 0., double = 0.) {return true;}
66 
67  // Top-level routine to do a full time-like shower in resonance decay.
68  // Usage: shower( iBeg, iEnd, event, pTmax, nBranchMax).
69  virtual int shower( int , int , Event& , double , int = 0) {return 0;}
70 
71  // Top-level routine for QED radiation in hadronic decays.
72  // Usage: showerQED( i1, i2, event, pTmax).
73  virtual int showerQED( int , int , Event& , double = -1.) {return 0;}
74 
75  // Optional method to add QED showers after remnants have been added
76  // but before hadronisation. (Called from PartonLevel.)
77  virtual int showerQEDafterRemnants(Event&) { return 0; }
78 
79  // Optional method to add QED showers after all hadron decays have been
80  // treated, as an alternative to handling QED showers inside each decay.
81  virtual int showerQEDafterDecays( int , int , Event&) { return 0; }
82 
83  // Prepare process-level event for shower + interleaved resonance decays.
84  // Usage: prepareProcess( process, event, iPos).
85  // iPos provides mapping from process to event entries (before showering).
86  virtual void prepareProcess( Event&, Event&, vector<int>&) {};
87 
88  // Global recoil: reset counters and store locations of outgoing partons.
89  // Usage: prepareGlobal( event).
90  virtual void prepareGlobal( Event& ) {}
91 
92  // Prepare system for evolution after each new interaction; identify ME.
93  // Usage: prepare( iSys, event, limitPTmax).
94  virtual void prepare( int , Event& , bool = true) {}
95 
96  // Update dipole list after a multiparton interactions rescattering.
97  // Usage: rescatterUpdate( iSys, event).
98  virtual void rescatterUpdate( int , Event& ) {}
99 
100  // Update dipole list after each ISR emission.
101  // Usage: update( iSys, event, hasWeakRad).
102  virtual void update( int , Event& , bool = false) {}
103 
104  // Select next pT in downwards evolution.
105  // Usage: pTnext( event, pTbegAll, pTendAll, isFirstTrial, doTrialIn).
106  virtual double pTnext( Event& , double , double , bool = false, bool = false)
107  { return 0.;}
108 
109  // Select next pT for interleaved resonance decays.
110  virtual double pTnextResDec() { return 0.; }
111 
112  // ME corrections and kinematics that may give failure.
113  // Usage: branch( event, isInterleaved).
114  virtual bool branch( Event& , bool = false) {return true;}
115 
116  // Handle a resonance decay + resonance shower (including any nested decays).
117  // Assumes decay channel and kinematics already selected and present in
118  // either the process or event record.
119  // May be called recursively for nested decays.
120  // Usage: resonanceShower( process, event, iPos, pTmerge), where iPos
121  // maps process to event entries, and pTmerge is the scale at which this
122  // system should be merged into its parent system.
123  virtual bool resonanceShower( Event&, Event&, vector<int>&, double = 0.)
124  { return false;}
125 
126  // Print dipole list; for debug mainly.
127  virtual void list() const {}
128 
129  // Initialize data members for calculation of uncertainty bands.
130  virtual bool initUncertainties() {return false;}
131 
132  // Initialize data members for application of enhancements.
133  virtual bool initEnhancements() {return false;}
134 
135  // Tell whether FSR has done a weak emission.
136  virtual bool getHasWeaklyRadiated() {return false;}
137 
138  // Tell which system was the last processed one.
139  virtual int system() const {return 0;}
140 
141  // Potential enhancement factor of pTmax scale for hardest emission.
142  virtual double enhancePTmax() {return 1.;}
143 
144  // Provide the pT scale of the last branching in the above shower.
145  virtual double pTLastInShower() {return 0.;}
146 
147  // Functions to allow usage of shower kinematics, evolution variables,
148  // and splitting probabilities outside of shower.
149  // Virtual so that shower plugins can overwrite these functions.
150  // This makes it possible for another piece of the code to request
151  // these - which is very convenient for merging.
152  // Function variable names are not included to avoid compiler warnings.
153  // Please see the documentation under "Implement New Showers" for details.
154 
155  // Return clustering kinematics - as needed for merging.
156  virtual Event clustered( const Event& , int , int , int , string )
157  { return Event();}
158 
159  // Return the evolution variable(s).
160  // Important note: this map must contain the following entries
161  // - a key "t" for the value of the shower evolution variable;
162  // - a key "tRS" for the value of the shower evolution variable
163  // from which the shower would be restarted after a branching;
164  // - a key "scaleAS" for the argument of alpha_s used for the branching;
165  // - a key "scalePDF" for the argument of the PDFs used for the branching.
166  // Usage: getStateVariables( event, iRad, iEmt, iRec, name)
167  virtual map<string, double> getStateVariables (const Event& , int , int ,
168  int , string ) { return map<string,double>();}
169 
170  // Check if attempted clustering is handled by timelike shower
171  // Usage: isTimelike( event, iRad, iEmt, iRec, name)
172  virtual bool isTimelike(const Event& , int , int , int , string )
173  { return false; }
174 
175  // Return a string identifier of a splitting.
176  // Usage: getSplittingName( event, iRad, iEmt, iRec)
177  virtual vector<string> getSplittingName( const Event& , int, int , int)
178  { return vector<string>();}
179 
180  // Return the splitting probability.
181  // Usage: getSplittingProb( event, iRad, iEmt, iRec)
182  virtual double getSplittingProb( const Event& , int , int , int , string )
183  { return 0.;}
184  virtual bool allowedSplitting( const Event& , int , int)
185  { return true; }
186  virtual vector<int> getRecoilers( const Event&, int, int, string)
187  { return vector<int>(); }
188 
189  virtual double enhanceFactor(const string& name) {
190  unordered_map<string, double>::iterator it = enhanceFSR.find(name);
191  if ( it == enhanceFSR.end() ) return 1.;
192  return it->second;
193  }
194 
195  // Functions to directly extract the probability of no emission between two
196  // scales. This functions is not used in the Pythia core code, but can be
197  // used by external programs to interface with the shower directly.
198  virtual double noEmissionProbability( double, double, double, int, int,
199  double, double) { return 1.; }
200 
201  // Pointer to MergingHooks object for NLO merging.
202  MergingHooksPtr mergingHooksPtr{};
203 
204  WeightContainer* weightContainerPtr{};
205 
206 protected:
207 
208  // Beam location offset in event.
209  int beamOffset{};
210 
211  // Pointer to assign space-time vertices during parton evolution.
212  PartonVertexPtr partonVertexPtr{};
213 
214  // Store uncertainty variations relevant to TimeShower.
215  bool doUncertainties{}, uVarMuSoftCorr{}, uVarMPIshowers{},
216  noResVariations{}, noProcVariations{};
217  int nUncertaintyVariations{}, nVarQCD{}, uVarNflavQ{};
218  double dASmax{}, cNSpTmin{}, uVarpTmin2{}, overFactor{}, overFactorEnhance{};
219  map<int,double> varG2GGmuRfac, varQ2QGmuRfac, varG2QQmuRfac, varX2XGmuRfac,
220  varG2GGcNS, varQ2QGcNS, varG2QQcNS, varX2XGcNS;
221  map<int,double>* varPDFplus;
222  map<int,double>* varPDFminus;
223  map<int,double>* varPDFmember;
224  unordered_map<string,double> enhanceFSR;
225 
226 };
227 
228 //==========================================================================
229 
230 } // end namespace Pythia8
231 
232 #endif // Pythia8_TimeShower_H
virtual bool isTimelike(const Event &, int, int, int, string)
Definition: TimeShower.h:172
virtual bool resonanceShower(Event &, Event &, vector< int > &, double=0.)
Definition: TimeShower.h:123
virtual double getSplittingProb(const Event &, int, int, int, string)
Definition: TimeShower.h:182
Definition: PhysicsBase.h:27
virtual bool initUncertainties()
Initialize data members for calculation of uncertainty bands.
Definition: TimeShower.h:130
virtual map< string, double > getStateVariables(const Event &, int, int, int, string)
Definition: TimeShower.h:167
The Event class holds all info on the generated event.
Definition: Event.h:408
The TimeShower class does timelike showers.
Definition: TimeShower.h:33
Definition: BeamParticle.h:133
Definition: Weights.h:433
virtual void init(BeamParticle *=0, BeamParticle *=0)
Definition: TimeShower.h:61
CoupSM * coupSMPtr
Pointers to Standard Model and Beyond SM couplings.
Definition: Info.h:95
virtual int shower(int, int, Event &, double, int=0)
Definition: TimeShower.h:69
virtual void prepareGlobal(Event &)
Definition: TimeShower.h:90
TimeShower()=default
Constructor.
virtual int system() const
Tell which system was the last processed one.
Definition: TimeShower.h:139
virtual ~TimeShower()
Destructor.
Definition: TimeShower.h:41
MergingHooksPtr mergingHooksPtr
Pointer to MergingHooks object for NLO merging.
Definition: TimeShower.h:202
virtual void update(int, Event &, bool=false)
Definition: TimeShower.h:102
void initPtrs(MergingHooksPtr mergingHooksPtrIn, PartonVertexPtr partonVertexPtrIn, WeightContainer *weightContainerPtrIn)
Definition: TimeShower.h:45
virtual bool limitPTmax(Event &, double=0., double=0.)
Definition: TimeShower.h:65
int beamOffset
Beam location offset in event.
Definition: TimeShower.h:209
virtual bool getHasWeaklyRadiated()
Tell whether FSR has done a weak emission.
Definition: TimeShower.h:136
virtual Event clustered(const Event &, int, int, int, string)
Return clustering kinematics - as needed for merging.
Definition: TimeShower.h:156
virtual void rescatterUpdate(int, Event &)
Definition: TimeShower.h:98
void reassignBeamPtrs(BeamParticle *beamAPtrIn, BeamParticle *beamBPtrIn, int beamOffsetIn=0)
New beams possible for handling of hard diffraction. (Not virtual.)
Definition: TimeShower.h:55
virtual vector< string > getSplittingName(const Event &, int, int, int)
Definition: TimeShower.h:177
virtual void prepareProcess(Event &, Event &, vector< int > &)
Definition: TimeShower.h:86
virtual double noEmissionProbability(double, double, double, int, int, double, double)
Definition: TimeShower.h:198
virtual bool initEnhancements()
Initialize data members for application of enhancements.
Definition: TimeShower.h:133
CoupSM * coupSMPtr
Pointers to SM and SUSY couplings.
Definition: PhysicsBase.h:96
virtual bool branch(Event &, bool=false)
Definition: TimeShower.h:114
virtual int showerQEDafterDecays(int, int, Event &)
Definition: TimeShower.h:81
Header for classes to set beam momentum and interaction vertex spread.
Definition: Analysis.h:20
PartonVertexPtr partonVertexPtr
Pointer to assign space-time vertices during parton evolution.
Definition: TimeShower.h:212
Info * infoPtr
Definition: PhysicsBase.h:78
virtual void prepare(int, Event &, bool=true)
Definition: TimeShower.h:94
virtual int showerQED(int, int, Event &, double=-1.)
Definition: TimeShower.h:73
virtual void list() const
Print dipole list; for debug mainly.
Definition: TimeShower.h:127
virtual double pTLastInShower()
Provide the pT scale of the last branching in the above shower.
Definition: TimeShower.h:145
virtual double pTnext(Event &, double, double, bool=false, bool=false)
Definition: TimeShower.h:106
virtual double pTnextResDec()
Select next pT for interleaved resonance decays.
Definition: TimeShower.h:110
bool doUncertainties
Store uncertainty variations relevant to TimeShower.
Definition: TimeShower.h:215
virtual int showerQEDafterRemnants(Event &)
Definition: TimeShower.h:77
virtual double enhancePTmax()
Potential enhancement factor of pTmax scale for hardest emission.
Definition: TimeShower.h:142