StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
PhysicsBase.h
1 // PhysicsBase.h is a part of the PYTHIA event generator.
2 // Copyright (C) 2020 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 base class for physics classes used inside Pyhia8.
7 
8 // Still to convert:
9 // BeamParticle
10 // BeamShape
11 
12 #ifndef Pythia8_PhysicsBase_H
13 #define Pythia8_PhysicsBase_H
14 
15 #include "Pythia8/Info.h"
16 #include "Pythia8/Settings.h"
17 #include "Pythia8/SharedPointers.h"
18 
19 namespace Pythia8 {
20 
21 //==========================================================================
22 
23 // Classes that implement physics models should inherit from the PhysicsBase
24 // class. It includes pointers to objects set up in the controlling Pythia
25 // object to take care of bookkeeping and simpler service tasks.
26 
27 class PhysicsBase {
28 
29 public:
30 
31  // Enumerate the different status codes the event generation can have.
32  enum Status { INCOMPLETE = -1, COMPLETE = 0, CONSTRUCTOR_FAILED,
33  INIT_FAILED, LHEF_END, LOWENERGY_FAILED, PROCESSLEVEL_FAILED,
34  PROCESSLEVEL_USERVETO, MERGING_FAILED, PARTONLEVEL_FAILED,
35  PARTONLEVEL_USERVETO, HADRONLEVEL_FAILED, CHECK_FAILED,
36  OTHER_UNPHYSICAL, HEAVYION_FAILED };
37 
38  // This function is called from above for physics objects used in a run.
39  void initInfoPtr(Info& infoPtrIn);
40 
41  // Empty virtual destructor.
42  virtual ~PhysicsBase() {}
43 
44  // Shorthand to read settings values.
45  bool flag(string key) const {return settingsPtr->flag(key);}
46  int mode(string key) const {return settingsPtr->mode(key);}
47  double parm(string key) const {return settingsPtr->parm(key);}
48  string word(string key) const {return settingsPtr->word(key);}
49 
50 protected:
51 
52  // Default constructor.
53  PhysicsBase() {}
54 
55  // If an object needs to set up infoPtr for sub objects, override this
56  // and call registerSubObject for each object in question.
57  virtual void onInitInfoPtr() {}
58 
59  // This function is called in the very beginning of each Pythia::next call.
60  virtual void onBeginEvent() {}
61 
62  // This function is called in the very end of each Pythia::next call
63  // with the argument set to the current status of the event.
64  virtual void onEndEvent(Status) {}
65 
66  // This function is called from the Pythia::stat() call.
67  virtual void onStat() {}
68 
69  // Register a sub object that should have its information in sync with this.
70  void registerSubObject(PhysicsBase& pb);
71 
72  // Pointer to various information on the generation.
73  // This is also the place from which a number of pointers are recovered.
74  Info* infoPtr = {};
75 
76  // Pointer to the settings database.
77  Settings* settingsPtr = {};
78 
79  // Pointer to the particle data table.
80  ParticleData* particleDataPtr = {};
81 
82  // Pointer to the hadron widths data table
83  HadronWidths* hadronWidthsPtr = {};
84 
85  // Pointer to the random number generator.
86  Rndm* rndmPtr = {};
87 
88  // Pointers to SM and SUSY couplings.
89  CoupSM* coupSMPtr = {};
90  CoupSUSY* coupSUSYPtr = {};
91 
92  // Pointers to the two incoming beams and to Pomeron, photon or VMD
93  // beam-inside-beam cases.
94  BeamParticle* beamAPtr = {};
95  BeamParticle* beamBPtr = {};
96  BeamParticle* beamPomAPtr = {};
97  BeamParticle* beamPomBPtr = {};
98  BeamParticle* beamGamAPtr = {};
99  BeamParticle* beamGamBPtr = {};
100  BeamParticle* beamVMDAPtr = {};
101  BeamParticle* beamVMDBPtr = {};
102 
103  // Pointer to information on subcollision parton locations.
104  PartonSystems* partonSystemsPtr = {};
105 
106  // Pointer to the total/elastic/diffractive cross sections.
107  SigmaTotal* sigmaTotPtr = {};
108 
109  // A set of sub objects that should have their information in sync
110  // with This.
111  set<PhysicsBase*> subObjects;
112 
113  // Pointer to the UserHooks object (needs to be sett to null in
114  // classes deriving from UserHooks to avoid closed loop ownership).
115  UserHooksPtr userHooksPtr;
116 
117 private:
118 
119  friend class Pythia;
120 
121  // Calls onBeginEvent, then propagates the call to all sub objects
122  void beginEvent();
123 
124  // Calls onEndEvent, then propagates the call to all sub objects
125  void endEvent(Status status);
126 
127  // Calls onStat, then propagates the call to all sub objects
128  void stat();
129 
130 };
131 
132 //==========================================================================
133 
134 } // end namespace Pythia8
135 
136 #endif // Pythia8_PhysicsBase_H