PYTHIA  8.311
DireMerging.h
1 // DireMerging.h is a part of the PYTHIA event generator.
2 // Copyright (C) 2024 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.
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  virtual void getStoppingInfo(double scales[100][100],
145  double masses[100][100]);
146  vector<double> startingScalesSave;
147 
148  virtual double generateSingleSudakov (double pTbegAll, double pTendAll,
149  double m2dip, int idA, int type, double s = -1., double x = -1.);
150 
151  vector<double> getSignalProb(string key) { return signalProbSave[key]; }
152  vector<double> getBkgrndProb(string key) { return bkgrndProbSave[key]; }
153  vector<double> getTotalProb() { return totalProbSave; }
154  vector<double> totalProbSave;
155  map<string, vector<double> > signalProbSave, bkgrndProbSave;
156  void clearClassifier() {
157  for ( map<string, vector<double> >::iterator it = signalProbSave.begin();
158  it != signalProbSave.end(); ++it) for (size_t i=0; i<it->second.size();
159  ++i) it->second[i]=0.;
160  for ( map<string, vector<double> >::iterator it = bkgrndProbSave.begin();
161  it != bkgrndProbSave.end(); ++it) for (size_t i=0; i<it->second.size();
162  ++i) it->second[i]=0.;
163  for (size_t i=0; i<totalProbSave.size(); ++i) totalProbSave[i]=0.;
164  }
165 
166 protected:
167 
168  // The members.
169  // Make Pythia class friend
170  friend class Pythia;
171 
172  // Function to perform CKKW-L merging on the event.
173  int mergeProcessCKKWL( Event& process);
174 
175  // Function to perform UMEPS merging on the event.
176  int mergeProcessUMEPS( Event& process);
177 
178  // Function to perform NL3 NLO merging on the event.
179  int mergeProcessNL3( Event& process);
180 
181  // Function to perform UNLOPS merging on the event.
182  int mergeProcessUNLOPS( Event& process);
183 
184  // Function to apply the merging scale cut on an input event.
185  bool cutOnProcess( Event& process);
186 
187  // Function to perform CKKW-L merging on the event.
188  int calculate( Event& process);
189 
190  DireHistory* myHistory;
191 
192  bool generateHistories( const Event& process, bool orderedOnly = true);
193  void tagHistories();
194 
195  double getPathIndex( bool useAll = false);
196  int calculateWeights( double RNpath, bool useAll = false);
197  int getStartingConditions( double RNpath, Event& process );
198 
199  void setSudakovs( double wt ) { sudakovs = wt; return; }
200  void setASratios( double wt ) { asRatios = wt; return; }
201  void setPDFratios( double wt ) { pdfRatios = wt; return; }
202 
203  void setSudakovExp( vector<double> wts ) {
204  // Clear previous results.
205  sudakovsExp.clear();
206  // Store coefficients of Sudakov expansion.
207  sudakovsExp.insert(sudakovsExp.end(), wts.begin(), wts.end());
208  return;
209  }
210  void setASratioExp( vector<double> wts ) {
211  // Clear previous results.
212  asRatiosExp.clear();
213  // Store coefficients of Sudakov expansion.
214  asRatiosExp.insert(asRatiosExp.end(), wts.begin(), wts.end());
215  return;
216  }
217  void setPDFratiosExp( vector<double> wts ) {
218  // Clear previous results.
219  pdfRatiosExp.clear();
220  // Store coefficients of Sudakov expansion.
221  pdfRatiosExp.insert(pdfRatiosExp.end(), wts.begin(), wts.end());
222  return;
223  }
224 
225  void clearSubtractions() { subtractions.clear(); }
226  void appendSubtraction( double wt, const Event& event ) {
227  subtractions.push_back( make_pair(wt, event) );
228  return;
229  }
230  bool calculateSubtractions();
231 
232  bool generateUnorderedPoint(Event& process);
233 
234  double sudakovs, asRatios, pdfRatios;
235  vector<double> sudakovsExp, asRatiosExp, pdfRatiosExp;
236  vector<pair<double,Event> > subtractions;
237 
238  DireWeightContainer* psweights;
239 
240  double sum_time_1, sum_time_2;
241  int sum_paths;
242 
243  bool enforceCutOnLHE, doMOPS, applyTMSCut, doMerging,
244  usePDF, allowReject, doMECs, doMEM, doGenerateSubtractions,
245  doGenerateMergingWeights, doExitAfterMerging, allowIncompleteReal;
246  int nQuarksMerge;
247 
248  bool first;
249 
250 };
251 
252 //==========================================================================
253 
254 } // end namespace Pythia8
255 
256 #endif // Pythia8_DireMerging_H
DireMerging()
Constructor.
Definition: DireMerging.h:45
Definition: DireHistory.h:167
void tagHistories()
Definition: DireMerging.cc:1595
Settings * settingsPtr
Pointer to the settings database.
Definition: PhysicsBase.h:81
void getSudakovs(double &wt) const
Return CKKW-L weight.
Definition: DireMerging.h:105
The Event class holds all info on the generated event.
Definition: Event.h:453
int calculate(Event &process)
Function to perform CKKW-L merging on the event.
virtual int mergeProcess(Event &process)
Functions that implement matrix element merging.
Definition: DireMerging.cc:402
virtual void statistics()
Function to print statistics.
Definition: DireMerging.cc:94
Rndm * rndmPtr
Pointer to the random number generator.
Definition: PhysicsBase.h:93
Definition: DireMerging.h:40
Definition: DireBasics.h:374
bool cutOnProcess(Event &process)
Function to apply the merging scale cut on an input event.
Definition: DireMerging.cc:2136
void storeInfos()
Definition: DireMerging.cc:128
ParticleData * particleDataPtr
Pointer to the particle data table.
Definition: PhysicsBase.h:84
virtual double generateSingleSudakov(double pTbegAll, double pTendAll, double m2dip, int idA, int type, double s=-1., double x=-1.)
Function to generate Sudakov factors for MCatNLO-Delta.
Definition: DireMerging.cc:160
Definition: Merging.h:33
vector< double > stoppingScalesSave
Definition: Merging.h:131
virtual void getStoppingInfo(double scales[100][100], double masses[100][100])
Definition: DireMerging.cc:147
PartonLevel * trialPartonLevelPtr
Pointer to trial PartonLevel object.
Definition: Merging.h:83
bool calculateSubtractions()
Function to set up all histories for an event.
Definition: DireMerging.cc:1688
~DireMerging()
Destructor.
Definition: DireMerging.h:88
Container for all shower weights, including handling.
Definition: DireWeightContainer.h:82
int mergeProcessCKKWL(Event &process)
Function to perform CKKW-L merging on the event.
Definition: DireMerging.cc:605
void setPDFratiosExp(vector< double > wts)
Definition: DireMerging.h:217
int mergeProcessUMEPS(Event &process)
Function to perform UMEPS merging on the event.
Definition: DireMerging.cc:828
void setASratioExp(vector< double > wts)
Definition: DireMerging.h:210
Header for classes to set beam momentum and interaction vertex spread.
Definition: Analysis.h:20
The Pythia class contains the top-level routines to generate an event.
Definition: Pythia.h:71
Info * infoPtr
Definition: PhysicsBase.h:78
int mergeProcessUNLOPS(Event &process)
Function to perform UNLOPS merging on the event.
Definition: DireMerging.cc:1226
MergingHooksPtr mergingHooksPtr
Pointer to trial MergingHooks object.
Definition: Merging.h:86
bool generateHistories(const Event &process, bool orderedOnly=true)
Function to set up all histories for an event.
Definition: DireMerging.cc:1543
int mergeProcessNL3(Event &process)
Function to perform NL3 NLO merging on the event.
Definition: DireMerging.cc:1000
virtual void init()
Initialisation function for internal use inside Pythia source code.
Definition: DireMerging.cc:65
int getStartingConditions(double RNpath, Event &process)
Function to perform UNLOPS merging on this event.
Definition: DireMerging.cc:2048
double getPathIndex(bool useAll=false)
Definition: DireMerging.cc:1652
bool generateUnorderedPoint(Event &process)
Function to steer different merging prescriptions.
Definition: DireMerging.cc:178
Definition: DireBasics.h:82
void setSudakovExp(vector< double > wts)
Definition: DireMerging.h:203
int calculateWeights(double RNpath, bool useAll=false)
Function to calulate the weights used for UNLOPS merging.
Definition: DireMerging.cc:1781