Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:06:19

0001 // Dire.h is a part of the PYTHIA event generator.
0002 // Copyright (C) 2024 Stefan Prestel, 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 // Header file for the top level Dire class.
0007 
0008 #ifndef Pythia8_Dire_H
0009 #define Pythia8_Dire_H
0010 
0011 #define DIRE_VERSION "2.002"
0012 
0013 // DIRE includes.
0014 #include "Pythia8/DireSplittingLibrary.h"
0015 #include "Pythia8/DireMerging.h"
0016 #include "Pythia8/DireTimes.h"
0017 #include "Pythia8/DireSpace.h"
0018 #include "Pythia8/DireWeightContainer.h"
0019 #include "Pythia8/DireHooks.h"
0020 
0021 // Pythia includes.
0022 #include "Pythia8/Info.h"
0023 #include "Pythia8/Settings.h"
0024 #include "Pythia8/ParticleData.h"
0025 #include "Pythia8/Basics.h"
0026 #include "Pythia8/PartonSystems.h"
0027 #include "Pythia8/UserHooks.h"
0028 #include "Pythia8/MergingHooks.h"
0029 #include "Pythia8/PartonVertex.h"
0030 #include "Pythia8/StandardModel.h"
0031 #include "Pythia8/ShowerModel.h"
0032 
0033 #include <iostream>
0034 #include <sstream>
0035 
0036 namespace Pythia8 {
0037 
0038 //==========================================================================
0039 
0040 class Dire : public ShowerModel {
0041 
0042   public:
0043 
0044   Dire() : weightsPtr(nullptr), timesPtr(nullptr), timesDecPtr(nullptr),
0045     spacePtr(nullptr), splittings(nullptr), hooksPtr(nullptr),
0046     mergingPtr(nullptr), hardProcessPtr(nullptr), mergingHooksPtr(nullptr),
0047     hasOwnWeights(false), hasOwnTimes(false), hasOwnTimesDec(false),
0048     hasOwnSpace(false), hasOwnSplittings(false), hasOwnHooks(false),
0049     hasUserHooks(false), hasOwnHardProcess(false),
0050     hasOwnMergingHooks(false), initNewSettings(false), isInit(false),
0051     isInitShower(false), printBannerSave(true) { createPointers(); }
0052 
0053   Dire( MergingHooksPtr mergingHooksPtrIn, PartonVertexPtr partonVertexPtrIn)
0054     :  pythiaMergingHooksPtr(mergingHooksPtrIn),
0055     partonVertexPtr(partonVertexPtrIn), weightsPtr(nullptr),
0056     timesPtr(nullptr), timesDecPtr(nullptr), spacePtr(nullptr),
0057     splittings(nullptr), hooksPtr(nullptr),
0058     mergingPtr(nullptr), hardProcessPtr(nullptr),
0059     hasOwnWeights(false), hasOwnTimes(false), hasOwnTimesDec(false),
0060     hasOwnSpace(false), hasOwnSplittings(false), hasOwnHooks(false),
0061     hasUserHooks(false), hasOwnHardProcess(false),
0062     hasOwnMergingHooks(false), initNewSettings(false), isInit(false),
0063     isInitShower(false), printBannerSave(true) { createPointers(); }
0064 
0065  ~Dire() {
0066     if (hasOwnWeights)      delete weightsPtr;
0067     if (hasOwnSplittings)   delete splittings;
0068     if (hasOwnHardProcess)  delete hardProcessPtr;
0069   }
0070 
0071   // Flexible-use call at the beginning of each event in pythia.next().
0072   // Currently not used, but should be used for clearing some internal
0073   // bookkeeping that is otherewise reset in shower prepare functions.
0074   void onBeginEvent() override {
0075     return;
0076   }
0077 
0078   // Flexible-use call at the end of each event in pythia.next().
0079   // Currently only to accumulate shower weights.
0080   void onEndEvent(PhysicsBase::Status status) override {
0081     // No finalize in case of failure.
0082     if (status == INCOMPLETE) return;
0083     // Update the event weight by the Dire shower weight when relevant.
0084     // Retrieve the shower weight.
0085     weightsPtr->calcWeight(0.);
0086     weightsPtr->reset();
0087     double pswt = weightsPtr->getShowerWeight();
0088     // Multiply the shower weight to the event weight.
0089     double wt = infoPtr->weight();
0090     infoPtr->weightContainerPtr->setWeightNominal(wt * pswt);
0091   }
0092 
0093   void createPointers();
0094 
0095   // Initialization function called before beams are set up.
0096   // Currently only to register objects as PhysicsBase (=initialize ptrs).
0097   bool init(MergingPtr, MergingHooksPtr, PartonVertexPtr, WeightContainer*)
0098     override {
0099     subObjects.clear();
0100     if (mergingHooksPtr) {
0101       registerSubObject(*mergingHooksPtr);
0102     }
0103     if (mergingPtr) {
0104       registerSubObject(*mergingPtr);
0105     }
0106     if (timesPtr)    registerSubObject(*timesPtr);
0107     if (timesDecPtr) registerSubObject(*timesDecPtr);
0108     if (spacePtr)    registerSubObject(*spacePtr);
0109     return true;
0110   }
0111 
0112   // Initialization function called after beams are set up, used as main
0113   // initialization.
0114   bool initAfterBeams() override;
0115 
0116   void initTune();
0117   void initShowersAndWeights();
0118   void setup(BeamParticle* beamA, BeamParticle* beamB);
0119   void printBanner();
0120 
0121   TimeShowerPtr  getTimeShower() const override    { return timesPtr; }
0122   TimeShowerPtr  getTimeDecShower() const override { return timesDecPtr; }
0123   SpaceShowerPtr getSpaceShower() const override   { return spacePtr; }
0124   MergingHooksPtr getMergingHooks() const override { return mergingHooksPtr; }
0125   MergingPtr getMerging() const override           { return mergingPtr; }
0126 
0127   MergingHooksPtr pythiaMergingHooksPtr;
0128   PartonVertexPtr partonVertexPtr;
0129 
0130   DireWeightContainer* weightsPtr;
0131   shared_ptr<DireTimes> timesPtr;
0132   shared_ptr<DireTimes> timesDecPtr;
0133   shared_ptr<DireSpace> spacePtr;
0134   DireSplittingLibrary* splittings;
0135   DireHooks* hooksPtr;
0136 
0137   DireInfo direInfo;
0138 
0139   // Pointer to Dire merging objects.
0140   shared_ptr<DireMerging>      mergingPtr;
0141   DireHardProcess*            hardProcessPtr;
0142   shared_ptr<DireMergingHooks> mergingHooksPtr;
0143 
0144   bool hasOwnWeights, hasOwnTimes, hasOwnTimesDec, hasOwnSpace,
0145        hasOwnSplittings, hasOwnHooks, hasUserHooks,
0146        hasOwnHardProcess, hasOwnMergingHooks;
0147   bool initNewSettings, isInit, isInitShower, printBannerSave;
0148 
0149 };
0150 
0151 //==========================================================================
0152 
0153 } // end namespace Pythia8
0154 
0155 #endif // Pythia8_Dire_H