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) 2014 Torbjorn Sjostrand.
3 // PYTHIA is licenced under the GNU GPL version 2, 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 #include "Pythia8/Analysis.h"
13 #include "Pythia8/Basics.h"
14 #include "Pythia8/BeamParticle.h"
15 #include "Pythia8/BeamShape.h"
16 #include "Pythia8/Event.h"
17 #include "Pythia8/FragmentationFlavZpT.h"
18 #include "Pythia8/HadronLevel.h"
19 #include "Pythia8/History.h"
20 #include "Pythia8/Info.h"
21 #include "Pythia8/LesHouches.h"
22 #include "Pythia8/PartonLevel.h"
23 #include "Pythia8/ParticleData.h"
24 #include "Pythia8/PartonDistributions.h"
25 #include "Pythia8/PartonSystems.h"
26 #include "Pythia8/ProcessLevel.h"
27 #include "Pythia8/PythiaStdlib.h"
28 #include "Pythia8/ResonanceWidths.h"
29 #include "Pythia8/RHadrons.h"
30 #include "Pythia8/Settings.h"
31 #include "Pythia8/SigmaTotal.h"
32 #include "Pythia8/SpaceShower.h"
33 #include "Pythia8/StandardModel.h"
34 #include "Pythia8/SLHAinterface.h"
35 #include "Pythia8/TimeShower.h"
36 #include "Pythia8/UserHooks.h"
37 #include "Pythia8/MergingHooks.h"
38 #include "Pythia8/Merging.h"
39 
40 namespace Pythia8 {
41 
42 //==========================================================================
43 
44 // The Pythia class contains the top-level routines to generate an event.
45 
46 class Pythia {
47 
48 public:
49 
50  // Constructor. (See Pythia.cc file.)
51  Pythia(string xmlDir = "../xmldoc", bool printBanner = true);
52 
53  // Destructor. (See Pythia.cc file.)
54  ~Pythia();
55 
56  // Read in one update for a setting or particle data from a single line.
57  bool readString(string, bool warn = true);
58 
59  // Read in updates for settings or particle data from user-defined file.
60  bool readFile(string fileName, bool warn = true,
61  int subrun = SUBRUNDEFAULT);
62  bool readFile(string fileName, int subrun) {
63  return readFile(fileName, true, subrun);}
64  bool readFile(istream& is = cin, bool warn = true,
65  int subrun = SUBRUNDEFAULT);
66  bool readFile(istream& is, int subrun) {
67  return readFile(is, true, subrun);}
68 
69  // Possibility to pass in pointers to PDF's.
70  bool setPDFPtr( PDF* pdfAPtrIn, PDF* pdfBPtrIn, PDF* pdfHardAPtrIn = 0,
71  PDF* pdfHardBPtrIn = 0, PDF* pdfPomAPtrIn = 0, PDF* pdfPomBPtrIn = 0);
72 
73  // Possibility to pass in pointer to external LHA-interfaced generator.
74  bool setLHAupPtr( LHAup* lhaUpPtrIn) {lhaUpPtr = lhaUpPtrIn; return true;}
75 
76  // Possibility to pass in pointer for external handling of some decays.
77  bool setDecayPtr( DecayHandler* decayHandlePtrIn,
78  vector<int> handledParticlesIn) {decayHandlePtr = decayHandlePtrIn;
79  handledParticles.resize(0);
80  for(int i = 0; i < int(handledParticlesIn.size()); ++i)
81  handledParticles.push_back( handledParticlesIn[i] ); return true;}
82 
83  // Possibility to pass in pointer for external random number generation.
84  bool setRndmEnginePtr( RndmEngine* rndmEnginePtrIn)
85  { return rndm.rndmEnginePtr( rndmEnginePtrIn);}
86 
87  // Possibility to pass in pointer for user hooks.
88  bool setUserHooksPtr( UserHooks* userHooksPtrIn)
89  { userHooksPtr = userHooksPtrIn; return true;}
90 
91  // Possibility to pass in pointer for merging hooks.
92  bool setMergingHooksPtr( MergingHooks* mergingHooksPtrIn)
93  { mergingHooksPtr = mergingHooksPtrIn; return true;}
94 
95  // Possibility to pass in pointer for beam shape.
96  bool setBeamShapePtr( BeamShape* beamShapePtrIn)
97  { beamShapePtr = beamShapePtrIn; return true;}
98 
99  // Possibility to pass in pointer(s) for external cross section.
100  bool setSigmaPtr( SigmaProcess* sigmaPtrIn)
101  { sigmaPtrs.push_back( sigmaPtrIn); return true;}
102 
103  // Possibility to pass in pointer(s) for external resonance.
104  bool setResonancePtr( ResonanceWidths* resonancePtrIn)
105  { resonancePtrs.push_back( resonancePtrIn); return true;}
106 
107  // Possibility to pass in pointer for external showers.
108  bool setShowerPtr( TimeShower* timesDecPtrIn,
109  TimeShower* timesPtrIn = 0, SpaceShower* spacePtrIn = 0)
110  { timesDecPtr = timesDecPtrIn; timesPtr = timesPtrIn;
111  spacePtr = spacePtrIn; return true;}
112 
113  // Initialization using the Beams variables.
114  bool init();
115 
116  // Deprecated: initialization in the CM frame.
117  bool init( int idAin, int idBin, double eCMin);
118 
119  // Deprecated: initialization with two collinear beams, e.g. fixed target.
120  bool init( int idAin, int idBin, double eAin, double eBin);
121 
122  // Deprecated: initialization with two acollinear beams.
123  bool init( int idAin, int idBin, double pxAin, double pyAin,
124  double pzAin, double pxBin, double pyBin, double pzBin);
125 
126  // Deprecated: initialization by a Les Houches Event File.
127  bool init( string LesHouchesEventFile, bool skipInit = false);
128 
129  // Deprecated: initialization according to the Les Houches Accord.
130  bool init( LHAup* lhaUpPtrIn);
131 
132  // Generate the next event.
133  bool next();
134 
135  // Generate only a single timelike shower as in a decay.
136  int forceTimeShower( int iBeg, int iEnd, double pTmax, int nBranchMax = 0)
137  { info.setScalup( 0, pTmax);
138  return timesDecPtr->shower( iBeg, iEnd, event, pTmax, nBranchMax); }
139 
140  // Generate only the hadronization/decay stage.
141  bool forceHadronLevel( bool findJunctions = true);
142 
143  // Special routine to allow more decays if on/off switches changed.
144  bool moreDecays() {return hadronLevel.moreDecays(event);}
145 
146  // Special routine to force R-hadron decay when not done before.
147  bool forceRHadronDecays() {return doRHadronDecays();}
148 
149  // List the current Les Houches event.
150  void LHAeventList(ostream& os = cout) {
151  if (lhaUpPtr != 0) lhaUpPtr->listEvent(os);}
152 
153  // Skip a number of Les Houches events at input.
154  bool LHAeventSkip(int nSkip) {
155  if (lhaUpPtr != 0) return lhaUpPtr->skipEvent(nSkip); return false;}
156 
157  // Main routine to provide final statistics on generation.
158  void stat();
159 
160  // Deprecated: alternative to provide final statistics on generation.
161  void statistics(bool all = false, bool reset = false);
162 
163  // Read in settings values: shorthand, not new functionality.
164  bool flag(string key) {return settings.flag(key);}
165  int mode(string key) {return settings.mode(key);}
166  double parm(string key) {return settings.parm(key);}
167  string word(string key) {return settings.word(key);}
168 
169  // Auxiliary to set parton densities among list of possibilities.
170  PDF* getPDFPtr(int idIn, int sequence = 1);
171 
172  // The event record for the parton-level central process.
173  Event process;
174 
175  // The event record for the complete event history.
176  Event event;
177 
178  // Information on the generation: current subprocess and error statistics.
179  Info info;
180 
181  // Settings: databases of flags/modes/parms/words to control run.
182  Settings settings;
183 
184  // ParticleData: the particle data table/database.
185  ParticleData particleData;
186 
187  // Random number generator.
188  Rndm rndm;
189 
190  // Standard Model couplings, including alphaS and alphaEM.
191  Couplings couplings;
192  Couplings* couplingsPtr;
193 
194  // SLHA Interface
195  SLHAinterface slhaInterface;
196 
197  // The partonic content of each subcollision system (auxiliary to event).
198  PartonSystems partonSystems;
199 
200  // Merging object as wrapper for matrix element merging routines.
201  Merging merging;
202 
203  // Pointer to MergingHooks object for user interaction with the merging.
204  // MergingHooks also more generally steers the matrix element merging.
205  MergingHooks* mergingHooksPtr;
206 
207 private:
208 
209  // Copy and = constructors are made private so they cannot be used.
210  Pythia(const Pythia&);
211  Pythia& operator=(const Pythia&);
212 
213  // Constants: could only be changed in the code itself.
214  static const double VERSIONNUMBERCODE;
215  static const int NTRY, SUBRUNDEFAULT;
216 
217  // Initialization data, extracted from database.
218  string xmlPath;
219  bool doProcessLevel, doPartonLevel, doHadronLevel, doDiffraction,
220  doResDec, doFSRinRes, decayRHadrons, abortIfVeto, checkEvent,
221  checkHistory;
222  int nErrList;
223  double epTolErr, epTolWarn;
224 
225  // Initialization data, extracted from init(...) call.
226  bool isConstructed, isInit, isUnresolvedA, isUnresolvedB, showSaV,
227  showMaD;
228  int idA, idB, frameType, boostType, nCount, nShowLHA, nShowInfo,
229  nShowProc, nShowEvt;
230  double mA, mB, pxA, pxB, pyA, pyB, pzA, pzB, eA, eB,
231  pzAcm, pzBcm, eCM, betaZ, gammaZ;
232  Vec4 pAinit, pBinit, pAnow, pBnow;
233  RotBstMatrix MfromCM, MtoCM;
234 
235  // information for error checkout.
236  int nErrEvent;
237  vector<int> iErrId, iErrCol, iErrEpm, iErrNan, iErrNanVtx;
238 
239  // Pointers to the parton distributions of the two incoming beams.
240  PDF* pdfAPtr;
241  PDF* pdfBPtr;
242 
243  // Extra PDF pointers to be used in hard processes only.
244  PDF* pdfHardAPtr;
245  PDF* pdfHardBPtr;
246 
247  // Extra Pomeron PDF pointers to be used in diffractive processes only.
248  PDF* pdfPomAPtr;
249  PDF* pdfPomBPtr;
250 
251  // Keep track when "new" has been used and needs a "delete" for PDF's.
252  bool useNewPdfA, useNewPdfB, useNewPdfHard, useNewPdfPomA, useNewPdfPomB;
253 
254  // The two incoming beams.
255  BeamParticle beamA;
256  BeamParticle beamB;
257 
258  // Alternative Pomeron beam-inside-beam.
259  BeamParticle beamPomA;
260  BeamParticle beamPomB;
261 
262  // LHAup object for generating external events.
263  bool doLHA, useNewLHA;
264  LHAup* lhaUpPtr;
265 
266  // Pointer to external decay handler and list of particles it handles.
267  DecayHandler* decayHandlePtr;
268  vector<int> handledParticles;
269 
270  // Pointer to UserHooks object for user interaction with program.
271  UserHooks* userHooksPtr;
272  bool hasUserHooks, doVetoProcess, doVetoPartons, retryPartonLevel;
273 
274  // Pointer to BeamShape object for beam momentum and interaction vertex.
275  BeamShape* beamShapePtr;
276  bool useNewBeamShape, doMomentumSpread, doVertexSpread;
277 
278  // Pointers to external processes derived from the Pythia base classes.
279  vector<SigmaProcess*> sigmaPtrs;
280 
281  // Pointers to external calculation of resonance widths.
282  vector<ResonanceWidths*> resonancePtrs;
283 
284  // Pointers to timelike and spacelike showers.
285  TimeShower* timesDecPtr;
286  TimeShower* timesPtr;
287  SpaceShower* spacePtr;
288  bool useNewTimes, useNewSpace;
289 
290  // The main generator class to define the core process of the event.
291  ProcessLevel processLevel;
292 
293  // The main generator class to produce the parton level of the event.
294  PartonLevel partonLevel;
295 
296  // The main generator class to perform trial showers of the event.
297  PartonLevel trialPartonLevel;
298 
299  // Flags for defining the merging scheme.
300  bool hasMergingHooks, hasOwnMergingHooks, doMerging;
301 
302  // The main generator class to produce the hadron level of the event.
303  HadronLevel hadronLevel;
304 
305  // The total cross section class is used both on process and parton level.
306  SigmaTotal sigmaTot;
307 
308  // The RHadrons class is used both at PartonLevel and HadronLevel.
309  RHadrons rHadrons;
310 
311  // Write the Pythia banner, with symbol and version information.
312  void banner(ostream& os = cout);
313 
314  // Check for lines in file that mark the beginning of new subrun.
315  int readSubrun(string line, bool warn = true, ostream& os = cout);
316 
317  // Check for lines that mark the beginning or end of commented section.
318  int readCommented(string line);
319 
320  // Check that combinations of settings are allowed; change if not.
321  void checkSettings();
322 
323  // Check that beams and beam combination can be handled.
324  bool checkBeams();
325 
326  // Calculate kinematics at initialization.
327  bool initKinematics();
328 
329  // Set up pointers to PDFs.
330  bool initPDFs();
331 
332  // Recalculate kinematics for each event when beam momentum has a spread.
333  void nextKinematics();
334 
335  // Boost from CM frame to lab frame, or inverse. Set production vertex.
336  void boostAndVertex(bool toLab, bool setVertex);
337 
338  // Perform R-hadron decays.
339  bool doRHadronDecays();
340 
341  // Check that the final event makes sense.
342  bool check(ostream& os = cout);
343 
344  // Initialization of SLHA data.
345  bool initSLHA ();
346 
347 };
348 
349 //==========================================================================
350 
351 } // end namespace Pythia8
352 
353 #endif // Pythia8_Pythia_H
Definition: AgUStep.h:26