StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
DireMerging.h
1 // DireMerging.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 merging with Dire.
7 
8 #ifndef Pythia8_DireMerging_H
9 #define Pythia8_DireMerging_H
10 
11 #define DIRE_MERGING_VERSION "2.002"
12 
13 #include "Pythia8/Basics.h"
14 #include "Pythia8/BeamParticle.h"
15 #include "Pythia8/Event.h"
16 #include "Pythia8/Info.h"
17 #include "Pythia8/ParticleData.h"
18 #include "Pythia8/PartonLevel.h"
19 #include "Pythia8/PythiaStdlib.h"
20 #include "Pythia8/Settings.h"
21 #include "Pythia8/StandardModel.h"
22 #include "Pythia8/Merging.h"
23 #include "Pythia8/MergingHooks.h"
24 #include "Pythia8/LesHouches.h"
25 
26 #include "Pythia8/DireHistory.h"
27 #include "Pythia8/DireMergingHooks.h"
28 #include "Pythia8/DireWeightContainer.h"
29 
30 namespace Pythia8 {
31 
32 class DireSpace;
33 class DireTimes;
34 
35 //==========================================================================
36 
37 // Merging is a wrapper class for the interface of matrix element merging and
38 // Pythia8.
39 
40 class DireMerging : public Merging {
41 
42 public:
43 
44  // Constructor.
45  DireMerging() : totalProbSave(createvector<double>(0.)(0.)(0.)),
46  sudakovs(1.), asRatios(1.), pdfRatios(1.), psweights(0), first(true) {
47  vector<double> tmp(createvector<double>(0.)(0.)(0.));
48  signalProbSave.insert(make_pair("higgs",tmp));
49  bkgrndProbSave.insert(make_pair("higgs",tmp));
50  signalProbSave.insert(make_pair("higgs-subt",tmp));
51  bkgrndProbSave.insert(make_pair("higgs-subt",tmp));
52  signalProbSave.insert(make_pair("higgs-nosud",tmp));
53  bkgrndProbSave.insert(make_pair("higgs-nosud",tmp));
54  signalProbSave.insert(make_pair("qed",tmp));
55  bkgrndProbSave.insert(make_pair("qed",tmp));
56  signalProbSave.insert(make_pair("qcd",tmp));
57  bkgrndProbSave.insert(make_pair("qcd",tmp));
58  settingsPtr = 0; infoPtr = 0; particleDataPtr = 0; rndmPtr = 0;
59  beamAPtr = 0; beamBPtr = 0; trialPartonLevelPtr = 0;
60  mergingHooksPtr = 0; myHistory = 0; fsr = 0; isr = 0;
61  direInfoPtr = 0; sum_time_1 = sum_time_2 = 0.; sum_paths = 0;
62  enforceCutOnLHE = doMOPS = applyTMSCut = doMerging
63  //= doMcAtNloDelta
64  = allowReject = doMECs = doMEM = doGenerateSubtractions
65  = doGenerateMergingWeights = doExitAfterMerging
66  = allowIncompleteReal = false;
67  usePDF = true;
68  nQuarksMerge = 5;
69  }
70 
71  void setWeightsPtr( DireWeightContainer* wgtsIn ) { psweights = wgtsIn; }
72  void setShowerPtrs( shared_ptr<DireTimes> timesPtr,
73  shared_ptr<DireSpace> spacePtr) {fsr = timesPtr; isr = spacePtr; }
74 
75  void initPtrs( DireWeightContainer* wgtsIn, shared_ptr<DireTimes> timesPtr,
76  shared_ptr<DireSpace> spacePtr, DireInfo* direInfoIn) {
77  psweights = wgtsIn;
78  fsr = timesPtr;
79  isr = spacePtr;
80  direInfoPtr = direInfoIn;
81  }
82 
83  shared_ptr<DireTimes> fsr;
84  shared_ptr<DireSpace> isr;
85  DireInfo* direInfoPtr;
86 
87  // Destructor.
88  ~DireMerging(){
89  if (myHistory) delete myHistory;
90  }
91 
92  // Initialisation function for internal use inside Pythia source code
93  virtual void init();
94  void reset();
95 
96  // Function to print statistics.
97  virtual void statistics();
98 
99  // Functions that implement matrix element merging.
100 
101  // Function to steer different merging prescriptions.
102  virtual int mergeProcess( Event& process);
103 
104  // Return CKKW-L weight.
105  void getSudakovs( double & wt ) const { wt = sudakovs; return; }
106  void getASratios( double & wt ) const { wt = asRatios; return; }
107  void getPDFratios( double & wt ) const { wt = pdfRatios; return; }
108 
109  void getSudakovExp( int order, double & wt ) const {
110  wt = 0.;
111  if (order >= 0 && order < int(sudakovsExp.size()))
112  wt = sudakovsExp[order];
113  return;
114  }
115  void getASratioExp( int order, double & wt ) const {
116  wt = 0.;
117  if (order >= 0 && order < int(asRatiosExp.size()))
118  wt = asRatiosExp[order];
119  return;
120  }
121  void getPDFratioExp( int order, double & wt ) const {
122  wt = 0.;
123  if (order >= 0 && order <= int(pdfRatiosExp.size()))
124  wt = pdfRatiosExp[order];
125  return;
126  }
127 
128  void clearInfos() {
129  stoppingScalesSave.clear();
130  startingScalesSave.clear();
131  mDipSave.clear();
132  radSave.clear();
133  emtSave.clear();
134  recSave.clear();
135  }
136  void storeInfos();
137 
138  vector<double> getStoppingScales() {
139  return stoppingScalesSave;
140  }
141  vector<double> getStartingScales() {
142  return startingScalesSave;
143  }
144  void getStoppingInfo(double scales [100][100], double masses [100][100]);
145  vector<double> stoppingScalesSave, startingScalesSave, mDipSave;
146  vector<int> radSave, emtSave, recSave;
147 
148  double generateSingleSudakov ( double pTbegAll,
149  double pTendAll, double m2dip, int idA, int type, double s = -1.,
150  double x = -1.);
151 
152  vector<double> getSignalProb(string key) { return signalProbSave[key]; }
153  vector<double> getBkgrndProb(string key) { return bkgrndProbSave[key]; }
154  vector<double> getTotalProb() { return totalProbSave; }
155  vector<double> totalProbSave;
156  map<string, vector<double> > signalProbSave, bkgrndProbSave;
157  void clearClassifier() {
158  for ( map<string, vector<double> >::iterator it = signalProbSave.begin();
159  it != signalProbSave.end(); ++it) for (size_t i=0; i<it->second.size();
160  ++i) it->second[i]=0.;
161  for ( map<string, vector<double> >::iterator it = bkgrndProbSave.begin();
162  it != bkgrndProbSave.end(); ++it) for (size_t i=0; i<it->second.size();
163  ++i) it->second[i]=0.;
164  for (size_t i=0; i<totalProbSave.size(); ++i) totalProbSave[i]=0.;
165  }
166 
167 protected:
168 
169  // The members.
170  // Make Pythia class friend
171  friend class Pythia;
172 
173  // Function to perform CKKW-L merging on the event.
174  int mergeProcessCKKWL( Event& process);
175 
176  // Function to perform UMEPS merging on the event.
177  int mergeProcessUMEPS( Event& process);
178 
179  // Function to perform NL3 NLO merging on the event.
180  int mergeProcessNL3( Event& process);
181 
182  // Function to perform UNLOPS merging on the event.
183  int mergeProcessUNLOPS( Event& process);
184 
185  // Function to apply the merging scale cut on an input event.
186  bool cutOnProcess( Event& process);
187 
188  // Function to perform CKKW-L merging on the event.
189  int calculate( Event& process);
190 
191  DireHistory* myHistory;
192 
193  bool generateHistories( const Event& process, bool orderedOnly = true);
194  void tagHistories();
195 
196  double getPathIndex( bool useAll = false);
197  int calculateWeights( double RNpath, bool useAll = false);
198  int getStartingConditions( double RNpath, Event& process );
199 
200  void setSudakovs( double wt ) { sudakovs = wt; return; }
201  void setASratios( double wt ) { asRatios = wt; return; }
202  void setPDFratios( double wt ) { pdfRatios = wt; return; }
203 
204  void setSudakovExp( vector<double> wts ) {
205  // Clear previous results.
206  sudakovsExp.clear();
207  // Store coefficients of Sudakov expansion.
208  sudakovsExp.insert(sudakovsExp.end(), wts.begin(), wts.end());
209  return;
210  }
211  void setASratioExp( vector<double> wts ) {
212  // Clear previous results.
213  asRatiosExp.clear();
214  // Store coefficients of Sudakov expansion.
215  asRatiosExp.insert(asRatiosExp.end(), wts.begin(), wts.end());
216  return;
217  }
218  void setPDFratiosExp( vector<double> wts ) {
219  // Clear previous results.
220  pdfRatiosExp.clear();
221  // Store coefficients of Sudakov expansion.
222  pdfRatiosExp.insert(pdfRatiosExp.end(), wts.begin(), wts.end());
223  return;
224  }
225 
226  void clearSubtractions() { subtractions.clear(); }
227  void appendSubtraction( double wt, const Event& event ) {
228  subtractions.push_back( make_pair(wt, event) );
229  return;
230  }
231  bool calculateSubtractions();
232 
233  bool generateUnorderedPoint(Event& process);
234 
235  double sudakovs, asRatios, pdfRatios;
236  vector<double> sudakovsExp, asRatiosExp, pdfRatiosExp;
237  vector<pair<double,Event> > subtractions;
238 
239  DireWeightContainer* psweights;
240 
241  double sum_time_1, sum_time_2;
242  int sum_paths;
243 
244  bool enforceCutOnLHE, doMOPS, applyTMSCut, doMerging,
245  usePDF, allowReject, doMECs, doMEM, doGenerateSubtractions,
246  doGenerateMergingWeights, doExitAfterMerging, allowIncompleteReal;
247  int nQuarksMerge;
248 
249  bool first;
250 
251 };
252 
253 //==========================================================================
254 
255 } // end namespace Pythia8
256 
257 #endif // end Pythia8_DireMerging_H