Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-12 08:49:10

0001 // PhysicsBase.h is a part of the PYTHIA event generator.
0002 // Copyright (C) 2025 Torbjorn Sjostrand.
0003 // PYTHIA is licenced under the GNU GPL v2 or later, see COPYING for details.
0004 // Please respect the MCnet Guidelines, see GUIDELINES for details.
0005 
0006 // This file contains the base class for physics classes used inside Pyhia8.
0007 
0008 #ifndef Pythia8_PhysicsBase_H
0009 #define Pythia8_PhysicsBase_H
0010 
0011 #include "Pythia8/Info.h"
0012 #include "Pythia8/Settings.h"
0013 #include "Pythia8/SharedPointers.h"
0014 
0015 namespace Pythia8 {
0016 
0017 // Forward declaration of Pythia class.
0018 class Pythia;
0019 
0020 //==========================================================================
0021 
0022 // Classes that implement physics models should inherit from the PhysicsBase
0023 // class. It includes pointers to objects set up in the controlling Pythia
0024 // object to take care of bookkeeping and simpler service tasks.
0025 
0026 class PhysicsBase {
0027 
0028 public:
0029 
0030   // Enumerate the different status codes the event generation can have.
0031   enum Status { INCOMPLETE = -1, COMPLETE = 0, CONSTRUCTOR_FAILED,
0032     INIT_FAILED, LHEF_END, LOWENERGY_FAILED, PROCESSLEVEL_FAILED,
0033     PROCESSLEVEL_USERVETO, MERGING_FAILED, PARTONLEVEL_FAILED,
0034     PARTONLEVEL_USERVETO, HADRONLEVEL_FAILED, CHECK_FAILED,
0035     OTHER_UNPHYSICAL, HEAVYION_FAILED, HADRONLEVEL_USERVETO };
0036 
0037   // This function is called from above for physics objects used in a run.
0038   void initInfoPtr(Info& infoPtrIn);
0039 
0040   // Empty virtual destructor.
0041   virtual ~PhysicsBase() {}
0042 
0043   // Shorthand to read settings values.
0044   bool   flag(string key) const {return settingsPtr->flag(key);}
0045   int    mode(string key) const {return settingsPtr->mode(key);}
0046   double parm(string key) const {return settingsPtr->parm(key);}
0047   string word(string key) const {return settingsPtr->word(key);}
0048   vector<bool>   fvec(string key) const {return settingsPtr->fvec(key);}
0049   vector<int>    mvec(string key) const {return settingsPtr->mvec(key);}
0050   vector<double> pvec(string key) const {return settingsPtr->pvec(key);}
0051   vector<string> wvec(string key) const {return settingsPtr->wvec(key);}
0052 
0053 protected:
0054 
0055   // Default constructor.
0056   PhysicsBase() {}
0057 
0058   // If an object needs to set up infoPtr for sub objects, override this
0059   // and call registerSubObject for each object in question.
0060   virtual void onInitInfoPtr() {}
0061 
0062   // This function is called in the very beginning of each Pythia::next call.
0063   virtual void onBeginEvent() {}
0064 
0065   // This function is called in the very end of each Pythia::next call
0066   // with the argument set to the current status of the event.
0067   virtual void onEndEvent(Status) {}
0068 
0069   // This function is called from the Pythia::stat() call.
0070   virtual void onStat() {}
0071 
0072   // This function is called from the PythiaParallel::stat() call.
0073   // The argument is all thread instances of this PhysicsBase.
0074   // Each instance can be recast as dynamic_cast<DerivedClass*>(ptr).
0075   virtual void onStat(vector<PhysicsBase*>, Pythia*) {}
0076 
0077   // Register a sub object that should have its information in sync with this.
0078   void registerSubObject(PhysicsBase& pb);
0079 
0080   // Pointer to various information on the generation.
0081   // This is also the place from which a number of pointers are recovered.
0082   Info*          infoPtr       =  {};
0083 
0084   // Pointer to the settings database.
0085   Settings*      settingsPtr      = {};
0086 
0087   // Pointer to the particle data table.
0088   ParticleData*  particleDataPtr  = {};
0089 
0090   // Pointer to logger.
0091   Logger*        loggerPtr        = {};
0092 
0093   // Pointer to the hadron widths data table
0094   HadronWidths*  hadronWidthsPtr  = {};
0095 
0096   // Pointer to the random number generator.
0097   Rndm*          rndmPtr          = {};
0098 
0099   // Pointers to SM and SUSY couplings.
0100   CoupSM*        coupSMPtr        = {};
0101   CoupSUSY*      coupSUSYPtr      = {};
0102 
0103   // Pointers to the two incoming beams and to Pomeron, photon or VMD
0104   // beam-inside-beam cases.
0105   BeamSetup*    beamSetupPtr    = {};
0106   BeamParticle* beamAPtr        = {};
0107   BeamParticle* beamBPtr        = {};
0108   BeamParticle* beamPomAPtr     = {};
0109   BeamParticle* beamPomBPtr     = {};
0110   BeamParticle* beamGamAPtr     = {};
0111   BeamParticle* beamGamBPtr     = {};
0112   BeamParticle* beamVMDAPtr     = {};
0113   BeamParticle* beamVMDBPtr     = {};
0114 
0115   // Pointer to information on subcollision parton locations.
0116   PartonSystems* partonSystemsPtr = {};
0117 
0118   // Pointers to the total/elastic/diffractive cross sections.
0119   SigmaTotal*    sigmaTotPtr      = {};
0120   SigmaCombined* sigmaCmbPtr      = {};
0121 
0122   // A set of sub objects that should have their information in sync
0123   // with This.
0124   set<PhysicsBase*> subObjects;
0125 
0126   // Pointer to the UserHooks object (needs to be set to null in
0127   // classes deriving from UserHooks to avoid closed loop ownership).
0128   UserHooksPtr      userHooksPtr;
0129 
0130   // Mutex that should be locked for thread-unsafe code.
0131   mutex* mutexPtr;
0132 
0133 private:
0134 
0135   friend class Pythia;
0136   friend class PythiaParallel;
0137 
0138   // Calls onBeginEvent, then propagates the call to all sub objects
0139   void beginEvent();
0140 
0141   // Calls onEndEvent, then propagates the call to all sub objects
0142   void endEvent(Status status);
0143 
0144   // Calls onStat, then propagates the call to all sub objects
0145   void stat();
0146 
0147 };
0148 
0149 //==========================================================================
0150 
0151 } // end namespace Pythia8
0152 
0153 #endif // Pythia8_PhysicsBase_H