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