source: HiSusy/trunk/Pythia8/pythia8170/include/MergingHooks.h @ 1

Last change on this file since 1 was 1, checked in by zerwas, 12 years ago

first import of structure, PYTHIA8 and DELPHES

File size: 20.3 KB
Line 
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
25namespace 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
34class HardProcess {
35
36public:
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 )
68    : state(hardProcessIn.state),
69      tms(hardProcessIn.tms), meGenType(hardProcessIn.meGenType) {
70    hardIncoming1 = hardProcessIn.hardIncoming1;
71    hardIncoming2 = hardProcessIn.hardIncoming2;
72    for(int i =0; i < int(hardProcessIn.hardOutgoing1.size());++i)
73      hardOutgoing1.push_back( hardProcessIn.hardOutgoing1[i]);
74    for(int i =0; i < int(hardProcessIn.hardOutgoing2.size());++i)
75      hardOutgoing2.push_back( hardProcessIn.hardOutgoing2[i]);
76    for(int i =0; i < int(hardProcessIn.hardIntermediate.size());++i)
77      hardIntermediate.push_back( hardProcessIn.hardIntermediate[i]);
78    for(int i =0; i < int(hardProcessIn.PosOutgoing1.size());++i)
79      PosOutgoing1.push_back( hardProcessIn.PosOutgoing1[i]);
80    for(int i =0; i < int(hardProcessIn.PosOutgoing2.size());++i)
81      PosOutgoing2.push_back( hardProcessIn.PosOutgoing2[i]);
82    for(int i =0; i < int(hardProcessIn.PosIntermediate.size());++i)
83      PosIntermediate.push_back( hardProcessIn.PosIntermediate[i]);
84  }
85
86  // Constructor with path to LHE file
87  HardProcess( string LHEfile, ParticleData* particleData) {
88    state = Event();
89    state.init("(hard process)", particleData);
90    translateLHEFString(LHEfile);
91  }
92
93  // Constructor with core process input
94  void initOnProcess( string process, ParticleData* particleData);
95
96  // Constructor with path to LHE file input
97  void initOnLHEF( string LHEfile, ParticleData* particleData);
98
99  // Function to access the LHE file and read relevant information
100  void translateLHEFString( string LHEpath);
101
102  // Function to translate the process string (in MG/ME notation)
103  void translateProcessString( string process);
104
105  // Function to clear hard process information
106  void clear();
107
108  // Function to check whether the sets of candidates Pos1, Pos2, together
109  // with the proposed candidate iPos give an allowed hard process state
110  bool allowCandidates(int iPos, vector<int> Pos1, vector<int> Pos2,
111    const Event& event);
112  // Function to identify the hard subprocess in the current event
113  void storeCandidates( const Event& event, string process);
114  // Function to check if the particle event[iPos] matches any of
115  // the stored outgoing particles of the hard subprocess
116  bool matchesAnyOutgoing(int iPos, const Event& event);
117
118  // Function to return the type of the ME generator
119  int MEgenType();
120  // Function to get the number of coloured final state partons in the
121  // hard process
122  int nQuarksOut();
123  // Function to get the number of uncoloured final state particles in the
124  // hard process
125  int nLeptonOut();
126  // Function to get the number of electroweak final state bosons in the
127  // hard process
128  int nBosonsOut();
129
130  // Function to get the number of coloured initial state partons in the
131  // hard process
132  int nQuarksIn();
133  // Function to get the number of uncoloured initial state particles in the
134  // hard process
135  int nLeptonIn();
136  // Function to report if a resonace decay was found in the 2->2 sub-process
137  // of the  current state
138  int hasResInCurrent();
139  // Function to report the number of resonace decays in the 2->2 sub-process
140  // of the  current state
141  int nResInCurrent();
142  // Function to report if a resonace decay was found in the 2->2 hard process
143  bool hasResInProc();
144  // Function to print the hard process (for debug)
145  void list() const;
146  // Function to print the hard process candidates in the
147  // Matrix element state (for debug)
148  void listCandidates() const;
149
150};
151
152//==========================================================================
153
154// MergingHooks is base class for user input to the merging procedure.
155
156class MergingHooks {
157
158public:
159
160  // Constructor.
161  MergingHooks() : 
162    doUserMergingSave(false),
163    doMGMergingSave(false),
164    doKTMergingSave(false),
165    doPTLundMergingSave(false),
166    doCutBasedMergingSave(false),
167    forceOrderedSave(false),
168    forceUnorderedSave(false),
169    doOrderHistoriesSave(true),
170    doForceUnorderedHistoriesSave(false),
171    doCutOnRecStateSave(false),
172    doWClusteringSave(false) {}
173
174  // Destructor.
175  virtual ~MergingHooks() {}
176  // Function encoding the functional definition of the merging scale
177  virtual double tmsDefinition( const Event& event){ return event[0].e();}
178
179  // Function returning the value of the merging scale.
180  double tms() {
181    if(doCutBasedMergingSave) return 0.;
182    else return tmsValueSave;
183  }
184  // Function returning the value of the Delta R_{ij} cut for
185  // cut based merging scale definition.
186  double dRijMS() {
187    return ((tmsListSave.size() == 3) ? tmsListSave[0] : 0.);
188  }
189  // Function returning the value of the pT_{i} cut for
190  // cut based merging scale definition.
191  double pTiMS() {
192    return ((tmsListSave.size() == 3) ? tmsListSave[1] : 0.);
193  }
194  // Function returning the value of the pT_{i} cut for
195  // cut based merging scale definition.
196  double QijMS() {
197    return ((tmsListSave.size() == 3) ? tmsListSave[2] : 0.);
198  }
199  // Function returning the value of the maximal number of merged jets.
200  int nMaxJets() { return nJetMaxSave;}
201
202  // Function to return hard process string.
203  string getProcessString() { return processSave;}
204
205  // Function to return the number of outgoing partons in the core process
206  int nHardOutPartons(){ return hardProcess.nQuarksOut();}
207  // Function to return the number of outgoing leptons in the core process
208  int nHardOutLeptons(){ return hardProcess.nLeptonOut();}
209  // Function to return the number of outgoing electroweak bosons in the core
210  // process.
211  int nHardOutBosons(){ return hardProcess.nBosonsOut();}
212
213  // Function to return the number of incoming partons (hadrons) in the core
214  // process.
215  int nHardInPartons(){ return hardProcess.nQuarksIn();}
216  // Function to return the number of incoming leptons in the core process.
217  int nHardInLeptons(){ return hardProcess.nLeptonIn();}
218  // Function to report the number of resonace decays in the 2->2 sub-process
219  // of the  current state.
220  int nResInCurrent(){ return hardProcess.nResInCurrent();}
221  // Function to check if event contains an emission not present in the hard
222  // process.
223  bool isFirstEmission(const Event& event);
224  // Function to allow effective gg -> EW boson couplings.
225  bool hasEffectiveG2EW() {
226    if ( getProcessString().compare("pp>h") == 0 ) return true;
227    return false; }
228
229  // Function to return the number of clustering steps for the current event
230  int getNumberOfClusteringSteps(const Event& event);
231
232  // Function to determine if user defined merging should be applied.
233  bool doUserMerging(){ return doUserMergingSave;}
234  // Function to determine if automated MG/ME merging should be applied.
235  bool doMGMerging() { return doMGMergingSave;}
236  // Function to determine if KT merging should be applied.
237  bool doKTMerging() { return doKTMergingSave;}
238  // Function to determine if PTLund merging should be applied.
239  bool doPTLundMerging() { return doPTLundMergingSave;}
240  // Function to determine if cut based merging should be applied.
241  bool doCutBasedMerging() { return doCutBasedMergingSave;}
242
243  // Function to dampen weights calculated from histories with lowest
244  // multiplicity reclustered events that do not pass the ME cuts
245  virtual double dampenIfFailCuts( const Event& inEvent ) {
246    // Dummy statement to avoid compiler warnings
247    if(false) cout << inEvent[0].e();
248    return 1.;
249  }
250
251  // Hooks to disallow states in the construction of all histories, e.g.
252  // because jets are below the merging scale or fail the matrix element cuts
253  // Function to allow interference in the construction of histories
254  virtual bool canCutOnRecState() { return doCutOnRecStateSave; }
255  // Function to check reclustered state while generating all possible
256  // histories
257  // Function implementing check of reclustered events while constructing
258  // all possible histories
259  virtual bool doCutOnRecState( const Event& event ) {
260    // Dummy statement to avoid compiler warnings.
261    if(false) cout << event[0].e();
262    // Count number of final state partons.
263    int nPartons = 0;
264    for( int i=0; i < int(event.size()); ++i)
265      if(  event[i].isFinal()
266        && (event[i].isGluon() || event[i].isQuark()) )
267        nPartons++;
268    // For gg -> h, allow only histories with gluons in initial state
269    if( hasEffectiveG2EW() && nPartons < 2){
270      if(event[3].id() != 21 || event[4].id() != 21)
271        return true;
272    }
273    return false;
274  }
275
276  // Function to allow not counting a trial emission.
277  virtual bool canVetoTrialEmission() { return false;}
278  // Function to check if trial emission should be rejected.
279  virtual bool doVetoTrialEmission( const Event&, const Event& ) {
280    return false; }
281
282  // Make History class friend to allow access to advanced switches
283  friend class History;
284  // Make Pythia class friend
285  friend class Pythia;
286  // Make PartonLevel class friend
287  friend class PartonLevel;
288  // Make SpaceShower class friend
289  friend class SpaceShower;
290  // Make TimeShower class friend
291  friend class TimeShower;
292
293  // Function to force preferred picking of ordered histories. By default,
294  // unordered histories will only be considered if no ordered histories
295  // were found.
296  void orderHistories( bool doOrderHistoriesIn) {
297    doOrderHistoriesSave = doOrderHistoriesIn; }
298  // Function to force preferred picking of unordered histories.
299  void forceUnorderedHistories( bool doForceUnorderedHistoriesIn) {
300    doForceUnorderedHistoriesSave = doForceUnorderedHistoriesIn; }
301  // Function to force cut on reconstructed states internally, as needed
302  // for gg -> Higgs to ensure that e.g. uu~ -> Higgs is not constructed.
303  void allowCutOnRecState( bool doCutOnRecStateIn) {
304    doCutOnRecStateSave = doCutOnRecStateIn; }
305
306  // Function to allow final state clusterings of W-bosons
307  void doWClustering( bool doWClusteringIn ) {
308    doWClusteringSave = doWClusteringIn; }
309
310protected:
311
312  // Functions for internal use inside Pythia source code
313  // Initialize.
314  void init(  Settings& settings, Info* infoPtrIn, 
315    ParticleData* particleDataPtrIn, ostream& os = cout);
316  // Function storing candidates for the hard process in the current event
317  // Needed in order not to cluster members of the core process
318  void storeHardProcessCandidates(const Event& event){
319    hardProcess.storeCandidates(event,getProcessString());
320  }
321  // Function to set the path to the LHE file, so that more automated merging
322  // can be used.
323  // Remove "_1.lhe" suffix from LHE file name.
324  // This is done so that the HarsProcess class can access both the +0 and +1
325  // LHE files to find both the merging scale and the core process string
326  // Store.
327  void setLHEInputFile( string lheFile) {
328    lheInputFile = lheFile.substr(0,lheFile.size()-6); }
329
330  // Function to save the current CKKW-L weight
331  void setWeight(double wgt){ weightSave = wgt;}
332
333  // Save CKKW-L weight / O(\alpha_s) weight.
334  double weightCKKWLSave;
335  // Return CKKW-L weight.
336  double getWeightCKKWL() { return weightCKKWLSave; }
337  // Set CKKW-L weight.
338  void setWeightCKKWL( double weightIn) { weightCKKWLSave = weightIn; }
339
340  // Function to calculate the minimal kT in the event
341  double kTms(const Event & event);
342
343  // Find the minimal Lund pT between coloured partons in the event
344  double rhoms( const Event& event, bool withColour);
345
346  // Function to check if the properties of the input particle should be
347  // checked against the cut-based merging scale defintion.
348  bool checkAgainstCut( const Particle& particle);
349
350  // Find the if the event passes the Delta R_{ij}, pT_{i} and Q_{ij} cuts on
351  // the matrix element, as needed for cut-based merging scale definition
352  double cutbasedms( const Event& event );
353
354  // Function to compute Delta R separation from 4-vector input
355  double deltaRij(Vec4 jet1, Vec4 jet2);
356
357  // Function to decide if (too) many events are significantly above the
358  // merging scale.
359  bool stats() { double ALLOWEDFRACTION = 0.75;
360    double fraction = double(infoPtr->getCounter(41))
361                    / max(1., double(infoPtr->nAccepted()));
362    return ( fraction > ALLOWEDFRACTION ); } 
363
364  // Function to get the CKKW-L weight for the current event
365  double getWeight() { return weightSave;}
366
367  // Helper class doing all the core process book-keeping
368  HardProcess hardProcess;
369
370  // Pointer to various information on the generation.
371  Info*          infoPtr;
372
373  // Pointer to the particle data table.
374  ParticleData*  particleDataPtr;
375
376  // AlphaS objects for alphaS reweighting use
377  AlphaStrong AlphaS_FSRSave;
378  AlphaStrong AlphaS_ISRSave;
379  AlphaEM AlphaEM_FSRSave;
380
381  // Return AlphaStrong objects
382  AlphaStrong* AlphaS_FSR() { return &AlphaS_FSRSave;}
383  AlphaStrong* AlphaS_ISR() { return &AlphaS_ISRSave;}
384  AlphaEM* AlphaEM_FSR() { return &AlphaEM_FSRSave;}
385
386  // Saved path to LHE file for more automated merging
387  string lheInputFile;
388
389  bool   doUserMergingSave, doMGMergingSave, doKTMergingSave,
390         doPTLundMergingSave, doCutBasedMergingSave,
391         includeMassiveSave, enforceStrongOrderingSave, orderInRapiditySave,
392         pickByFullPSave, pickByPoPT2Save, includeRedundantSave,
393         pickBySumPTSave, allowColourShufflingSave, resetHardQRenSave,
394         resetHardQFacSave;
395  int    unorderedScalePrescipSave, unorderedASscalePrescipSave,
396         unorderedPDFscalePrescipSave, incompleteScalePrescipSave,
397         ktTypeSave;
398  double scaleSeparationFactorSave, nonJoinedNormSave,
399         fsrInRecNormSave, herwigAcollFSRSave, herwigAcollISRSave,
400         pT0ISRSave, pTcutSave;
401  bool   forceOrderedSave, forceUnorderedSave;
402
403  // Functions to return advanced merging switches
404  // Include masses in definition of evolution pT and splitting kernels
405  bool includeMassive() { return includeMassiveSave;}
406  // Prefer strongly ordered histories
407  bool enforceStrongOrdering() { return enforceStrongOrderingSave;}
408  // Prefer histories ordered in rapidity and evolution pT
409  bool orderInRapidity() { return orderInRapiditySave;}
410  // Pick history probabilistically by full (correct) splitting probabilities
411  bool pickByFull() { return pickByFullPSave;}
412  // Pick history probabilistically, with easier form of probabilities
413  bool pickByPoPT2() { return pickByPoPT2Save;}
414  // Include redundant terms (e.g. PDF ratios) in the splitting probabilities
415  bool includeRedundant(){ return includeRedundantSave;}
416  // Pick by winner-takes-it-all, with minimum sum of scalar evolution pT
417  bool pickBySumPT(){ return pickBySumPTSave;}
418
419  bool forceOrdered() { return forceOrderedSave;}
420  bool forceUnordered() { return forceUnorderedSave;}
421
422  // Prescription for combined scale of unordered emissions
423  // 0 : use larger scale
424  // 1 : use smaller scale
425  int unorderedScalePrescip() { return unorderedScalePrescipSave;}
426  // Prescription for combined scale used in alpha_s for unordered emissions
427  // 0 : use combined emission scale in alpha_s weight for both (!) splittings
428  // 1 : use original reclustered scales of each emission in alpha_s weight
429  int unorderedASscalePrescip() { return unorderedASscalePrescipSave;}
430  // Prescription for combined scale used in PDF ratios for unordered
431  // emissions
432  // 0 : use combined emission scale in PDFs for both (!) splittings
433  // 1 : use original reclustered scales of each emission in PDF ratiost
434  int unorderedPDFscalePrescip() { return unorderedPDFscalePrescipSave;}
435  // Prescription for starting scale of incomplete histories
436  // 0: use factorization scale
437  // 1: use sHat
438  // 2: use s
439  int incompleteScalePrescip() { return incompleteScalePrescipSave;}
440
441  // Allow swapping one colour index while reclustering
442  bool allowColourShuffling() { return allowColourShufflingSave;}
443
444  // Allow use of dynamical renormalisation scale of the core 2-> 2 process.
445  bool resetHardQRen() { return resetHardQRenSave; }
446  // Allow use of dynamical factorisation scale of the core 2-> 2 process.
447  bool resetHardQFac() { return resetHardQFacSave; }
448
449  // Factor by which two scales should differ to be classified strongly
450  // ordered.
451  double scaleSeparationFactor() { return scaleSeparationFactorSave;}
452  // Absolute normalization of splitting probability for non-joined
453  // evolution.
454  double nonJoinedNorm() { return nonJoinedNormSave;}
455  // Absolute normalization of splitting probability for final state
456  // splittings with initial state recoiler
457  double fsrInRecNorm() { return fsrInRecNormSave;}
458  // Factor multiplying scalar evolution pT for FSR splitting, when picking
459  // history by minimum scalar pT (see Jonathan Tully's thesis)
460  double herwigAcollFSR() { return herwigAcollFSRSave;}
461  // Factor multiplying scalar evolution pT for ISR splitting, when picking
462  // history by minimum scalar pT (see Jonathan Tully's thesis)
463  double herwigAcollISR() { return herwigAcollISRSave;}
464  // ISR regularisation scale
465  double pT0ISR() { return pT0ISRSave;}
466  // Shower cut-off scale
467  double pTcut() { return pTcutSave;}
468
469  // Function to calculate the kT separation between two particles
470  double kTdurham(const Particle& RadAfterBranch,
471    const Particle& EmtAfterBranch, int Type, double D );
472  // Function to compute "pythia pT separation" from Particle input
473  double rhoPythia(const Particle& RadAfterBranch,
474    const Particle& EmtAfterBranch, const Particle& RecAfterBranch, 
475    int ShowerType);
476  // Function to find a colour (anticolour) index in the input event,
477  // used to find colour-connected recoilers
478  int findColour(int col, int iExclude1, int iExclude2,
479    const Event& event, int type, bool isHardIn);
480
481  // Saved members.
482  double tmsValueSave;
483  int nJetMaxSave;
484  string processSave;
485  double weightSave;
486
487  // List of cut values to used to define a merging scale. Ordering:
488  // 0: DeltaR_{jet_i,jet_j,min}
489  // 1: p_{T,jet_i,min}
490  // 2: Q_{jet_i,jet_j,min}
491  vector<double> tmsListSave;
492
493  // INTERNAL Hooks to allow construction of all histories,
494  // including un-ordered ones
495  bool doOrderHistoriesSave, doForceUnorderedHistoriesSave;
496  bool orderHistories() { return doOrderHistoriesSave;}
497
498  // INTERNAL Hooks to force construction of only unordered histories,
499  bool forceUnorderedHistories() { return doForceUnorderedHistoriesSave;}
500
501  // INTERNAL Hooks to disallow states in the construction of all histories,
502  // e.g. because jets are below the merging scale, of to avoid the
503  // construction of uu~ -> Higgs histories.
504  bool doCutOnRecStateSave;
505  bool allowCutOnRecState() { return doCutOnRecStateSave;}
506
507  // INTERNAL Hooks to allow clustering W bosons.
508  bool doWClusteringSave;
509  bool doWClustering() { return doWClusteringSave;}
510
511};
512
513//==========================================================================
514
515} // end namespace Pythia8
516
517#endif // Pythia8_MergingHooks_H
Note: See TracBrowser for help on using the repository browser.