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) 2020 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 // 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 "Pythia8/Basics.h"
17 #include "Pythia8/BeamParticle.h"
18 #include "Pythia8/Event.h"
19 #include "Pythia8/Info.h"
20 #include "Pythia8/ParticleData.h"
21 #include "Pythia8/PartonSystems.h"
22 #include "Pythia8/PhysicsBase.h"
23 #include "Pythia8/PythiaStdlib.h"
24 #include "Pythia8/Settings.h"
25 
26 
27 namespace Pythia8 {
28 
29 class PartonLevel;
30 
31 //==========================================================================
32 
33 // Declaration of hard process class
34 // This class holds information on the desired hard 2->2 process
35 // for the merging.
36 // This class is a container class for History class use.
37 
38 class HardProcess {
39 
40 public:
41 
42  // Flavour of the first incoming particle
43  int hardIncoming1;
44  // Flavour of the second incoming particle
45  int hardIncoming2;
46  // Flavours of the outgoing particles
47  vector<int> hardOutgoing1;
48  vector<int> hardOutgoing2;
49  // Flavour of intermediate bosons in the hard 2->2
50  vector<int> hardIntermediate;
51 
52  // Current reference event
53  Event state;
54  // Potential positions of outgoing particles in reference event
55  vector<int> PosOutgoing1;
56  vector<int> PosOutgoing2;
57  // Potential positions of intermediate bosons in reference event
58  vector<int> PosIntermediate;
59 
60  // Information on merging scale read from LHE file
61  double tms;
62 
63  // Default constructor
64  HardProcess() : hardIncoming1(), hardIncoming2(), tms(){}
65  // Default destructor
66  virtual ~HardProcess(){}
67 
68  // Copy constructor
69  HardProcess( const HardProcess& hardProcessIn )
70  : state(hardProcessIn.state),
71  tms(hardProcessIn.tms) {
72  hardIncoming1 = hardProcessIn.hardIncoming1;
73  hardIncoming2 = hardProcessIn.hardIncoming2;
74  for(int i =0; i < int(hardProcessIn.hardOutgoing1.size());++i)
75  hardOutgoing1.push_back( hardProcessIn.hardOutgoing1[i]);
76  for(int i =0; i < int(hardProcessIn.hardOutgoing2.size());++i)
77  hardOutgoing2.push_back( hardProcessIn.hardOutgoing2[i]);
78  for(int i =0; i < int(hardProcessIn.hardIntermediate.size());++i)
79  hardIntermediate.push_back( hardProcessIn.hardIntermediate[i]);
80  for(int i =0; i < int(hardProcessIn.PosOutgoing1.size());++i)
81  PosOutgoing1.push_back( hardProcessIn.PosOutgoing1[i]);
82  for(int i =0; i < int(hardProcessIn.PosOutgoing2.size());++i)
83  PosOutgoing2.push_back( hardProcessIn.PosOutgoing2[i]);
84  for(int i =0; i < int(hardProcessIn.PosIntermediate.size());++i)
85  PosIntermediate.push_back( hardProcessIn.PosIntermediate[i]);
86  }
87 
88  // Constructor with path to LHE file
89  HardProcess( string LHEfile, ParticleData* particleData) : hardIncoming1(),
90  hardIncoming2(), tms() {
91  state = Event();
92  state.init("(hard process)", particleData);
93  translateLHEFString(LHEfile);
94  }
95 
96  // Constructor with core process input
97  virtual void initOnProcess( string process, ParticleData* particleData);
98 
99  // Constructor with path to LHE file input
100  void initOnLHEF( string LHEfile, ParticleData* particleData);
101 
102  // Function to access the LHE file and read relevant information
103  void translateLHEFString( string LHEpath);
104 
105  // Function to translate the process string (in MG/ME notation)
106  virtual void translateProcessString( string process);
107 
108  // Function to clear hard process information
109  void clear();
110 
111  // Function to check whether the sets of candidates Pos1, Pos2, together
112  // with the proposed candidate iPos give an allowed hard process state
113  virtual bool allowCandidates(int iPos, vector<int> Pos1, vector<int> Pos2,
114  const Event& event);
115  // Function to identify the hard subprocess in the current event
116  virtual void storeCandidates( const Event& event, string process);
117  // Function to check if the particle event[iPos] matches any of
118  // the stored outgoing particles of the hard subprocess
119  virtual bool matchesAnyOutgoing(int iPos, const Event& event);
120  // Function to check if instead of the particle event[iCandidate], another
121  // particle could serve as part of the hard process. Assumes that iCandidate
122  // is already stored as part of the hard process.
123  virtual bool findOtherCandidates(int iPos, const Event& event,
124  bool doReplace);
125  // Function to exchange a stored hard process candidate with another choice.
126  virtual bool exchangeCandidates( vector<int> candidates1,
127  vector<int> candidates2,
128  unordered_map<int,int> further1, unordered_map<int,int> further2);
129 
130  // Function to get the number of coloured final state partons in the
131  // hard process
132  int nQuarksOut();
133  // Function to get the number of uncoloured final state particles in the
134  // hard process
135  int nLeptonOut();
136  // Function to get the number of electroweak final state bosons in the
137  // hard process
138  int nBosonsOut();
139 
140  // Function to get the number of coloured initial state partons in the
141  // hard process
142  int nQuarksIn();
143  // Function to get the number of uncoloured initial state particles in the
144  // hard process
145  int nLeptonIn();
146  // Function to report if a resonace decay was found in the 2->2 sub-process
147  // of the current state
148  int hasResInCurrent();
149  // Function to report the number of resonace decays in the 2->2 sub-process
150  // of the current state
151  int nResInCurrent();
152  // Function to report if a resonace decay was found in the 2->2 hard process
153  bool hasResInProc();
154  // Function to print the hard process (for debug)
155  void list() const;
156  // Function to print the hard process candidates in the
157  // Matrix element state (for debug)
158  void listCandidates() const;
159 
160 };
161 
162 //==========================================================================
163 
164 // MergingHooks is base class for user input to the merging procedure.
165 
166 class MergingHooks : public PhysicsBase {
167 
168 public:
169 
170  // Constructor.
171  MergingHooks() : useShowerPluginSave(), showers(),
172  doUserMergingSave(false),
173  doMGMergingSave(false),
174  doKTMergingSave(false),
175  doPTLundMergingSave(false),
176  doCutBasedMergingSave(false), includeMassiveSave(),
177  enforceStrongOrderingSave(),
178  orderInRapiditySave(), pickByFullPSave(), pickByPoPT2Save(),
179  includeRedundantSave(), pickBySumPTSave(), allowColourShufflingSave(),
180  resetHardQRenSave(), resetHardQFacSave(), unorderedScalePrescipSave(),
181  unorderedASscalePrescipSave(), unorderedPDFscalePrescipSave(),
182  incompleteScalePrescipSave(), ktTypeSave(), nReclusterSave(),
183  nQuarksMergeSave(), nRequestedSave(), scaleSeparationFactorSave(),
184  nonJoinedNormSave(), fsrInRecNormSave(), herwigAcollFSRSave(),
185  herwigAcollISRSave(), pT0ISRSave(), pTcutSave(),
186  doNL3TreeSave(false),
187  doNL3LoopSave(false),
188  doNL3SubtSave(false),
189  doUNLOPSTreeSave(false),
190  doUNLOPSLoopSave(false),
191  doUNLOPSSubtSave(false),
192  doUNLOPSSubtNLOSave(false),
193  doUMEPSTreeSave(false),
194  doUMEPSSubtSave(false),
195  doEstimateXSection(false), applyVeto(),
196  doRemoveDecayProducts(false), muMISave(), kFactor0jSave(), kFactor1jSave(),
197  kFactor2jSave(), tmsValueSave(), tmsValueNow(), DparameterSave(),
198  nJetMaxSave(), nJetMaxNLOSave(),
199  doOrderHistoriesSave(true),
200  doCutOnRecStateSave(false),
201  doWeakClusteringSave(false),
202  doSQCDClusteringSave(false), muFSave(), muRSave(), muFinMESave(),
203  muRinMESave(),
204  doIgnoreEmissionsSave(true),
205  doIgnoreStepSave(true), pTsave(), weightCKKWL1Save(), weightCKKWL2Save(),
206  nMinMPISave(), weightCKKWLSave(), weightFIRSTSave(), nJetMaxLocal(),
207  nJetMaxNLOLocal(),
208  hasJetMaxLocal(false),
209  includeWGTinXSECSave(false), nHardNowSave(), nJetNowSave(),
210  tmsHardNowSave(), tmsNowSave() {
211  inputEvent = Event(); resonances.resize(0);
212  useOwnHardProcess = false; hardProcess = 0; stopScaleSave= 0.0; }
213 
214  // Make History class friend to allow access to advanced switches
215  friend class History;
216  // Make Pythia class friend
217  friend class Pythia;
218  // Make PartonLevel class friend
219  friend class PartonLevel;
220  // Make SpaceShower class friend
221  friend class SpaceShower;
222  // Make TimeShower class friend
223  friend class TimeShower;
224  // Make Merging class friend
225  friend class Merging;
226 
227  //----------------------------------------------------------------------//
228  // Functions that allow user interference
229  //----------------------------------------------------------------------//
230 
231  // Destructor.
232  virtual ~MergingHooks();
233  // Function encoding the functional definition of the merging scale
234  virtual double tmsDefinition( const Event& event){ return event[0].e();}
235  // Function to dampen weights calculated from histories with lowest
236  // multiplicity reclustered events that do not pass the ME cuts
237  virtual double dampenIfFailCuts( const Event& inEvent ) {
238  // Dummy statement to avoid compiler warnings
239  if(false) cout << inEvent[0].e();
240  return 1.;
241  }
242  // Hooks to disallow states in the construction of all histories, e.g.
243  // because jets are below the merging scale or fail the matrix element cuts
244  // Function to allow interference in the construction of histories
245  virtual bool canCutOnRecState() { return doCutOnRecStateSave; }
246  // Function to check reclustered state while generating all possible
247  // histories
248  // Function implementing check of reclustered events while constructing
249  // all possible histories
250  virtual bool doCutOnRecState( const Event& event ) {
251  // Dummy statement to avoid compiler warnings.
252  if(false) cout << event[0].e();
253  // Count number of final state partons.
254  int nPartons = 0;
255  for( int i=0; i < int(event.size()); ++i)
256  if( event[i].isFinal()
257  && (event[i].isGluon() || event[i].isQuark()) )
258  nPartons++;
259  // For gg -> h, allow only histories with gluons in initial state
260  if( hasEffectiveG2EW() && nPartons < 2){
261  if(event[3].id() != 21 && event[4].id() != 21)
262  return true;
263  }
264  return false;
265  }
266  // Function to allow not counting a trial emission.
267  virtual bool canVetoTrialEmission() { return false;}
268  // Function to check if trial emission should be rejected.
269  virtual bool doVetoTrialEmission( const Event&, const Event& ) {
270  return false; }
271 
272  // Function to calculate the hard process matrix element.
273  virtual double hardProcessME( const Event& inEvent ) {
274  // Dummy statement to avoid compiler warnings.
275  if ( false ) cout << inEvent[0].e();
276  return 1.; }
277 
278  // Functions for internal use inside Pythia source code
279  // Initialize.
280  virtual void init();
281 
282  //----------------------------------------------------------------------//
283  // Simple output functions
284  //----------------------------------------------------------------------//
285 
286  // Function returning the value of the merging scale.
287  double tms() {
288  if(doCutBasedMergingSave) return 0.;
289  //else return tmsValueSave;
290  else return tmsValueNow;
291  }
292  double tmsCut() {
293  if(doCutBasedMergingSave) return 0.;
294  else return tmsValueSave;
295  }
296  void tms( double tmsIn ) { tmsValueNow = tmsIn; }
297 
298  // Function returning the value of the Delta R_{ij} cut for
299  // cut based merging scale definition.
300  double dRijMS() {
301  return ((tmsListSave.size() == 3) ? tmsListSave[0] : 0.);
302  }
303  // Function returning the value of the pT_{i} cut for
304  // cut based merging scale definition.
305  double pTiMS() {
306  return ((tmsListSave.size() == 3) ? tmsListSave[1] : 0.);
307  }
308  // Function returning the value of the pT_{i} cut for
309  // cut based merging scale definition.
310  double QijMS() {
311  return ((tmsListSave.size() == 3) ? tmsListSave[2] : 0.);
312  }
313  // Function returning the value of the maximal number of merged jets.
314  int nMaxJets() { return (hasJetMaxLocal) ? nJetMaxLocal : nJetMaxSave;}
315  // Function returning the value of the maximal number of merged jets,
316  // for which NLO corrections are available.
317  int nMaxJetsNLO()
318  { return (hasJetMaxLocal) ? nJetMaxNLOLocal : nJetMaxNLOSave;}
319  // Function to return hard process string.
320  string getProcessString() { return processNow;}
321  // Function to return the number of outgoing partons in the core process
322  int nHardOutPartons(){ return hardProcess->nQuarksOut();}
323  // Function to return the number of outgoing leptons in the core process
324  int nHardOutLeptons(){ return hardProcess->nLeptonOut();}
325  // Function to return the number of outgoing electroweak bosons in the core
326  // process.
327  int nHardOutBosons(){ return hardProcess->nBosonsOut();}
328  // Function to return the number of incoming partons (hadrons) in the core
329  // process.
330  int nHardInPartons(){ return hardProcess->nQuarksIn();}
331  // Function to return the number of incoming leptons in the core process.
332  int nHardInLeptons(){ return hardProcess->nLeptonIn();}
333  // Function to report the number of resonace decays in the 2->2 sub-process
334  // of the current state.
335  int nResInCurrent(){ return hardProcess->nResInCurrent();}
336  // Function to determine if user defined merging should be applied.
337  bool doUserMerging(){ return doUserMergingSave;}
338  // Function to determine if automated MG/ME merging should be applied.
339  bool doMGMerging() { return doMGMergingSave;}
340  // Function to determine if KT merging should be applied.
341  bool doKTMerging() { return doKTMergingSave;}
342  // Function to determine if PTLund merging should be applied.
343  bool doPTLundMerging() { return doPTLundMergingSave;}
344  // Function to determine if cut based merging should be applied.
345  bool doCutBasedMerging() { return doCutBasedMergingSave;}
346  bool doCKKWLMerging() { return (doUserMergingSave || doMGMergingSave
347  || doKTMergingSave || doPTLundMergingSave || doCutBasedMergingSave); }
348  // Functions to determine if and which part of UMEPS merging
349  // should be applied
350  bool doUMEPSTree() { return doUMEPSTreeSave;}
351  bool doUMEPSSubt() { return doUMEPSSubtSave;}
352  bool doUMEPSMerging() { return (doUMEPSTreeSave || doUMEPSSubtSave);}
353  // Functions to determine if and which part of NL3 merging
354  // should be applied
355  bool doNL3Tree() { return doNL3TreeSave;}
356  bool doNL3Loop() { return doNL3LoopSave;}
357  bool doNL3Subt() { return doNL3SubtSave;}
358  bool doNL3Merging() { return (doNL3TreeSave || doNL3LoopSave
359  || doNL3SubtSave); }
360  // Functions to determine if and which part of UNLOPS merging
361  // should be applied
362  bool doUNLOPSTree() { return doUNLOPSTreeSave;}
363  bool doUNLOPSLoop() { return doUNLOPSLoopSave;}
364  bool doUNLOPSSubt() { return doUNLOPSSubtSave;}
365  bool doUNLOPSSubtNLO() { return doUNLOPSSubtNLOSave;}
366  bool doUNLOPSMerging() { return (doUNLOPSTreeSave || doUNLOPSLoopSave
367  || doUNLOPSSubtSave || doUNLOPSSubtNLOSave); }
368  // Return the number clustering steps that have actually been done.
369  int nRecluster() { return nReclusterSave;}
370 
371  // Return number of requested additional jets on top of the Born process.
372  int nRequested() { return nRequestedSave;}
373 
374  //----------------------------------------------------------------------//
375  // Output functions to analyse/prepare event for merging
376  //----------------------------------------------------------------------//
377 
378  // Function to check if event contains an emission not present in the hard
379  // process.
380  bool isFirstEmission(const Event& event);
381 
382  // Function to allow effective gg -> EW boson couplings.
383  bool hasEffectiveG2EW() {
384  if ( getProcessString().compare("pp>h") == 0 ) return true;
385  return false; }
386 
387  // Function to allow effective gg -> EW boson couplings.
388  bool allowEffectiveVertex( vector<int> in, vector<int> out) {
389  if ( getProcessString().compare("ta+ta->jj") == 0
390  || getProcessString().compare("ta-ta+>jj") == 0 ) {
391  int nInFermions(0), nOutFermions(0), nOutBosons(0);
392  for (int i=0; i < int(in.size()); ++i)
393  if (abs(in[i])<20) nInFermions++;
394  for (int i=0; i < int(out.size()); ++i) {
395  if (abs(out[i])<20) nOutFermions++;
396  if (abs(out[i])>20) nOutBosons++;
397  }
398  return (nInFermions%2==0 && nOutFermions%2==0);
399  }
400  return false;
401  }
402 
403  // Return event stripped from decay products.
404  Event bareEvent( const Event& inputEventIn, bool storeInputEvent );
405  // Write event with decay products attached to argument.
406  bool reattachResonanceDecays( Event& process );
407 
408  // Check if particle at position iPos is part of the hard sub-system
409  bool isInHard( int iPos, const Event& event);
410 
411  // Function to return the number of clustering steps for the current event
412  virtual int getNumberOfClusteringSteps(const Event& event,
413  bool resetNjetMax = false);
414 
415  //----------------------------------------------------------------------//
416  // Functions to steer construction of histories
417  //----------------------------------------------------------------------//
418 
419  // Function to force preferred picking of ordered histories. By default,
420  // unordered histories will only be considered if no ordered histories
421  // were found.
422  void orderHistories( bool doOrderHistoriesIn) {
423  doOrderHistoriesSave = doOrderHistoriesIn; }
424  // Function to force cut on reconstructed states internally, as needed
425  // for gg -> Higgs to ensure that e.g. uu~ -> Higgs is not constructed.
426  void allowCutOnRecState( bool doCutOnRecStateIn) {
427  doCutOnRecStateSave = doCutOnRecStateIn; }
428 
429  // Function to allow final state clusterings of weak bosons
430  void doWeakClustering( bool doWeakClusteringIn ) {
431  doWeakClusteringSave = doWeakClusteringIn; }
432 
433  //----------------------------------------------------------------------//
434  // Functions used as default merging scales
435  //----------------------------------------------------------------------//
436 
437  // Function to check if the input particle is a light jet, i.e. should be
438  // checked against the merging scale defintion.
439  bool checkAgainstCut( const Particle& particle);
440  // Function to return the value of the merging scale function in the
441  // current event.
442  virtual double tmsNow( const Event& event );
443  // Find the minimal Lund pT between coloured partons in the event
444  double rhoms( const Event& event, bool withColour);
445  // Function to calculate the minimal kT in the event
446  double kTms(const Event & event);
447  // Find the if the event passes the Delta R_{ij}, pT_{i} and Q_{ij} cuts on
448  // the matrix element, as needed for cut-based merging scale definition
449  double cutbasedms( const Event& event );
450 
451  //----------------------------------------------------------------------//
452  // Functions to steer shower evolution (public to allow for PS plugin)
453  //----------------------------------------------------------------------//
454 
455  // Flag to indicate trial shower usage.
456  void doIgnoreEmissions( bool doIgnoreIn ) {
457  doIgnoreEmissionsSave = doIgnoreIn;
458  }
459  // Function to allow not counting a trial emission.
460  virtual bool canVetoEmission() { return !doIgnoreEmissionsSave; }
461  // Function to check if emission should be rejected.
462  virtual bool doVetoEmission( const Event& );
463 
464  //----------------------------------------------------------------------//
465  // Functions used as clusterings / probabilities
466  //----------------------------------------------------------------------//
467 
468  bool useShowerPluginSave;
469  virtual bool useShowerPlugin() { return useShowerPluginSave; }
470 
471  //----------------------------------------------------------------------//
472  // Functions to retrieve if merging weight should countin the internal
473  // cross section and the event weight.
474  //----------------------------------------------------------------------//
475 
476  bool includeWGTinXSEC() { return includeWGTinXSECSave;}
477 
478  //----------------------------------------------------------------------//
479  // Functions to retrieve event veto information
480  //----------------------------------------------------------------------//
481 
482  int nHardNow() { return nHardNowSave; }
483  double tmsHardNow() { return tmsHardNowSave; }
484  int nJetsNow() { return nJetNowSave; }
485  double tmsNow() { return tmsNowSave;}
486 
487  void setHardProcessPtr(HardProcess* hardProcIn) { hardProcess = hardProcIn; }
488 
489  //----------------------------------------------------------------------//
490  // Functions related to renormalization scale variations
491  //----------------------------------------------------------------------//
492 
493  int nMuRVar() { return muRVarFactors.size(); }
494  void printIndividualWeights();
495 
496  //----------------------------------------------------------------------//
497  // The members, switches etc.
498  //----------------------------------------------------------------------//
499 
500  // Helper class doing all the core process book-keeping
501  bool useOwnHardProcess;
502  HardProcess* hardProcess;
503 
504  PartonLevel* showers;
505  void setShowerPointer(PartonLevel* psIn ) {showers = psIn;}
506 
507  // AlphaS objects for alphaS reweighting use
508  AlphaStrong AlphaS_FSRSave;
509  AlphaStrong AlphaS_ISRSave;
510  AlphaEM AlphaEM_FSRSave;
511  AlphaEM AlphaEM_ISRSave;
512 
513  // Saved path to LHE file for more automated merging
514  string lheInputFile;
515 
516  // Flags for merging procedure definition.
517  bool doUserMergingSave, doMGMergingSave, doKTMergingSave,
518  doPTLundMergingSave, doCutBasedMergingSave,
519  includeMassiveSave, enforceStrongOrderingSave, orderInRapiditySave,
520  pickByFullPSave, pickByPoPT2Save, includeRedundantSave,
521  pickBySumPTSave, allowColourShufflingSave, resetHardQRenSave,
522  resetHardQFacSave;
523  int unorderedScalePrescipSave, unorderedASscalePrescipSave,
524  unorderedPDFscalePrescipSave, incompleteScalePrescipSave,
525  ktTypeSave, nReclusterSave, nQuarksMergeSave, nRequestedSave;
526 
527  double scaleSeparationFactorSave, nonJoinedNormSave,
528  fsrInRecNormSave, herwigAcollFSRSave, herwigAcollISRSave,
529  pT0ISRSave, pTcutSave;
530  bool doNL3TreeSave, doNL3LoopSave, doNL3SubtSave;
531  bool doUNLOPSTreeSave, doUNLOPSLoopSave, doUNLOPSSubtSave,
532  doUNLOPSSubtNLOSave;
533  bool doUMEPSTreeSave, doUMEPSSubtSave;
534 
535  // Flag to only do phase space cut, rejecting events below the tms cut.
536  bool doEstimateXSection;
537 
538  bool applyVeto;
539 
540  // Save input event in case decay products need to be detached.
541  Event inputEvent;
542  vector< pair<int,int> > resonances;
543  bool doRemoveDecayProducts;
544 
545  // Starting scale for attaching MPI.
546  double muMISave;
547 
548  // Precalculated K-factors.
549  double kFactor0jSave;
550  double kFactor1jSave;
551  double kFactor2jSave;
552 
553  // Saved members.
554  double tmsValueSave, tmsValueNow, DparameterSave;
555  int nJetMaxSave;
556  int nJetMaxNLOSave;
557 
558  string processSave, processNow;
559 
560  // List of cut values to used to define a merging scale. Ordering:
561  // 0: DeltaR_{jet_i,jet_j,min}
562  // 1: p_{T,jet_i,min}
563  // 2: Q_{jet_i,jet_j,min}
564  vector<double> tmsListSave;
565 
566  // INTERNAL Hooks to allow construction of all histories,
567  // including un-ordered ones
568  bool doOrderHistoriesSave;
569 
570  // INTERNAL Hooks to disallow states in the construction of all histories,
571  // e.g. because jets are below the merging scale, of to avoid the
572  // construction of uu~ -> Higgs histories.
573  bool doCutOnRecStateSave;
574 
575  // INTERNAL Hooks to allow clustering W bosons.
576  bool doWeakClusteringSave, doSQCDClusteringSave;
577 
578  // Store / get first scale in PDF's that Pythia should have used
579  double muFSave;
580  double muRSave;
581 
582  // Store / get factorisation scale used in matrix element calculation.
583  double muFinMESave;
584  double muRinMESave;
585 
586  // Flag to indicate trial shower usage.
587  bool doIgnoreEmissionsSave;
588  // Flag to indicate if events should be vetoed.
589  bool doIgnoreStepSave;
590  // Stored weights in case veot needs to be revoked
591  double pTsave;
592  vector<double> weightCKKWL1Save, weightCKKWL2Save;
593  int nMinMPISave;
594  // Save CKKW-L weight / O(\alpha_s) weight.
595  vector<double> weightCKKWLSave, weightFIRSTSave;
596 
597  // Struct to save individual weights
599  vector<double> wtSave;
600  vector<double> pdfWeightSave;
601  vector<double> mpiWeightSave;
602  vector<double> asWeightSave;
603  vector<double> aemWeightSave;
604  vector<double> bornAsVarFac;
605  };
606 
607  IndividualWeights individualWeights;
608 
609  // Flag to indicate whether renormalization scale variations are performed
610  bool doVariations;
611  // Vector of variation factors applied to renormalization scale
612  vector<double> muRVarFactors;
613  // Number of weights, nominal + variations
614  int nWgts;
615 
616  // Local copies of nJetMax inputs, if recalculation is necessary.
617  int nJetMaxLocal;
618  int nJetMaxNLOLocal;
619  bool hasJetMaxLocal;
620 
621  // Event veto and hard process information, if veto should not applied be
622  // directly, but is up to the user.
623  bool includeWGTinXSECSave;
624  int nHardNowSave, nJetNowSave;
625  double tmsHardNowSave, tmsNowSave;
626 
627  //----------------------------------------------------------------------//
628  // Generic setup functions
629  //----------------------------------------------------------------------//
630 
631  // Function storing candidates for the hard process in the current event
632  // Needed in order not to cluster members of the core process
633  void storeHardProcessCandidates(const Event& event){
634  hardProcess->storeCandidates(event,getProcessString());
635  }
636 
637  // Function to set the path to the LHE file, so that more automated merging
638  // can be used.
639  // Remove "_1.lhe" suffix from LHE file name.
640  // This is done so that the HarsProcess class can access both the +0 and +1
641  // LHE files to find both the merging scale and the core process string
642  // Store.
643  void setLHEInputFile( string lheFile) {
644  lheInputFile = lheFile.substr(0,lheFile.size()-6); }
645 
646  //----------------------------------------------------------------------//
647  // Functions for output of class members.
648  //----------------------------------------------------------------------//
649 
650  // Return AlphaStrong objects
651  AlphaStrong* AlphaS_FSR() { return &AlphaS_FSRSave;}
652  AlphaStrong* AlphaS_ISR() { return &AlphaS_ISRSave;}
653  AlphaEM* AlphaEM_FSR() { return &AlphaEM_FSRSave;}
654  AlphaEM* AlphaEM_ISR() { return &AlphaEM_ISRSave;}
655 
656  // Functions to return advanced merging switches
657  // Include masses in definition of evolution pT and splitting kernels
658  bool includeMassive() { return includeMassiveSave;}
659  // Prefer strongly ordered histories
660  bool enforceStrongOrdering() { return enforceStrongOrderingSave;}
661  // Prefer histories ordered in rapidity and evolution pT
662  bool orderInRapidity() { return orderInRapiditySave;}
663  // Pick history probabilistically by full (correct) splitting probabilities
664  bool pickByFull() { return pickByFullPSave;}
665  // Pick history probabilistically, with easier form of probabilities
666  bool pickByPoPT2() { return pickByPoPT2Save;}
667  // Include redundant terms (e.g. PDF ratios) in the splitting probabilities
668  bool includeRedundant(){ return includeRedundantSave;}
669  // Pick by winner-takes-it-all, with minimum sum of scalar evolution pT
670  bool pickBySumPT(){ return pickBySumPTSave;}
671 
672  // Prescription for combined scale of unordered emissions
673  // 0 : use larger scale
674  // 1 : use smaller scale
675  int unorderedScalePrescip() { return unorderedScalePrescipSave;}
676  // Prescription for combined scale used in alpha_s for unordered emissions
677  // 0 : use combined emission scale in alpha_s weight for both (!) splittings
678  // 1 : use original reclustered scales of each emission in alpha_s weight
679  int unorderedASscalePrescip() { return unorderedASscalePrescipSave;}
680  // Prescription for combined scale used in PDF ratios for unordered
681  // emissions
682  // 0 : use combined emission scale in PDFs for both (!) splittings
683  // 1 : use original reclustered scales of each emission in PDF ratiost
684  int unorderedPDFscalePrescip() { return unorderedPDFscalePrescipSave;}
685  // Prescription for starting scale of incomplete histories
686  // 0: use factorization scale
687  // 1: use sHat
688  // 2: use s
689  int incompleteScalePrescip() { return incompleteScalePrescipSave;}
690 
691  // Allow swapping one colour index while reclustering
692  bool allowColourShuffling() { return allowColourShufflingSave;}
693 
694  // Allow use of dynamical renormalisation scale of the core 2-> 2 process.
695  bool resetHardQRen() { return resetHardQRenSave; }
696  // Allow use of dynamical factorisation scale of the core 2-> 2 process.
697  bool resetHardQFac() { return resetHardQFacSave; }
698 
699  // Factor by which two scales should differ to be classified strongly
700  // ordered.
701  double scaleSeparationFactor() { return scaleSeparationFactorSave;}
702  // Absolute normalization of splitting probability for non-joined
703  // evolution.
704  double nonJoinedNorm() { return nonJoinedNormSave;}
705  // Absolute normalization of splitting probability for final state
706  // splittings with initial state recoiler
707  double fsrInRecNorm() { return fsrInRecNormSave;}
708  // Factor multiplying scalar evolution pT for FSR splitting, when picking
709  // history by minimum scalar pT (see Jonathan Tully's thesis)
710  double herwigAcollFSR() { return herwigAcollFSRSave;}
711  // Factor multiplying scalar evolution pT for ISR splitting, when picking
712  // history by minimum scalar pT (see Jonathan Tully's thesis)
713  double herwigAcollISR() { return herwigAcollISRSave;}
714  // ISR regularisation scale
715  double pT0ISR() { return pT0ISRSave;}
716  // Shower cut-off scale
717  double pTcut() { return pTcutSave;}
718 
719  // MI starting scale.
720  void muMI( double mu) { muMISave = mu; }
721  double muMI() { return muMISave;}
722 
723  // Full k-Factor for current event
724  double kFactor(int njet = 0) {
725  return (njet == 0) ? kFactor0jSave
726  :(njet == 1) ? kFactor1jSave
727  : kFactor2jSave;
728  }
729  // O(\alhpa_s)-term of the k-Factor for current event
730  double k1Factor( int njet = 0) {
731  return (kFactor(njet) - 1)/infoPtr->alphaS();
732  }
733 
734  // Function to return if construction of histories is biased towards ordered
735  // histories.
736  bool orderHistories() { return doOrderHistoriesSave;}
737 
738  // INTERNAL Hooks to disallow states in the construction of all histories,
739  // e.g. because jets are below the merging scale, of to avoid the
740  // construction of uu~ -> Higgs histories.
741  bool allowCutOnRecState() { return doCutOnRecStateSave;}
742 
743  // INTERNAL Hooks to allow clustering W bosons.
744  bool doWeakClustering() { return doWeakClusteringSave;}
745  // INTERNAL Hooks to allow clustering clustering of gluons to squarks.
746  bool doSQCDClustering() { return doSQCDClusteringSave;}
747 
748  // Store / get first scale in PDF's that Pythia should have used
749  double muF() { return (muFSave > 0.) ? muFSave : infoPtr->QFac();}
750  double muR() { return (muRSave > 0.) ? muRSave : infoPtr->QRen();}
751  // Store / get factorisation scale used in matrix element calculation.
752  double muFinME() {
753  // Start with checking the event attribute called "muf".
754  string mus = infoPtr->getEventAttribute("muf2",true);
755  double mu = (mus.empty()) ? 0. : atof((char*)mus.c_str());
756  mu = sqrt(mu);
757  // Check the scales tag of the event.
758  if (infoPtr->scales) mu = infoPtr->getScalesAttribute("muf");
759  return (mu > 0.) ? mu : (muFinMESave > 0.) ? muFinMESave
760  : infoPtr->QFac();
761  }
762  double muRinME() {
763  // Start with checking the event attribute called "mur2".
764  string mus = infoPtr->getEventAttribute("mur2",true);
765  double mu = (mus.empty()) ? 0. : atof((char*)mus.c_str());
766  mu = sqrt(mu);
767  // Check the scales tag of the event.
768  if (infoPtr->scales) mu = infoPtr->getScalesAttribute("mur");
769  return (mu > 0.) ? mu : (muRinMESave > 0.) ? muRinMESave
770  : infoPtr->QRen();
771  }
772 
773 
774  //----------------------------------------------------------------------//
775  // Functions to steer merging code
776  //----------------------------------------------------------------------//
777 
778  // Flag to indicate if events should be vetoed.
779  void doIgnoreStep(bool doIgnoreIn) {doIgnoreStepSave = doIgnoreIn;}
780  // Function to allow event veto.
781  virtual bool canVetoStep() {return !doIgnoreStepSave;}
782 
783  // Stored weights in case veto needs to be revoked
784  void storeWeights(vector<double> weight) {
785  weightCKKWL1Save = weightCKKWL2Save = weight;}
786 
787  // Function to check event veto.
788  virtual bool doVetoStep(const Event& process, const Event& event,
789  bool doResonance = false);
790 
791  // Set starting scales
792  virtual bool setShowerStartingScales( bool isTrial, bool doMergeFirstEmm,
793  double& pTscaleIn, const Event& event,
794  double& pTmaxFSRIn, bool& limitPTmaxFSRin,
795  double& pTmaxISRIn, bool& limitPTmaxISRin,
796  double& pTmaxMPIIn, bool& limitPTmaxMPIin );
797 
798  // Set shower stopping scale. Necessary to e.g. avoid accumulation of
799  // incorrect (low-pT) shower weights through trial showering.
800  double stopScaleSave;
801  void setShowerStoppingScale(double scale = 0.) {stopScaleSave = scale;}
802  double getShowerStoppingScale() {return stopScaleSave;}
803 
804  void nMinMPI(int nMinMPIIn) {nMinMPISave = nMinMPIIn; }
805  int nMinMPI() {return nMinMPISave;}
806 
807  //----------------------------------------------------------------------//
808  // Functions for internal merging scale definions
809  //----------------------------------------------------------------------//
810 
811  // Function to calculate the kT separation between two particles
812  double kTdurham(const Particle& RadAfterBranch,
813  const Particle& EmtAfterBranch, int Type, double D );
814  // Function to compute "pythia pT separation" from Particle input
815  double rhoPythia(const Event& event, int rad, int emt, int rec,
816  int ShowerType);
817 
818  // Function to find a colour (anticolour) index in the input event,
819  // used to find colour-connected recoilers
820  int findColour(int col, int iExclude1, int iExclude2,
821  const Event& event, int type, bool isHardIn);
822  // Function to compute Delta R separation from 4-vector input
823  double deltaRij(Vec4 jet1, Vec4 jet2);
824 
825  //----------------------------------------------------------------------//
826  // Functions for weight management
827  //----------------------------------------------------------------------//
828 
829  // Function to get the CKKW-L weight for the current event
830  double getWeightNLO(int i=0) { return (weightCKKWLSave[i]
831  - weightFIRSTSave[i]);}
832  // Return CKKW-L weight.
833  vector<double> getWeightCKKWL() { return weightCKKWLSave; }
834  // Return O(\alpha_s) weight.
835  vector<double> getWeightFIRST() { return weightFIRSTSave; }
836  // Set CKKW-L weight.
837  void setWeightCKKWL( vector<double> weightIn){
838  weightCKKWLSave = weightIn;
839  if ( !includeWGTinXSEC() ) infoPtr->weightContainerPtr
840  ->weightsMerging.setValueVector(weightIn); }
841  // Set O(\alpha_s) weight.
842  void setWeightFIRST( vector<double> weightIn){
843  weightFIRSTSave = weightIn;
844  infoPtr->weightContainerPtr->weightsMerging
845  .setValueFirstVector(weightIn); }
846  // Function to return Sudakov weight as calculated before, also include MPI
847  // weight. Only call after regular weight functions, since it is calculated
848  // there.
849  vector<double> getSudakovWeight() {
850  vector<double> ret = individualWeights.wtSave;
851  for (int i = 0; i < nWgts; ++i) {
852  ret[i] *= individualWeights.pdfWeightSave[i] *
853  individualWeights.mpiWeightSave[i];
854  }
855  return ret;
856  }
857  // Function to return coupling weight.
858  vector<double> getCouplingWeight() {
859  vector<double> ret = individualWeights.asWeightSave;
860  for (int i = 0; i < nWgts; ++i) {
861  ret[i] *= individualWeights.aemWeightSave[i];
862  }
863  return ret;
864  }
865 
866 //--------------------------------------------------------------------------
867 
868 
869 
870  //----------------------------------------------------------------------//
871  // Functions and members to store the event veto information
872  //----------------------------------------------------------------------//
873 
874  // Set CKKWL veto information.
875  void setEventVetoInfo(int nJetNowIn, double tmsNowIn) {
876  nJetNowSave = nJetNowIn; tmsNowSave = tmsNowIn; }
877 
878  // Set the hard process information.
879  void setHardProcessInfo(int nHardNowIn, double tmsHardNowIn) {
880  nHardNowSave = nHardNowIn; tmsHardNowSave = tmsHardNowIn; }
881 
882 };
883 
884 //==========================================================================
885 
886 } // end namespace Pythia8
887 
888 #endif // Pythia8_MergingHooks_H
Definition: AgUStep.h:26