PYTHIA  8.315
PhysicsBase.h
1 // PhysicsBase.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 // This file contains the base class for physics classes used inside Pyhia8.
7 
8 #ifndef Pythia8_PhysicsBase_H
9 #define Pythia8_PhysicsBase_H
10 
11 #include "Pythia8/Info.h"
12 #include "Pythia8/Settings.h"
13 #include "Pythia8/SharedPointers.h"
14 
15 namespace Pythia8 {
16 
17 //==========================================================================
18 
19 // Classes that implement physics models should inherit from the PhysicsBase
20 // class. It includes pointers to objects set up in the controlling Pythia
21 // object to take care of bookkeeping and simpler service tasks.
22 
23 class PhysicsBase {
24 
25 public:
26 
27  // Enumerate the different status codes the event generation can have.
28  enum Status { INCOMPLETE = -1, COMPLETE = 0, CONSTRUCTOR_FAILED,
29  INIT_FAILED, LHEF_END, LOWENERGY_FAILED, PROCESSLEVEL_FAILED,
30  PROCESSLEVEL_USERVETO, MERGING_FAILED, PARTONLEVEL_FAILED,
31  PARTONLEVEL_USERVETO, HADRONLEVEL_FAILED, CHECK_FAILED,
32  OTHER_UNPHYSICAL, HEAVYION_FAILED, HADRONLEVEL_USERVETO };
33 
34  // This function is called from above for physics objects used in a run.
35  void initInfoPtr(Info& infoPtrIn);
36 
37  // Empty virtual destructor.
38  virtual ~PhysicsBase() {}
39 
40  // Shorthand to read settings values.
41  bool flag(string key) const {return settingsPtr->flag(key);}
42  int mode(string key) const {return settingsPtr->mode(key);}
43  double parm(string key) const {return settingsPtr->parm(key);}
44  string word(string key) const {return settingsPtr->word(key);}
45  vector<bool> fvec(string key) const {return settingsPtr->fvec(key);}
46  vector<int> mvec(string key) const {return settingsPtr->mvec(key);}
47  vector<double> pvec(string key) const {return settingsPtr->pvec(key);}
48  vector<string> wvec(string key) const {return settingsPtr->wvec(key);}
49 
50 protected:
51 
52  // Default constructor.
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.
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.
78 
79  // Pointer to the particle data table.
81 
82  // Pointer to logger.
84 
85  // Pointer to the hadron widths data table
87 
88  // Pointer to the random number generator.
89  Rndm* rndmPtr = {};
90 
91  // Pointers to SM and SUSY couplings.
93  CoupSUSY* coupSUSYPtr = {};
94 
95  // Pointers to the two incoming beams and to Pomeron, photon or VMD
96  // beam-inside-beam cases.
98  BeamParticle* beamAPtr = {};
99  BeamParticle* beamBPtr = {};
100  BeamParticle* beamPomAPtr = {};
101  BeamParticle* beamPomBPtr = {};
102  BeamParticle* beamGamAPtr = {};
103  BeamParticle* beamGamBPtr = {};
104  BeamParticle* beamVMDAPtr = {};
105  BeamParticle* beamVMDBPtr = {};
106 
107  // Pointer to information on subcollision parton locations.
109 
110  // Pointers to the total/elastic/diffractive cross sections.
112  SigmaCombined* sigmaCmbPtr = {};
113 
114  // A set of sub objects that should have their information in sync
115  // with This.
116  set<PhysicsBase*> subObjects;
117 
118  // Pointer to the UserHooks object (needs to be sett to null in
119  // classes deriving from UserHooks to avoid closed loop ownership).
120  UserHooksPtr userHooksPtr;
121 
122 private:
123 
124  friend class Pythia;
125 
126  // Calls onBeginEvent, then propagates the call to all sub objects
127  void beginEvent();
128 
129  // Calls onEndEvent, then propagates the call to all sub objects
130  void endEvent(Status status);
131 
132  // Calls onStat, then propagates the call to all sub objects
133  void stat();
134 
135 };
136 
137 //==========================================================================
138 
139 } // end namespace Pythia8
140 
141 #endif // Pythia8_PhysicsBase_H
virtual ~PhysicsBase()
Empty virtual destructor.
Definition: PhysicsBase.h:38
bool flag(string keyIn)
Give back current value, with check that key exists.
Definition: Settings.cc:1602
Settings * settingsPtr
Pointer to the settings database.
Definition: PhysicsBase.h:77
Definition: PhysicsBase.h:23
void registerSubObject(PhysicsBase &pb)
Register a sub object that should have its information in sync with this.
Definition: PhysicsBase.cc:56
Definition: Info.h:45
Definition: BeamSetup.h:33
Definition: BeamParticle.h:133
virtual void onBeginEvent()
This function is called in the very beginning of each Pythia::next call.
Definition: PhysicsBase.h:60
Definition: SigmaLowEnergy.h:135
PartonSystems * partonSystemsPtr
Pointer to information on subcollision parton locations.
Definition: PhysicsBase.h:108
Definition: SigmaTotal.h:141
void initInfoPtr(Info &infoPtrIn)
This function is called from above for physics objects used in a run.
Definition: PhysicsBase.cc:21
Rndm * rndmPtr
Pointer to the random number generator.
Definition: PhysicsBase.h:89
virtual void onStat()
This function is called from the Pythia::stat() call.
Definition: PhysicsBase.h:67
Definition: Logger.h:23
BeamSetup * beamSetupPtr
Definition: PhysicsBase.h:97
ParticleData * particleDataPtr
Pointer to the particle data table.
Definition: PhysicsBase.h:80
Definition: Basics.h:388
UserHooksPtr userHooksPtr
Definition: PhysicsBase.h:120
virtual void onInitInfoPtr()
Definition: PhysicsBase.h:57
set< PhysicsBase * > subObjects
Definition: PhysicsBase.h:116
Status
Enumerate the different status codes the event generation can have.
Definition: PhysicsBase.h:28
Definition: HadronWidths.h:22
Definition: StandardModel.h:135
CoupSM * coupSMPtr
Pointers to SM and SUSY couplings.
Definition: PhysicsBase.h:92
Logger * loggerPtr
Pointer to logger.
Definition: PhysicsBase.h:83
PhysicsBase()
Default constructor.
Definition: PhysicsBase.h:53
The PartonSystems class describes the whole set of subcollisions.
Definition: PartonSystems.h:42
Header for classes to set beam momentum and interaction vertex spread.
Definition: Analysis.h:20
The Pythia class contains the top-level routines to generate an event.
Definition: Pythia.h:71
Info * infoPtr
Definition: PhysicsBase.h:74
virtual void onEndEvent(Status)
Definition: PhysicsBase.h:64
bool flag(string key) const
Shorthand to read settings values.
Definition: PhysicsBase.h:41
This class holds a map of all ParticleDataEntries.
Definition: ParticleData.h:422
SigmaTotal * sigmaTotPtr
Pointers to the total/elastic/diffractive cross sections.
Definition: PhysicsBase.h:111
Definition: SusyCouplings.h:27
Definition: Settings.h:196
HadronWidths * hadronWidthsPtr
Pointer to the hadron widths data table.
Definition: PhysicsBase.h:86