StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
MergingHooks.h
1 // MergingHooks.h is a part of the PYTHIA event generator.
2 // Copyright (C) 2012 Torbjorn Sjostrand.
3 // PYTHIA is licenced under the GNU GPL version 2, see COPYING for details.
4 // Please respect the MCnet Guidelines, see GUIDELINES for details.
5 
6 // This file is written by Stefan Prestel.
7 // Header file to allow user access to program at different stages.
8 // HardProcess: Container class for the hard process to be merged. Holds the
9 // bookkeeping of particles not be be reclustered
10 // MergingHooks: Steering class for matrix element merging. Some functions can
11 // be redefined in a derived class to have access to the merging
12 
13 #ifndef Pythia8_MergingHooks_H
14 #define Pythia8_MergingHooks_H
15 
16 #include "Basics.h"
17 #include "BeamParticle.h"
18 #include "Event.h"
19 #include "Info.h"
20 #include "ParticleData.h"
21 #include "PartonSystems.h"
22 #include "PythiaStdlib.h"
23 #include "Settings.h"
24 
25 namespace Pythia8 {
26 
27 //==========================================================================
28 
29 // Declaration of hard process class
30 // This class holds information on the desired hard 2->2 process
31 // for the merging.
32 // This class is a container class for History class use.
33 
34 class HardProcess {
35 
36 public:
37 
38  // Flavour of the first incoming particle
39  int hardIncoming1;
40  // Flavour of the second incoming particle
41  int hardIncoming2;
42  // Flavours of the outgoing particles
43  vector<int> hardOutgoing1;
44  vector<int> hardOutgoing2;
45  // Flavour of intermediate bosons in the hard 2->2
46  vector<int> hardIntermediate;
47 
48  // Current reference event
49  Event state;
50  // Potential positions of outgoing particles in reference event
51  vector<int> PosOutgoing1;
52  vector<int> PosOutgoing2;
53  // Potential positions of intermediate bosons in reference event
54  vector<int> PosIntermediate;
55 
56  // Information on merging scale read from LHE file
57  double tms;
58  // Type of ME generator
59  int meGenType;
60 
61  // Default constructor
62  HardProcess(){}
63  // Default destructor
64  ~HardProcess(){}
65 
66  // Copy constructor
67  HardProcess( const HardProcess& hardProcessIn ) : state(hardProcessIn.state),
68  tms(hardProcessIn.tms), meGenType(hardProcessIn.meGenType) {
69  hardIncoming1 = hardProcessIn.hardIncoming1;
70  hardIncoming2 = hardProcessIn.hardIncoming2;
71  for(int i =0; i < int(hardProcessIn.hardOutgoing1.size());++i)
72  hardOutgoing1.push_back( hardProcessIn.hardOutgoing1[i]);
73  for(int i =0; i < int(hardProcessIn.hardOutgoing2.size());++i)
74  hardOutgoing2.push_back( hardProcessIn.hardOutgoing2[i]);
75  for(int i =0; i < int(hardProcessIn.hardIntermediate.size());++i)
76  hardIntermediate.push_back( hardProcessIn.hardIntermediate[i]);
77  for(int i =0; i < int(hardProcessIn.PosOutgoing1.size());++i)
78  PosOutgoing1.push_back( hardProcessIn.PosOutgoing1[i]);
79  for(int i =0; i < int(hardProcessIn.PosOutgoing2.size());++i)
80  PosOutgoing2.push_back( hardProcessIn.PosOutgoing2[i]);
81  for(int i =0; i < int(hardProcessIn.PosIntermediate.size());++i)
82  PosIntermediate.push_back( hardProcessIn.PosIntermediate[i]);
83  }
84 
85  // Constructor with path to LHE file
86  HardProcess( string LHEfile, ParticleData* particleData) {
87  state = Event();
88  state.init("(hard process)", particleData);
89  translateLHEFString(LHEfile);
90  }
91 
92  // Constructor with core process input
93  void initOnProcess( string process, ParticleData* particleData);
94 
95  // Constructor with path to LHE file input
96  void initOnLHEF( string LHEfile, ParticleData* particleData);
97 
98  // Function to access the LHE file and read relevant information
99  void translateLHEFString( string LHEpath);
100 
101  // Function to translate the process string (in MG/ME notation)
102  void translateProcessString( string process);
103 
104  // Function to clear hard process information
105  void clear();
106 
107  // Function to identify the hard subprocess in the current event
108  void storeCandidates( const Event& event);
109  // Function to check if the particle event[iPos] matches any of
110  // the stored outgoing particles of the hard subprocess
111  bool matchesAnyOutgoing(int iPos, const Event& event);
112  // Function to return the type of the ME generator
113  int MEgenType();
114  // Function to get the number of coloured final state partons in the
115  // hard process
116  int nQuarksOut();
117  // Function to get the number of uncoloured final state particles in the
118  // hard process
119  int nLeptonOut();
120  // Function to get the number of coloured initial state partons in the
121  // hard process
122  int nQuarksIn();
123  // Function to get the number of uncoloured initial state particles in the
124  // hard process
125  int nLeptonIn();
126  // Function to report if a resonace decay was found in the 2->2 sub-process
127  // of the current state
128  int hasResInCurrent();
129  // Function to report the number of resonace decays in the 2->2 sub-process
130  // of the current state
131  int nResInCurrent();
132  // Function to report if a resonace decay was found in the 2->2 hard process
133  bool hasResInProc();
134  // Function to print the hard process (for debug)
135  void list() const;
136  // Function to print the hard process candidates in the
137  // Matrix element state (for debug)
138  void listCandidates() const;
139 
140 };
141 
142 //==========================================================================
143 
144 // MergingHooks is base class for user input to the merging procedure.
145 
147 
148 public:
149 
150  // Constructor.
151  MergingHooks() {}
152  // Destructor.
153  virtual ~MergingHooks() {}
154  // Function encoding the functional definition of the merging scale
155  virtual double tmsDefinition( const Event& event){ return event[0].e();}
156 
157  // Function returning the value of the merging scale.
158  double tms() { return tmsValueSave;}
159  // Function returning the value of the maximal number of merged jets.
160  int nMaxJets() { return nJetMaxSave;}
161 
162  // Function to return the number of outgoing partons in the core process
163  int nHardOutPartons(){ return hardProcess.nQuarksOut();}
164  // Function to return the number of outgoing leptons in the core process
165  int nHardOutLeptons(){ return hardProcess.nLeptonOut();}
166  // Function to return the number of incoming partons (hadrons) in the core
167  // process
168  int nHardInPartons(){ return hardProcess.nQuarksIn();}
169  // Function to return the number of incoming leptons in the core process
170  int nHardInLeptons(){ return hardProcess.nLeptonIn();}
171  // Function to report the number of resonace decays in the 2->2 sub-process
172  // of the current state
173  int nResInCurrent(){ return hardProcess.nResInCurrent();}
174 
175  // Function to return the number of clustering steps for the current event
176  int getNumberOfClusteringSteps(const Event& event);
177 
178  // Function to determine if user defined merging should be applied
179  bool doUserMerging(){ return doUserMergingSave;}
180  // Function to determine if automated MG/ME merging should be applied
181  bool doMGMerging() { return doMGMergingSave;}
182  // Function to determine if KT merging should be applied
183  bool doKTMerging() { return doKTMergingSave;}
184 
185  // Function to dampen weights calculated from histories with lowest
186  // multiplicity reclustered events that do not pass the ME cuts
187  virtual double dampenIfFailCuts( const Event& inEvent ) {
188  // Dummy statement to avoid compiler warnings
189  if(false) cout << inEvent[0].e();
190  return 1.;
191  }
192 
193  // Hooks to disallow states in the construction of all histories, e.g.
194  // because jets are below the merging scale or fail the matrix element cuts
195  // Function to allow interference in the construction of histories
196  virtual bool canCutOnRecState() { return false; }
197  // Function to check reclustered state while generating all possible
198  // histories
199  // Function implementing check of reclustered events while constructing
200  // all possible histories
201  virtual bool doCutOnRecState( const Event& event ) {
202  // Dummy statement to avoid compiler warnings
203  if(false) cout << event[0].e();
204  return false;
205  }
206 
207  // Make History class friend to allow access to advanced switches
208  friend class History;
209  // Make Pythia class friend
210  friend class Pythia;
211  // Make PartonLevel class friend
212  friend class PartonLevel;
213 
214 protected:
215 
216  // Functions for internal use inside Pythia source code
217  // Initialize.
218  void init( Settings& settings, Info* infoPtrIn,
219  ParticleData* particleDataPtrIn, ostream& os = cout);
220  // Function storing candidates for the hard process in the current event
221  // Needed in order not to cluster members of the core process
222  void storeHardProcessCandidates(const Event& event){
223  hardProcess.storeCandidates(event);
224  }
225  // Function to set the path to the LHE file, so that more automated merging
226  // can be used
227  void setLHEInputFile( string lheFile);
228 
229  // Function to save the current CKKWL weight
230  void setWeight(double wgt){ weightSave = wgt;}
231 
232  // Function to calculate the minimal kT in the event
233  double kTms(const Event & event);
234 
235  // Function to get the CKKWL weight for the current event
236  double getWeight() { return weightSave;}
237 
238  // Helper class doing all the core process book-keeping
239  HardProcess hardProcess;
240 
241  // Pointer to various information on the generation.
242  Info* infoPtr;
243 
244  // Pointer to the particle data table.
245  ParticleData* particleDataPtr;
246 
247  // AlphaS objects for alphaS reweighting use
248  AlphaStrong AlphaS_FSRSave;
249  AlphaStrong AlphaS_ISRSave;
250 
251  // Return AlphaStrong objects
252  AlphaStrong* AlphaS_FSR() { return &AlphaS_FSRSave;}
253  AlphaStrong* AlphaS_ISR() { return &AlphaS_ISRSave;}
254 
255  // Saved path to LHE file for more automated merging
256  string lheInputFile;
257 
258  bool doUserMergingSave, doMGMergingSave, doKTMergingSave,
259  includeMassiveSave, enforceStrongOrderingSave, orderInRapiditySave,
260  pickByFullPSave, pickByPoPT2Save, includeRedundantSave,
261  pickBySumPTSave, allowColourShufflingSave;
262  int unorderedScalePrescipSave, unorderedASscalePrescipSave,
263  incompleteScalePrescipSave, ktTypeSave;
264  double scaleSeparationFactorSave, nonJoinedNormSave,
265  fsrInRecNormSave, herwigAcollFSRSave, herwigAcollISRSave,
266  pT0ISRSave, pTcutSave;
267 
268  // Functions to return advanced merging switches
269  // Include masses in definition of evolution pT and splitting kernels
270  bool includeMassive() { return includeMassiveSave;}
271  // Prefer strongly ordered histories
272  bool enforceStrongOrdering() { return enforceStrongOrderingSave;}
273  // Prefer histories ordered in rapidity and evolution pT
274  bool orderInRapidity() { return orderInRapiditySave;}
275  // Pick history probabilistically by full (correct) splitting probabilities
276  bool pickByFull() { return pickByFullPSave;}
277  // Pick history probabilistically, with easier form of probabilities
278  bool pickByPoPT2() { return pickByPoPT2Save;}
279  // Include redundant terms (e.g. PDF ratios) in the splitting probabilities
280  bool includeRedundant(){ return includeRedundantSave;}
281  // Pick by winner-takes-it-all, with minimum sum of scalar evolution pT
282  bool pickBySumPT(){ return pickBySumPTSave;}
283 
284  // Prescription for combined scale of unordered emissions
285  // 0 : use larger scale
286  // 1 : use smaller scale
287  int unorderedScalePrescip() { return unorderedScalePrescipSave;}
288  // Prescription for combined scale used in alpha_s for unordered emissions
289  // 0 : use combined emission scale in alpha_s weight for both (!) splittings
290  // 1 : use original reclustered scales of each emission in alpha_s weight
291  int unorderedASscalePrescip() { return unorderedASscalePrescipSave;}
292  // Prescription for starting scale of incomplete histories
293  // 0: use factorization scale
294  // 1: use sHat
295  // 2: use s
296  int incompleteScalePrescip() { return incompleteScalePrescipSave;}
297 
298  // Allow swapping one colour index while reclustering
299  bool allowColourShuffling() { return allowColourShufflingSave;}
300 
301  // Factor by which two scales should differ to be classified strongly ordered
302  double scaleSeparationFactor() { return scaleSeparationFactorSave;}
303  // Absolute normalization of splitting probability for non-joined
304  // evolution
305  double nonJoinedNorm() { return nonJoinedNormSave;}
306  // Absolute normalization of splitting probability for final state
307  // splittings with initial state recoiler
308  double fsrInRecNorm() { return fsrInRecNormSave;}
309  // Factor multiplying scalar evolution pT for FSR splitting, when picking
310  // history by minimum scalar pT (see Jonathan Tully's thesis)
311  double herwigAcollFSR() { return herwigAcollFSRSave;}
312  // Factor multiplying scalar evolution pT for ISR splitting, when picking
313  // history by minimum scalar pT (see Jonathan Tully's thesis)
314  double herwigAcollISR() { return herwigAcollISRSave;}
315  // ISR regularisation scale
316  double pT0ISR() { return pT0ISRSave;}
317  // Shower cut-off scale
318  double pTcut() { return pTcutSave;}
319 
320  // Function to calculate the kT separation between two particles
321  double kTdurham(const Particle& RadAfterBranch,
322  const Particle& EmtAfterBranch, int Type, double D );
323 
324  // Saved members. Not used at the moment
325  double tmsValueSave;
326  int nJetMaxSave;
327  string processSave;
328  double weightSave;
329 
330 };
331 
332 //==========================================================================
333 
334 } // end namespace Pythia8
335 
336 #endif // Pythia8_MergingHooks_H