PYTHIA  8.316
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 // Forward declaration of Pythia class.
18 class Pythia;
19 
20 //==========================================================================
21 
22 // Classes that implement physics models should inherit from the PhysicsBase
23 // class. It includes pointers to objects set up in the controlling Pythia
24 // object to take care of bookkeeping and simpler service tasks.
25 
26 class PhysicsBase {
27 
28 public:
29 
30  // Enumerate the different status codes the event generation can have.
31  enum Status { INCOMPLETE = -1, COMPLETE = 0, CONSTRUCTOR_FAILED,
32  INIT_FAILED, LHEF_END, LOWENERGY_FAILED, PROCESSLEVEL_FAILED,
33  PROCESSLEVEL_USERVETO, MERGING_FAILED, PARTONLEVEL_FAILED,
34  PARTONLEVEL_USERVETO, HADRONLEVEL_FAILED, CHECK_FAILED,
35  OTHER_UNPHYSICAL, HEAVYION_FAILED, HADRONLEVEL_USERVETO };
36 
37  // This function is called from above for physics objects used in a run.
38  void initInfoPtr(Info& infoPtrIn);
39 
40  // Empty virtual destructor.
41  virtual ~PhysicsBase() {}
42 
43  // Shorthand to read settings values.
44  bool flag(string key) const {return settingsPtr->flag(key);}
45  int mode(string key) const {return settingsPtr->mode(key);}
46  double parm(string key) const {return settingsPtr->parm(key);}
47  string word(string key) const {return settingsPtr->word(key);}
48  vector<bool> fvec(string key) const {return settingsPtr->fvec(key);}
49  vector<int> mvec(string key) const {return settingsPtr->mvec(key);}
50  vector<double> pvec(string key) const {return settingsPtr->pvec(key);}
51  vector<string> wvec(string key) const {return settingsPtr->wvec(key);}
52 
53 protected:
54 
55  // Default constructor.
57 
58  // If an object needs to set up infoPtr for sub objects, override this
59  // and call registerSubObject for each object in question.
60  virtual void onInitInfoPtr() {}
61 
62  // This function is called in the very beginning of each Pythia::next call.
63  virtual void onBeginEvent() {}
64 
65  // This function is called in the very end of each Pythia::next call
66  // with the argument set to the current status of the event.
67  virtual void onEndEvent(Status) {}
68 
69  // This function is called from the Pythia::stat() call.
70  virtual void onStat() {}
71 
72  // This function is called from the PythiaParallel::stat() call.
73  // The argument is all thread instances of this PhysicsBase.
74  // Each instance can be recast as dynamic_cast<DerivedClass*>(ptr).
75  virtual void onStat(vector<PhysicsBase*>, Pythia*) {}
76 
77  // Register a sub object that should have its information in sync with this.
79 
80  // Pointer to various information on the generation.
81  // This is also the place from which a number of pointers are recovered.
82  Info* infoPtr = {};
83 
84  // Pointer to the settings database.
86 
87  // Pointer to the particle data table.
89 
90  // Pointer to logger.
92 
93  // Pointer to the hadron widths data table
95 
96  // Pointer to the random number generator.
97  Rndm* rndmPtr = {};
98 
99  // Pointers to SM and SUSY couplings.
101  CoupSUSY* coupSUSYPtr = {};
102 
103  // Pointers to the two incoming beams and to Pomeron, photon or VMD
104  // beam-inside-beam cases.
106  BeamParticle* beamAPtr = {};
107  BeamParticle* beamBPtr = {};
108  BeamParticle* beamPomAPtr = {};
109  BeamParticle* beamPomBPtr = {};
110  BeamParticle* beamGamAPtr = {};
111  BeamParticle* beamGamBPtr = {};
112  BeamParticle* beamVMDAPtr = {};
113  BeamParticle* beamVMDBPtr = {};
114 
115  // Pointer to information on subcollision parton locations.
117 
118  // Pointers to the total/elastic/diffractive cross sections.
120  SigmaCombined* sigmaCmbPtr = {};
121 
122  // A set of sub objects that should have their information in sync
123  // with This.
124  set<PhysicsBase*> subObjects;
125 
126  // Pointer to the UserHooks object (needs to be set to null in
127  // classes deriving from UserHooks to avoid closed loop ownership).
128  UserHooksPtr userHooksPtr;
129 
130  // Mutex that should be locked for thread-unsafe code.
131  mutex* mutexPtr;
132 
133 private:
134 
135  friend class Pythia;
136  friend class PythiaParallel;
137 
138  // Calls onBeginEvent, then propagates the call to all sub objects
139  void beginEvent();
140 
141  // Calls onEndEvent, then propagates the call to all sub objects
142  void endEvent(Status status);
143 
144  // Calls onStat, then propagates the call to all sub objects
145  void stat();
146 
147 };
148 
149 //==========================================================================
150 
151 } // end namespace Pythia8
152 
153 #endif // Pythia8_PhysicsBase_H
virtual ~PhysicsBase()
Empty virtual destructor.
Definition: PhysicsBase.h:41
bool flag(string keyIn)
Give back current value, with check that key exists.
Definition: Settings.cc:1613
Settings * settingsPtr
Pointer to the settings database.
Definition: PhysicsBase.h:85
Definition: PhysicsBase.h:26
void registerSubObject(PhysicsBase &pb)
Register a sub object that should have its information in sync with this.
Definition: PhysicsBase.cc:57
Definition: Info.h:45
mutex * mutexPtr
Mutex that should be locked for thread-unsafe code.
Definition: PhysicsBase.h:131
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:63
Definition: SigmaLowEnergy.h:135
PartonSystems * partonSystemsPtr
Pointer to information on subcollision parton locations.
Definition: PhysicsBase.h:116
Definition: SigmaTotal.h:141
Class for doing Pythia runs in parallel.
Definition: PythiaParallel.h:18
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:97
virtual void onStat()
This function is called from the Pythia::stat() call.
Definition: PhysicsBase.h:70
Definition: Logger.h:23
BeamSetup * beamSetupPtr
Definition: PhysicsBase.h:105
ParticleData * particleDataPtr
Pointer to the particle data table.
Definition: PhysicsBase.h:88
Definition: Basics.h:388
UserHooksPtr userHooksPtr
Definition: PhysicsBase.h:128
virtual void onInitInfoPtr()
Definition: PhysicsBase.h:60
set< PhysicsBase * > subObjects
Definition: PhysicsBase.h:124
Status
Enumerate the different status codes the event generation can have.
Definition: PhysicsBase.h:31
Definition: HadronWidths.h:22
Definition: StandardModel.h:142
CoupSM * coupSMPtr
Pointers to SM and SUSY couplings.
Definition: PhysicsBase.h:100
virtual void onStat(vector< PhysicsBase * >, Pythia *)
Definition: PhysicsBase.h:75
Logger * loggerPtr
Pointer to logger.
Definition: PhysicsBase.h:91
PhysicsBase()
Default constructor.
Definition: PhysicsBase.h:56
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:72
Info * infoPtr
Definition: PhysicsBase.h:82
virtual void onEndEvent(Status)
Definition: PhysicsBase.h:67
bool flag(string key) const
Shorthand to read settings values.
Definition: PhysicsBase.h:44
This class holds a map of all ParticleDataEntries.
Definition: ParticleData.h:423
SigmaTotal * sigmaTotPtr
Pointers to the total/elastic/diffractive cross sections.
Definition: PhysicsBase.h:119
Definition: SusyCouplings.h:27
Definition: Settings.h:196
HadronWidths * hadronWidthsPtr
Pointer to the hadron widths data table.
Definition: PhysicsBase.h:94