StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Dire.h
1 // Dire.h is a part of the PYTHIA event generator.
2 // Copyright (C) 2020 Stefan Prestel, 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 // Header file for the top level Dire class.
7 
8 #ifndef Pythia8_Dire_H
9 #define Pythia8_Dire_H
10 
11 #define DIRE_VERSION "2.002"
12 
13 // DIRE includes.
14 #include "Pythia8/DireSplittingLibrary.h"
15 #include "Pythia8/DireMerging.h"
16 #include "Pythia8/DireTimes.h"
17 #include "Pythia8/DireSpace.h"
18 #include "Pythia8/DireWeightContainer.h"
19 #include "Pythia8/DireHooks.h"
20 
21 // Pythia includes.
22 #include "Pythia8/Info.h"
23 #include "Pythia8/Settings.h"
24 #include "Pythia8/ParticleData.h"
25 #include "Pythia8/Basics.h"
26 #include "Pythia8/PartonSystems.h"
27 #include "Pythia8/UserHooks.h"
28 #include "Pythia8/MergingHooks.h"
29 #include "Pythia8/PartonVertex.h"
30 #include "Pythia8/StandardModel.h"
31 #include "Pythia8/ShowerModel.h"
32 
33 #include <iostream>
34 #include <sstream>
35 
36 namespace Pythia8 {
37 
38 //==========================================================================
39 
40 class Dire : public ShowerModel {
41 
42  public:
43 
44  Dire() : weightsPtr(nullptr), timesPtr(nullptr), timesDecPtr(nullptr),
45  spacePtr(nullptr), splittings(nullptr), hooksPtr(nullptr),
46  mergingPtr(nullptr), hardProcessPtr(nullptr), mergingHooksPtr(nullptr),
47  hasOwnWeights(false), hasOwnTimes(false), hasOwnTimesDec(false),
48  hasOwnSpace(false), hasOwnSplittings(false), hasOwnHooks(false),
49  hasUserHooks(false), hasOwnHardProcess(false),
50  hasOwnMergingHooks(false), initNewSettings(false), isInit(false),
51  isInitShower(false), printBannerSave(true) { createPointers(); }
52 
53  Dire( MergingHooksPtr mergingHooksPtrIn, PartonVertexPtr partonVertexPtrIn)
54  : pythiaMergingHooksPtr(mergingHooksPtrIn),
55  partonVertexPtr(partonVertexPtrIn), weightsPtr(nullptr),
56  timesPtr(nullptr), timesDecPtr(nullptr), spacePtr(nullptr),
57  splittings(nullptr), hooksPtr(nullptr),
58  mergingPtr(nullptr), hardProcessPtr(nullptr),
59  hasOwnWeights(false), hasOwnTimes(false), hasOwnTimesDec(false),
60  hasOwnSpace(false), hasOwnSplittings(false), hasOwnHooks(false),
61  hasUserHooks(false), hasOwnHardProcess(false),
62  hasOwnMergingHooks(false), initNewSettings(false), isInit(false),
63  isInitShower(false), printBannerSave(true) { createPointers(); }
64 
65  ~Dire() {
66  if (hasOwnWeights) delete weightsPtr;
67  if (hasOwnSplittings) delete splittings;
68  if (hasOwnHardProcess) delete hardProcessPtr;
69  }
70 
71  // Flexible-use call at the beginning of each event in pythia.next().
72  // Currently not used, but should be used for clearing some internal
73  // bookkeeping that is otherewise reset in shower prepare functions.
74  void beginEvent() {
75  return;
76  }
77 
78  // Flexible-use call at the end of each event in pythia.next().
79  // Currently only to accumulate shower weights.
80  void endEvent(PhysicsBase::Status status) {
81  // No finalize in case of failure.
82  if (status == INCOMPLETE) return;
83  // Update the event weight by the Dire shower weight when relevant.
84  // Retrieve the shower weight.
85  weightsPtr->calcWeight(0.);
86  weightsPtr->reset();
87  double pswt = weightsPtr->getShowerWeight();
88  // Multiply the shower weight to the event weight.
89  double wt = infoPtr->weight();
90  infoPtr->weightContainerPtr->setWeightNominal(wt * pswt);
91  }
92 
93  void createPointers();
94 
95  // Initialization function called before beams are set up.
96  // Currently only to register objects as PhysicsBase (=initialize ptrs).
97  bool init(MergingPtr, MergingHooksPtr, PartonVertexPtr, WeightContainer*) {
98  subObjects.clear();
99  if (mergingHooksPtr) {
100  registerSubObject(*mergingHooksPtr);
101  }
102  if (mergingPtr) {
103  registerSubObject(*mergingPtr);
104  }
105  if (timesPtr) registerSubObject(*timesPtr);
106  if (timesDecPtr) registerSubObject(*timesDecPtr);
107  if (spacePtr) registerSubObject(*spacePtr);
108  return true;
109  }
110 
111  // Initialization function called after beams are set up, used as main
112  // initialization.
113  bool initAfterBeams();
114 
115  void initTune();
116  void initShowersAndWeights();
117  void setup(BeamParticle* beamA, BeamParticle* beamB);
118  void printBanner();
119 
120  TimeShowerPtr getTimeShower() const { return timesPtr; }
121  TimeShowerPtr getTimeDecShower() const { return timesDecPtr; }
122  SpaceShowerPtr getSpaceShower() const { return spacePtr; }
123  MergingHooksPtr getMergingHooks() const { return mergingHooksPtr; }
124  MergingPtr getMerging() const { return mergingPtr; }
125 
126  MergingHooksPtr pythiaMergingHooksPtr;
127  PartonVertexPtr partonVertexPtr;
128 
129  DireWeightContainer* weightsPtr;
130  shared_ptr<DireTimes> timesPtr;
131  shared_ptr<DireTimes> timesDecPtr;
132  shared_ptr<DireSpace> spacePtr;
133  DireSplittingLibrary* splittings;
134  DireHooks* hooksPtr;
135 
136  DireInfo direInfo;
137 
138  // Pointer to Dire merging objects.
139  shared_ptr<DireMerging> mergingPtr;
140  DireHardProcess* hardProcessPtr;
141  shared_ptr<DireMergingHooks> mergingHooksPtr;
142 
143  bool hasOwnWeights, hasOwnTimes, hasOwnTimesDec, hasOwnSpace,
144  hasOwnSplittings, hasOwnHooks, hasUserHooks,
145  hasOwnHardProcess, hasOwnMergingHooks;
146  bool initNewSettings, isInit, isInitShower, printBannerSave;
147 
148 };
149 
150 //==========================================================================
151 
152 } // end namespace Pythia8
153 
154 #endif // end Pythia8_Dire_H