StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
ShowerMEs.h
1 // ShowerMEs.h is a part of the PYTHIA event generator.
2 // Copyright (C) 2020 Peter Skands, Stefan Prestel, Philip Ilten, Torbjorn
3 // Sjostrand.
4 // PYTHIA is licenced under the GNU GPL v2 or later, see COPYING for details.
5 // Please respect the MCnet Guidelines, see GUIDELINES for details.
6 
7 // This file contains the functionality to interface external matrix
8 // elements for matrix element corrections to parton showers.
9 
10 #ifndef Pythia8_ShowerMEs_H
11 #define Pythia8_ShowerMEs_H
12 
13 // Include Pythia headers.
14 #include "Pythia8/Basics.h"
15 #include "Pythia8/PythiaComplex.h"
16 #include "Pythia8/Event.h"
17 #include "Pythia8/Info.h"
18 #include "Pythia8/ParticleData.h"
19 #include "Pythia8/PythiaStdlib.h"
20 #include "Pythia8/Settings.h"
21 #include "Pythia8/StandardModel.h"
22 #include "Pythia8/SusyLesHouches.h"
23 
24 // Include Vincia.
25 #include "Pythia8/VinciaCommon.h"
26 
27 namespace Pythia8 {
28 
29 //==========================================================================
30 
31 // The parton shower matrix-element interface.
32 
33 class ShowerMEs {
34 
35 public:
36 
37  // Constructor.
38  ShowerMEs() = default;
39 
40  // VINCIA methods.
41  // Set pointers to required PYTHIA 8 objects.
42  virtual void initPtrVincia(Info* infoPtrIn, SusyLesHouches* slhaPtrIn,
43  VinciaCommon* vinComPtrIn);
44  // Initialise the MG5 model, parameters, and couplings.
45  virtual bool initVincia() = 0;
46  // Check if the process is available.
47  virtual bool hasProcessVincia
48  (vector<int> idIn, vector<int> idOut, set<int> sChan) = 0;
49  // Get the matrix element squared for a particle state.
50  virtual double me2Vincia(vector<Particle> state, int nIn) = 0;
51  // Use me2 to set helicities for a state. Takes a reference as
52  // input and operates on it.
53  virtual bool selectHelicitiesVincia(vector<Particle>& state, int nIn);
54  // Set and get colour depth.
55  virtual void setColourDepthVincia(int colourDepthIn) {
56  colourDepth = colourDepthIn;}
57  virtual int getColourDepthVincia() {return colourDepth;}
58  // Convert a process label to a string, e.g. for printing to stdout.
59  string makeLabelVincia
60  (vector<int>& id, int nIn, bool convertToNames = false) const;
61  // Set verbosity level.
62  virtual void setVerboseVincia(int verboseIn) {verbose = verboseIn;}
63 
64  // Dire methods.
65  virtual bool initDire(Info* infoPtrIn, string card) = 0;
66  virtual bool isAvailableMEDire(vector <int> in, vector<int> out) = 0;
67  virtual bool isAvailableMEDire(const Pythia8::Event& event) = 0;
68  virtual double calcMEDire(const Pythia8::Event& event) = 0;
69 
70  // Common methods.
71  // Fill a vector of IDs.
72  void fillIds(const Event& event, vector<int>& in, vector<int>& out) const;
73  // Fill a vector of momenta.
74  void fillMoms(const Event& event, vector<Vec4>& p) const;
75  // Fill a vector of colors.
76  void fillCols(const Event& event, vector<int>& colors) const;
77  // Return the momenta.
78  vector<vector<double> > fillMoms(const Event& event) const;
79 
80 protected:
81 
82  // Is initialized.
83  bool isInitPtr{false}, isInit{false};
84 
85  // Saved list of helicity components for last ME evaluated.
86  map< vector<int> , double > me2hel{};
87 
88  // Pointers to VINCIA and Pythia 8 objects.
89  Info* infoPtr{};
90  CoupSM* coupSMPtr{};
91  ParticleData* particleDataPtr{};
92  Rndm* rndmPtr{};
93  Settings* settingsPtr{};
94  VinciaCommon* vinComPtr{};
95  SusyLesHouches* slhaPtr{};
96 
97  // Colour mode (0: leading colour, 1: Vincia colour).
98  int colourDepth{0};
99 
100  // Verbosity level.
101  int verbose{0};
102 
103 };
104 
105 //==========================================================================
106 
107 // Interface to external matrix elements for parton shower matrix
108 // element corrections.
109 
110 class ShowerMEsPlugin : public ShowerMEs {
111 
112 public:
113 
114  // Constructor and destructor.
115  ShowerMEsPlugin(string nameIn = "") : ShowerMEs(), mesPtr(nullptr),
116  libPtr(nullptr), name(nameIn) {};
117  ~ShowerMEsPlugin();
118 
119  // VINCIA methods.
120  // Set pointers to required PYTHIA 8 objects.
121  void initPtrVincia(Info* infoPtrIn, SusyLesHouches* slhaPtrIn,
122  VinciaCommon* vinComPtrIn) override;
123  // Initialise the MG5 model, parameters, and couplings.
124  bool initVincia() override;
125  // Get the matrix element squared for a particle state.
126  double me2Vincia(vector<Particle> state, int nIn) override {
127  return mesPtr != nullptr ? mesPtr->me2Vincia(state, nIn) : -1;}
128  // Check if the process is available.
129  bool hasProcessVincia(vector<int> idIn, vector<int> idOut,
130  set<int> sChan) override {return mesPtr != nullptr ?
131  mesPtr->hasProcessVincia(idIn, idOut, sChan) : false;}
132  // Use me2 to set helicities for a state. Takes a reference as
133  // input and operates on it.
134  bool selectHelicitiesVincia(vector<Particle>& state, int nIn) override {
135  return mesPtr != nullptr ?
136  mesPtr->selectHelicitiesVincia(state, nIn) : false;}
137  // Set and get colour depth.
138  void setColourDepthVincia(int colourDepthIn) override {
139  if (mesPtr != nullptr) mesPtr->setColourDepthVincia(colourDepthIn);}
140  int getColourDepthVincia() override {
141  return mesPtr != nullptr ? mesPtr->getColourDepthVincia() : 0;}
142  // Set verbosity level.
143  void setVerboseVincia(int verboseIn) override {
144  if (mesPtr != nullptr) mesPtr->setVerboseVincia(verboseIn);}
145 
146  // Dire methods.
147  bool initDire(Info* infoPtrIn, string card) override;
148  bool isAvailableMEDire(vector <int> in, vector<int> out) override {
149  return mesPtr != nullptr ? mesPtr->isAvailableMEDire(in, out) : false;}
150  bool isAvailableMEDire(const Pythia8::Event& event) override {
151  return mesPtr != nullptr ? mesPtr->isAvailableMEDire(event) : false;}
152  double calcMEDire(const Pythia8::Event& event) override {
153  return mesPtr != nullptr ? mesPtr->calcMEDire(event) : 0;}
154 
155 private:
156 
157  // Typedefs of the hooks used to access the plugin.
158  typedef ShowerMEs* NewShowerMEs();
159  typedef void DeleteShowerMEs(ShowerMEs*);
160 
161  // The loaded MEs object, plugin library, and plugin name.
162  ShowerMEs *mesPtr;
163  PluginPtr libPtr;
164  string name;
165 
166 };
167 
168 //==========================================================================
169 
170 } // end namespace Pythia8
171 
172 #endif // end Pythia8_ShowerMEs_H