StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Pythia.h
1 // Pythia.h is a part of the PYTHIA event generator.
2 // Copyright (C) 2018 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 event generation.
7 // Pythia: provide the main user interface to everything else.
8 
9 #ifndef Pythia8_Pythia_H
10 #define Pythia8_Pythia_H
11 
12 // Version number defined for use in macros and for consistency checks.
13 #define PYTHIA_VERSION 8.235
14 #define PYTHIA_VERSION_INTEGER 8235
15 
16 // Header files for the Pythia class and for what else the user may need.
17 #include "Pythia8/Analysis.h"
18 #include "Pythia8/Basics.h"
19 #include "Pythia8/BeamParticle.h"
20 #include "Pythia8/BeamShape.h"
21 #include "Pythia8/ColourReconnection.h"
22 #include "Pythia8/Event.h"
23 #include "Pythia8/FragmentationFlavZpT.h"
24 #include "Pythia8/HadronLevel.h"
25 #include "Pythia8/History.h"
26 #include "Pythia8/Info.h"
27 #include "Pythia8/JunctionSplitting.h"
28 #include "Pythia8/LesHouches.h"
29 #include "Pythia8/Merging.h"
30 #include "Pythia8/MergingHooks.h"
31 #include "Pythia8/PartonLevel.h"
32 #include "Pythia8/ParticleData.h"
33 #include "Pythia8/PartonDistributions.h"
34 #include "Pythia8/PartonSystems.h"
35 #include "Pythia8/PartonVertex.h"
36 #include "Pythia8/ProcessLevel.h"
37 #include "Pythia8/PythiaStdlib.h"
38 #include "Pythia8/ResonanceWidths.h"
39 #include "Pythia8/RHadrons.h"
40 #include "Pythia8/Ropewalk.h"
41 #include "Pythia8/Settings.h"
42 #include "Pythia8/SigmaTotal.h"
43 #include "Pythia8/SpaceShower.h"
44 #include "Pythia8/StandardModel.h"
45 #include "Pythia8/SLHAinterface.h"
46 #include "Pythia8/TimeShower.h"
47 #include "Pythia8/UserHooks.h"
48 
49 namespace Pythia8 {
50 
51 //==========================================================================
52 
53 // Forward declaration of HeavyIons and HIUserHooks classes.
54 class HeavyIons;
55 class HIUserHooks;
56 
57 // The Pythia class contains the top-level routines to generate an event.
58 
59 class Pythia {
60 
61 public:
62 
63  // Constructor. (See Pythia.cc file.)
64  Pythia(string xmlDir = "../share/Pythia8/xmldoc", bool printBanner = true);
65 
66  // Constructor to copy settings and particle database from another Pythia
67  // object instead of XML files (to speed up multiple initialisations).
68  Pythia(Settings& settingsIn, ParticleData& particleDataIn,
69  bool printBanner = true);
70 
71  // Constructor taking input from streams instead of files.
72  Pythia( istream& settingsStrings, istream& particleDataStrings,
73  bool printBanner = true);
74 
75  // Destructor. (See Pythia.cc file.)
76  ~Pythia();
77 
78  // Initialise new Pythia object (called by constructors).
79  void initPtrs();
80 
81  // Check consistency of version numbers (called by constructors).
82  bool checkVersion();
83 
84  // Read in one update for a setting or particle data from a single line.
85  bool readString(string, bool warn = true);
86 
87  // Read in updates for settings or particle data from user-defined file.
88  bool readFile(string fileName, bool warn = true,
89  int subrun = SUBRUNDEFAULT);
90  bool readFile(string fileName, int subrun) {
91  return readFile(fileName, true, subrun);}
92  bool readFile(istream& is = cin, bool warn = true,
93  int subrun = SUBRUNDEFAULT);
94  bool readFile(istream& is, int subrun) {
95  return readFile(is, true, subrun);}
96 
97  // Possibility to pass in pointers to PDF's.
98  bool setPDFPtr( PDF* pdfAPtrIn, PDF* pdfBPtrIn, PDF* pdfHardAPtrIn = 0,
99  PDF* pdfHardBPtrIn = 0, PDF* pdfPomAPtrIn = 0, PDF* pdfPomBPtrIn = 0,
100  PDF* pdfGamAPtrIn = 0, PDF* pdfGamBPtrIn = 0, PDF* pdfHardGamAPtrIn = 0,
101  PDF* pdfHardGamBPtrIn = 0, PDF* pdfUnresAPtrIn = 0,
102  PDF* pdfUnresBPtrIn = 0, PDF* pdfUnresGamAPtrIn = 0,
103  PDF* pdfUnresGamBPtrIn = 0, PDF* pdfVMDAPtrIn = 0, PDF* pdfVMDBPtrIn = 0);
104 
105  // Set photon fluxes externally. Used with option "PDF:lepton2gammaSet = 2".
106  bool setPhotonFluxPtr( PDF* photonFluxAIn, PDF* photonFluxBIn) {
107  if ( photonFluxAIn != 0 ) pdfGamFluxAPtr = photonFluxAIn;
108  if ( photonFluxBIn != 0 ) pdfGamFluxBPtr = photonFluxBIn;
109  return true;}
110 
111  // Possibility to pass in pointer to external LHA-interfaced generator.
112  bool setLHAupPtr( LHAup* lhaUpPtrIn) {lhaUpPtr = lhaUpPtrIn; return true;}
113 
114  // Possibility to pass in pointer for external handling of some decays.
115  bool setDecayPtr( DecayHandler* decayHandlePtrIn,
116  vector<int> handledParticlesIn) {decayHandlePtr = decayHandlePtrIn;
117  handledParticles.resize(0);
118  for (int i = 0; i < int(handledParticlesIn.size()); ++i)
119  handledParticles.push_back( handledParticlesIn[i] );
120  return true;}
121 
122  // Possibility to pass in pointer for external random number generation.
123  bool setRndmEnginePtr( RndmEngine* rndmEnginePtrIn)
124  { return rndm.rndmEnginePtr( rndmEnginePtrIn);}
125 
126  // Possibility to pass in pointer for user hooks.
127  bool setUserHooksPtr( UserHooks* userHooksPtrIn) {
128  if (hasUserHooksVector) delete userHooksPtr;
129  hasUserHooksVector = false;
130  userHooksPtr = userHooksPtrIn; return true;}
131 
132  // Possibility to add further pointers to allow multiple user hooks.
133  bool addUserHooksPtr( UserHooks* userHooksPtrIn) {
134  if ( !userHooksPtr ) return setUserHooksPtr(userHooksPtrIn);
135  UserHooksVector* uhv = dynamic_cast<UserHooksVector*>(userHooksPtr);
136  if ( !uhv ) { uhv = new UserHooksVector();
137  uhv->hooks.push_back(userHooksPtr); userHooksPtr = uhv; }
138  uhv->hooks.push_back(userHooksPtrIn);
139  hasUserHooksVector = true; return true;}
140 
141  // Possibility to pass in pointer for full merging class.
142  bool setMergingPtr( Merging* mergingPtrIn)
143  { mergingPtr = mergingPtrIn; return true;}
144 
145  // Possibility to pass in pointer for merging hooks.
146  bool setMergingHooksPtr( MergingHooks* mergingHooksPtrIn)
147  { mergingHooksPtr = mergingHooksPtrIn; return true;}
148 
149  // Possibility to pass in pointer for beam shape.
150  bool setBeamShapePtr( BeamShape* beamShapePtrIn)
151  { beamShapePtr = beamShapePtrIn; return true;}
152 
153  // Possibility to pass in pointer(s) for external cross section,
154  // with option to include external phase-space generator(s).
155  bool setSigmaPtr( SigmaProcess* sigmaPtrIn, PhaseSpace* phaseSpacePtrIn = 0)
156  { sigmaPtrs.push_back( sigmaPtrIn);
157  phaseSpacePtrs.push_back(phaseSpacePtrIn); return true;}
158 
159  // Possibility to pass in pointer(s) for external resonance.
160  bool setResonancePtr( ResonanceWidths* resonancePtrIn)
161  { resonancePtrs.push_back( resonancePtrIn); return true;}
162 
163  // Possibility to pass in pointer for external showers.
164  bool setShowerPtr( TimeShower* timesDecPtrIn,
165  TimeShower* timesPtrIn = 0, SpaceShower* spacePtrIn = 0)
166  { timesDecPtr = timesDecPtrIn; timesPtr = timesPtrIn;
167  spacePtr = spacePtrIn; return true;}
168 
169  // Possibility to pass in pointer for modelling of heavy ion collisions.
170  bool setHeavyIonsPtr( HeavyIons* heavyIonsPtrIn)
171  { heavyIonsPtr = heavyIonsPtrIn; return true;}
172 
173  // Possibility to pass a HIUserHooks pointer for modifying the
174  // behavior of the heavy ion modelling.
175  bool setHIHooks(HIUserHooks* hiHooksPtrIn)
176  { hiHooksPtr = hiHooksPtrIn; return true; }
177 
178  // Possibility to get the pointer to a object modelling heavy ion
179  // collisions.
180  HeavyIons* getHeavyIonsPtr() { return heavyIonsPtr;}
181 
182  // Possibility to pass in pointer for setting of parton space-time vertices.
183  bool setPartonVertexPtr( PartonVertex* partonVertexPtrIn)
184  { partonVertexPtr = partonVertexPtrIn; return true;}
185 
186  // Initialize.
187  bool init();
188 
189  // Generate the next event.
190  bool next();
191 
192  // Generate only a single timelike shower as in a decay.
193  int forceTimeShower( int iBeg, int iEnd, double pTmax, int nBranchMax = 0)
194  { partonSystems.clear(); info.setScalup( 0, pTmax);
195  return timesDecPtr->shower( iBeg, iEnd, event, pTmax, nBranchMax); }
196 
197  // Generate only the hadronization/decay stage.
198  bool forceHadronLevel( bool findJunctions = true);
199 
200  // Special routine to allow more decays if on/off switches changed.
201  bool moreDecays() {return hadronLevel.moreDecays(event);}
202 
203  // Special routine to force R-hadron decay when not done before.
204  bool forceRHadronDecays() {return doRHadronDecays();}
205 
206  // List the current Les Houches event.
207  void LHAeventList() { if (lhaUpPtr != 0) lhaUpPtr->listEvent();}
208 
209  // Skip a number of Les Houches events at input.
210  bool LHAeventSkip(int nSkip) {
211  if (lhaUpPtr != 0) return lhaUpPtr->skipEvent(nSkip);
212  return false;}
213 
214  // Main routine to provide final statistics on generation.
215  void stat();
216 
217  // Read in settings values: shorthand, not new functionality.
218  bool flag(string key) {return settings.flag(key);}
219  int mode(string key) {return settings.mode(key);}
220  double parm(string key) {return settings.parm(key);}
221  string word(string key) {return settings.word(key);}
222 
223  // Auxiliary to set parton densities among list of possibilities.
224  PDF* getPDFPtr(int idIn, int sequence = 1, string beam = "",
225  bool resolved = true);
226 
227  // The event record for the parton-level central process.
228  Event process;
229 
230  // The event record for the complete event history.
231  Event event;
232 
233  // Information on the generation: current subprocess and error statistics.
234  Info info;
235 
236  // Settings: databases of flags/modes/parms/words to control run.
237  Settings settings;
238 
239  // ParticleData: the particle data table/database.
240  ParticleData particleData;
241 
242  // Random number generator.
243  Rndm rndm;
244 
245  // Standard Model couplings, including alphaS and alphaEM.
246  Couplings couplings;
247  Couplings* couplingsPtr;
248 
249  // SLHA Interface
250  SLHAinterface slhaInterface;
251 
252  // The partonic content of each subcollision system (auxiliary to event).
253  PartonSystems partonSystems;
254 
255  // Merging object as wrapper for matrix element merging routines.
256  Merging* mergingPtr;
257 
258  // Pointer to MergingHooks object for user interaction with the merging.
259  // MergingHooks also more generally steers the matrix element merging.
260  MergingHooks* mergingHooksPtr;
261 
262  // Pointer to a HeavyIons object for generating heavy ion collisions
263  HeavyIons* heavyIonsPtr;
264 
265  // Pointer to a HIUserHooks object to modify heavy ion modelling.
266  HIUserHooks* hiHooksPtr;
267 
268  // The two incoming beams.
269  BeamParticle beamA;
270  BeamParticle beamB;
271 
272 private:
273 
274  // Copy and = constructors are made private so they cannot be used.
275  Pythia(const Pythia&);
276  Pythia& operator=(const Pythia&);
277 
278  // Constants: could only be changed in the code itself.
279  static const double VERSIONNUMBERHEAD, VERSIONNUMBERCODE;
280  static const int NTRY, SUBRUNDEFAULT;
281 
282  // Initialization data, extracted from database.
283  string xmlPath;
284  bool doProcessLevel, doPartonLevel, doHadronLevel, doSoftQCDall,
285  doSoftQCDinel, doCentralDiff, doDiffraction,
286  doSoftQCD, doVMDsideA, doVMDsideB, doHardDiff, doResDec,
287  doFSRinRes, decayRHadrons, abortIfVeto, checkEvent, checkHistory;
288  int nErrList;
289  double epTolErr, epTolWarn, mTolErr, mTolWarn;
290 
291  // Initialization data related to photon-photon interactions.
292  bool beamHasGamma, beamAisResGamma, beamBisResGamma, beamAhasResGamma,
293  beamBhasResGamma;
294  int gammaMode;
295 
296  // Initialization data, extracted from init(...) call.
297  bool isConstructed, isInit, isUnresolvedA, isUnresolvedB, showSaV,
298  showMaD, doReconnect, forceHadronLevelCR;
299  int idA, idB, frameType, boostType, nCount, nShowLHA, nShowInfo,
300  nShowProc, nShowEvt, reconnectMode;
301  double mA, mB, pxA, pxB, pyA, pyB, pzA, pzB, eA, eB,
302  pzAcm, pzBcm, eCM, betaZ, gammaZ;
303  Vec4 pAinit, pBinit, pAnow, pBnow;
304  RotBstMatrix MfromCM, MtoCM;
305 
306  // information for error checkout.
307  int nErrEvent;
308  vector<int> iErrId, iErrCol, iErrEpm, iErrNan, iErrNanVtx;
309 
310  // Pointers to the parton distributions of the two incoming beams.
311  PDF* pdfAPtr;
312  PDF* pdfBPtr;
313 
314  // Extra PDF pointers to be used in hard processes only.
315  PDF* pdfHardAPtr;
316  PDF* pdfHardBPtr;
317 
318  // Extra Pomeron PDF pointers to be used in diffractive processes only.
319  PDF* pdfPomAPtr;
320  PDF* pdfPomBPtr;
321 
322  // Extra Photon PDF pointers to be used in lepton -> gamma processes.
323  PDF* pdfGamAPtr;
324  PDF* pdfGamBPtr;
325 
326  // Extra PDF pointers to be used in hard lepton -> gamma processes.
327  PDF* pdfHardGamAPtr;
328  PDF* pdfHardGamBPtr;
329 
330  // Alternative unresolved PDFs when mixing resolved and unresolved processes.
331  PDF* pdfUnresAPtr;
332  PDF* pdfUnresBPtr;
333  PDF* pdfUnresGamAPtr;
334  PDF* pdfUnresGamBPtr;
335 
336  // PDF pointers to externally provided photon fluxes.
337  PDF* pdfGamFluxAPtr;
338  PDF* pdfGamFluxBPtr;
339 
340  // Extra VMD PDF pointers to be used in SoftQCD with gammas.
341  PDF* pdfVMDAPtr;
342  PDF* pdfVMDBPtr;
343 
344  // Keep track when "new" has been used and needs a "delete" for PDF's etc.
345  bool useNewPdfA, useNewPdfB, useNewPdfHard, useNewPdfPomA, useNewPdfPomB,
346  useNewPdfGamA, useNewPdfGamB, useNewPdfHardGamA, useNewPdfHardGamB,
347  useNewPdfUnresA, useNewPdfUnresB, useNewPdfUnresGamA, useNewPdfUnresGamB,
348  useNewPdfVMDA, useNewPdfVMDB, hasUserHooksVector;
349 
350  // Alternative Pomeron beam-inside-beam.
351  BeamParticle beamPomA;
352  BeamParticle beamPomB;
353 
354  // Alternative photon beam-inside-beam.
355  BeamParticle beamGamA;
356  BeamParticle beamGamB;
357 
358  // Alternative VMD beam-inside-beam.
359  BeamParticle beamVMDA;
360  BeamParticle beamVMDB;
361 
362  // LHAup object for generating external events.
363  bool doLHA, useNewLHA;
364  LHAup* lhaUpPtr;
365 
366  // Pointer to external decay handler and list of particles it handles.
367  DecayHandler* decayHandlePtr;
368  vector<int> handledParticles;
369 
370  // Pointer to UserHooks object for user interaction with program.
371  UserHooks* userHooksPtr;
372  bool hasUserHooks, doVetoProcess, doVetoPartons, retryPartonLevel;
373 
374  // Pointer to BeamShape object for beam momentum and interaction vertex.
375  BeamShape* beamShapePtr;
376  bool useNewBeamShape, doMomentumSpread, doVertexSpread;
377 
378  // Pointers to external processes derived from the Pythia base classes.
379  vector<SigmaProcess*> sigmaPtrs;
380 
381  // Pointers to external phase-space generators derived from Pythia
382  // base classes.
383  vector<PhaseSpace*> phaseSpacePtrs;
384 
385  // Pointers to external calculation of resonance widths.
386  vector<ResonanceWidths*> resonancePtrs;
387 
388  // Pointers to timelike and spacelike showers.
389  TimeShower* timesDecPtr;
390  TimeShower* timesPtr;
391  SpaceShower* spacePtr;
392  bool useNewTimesDec, useNewTimes, useNewSpace;
393 
394  // Pointer to assign space-time vertices during parton evolution.
395  PartonVertex* partonVertexPtr;
396  bool useNewPartonVertex;
397 
398  // The main generator class to define the core process of the event.
399  ProcessLevel processLevel;
400 
401  // The main generator class to produce the parton level of the event.
402  PartonLevel partonLevel;
403 
404  // The main generator class to perform trial showers of the event.
405  PartonLevel trialPartonLevel;
406 
407  // Flags for defining the merging scheme.
408  bool hasMerging, hasOwnMerging;
409  bool hasMergingHooks, hasOwnMergingHooks, doMerging;
410 
411  // The Colour reconnection class.
412  ColourReconnection colourReconnection;
413 
414  // The junction spltiting class.
415  JunctionSplitting junctionSplitting;
416 
417  // The main generator class to produce the hadron level of the event.
418  HadronLevel hadronLevel;
419 
420  // The total cross section class is used both on process and parton level.
421  SigmaTotal sigmaTot;
422 
423  // The RHadrons class is used both at PartonLevel and HadronLevel.
424  RHadrons rHadrons;
425 
426  // Flags for handling generation of heavy ion collisons.
427  bool hasHeavyIons, hasOwnHeavyIons, doHeavyIons;
428 
429  // Write the Pythia banner, with symbol and version information.
430  void banner();
431 
432  // Check for lines in file that mark the beginning of new subrun.
433  int readSubrun(string line, bool warn = true);
434 
435  // Check for lines that mark the beginning or end of commented section.
436  int readCommented(string line);
437 
438  // Check that combinations of settings are allowed; change if not.
439  void checkSettings();
440 
441  // Check that beams and beam combination can be handled.
442  bool checkBeams();
443 
444  // Calculate kinematics at initialization.
445  bool initKinematics();
446 
447  // Set up pointers to PDFs.
448  bool initPDFs();
449 
450  // Recalculate kinematics for each event when beam momentum has a spread.
451  void nextKinematics();
452 
453  // Boost from CM frame to lab frame, or inverse. Set production vertex.
454  void boostAndVertex(bool toLab, bool setVertex);
455 
456  // Perform R-hadron decays.
457  bool doRHadronDecays();
458 
459  // Check that the final event makes sense.
460  bool check();
461 
462  // Initialization of SLHA data.
463  bool initSLHA ();
464  stringstream particleDataBuffer;
465 
466 };
467 
468 //==========================================================================
469 
470 } // end namespace Pythia8
471 
472 #endif // Pythia8_Pythia_H
Definition: beam.h:43
Definition: AgUStep.h:26