StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
History.h
1 // History.h is a part of the PYTHIA event generator.
2 // Copyright (C) 2018 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 // It contains the main class for matrix element merging.
8 // Header file for the Clustering and History classes.
9 
10 #ifndef Pythia8_History_H
11 #define Pythia8_History_H
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/WeakShowerMEs.h"
23 
24 namespace Pythia8 {
25 
26 //==========================================================================
27 
28 // Declaration of Clustering class.
29 // This class holds information about one radiator, recoiler, emitted system.
30 // This class is a container class for History class use.
31 
32 class Clustering {
33 
34 public:
35 
36  // The emitted parton location.
37  int emitted;
38  // The emittor parton
39  int emittor;
40  // The recoiler parton.
41  int recoiler;
42  // The colour connected recoiler (Can be different for ISR)
43  int partner;
44  // The scale associated with this clustering.
45  double pTscale;
46  // The flavour of the radiator prior to the emission.
47  int flavRadBef;
48  // Spin of the radiator (-1 is left handed, +1 is right handed).
49  int spinRad;
50  // Spin of the emitted (-1 is left handed, +1 is right handed).
51  int spinEmt;
52  // Spin of the recoiler (-1 is left handed, +1 is right handed).
53  int spinRec;
54  // Spin of the radiator before the splitting.
55  int spinRadBef;
56  // The radiator before the splitting.
57  int radBef;
58  // The recoiler before the splitting.
59  int recBef;
60 
61  // Default constructor
62  Clustering(){
63  emitted = 0;
64  emittor = 0;
65  recoiler = 0;
66  partner = 0;
67  flavRadBef = 0;
68  spinRad = 9;
69  spinEmt = 9;
70  spinRec = 9;
71  spinRadBef = 9;
72  recBef = 0;
73  radBef = 0;
74  }
75 
76  // Default destructor
77  ~Clustering(){}
78 
79  // Copy constructor
80  Clustering( const Clustering& inSystem ){
81  emitted = inSystem.emitted;
82  emittor = inSystem.emittor;
83  recoiler = inSystem.recoiler;
84  partner = inSystem.partner;
85  pTscale = inSystem.pTscale;
86  flavRadBef = inSystem.flavRadBef;
87  spinRad = inSystem.spinRad;
88  spinEmt = inSystem.spinEmt;
89  spinRec = inSystem.spinRec;
90  spinRadBef = inSystem.spinRad;
91  radBef = inSystem.radBef;
92  recBef = inSystem.recBef;
93  }
94 
95  // Constructor with input
96  Clustering( int emtIn, int radIn, int recIn, int partnerIn,
97  double pTscaleIn, int flavRadBefIn = 0, int spinRadIn = 9,
98  int spinEmtIn = 9, int spinRecIn = 9, int spinRadBefIn = 9,
99  int radBefIn = 0, int recBefIn = 0)
100  : emitted(emtIn), emittor(radIn), recoiler(recIn), partner(partnerIn),
101  pTscale(pTscaleIn), flavRadBef(flavRadBefIn), spinRad(spinRadIn),
102  spinEmt(spinEmtIn), spinRec(spinRecIn), spinRadBef(spinRadBefIn),
103  radBef(radBefIn), recBef(recBefIn) {}
104 
105  // Function to return pythia pT scale of clustering
106  double pT() const { return pTscale; }
107 
108  // print for debug
109  void list() const;
110 
111 };
112 
113 //==========================================================================
114 
115 // Declaration of History class
116 //
117 // A History object represents an event in a given step in the CKKW-L
118 // clustering procedure. It defines a tree-like recursive structure,
119 // where the root node represents the state with n jets as given by
120 // the matrix element generator, and is characterized by the member
121 // variable mother being null. The leaves on the tree corresponds to a
122 // fully clustered paths where the original n-jets has been clustered
123 // down to the Born-level state. Also states which cannot be clustered
124 // down to the Born-level are possible - these will be called
125 // incomplete. The leaves are characterized by the vector of children
126 // being empty.
127 
128 class History {
129 
130 public:
131 
132  // The only constructor. Default arguments are used when creating
133  // the initial history node. The \a depth is the maximum number of
134  // clusterings requested. \a scalein is the scale at which the \a
135  // statein was clustered (should be set to the merging scale for the
136  // initial history node. \a beamAIn and beamBIn are needed to
137  // calcutate PDF ratios, \a particleDataIn to have access to the
138  // correct masses of particles. If \a isOrdered is true, the previous
139  // clusterings has been ordered. \a is the PDF ratio for this
140  // clustering (=1 for FSR clusterings). \a probin is the accumulated
141  // probabilities for the previous clusterings, and \ mothin is the
142  // previous history node (null for the initial node).
143  History( int depth,
144  double scalein,
145  Event statein,
146  Clustering c,
147  MergingHooks* mergingHooksPtrIn,
148  BeamParticle beamAIn,
149  BeamParticle beamBIn,
150  ParticleData* particleDataPtrIn,
151  Info* infoPtrIn,
152  PartonLevel* showersIn,
153  CoupSM* coupSMPtrIn,
154  bool isOrdered,
155  bool isStronglyOrdered,
156  bool isAllowed,
157  bool isNextInInput,
158  double probin,
159  History * mothin);
160 
161  // The destructor deletes each child.
162  ~History() {
163  for ( int i = 0, N = children.size(); i < N; ++i ) delete children[i];
164  }
165 
166  // Function to project paths onto desired paths.
167  bool projectOntoDesiredHistories();
168 
169  // For CKKW-L, NL3 and UMEPS:
170  // In the initial history node, select one of the paths according to
171  // the probabilities. This function should be called for the initial
172  // history node.
173  // IN trialShower* : Previously initialised trialShower object,
174  // to perform trial showering and as
175  // repository of pointers to initialise alphaS
176  // PartonSystems* : PartonSystems object needed to initialise
177  // shower objects
178  // OUT double : (Sukadov) , (alpha_S ratios) , (PDF ratios)
179  double weightTREE(PartonLevel* trial, AlphaStrong * asFSR,
180  AlphaStrong * asISR, AlphaEM * aemFSR, AlphaEM * aemISR, double RN);
181 
182 
183  // For default NL3:
184  // Return weight of virtual correction and subtractive for NL3 merging
185  double weightLOOP(PartonLevel* trial, double RN);
186  // Return O(\alpha_s)-term of CKKWL-weight for NL3 merging
187  double weightFIRST(PartonLevel* trial, AlphaStrong* asFSR,
188  AlphaStrong * asISR, AlphaEM * aemFSR, AlphaEM * aemISR, double RN,
189  Rndm* rndmPtr);
190 
191 
192  // For UMEPS:
193  double weight_UMEPS_TREE(PartonLevel* trial, AlphaStrong * asFSR,
194  AlphaStrong * asISR, AlphaEM * aemFSR, AlphaEM * aemISR, double RN);
195  double weight_UMEPS_SUBT(PartonLevel* trial, AlphaStrong * asFSR,
196  AlphaStrong * asISR, AlphaEM * aemFSR, AlphaEM * aemISR, double RN);
197 
198 
199  // For unitary NL3:
200  double weight_UNLOPS_TREE(PartonLevel* trial, AlphaStrong * asFSR,
201  AlphaStrong * asISR, AlphaEM * aemFSR, AlphaEM * aemISR, double RN,
202  int depth = -1);
203  double weight_UNLOPS_SUBT(PartonLevel* trial, AlphaStrong * asFSR,
204  AlphaStrong * asISR, AlphaEM * aemFSR, AlphaEM * aemISR, double RN,
205  int depth = -1);
206  double weight_UNLOPS_LOOP(PartonLevel* trial, AlphaStrong * asFSR,
207  AlphaStrong * asISR, AlphaEM * aemFSR, AlphaEM * aemISR, double RN,
208  int depth = -1);
209  double weight_UNLOPS_SUBTNLO(PartonLevel* trial, AlphaStrong * asFSR,
210  AlphaStrong * asISR, AlphaEM * aemFSR, AlphaEM * aemISR, double RN,
211  int depth = -1);
212  double weight_UNLOPS_CORRECTION( int order, PartonLevel* trial,
213  AlphaStrong* asFSR, AlphaStrong * asISR, AlphaEM * aemFSR,
214  AlphaEM * aemISR, double RN, Rndm* rndmPtr );
215 
216  // Function to check if any allowed histories were found
217  bool foundAllowedHistories() {
218  return (children.size() > 0 && foundAllowedPath); }
219  // Function to check if any ordered histories were found
220  bool foundOrderedHistories() {
221  return (children.size() > 0 && foundOrderedPath); }
222  // Function to check if any ordered histories were found
223  bool foundCompleteHistories() {
224  return (children.size() > 0 && foundCompletePath); }
225 
226  // Function to set the state with complete scales for evolution
227  void getStartingConditions( const double RN, Event& outState );
228  // Function to get the state with complete scales for evolution
229  bool getClusteredEvent( const double RN, int nSteps, Event& outState);
230  // Function to get the first reclustered state above the merging scale.
231  bool getFirstClusteredEventAboveTMS( const double RN, int nDesired,
232  Event& process, int & nPerformed, bool updateProcess = true );
233  // Function to return the depth of the history (i.e. the number of
234  // reclustered splittings)
235  int nClusterings();
236 
237  // Function to get the lowest multiplicity reclustered event
238  Event lowestMultProc( const double RN) {
239  // Return lowest multiplicity state
240  return (select(RN)->state);
241  }
242 
243  // Calculate and return pdf ratio
244  double getPDFratio( int side, bool forSudakov, bool useHardPDF,
245  int flavNum, double xNum, double muNum,
246  int flavDen, double xDen, double muDen);
247 
248  // Envelope function that calls the recursive getWeakProb.
249  double getWeakProb();
250 
251  // Recursive function that returns the weak probability for the given path.
252  // Mode refers to which ME correction to use, 1 = sChannel, 2 = gluon
253  // channel, 3 = double quark t-channel, 4 is double quark u-channel.
254  double getWeakProb(vector<int>& mode, vector<Vec4>& mom,
255  vector<int> fermionLines);
256 
257  // return the weak probability of a single reclustering.
258  // Mode refers to which ME correction to use, 1 = sChannel, 2 = gluon
259  // channel, 3 = double quark t-channel, 4 is double quark u-channel.
260  double getSingleWeakProb(vector<int> &mode, vector<Vec4> &mom,
261  vector<int> fermionLines);
262 
263  // Find map between indecies in the current state and the state after
264  // the splitting.
265  // NOT IMPLEMENTED FOR MULTIPLE W/Z/GAMMA (NEED TO HAVE A WAY TO
266  // IDENTIFY THEM).
267  void findStateTransfer(map<int,int> &transfer);
268 
269  // Function to print the history that would be chosen from the random number
270  // RN. Mainly for debugging.
271  void printHistory( const double RN );
272  // Function to print the states in a history, starting from the hard process.
273  // Mainly for debugging.
274  void printStates();
275 
276  // Make Pythia class friend
277  friend class Pythia;
278  // Make Merging class friend
279  friend class Merging;
280 
281 private:
282 
283  // Number of trial emission to use for calculating the average number of
284  // emissions
285  static const int NTRIAL;
286 
287  // Function to set all scales in the sequence of states. This is a
288  // wrapper routine for setScales and setEventScales methods
289  void setScalesInHistory();
290 
291  // Function to find the index (in the mother histories) of the
292  // child history, thus providing a way access the path from both
293  // initial history (mother == 0) and final history (all children == 0)
294  // IN vector<int> : The index of each child in the children vector
295  // of the current history node will be saved in
296  // this vector
297  // NO OUTPUT
298  void findPath(vector<int>& out);
299 
300  // Functions to set the parton production scales and enforce
301  // ordering on the scales of the respective clusterings stored in
302  // the History node:
303  // Method will start from lowest multiplicity state and move to
304  // higher states, setting the production scales the shower would
305  // have used.
306  // When arriving at the highest multiplicity, the method will switch
307  // and go back in direction of lower states to check and enforce
308  // ordering for unordered histories.
309  // IN vector<int> : Vector of positions of the chosen child
310  // in the mother history to allow to move
311  // in direction initial->final along path
312  // bool : True: Move in direction low->high
313  // multiplicity and set production scales
314  // False: Move in direction high->low
315  // multiplicity and check and enforce
316  // ordering
317  // NO OUTPUT
318  void setScales( vector<int> index, bool forward);
319 
320  // Function to find a particle in all higher multiplicity events
321  // along the history path and set its production scale to the input
322  // scale
323  // IN int iPart : Parton in refEvent to be checked / rescaled
324  // Event& refEvent : Reference event for iPart
325  // double scale : Scale to be set as production scale for
326  // unchanged copies of iPart in subsequent steps
327  void scaleCopies(int iPart, const Event& refEvent, double rho);
328 
329  // Function to set the OVERALL EVENT SCALES [=state.scale()] to
330  // the scale of the last clustering
331  // NO INPUT
332  // NO OUTPUT
333  void setEventScales();
334 
335  // Function to print information on the reconstructed scales in one path.
336  // For debug only.
337  void printScales() { if ( mother ) mother->printScales();
338  cout << " size " << state.size() << " scale " << scale << " clusterIn "
339  << clusterIn.pT() << " state.scale() " << state.scale() << endl; }
340 
341  // Function to project paths onto desired paths.
342  bool trimHistories();
343  // Function to tag history for removal.
344  void remove(){ doInclude = false; }
345  // Function to return flag of allowed histories to choose from.
346  bool keep(){ return doInclude; }
347  // Function implementing checks on a paths, for deciding if the path should
348  // be considered valid or not.
349  bool keepHistory();
350  // Function to check if a path is ordered in evolution pT.
351  bool isOrderedPath( double maxscale );
352 
353  bool followsInputPath();
354 
355  // Function to check if all reconstucted states in a path pass the merging
356  // scale cut.
357  bool allIntermediateAboveRhoMS( double rhoms, bool good = true );
358  // Function to check if any ordered paths were found (and kept).
359  bool foundAnyOrderedPaths();
360 
361  // Functions to return the z value of the last ISR splitting
362  // NO INPUT
363  // OUTPUT double : z value of last ISR splitting in history
364  double zISR();
365 
366  // Functions to return the z value of the last FSR splitting
367  // NO INPUT
368  // OUTPUT double : z value of last FSR splitting in history
369  double zFSR();
370 
371  // Functions to return the pT scale of the last ISR splitting
372  // NO INPUT
373  // OUTPUT double : pT scale of last ISR splitting in history
374  double pTISR();
375 
376  // Functions to return the pT scale of the last FSR splitting
377  // NO INPUT
378  // OUTPUT double : pT scale of last FSR splitting in history
379  double pTFSR();
380 
381  // Functions to return the event with nSteps additional partons
382  // INPUT int : Number of splittings in the event,
383  // as counted from core 2->2 process
384  // OUTPUT Event : event with nSteps additional partons
385  Event clusteredState( int nSteps);
386 
387  // Function to choose a path from all paths in the tree
388  // according to their splitting probabilities
389  // IN double : Random number
390  // OUT History* : Leaf of history path chosen
391  History * select(double rnd);
392 
393  // For a full path, find the weight calculated from the ratio of
394  // couplings, the no-emission probabilities, and possible PDF
395  // ratios. This function should only be called for the last history
396  // node of a full path.
397  // IN TimeShower : Already initialised shower object to be used as
398  // trial shower
399  // double : alpha_s value used in ME calculation
400  // double : Maximal mass scale of the problem (e.g. E_CM)
401  // AlphaStrong: Initialised shower alpha_s object for FSR alpha_s
402  // ratio calculation
403  // AlphaStrong: Initialised shower alpha_s object for ISR alpha_s
404  // ratio calculation (can be different from previous)
405  double weightTree(PartonLevel* trial, double as0, double aem0,
406  double maxscale, double pdfScale, AlphaStrong * asFSR, AlphaStrong * asISR,
407  AlphaEM * aemFSR, AlphaEM * aemISR, double& asWeight, double& aemWeight,
408  double& pdfWeight);
409 
410  // Function to return the \alpha_s-ratio part of the CKKWL weight.
411  double weightTreeALPHAS( double as0, AlphaStrong * asFSR,
412  AlphaStrong * asISR, int njetMax = -1 );
413  // Function to return the \alpha_em-ratio part of the CKKWL weight.
414  double weightTreeALPHAEM( double aem0, AlphaEM * aemFSR,
415  AlphaEM * aemISR, int njetMax = -1 );
416  // Function to return the PDF-ratio part of the CKKWL weight.
417  double weightTreePDFs( double maxscale, double pdfScale, int njetMax = -1 );
418  // Function to return the no-emission probability part of the CKKWL weight.
419  double weightTreeEmissions( PartonLevel* trial, int type, int njetMin,
420  int njetMax, double maxscale );
421 
422  // Function to generate the O(\alpha_s)-term of the CKKWL-weight
423  double weightFirst(PartonLevel* trial, double as0, double muR,
424  double maxscale, AlphaStrong * asFSR, AlphaStrong * asISR, Rndm* rndmPtr );
425 
426  // Function to generate the O(\alpha_s)-term of the \alpha_s-ratios
427  // appearing in the CKKWL-weight.
428  double weightFirstALPHAS( double as0, double muR, AlphaStrong * asFSR,
429  AlphaStrong * asISR);
430  // Function to generate the O(\alpha_em)-term of the \alpha_em-ratios
431  // appearing in the CKKWL-weight.
432  double weightFirstALPHAEM( double aem0, double muR, AlphaEM * aemFSR,
433  AlphaEM * aemISR);
434  // Function to generate the O(\alpha_s)-term of the PDF-ratios
435  // appearing in the CKKWL-weight.
436  double weightFirstPDFs( double as0, double maxscale, double pdfScale,
437  Rndm* rndmPtr );
438  // Function to generate the O(\alpha_s)-term of the no-emission
439  // probabilities appearing in the CKKWL-weight.
440  double weightFirstEmissions(PartonLevel* trial, double as0, double maxscale,
441  AlphaStrong * asFSR, AlphaStrong * asISR, bool fixpdf, bool fixas );
442 
443  // Function to return the default factorisation scale of the hard process.
444  double hardFacScale(const Event& event);
445  // Function to return the default renormalisation scale of the hard process.
446  double hardRenScale(const Event& event);
447 
448  // Perform a trial shower using the \a pythia object between
449  // maxscale down to this scale and return the corresponding Sudakov
450  // form factor.
451  // IN trialShower : Shower object used as trial shower
452  // double : Maximum scale for trial shower branching
453  // OUT 0.0 : trial shower emission outside allowed pT range
454  // 1.0 : trial shower successful (any emission was below
455  // the minimal scale )
456  double doTrialShower(PartonLevel* trial, int type, double maxscale,
457  double minscale = 0.);
458 
459  // Function to bookkeep the indices of weights generated in countEmissions
460  bool updateind(vector<int> & ind, int i, int N);
461 
462  // Function to count number of emissions between two scales for NLO merging
463  vector<double> countEmissions(PartonLevel* trial, double maxscale,
464  double minscale, int showerType, double as0, AlphaStrong * asFSR,
465  AlphaStrong * asISR, int N, bool fixpdf, bool fixas);
466 
467  // Function to integrate PDF ratios between two scales over x and t,
468  // where the PDFs are always evaluated at the lower t-integration limit
469  double monteCarloPDFratios(int flav, double x, double maxScale,
470  double minScale, double pdfScale, double asME, Rndm* rndmPtr);
471 
472  // Default: Check if a ordered (and complete) path has been found in
473  // the initial node, in which case we will no longer be interested in
474  // any unordered paths.
475  bool onlyOrderedPaths();
476 
477  // Check if a strongly ordered (and complete) path has been found in the
478  // initial node, in which case we will no longer be interested in
479  // any unordered paths.
480  bool onlyStronglyOrderedPaths();
481 
482  // Check if an allowed (according to user-criterion) path has been found in
483  // the initial node, in which case we will no longer be interested in
484  // any forbidden paths.
485  bool onlyAllowedPaths();
486 
487  // When a full path has been found, register it with the initial
488  // history node.
489  // IN History : History to be registered as path
490  // bool : Specifying if clusterings so far were ordered
491  // bool : Specifying if path is complete down to 2->2 process
492  // OUT true if History object forms a plausible path (eg prob>0 ...)
493  bool registerPath(History & l, bool isOrdered, bool isStronglyOrdered,
494  bool isAllowed, bool isComplete);
495 
496  // For the history-defining state (and if necessary interfering
497  // states), find all possible clusterings.
498  // NO INPUT
499  // OUT vector of all (rad,rec,emt) systems
500  vector<Clustering> getAllQCDClusterings();
501 
502  // For one given state, find all possible clusterings.
503  // IN Event : state to be investigated
504  // OUT vector of all (rad,rec,emt) systems in the state
505  vector<Clustering> getQCDClusterings( const Event& event);
506 
507  // Function to construct (rad,rec,emt) triples from the event
508  // IN int : Position of Emitted in event record for which
509  // dipoles should be constructed
510  // int : Colour topogy to be tested
511  // 1= g -> qqbar, causing 2 -> 2 dipole splitting
512  // 2= q(bar) -> q(bar) g && g -> gg,
513  // causing a 2 -> 3 dipole splitting
514  // Event : event record to be checked for ptential partners
515  // OUT vector of all allowed radiator+recoiler+emitted triples
516  vector<Clustering> findQCDTriple (int emtTagIn, int colTopIn,
517  const Event& event, vector<int> posFinalPartn,
518  vector <int> posInitPartn );
519 
520  vector<Clustering> getAllEWClusterings();
521  vector<Clustering> getEWClusterings( const Event& event);
522  vector<Clustering> findEWTripleW( int emtTagIn, const Event& event,
523  vector<int> posFinalPartn, vector<int> posInitPartn );
524  vector<Clustering> findEWTripleZ( int emtTagIn, const Event& event,
525  vector<int> posFinalPartn, vector<int> posInitPartn );
526 
527  vector<Clustering> getAllSQCDClusterings();
528  vector<Clustering> getSQCDClusterings( const Event& event);
529  vector<Clustering> findSQCDTriple (int emtTagIn, int colTopIn,
530  const Event& event, vector<int> posFinalPartn,
531  vector <int> posInitPartn );
532 
533  // Function to attach (spin-dependent duplicates of) a clustering.
534  void attachClusterings (vector<Clustering>& clus, int iEmt, int iRad,
535  int iRec, int iPartner, double pT, const Event& event);
536 
537  // Calculate and return the probability of a clustering.
538  // IN Clustering : rad,rec,emt - System for which the splitting
539  // probability should be calcuated
540  // OUT splitting probability
541  double getProb(const Clustering & SystemIn);
542 
543  // Set up the beams (fill the beam particles with the correct
544  // current incoming particles) to allow calculation of splitting
545  // probability.
546  // For interleaved evolution, set assignments dividing PDFs into
547  // sea and valence content. This assignment is, until a history path
548  // is chosen and a first trial shower performed, not fully correct
549  // (since content is chosen form too high x and too low scale). The
550  // assignment used for reweighting will be corrected after trial
551  // showering
552  void setupBeams();
553 
554  // Calculate the PDF ratio used in the argument of the no-emission
555  // probability.
556  double pdfForSudakov();
557 
558  // Calculate the hard process matrix element to include in the selection
559  // probability.
560  double hardProcessME( const Event& event);
561 
562  // Perform the clustering of the current state and return the
563  // clustered state.
564  // IN Clustering : rad,rec,emt triple to be clustered to two partons
565  // OUT clustered state
566  Event cluster( Clustering & inSystem);
567 
568  // Function to get the flavour of the radiator before the splitting
569  // for clustering
570  // IN int : Position of the radiator after the splitting, in the event
571  // int : Position of the emitted after the splitting, in the event
572  // Event : Reference event
573  // OUT int : Flavour of the radiator before the splitting
574  int getRadBeforeFlav(const int radAfter, const int emtAfter,
575  const Event& event);
576 
577  // Function to get the spin of the radiator before the splitting
578  // IN int : Spin of the radiator after the splitting
579  // int : Spin of the emitted after the splitting
580  // OUT int : Spin of the radiator before the splitting
581  int getRadBeforeSpin(const int radAfter, const int emtAfter,
582  const int spinRadAfter, const int spinEmtAfter,
583  const Event& event);
584 
585  // Function to get the colour of the radiator before the splitting
586  // for clustering
587  // IN int : Position of the radiator after the splitting, in the event
588  // int : Position of the emitted after the splitting, in the event
589  // Event : Reference event
590  // OUT int : Colour of the radiator before the splitting
591  int getRadBeforeCol(const int radAfter, const int emtAfter,
592  const Event& event);
593 
594  // Function to get the anticolour of the radiator before the splitting
595  // for clustering
596  // IN int : Position of the radiator after the splitting, in the event
597  // int : Position of the emitted after the splitting, in the event
598  // Event : Reference event
599  // OUT int : Anticolour of the radiator before the splitting
600  int getRadBeforeAcol(const int radAfter, const int emtAfter,
601  const Event& event);
602 
603  // Function to get the parton connected to in by a colour line
604  // IN int : Position of parton for which partner should be found
605  // Event : Reference event
606  // OUT int : If a colour line connects the "in" parton with another
607  // parton, return the Position of the partner, else return 0
608  int getColPartner(const int in, const Event& event);
609 
610  // Function to get the parton connected to in by an anticolour line
611  // IN int : Position of parton for which partner should be found
612  // Event : Reference event
613  // OUT int : If an anticolour line connects the "in" parton with another
614  // parton, return the Position of the partner, else return 0
615  int getAcolPartner(const int in, const Event& event);
616 
617  // Function to get the list of partons connected to the particle
618  // formed by reclusterinf emt and rad by colour and anticolour lines
619  // IN int : Position of radiator in the clustering
620  // IN int : Position of emitted in the clustering
621  // Event : Reference event
622  // OUT vector<int> : List of positions of all partons that are connected
623  // to the parton that will be formed
624  // by clustering emt and rad.
625  vector<int> getReclusteredPartners(const int rad, const int emt,
626  const Event& event);
627 
628  // Function to extract a chain of colour-connected partons in
629  // the event
630  // IN int : Type of parton from which to start extracting a
631  // parton chain. If the starting point is a quark
632  // i.e. flavType = 1, a chain of partons that are
633  // consecutively connected by colour-lines will be
634  // extracted. If the starting point is an antiquark
635  // i.e. flavType =-1, a chain of partons that are
636  // consecutively connected by anticolour-lines
637  // will be extracted.
638  // IN int : Position of the parton from which a
639  // colour-connected chain should be derived
640  // IN Event : Refernence event
641  // IN/OUT vector<int> : Partons that should be excluded from the search.
642  // OUT vector<int> : Positions of partons along the chain
643  // OUT bool : Found singlet / did not find singlet
644  bool getColSinglet(const int flavType, const int iParton,
645  const Event& event, vector<int>& exclude,
646  vector<int>& colSinglet);
647 
648  // Function to check that a set of partons forms a colour singlet
649  // IN Event : Reference event
650  // IN vector<int> : Positions of the partons in the set
651  // OUT bool : Is a colour singlet / is not
652  bool isColSinglet( const Event& event, vector<int> system);
653  // Function to check that a set of partons forms a flavour singlet
654  // IN Event : Reference event
655  // IN vector<int> : Positions of the partons in the set
656  // IN int : Flavour of all the quarks in the set, if
657  // all quarks in a set should have a fixed flavour
658  // OUT bool : Is a flavour singlet / is not
659  bool isFlavSinglet( const Event& event,
660  vector<int> system, int flav=0);
661 
662  // Function to properly colour-connect the radiator to the rest of
663  // the event, as needed during clustering
664  // IN Particle& : Particle to be connected
665  // Particle : Recoiler forming a dipole with Radiator
666  // Event : event to which Radiator shall be appended
667  // OUT true : Radiator could be connected to the event
668  // false : Radiator could not be connected to the
669  // event or the resulting event was
670  // non-valid
671  bool connectRadiator( Particle& radiator, const int radType,
672  const Particle& recoiler, const int recType,
673  const Event& event );
674 
675  // Function to find a colour (anticolour) index in the input event
676  // IN int col : Colour tag to be investigated
677  // int iExclude1 : Identifier of first particle to be excluded
678  // from search
679  // int iExclude2 : Identifier of second particle to be excluded
680  // from search
681  // Event event : event to be searched for colour tag
682  // int type : Tag to define if col should be counted as
683  // colour (type = 1) [->find anti-colour index
684  // contracted with col]
685  // anticolour (type = 2) [->find colour index
686  // contracted with col]
687  // OUT int : Position of particle in event record
688  // contraced with col [0 if col is free tag]
689  int FindCol(int col, int iExclude1, int iExclude2,
690  const Event& event, int type, bool isHardIn);
691 
692  // Function to in the input event find a particle with quantum
693  // numbers matching those of the input particle
694  // IN Particle : Particle to be searched for
695  // Event : Event to be searched in
696  // OUT int : > 0 : Position of matching particle in event
697  // < 0 : No match in event
698  int FindParticle( const Particle& particle, const Event& event,
699  bool checkStatus = true );
700 
701  // Function to check if rad,emt,rec triple is allowed for clustering
702  // IN int rad,emt,rec,partner : Positions (in event record) of the three
703  // particles considered for clustering, and the
704  // correct colour-connected recoiler (=partner)
705  // Event event : Reference event
706  bool allowedClustering( int rad, int emt, int rec, int partner,
707  const Event& event );
708 
709  // Function to check if rad,emt,rec triple is results in
710  // colour singlet radBefore+recBefore
711  // IN int rad,emt,rec : Positions (in event record) of the three
712  // particles considered for clustering
713  // Event event : Reference event
714  bool isSinglett( int rad, int emt, int rec, const Event& event );
715 
716  // Function to check if event is sensibly constructed: Meaning
717  // that all colour indices are contracted and that the charge in
718  // initial and final states matches
719  // IN event : event to be checked
720  // OUT TRUE : event is properly construced
721  // FALSE : event not valid
722  bool validEvent( const Event& event );
723 
724  // Function to check whether two clusterings are identical, used
725  // for finding the history path in the mother -> children direction
726  bool equalClustering( Clustering clus1 , Clustering clus2 );
727 
728  // Chose dummy scale for event construction. By default, choose
729  // sHat for 2->Boson(->2)+ n partons processes and
730  // M_Boson for 2->Boson(->) processes
731  double choseHardScale( const Event& event ) const;
732 
733  // If the state has an incoming hadron return the flavour of the
734  // parton entering the hard interaction. Otherwise return 0
735  int getCurrentFlav(const int) const;
736 
737  // If the state has an incoming hadron return the x-value for the
738  // parton entering the hard interaction. Otherwise return 0.
739  double getCurrentX(const int) const;
740 
741  double getCurrentZ(const int rad, const int rec, const int emt,
742  int idRadBef = 0) const;
743 
744  // Function to compute "pythia pT separation" from Particle input
745  double pTLund(const Event& event, int radAfterBranch, int emtAfterBranch,
746  int recAfterBranch, int showerType, int idRadBef = 0);
747 
748  // Function to return the position of the initial line before (or after)
749  // a single (!) splitting.
750  int posChangedIncoming(const Event& event, bool before);
751 
752  // Function to give back the ratio of PDFs and PDF * splitting kernels
753  // needed to convert a splitting at scale pdfScale, chosen with running
754  // PDFs, to a splitting chosen with PDFs at a fixed scale mu. As needed to
755  // properly count emissions.
756  double pdfFactor( const Event& event, const int type, double pdfScale,
757  double mu );
758 
759  // Function giving the product of splitting kernels and PDFs so that the
760  // resulting flavour is given by flav. This is used as a helper routine
761  // to dgauss
762  double integrand(int flav, double x, double scaleInt, double z);
763 
764  // Function providing a list of possible new flavours after a w emssion
765  // from the input flavour.
766  vector<int> posFlavCKM(int flav);
767 
768  // Check if the new flavour structure is possible.
769  // If clusType is 1 final clustering is assumed, otherwise initial clustering
770  // is assumed.
771  bool checkFlavour(vector<int>& flavCounts, int flavRad, int flavRadBef,
772  int clusType);
773 
774  // Check if the weak recoil structure is allowed.
775  bool checkWeakRecoils(map<int,int> &allowedRecoils, bool isFirst = false);
776 
777  // Find the recoiler for an ISR scattered weak particle.
778 
779  int findISRRecoiler();
780 
781  // Reverse the boost carried out by the ISR.
782  // The three first momenta are given by the ME,
783  // the last two are filled in by this function.
784  void reverseBoostISR(Vec4& pMother, Vec4& pSister, Vec4& pPartner,
785  Vec4& pDaughter, Vec4& pRecoiler, int sign, double eCM, double& phi);
786 
787  // Check if an event reclustered into a 2 -> 2 dijet.
788  // (Only enabled if W reclustering is used).
789  bool isQCD2to2(const Event& event);
790 
791  // Check if an event reclustered into a 2 -> 1 Drell-Yan.
792  // (Only enabled if W reclustering is used).
793  bool isEW2to1(const Event& event);
794 
795  // Set selected child indices.
796  void setSelectedChild();
797 
798  // Setup the weak dipole showers.
799  void setupWeakShower(int nSteps);
800 
801  // Update weak dipoles after an emission.
802  void transferWeakShower(vector<int> &mode, vector<Vec4> &mom,
803  vector<int> fermionLines, vector<pair<int,int> > &dipoles, int nSteps);
804 
805  // Update the weak modes after an emission.
806  vector<int> updateWeakModes(vector<int>& weakModes,
807  map<int,int>& stateTransfer);
808 
809  // Update the fermion lines for the 2 -> 2 process. This is needed for
810  // the weak probabilities.
811  vector<int> updateWeakFermionLines(vector<int> fermionLines,
812  map<int,int>& stateTransfer);
813 
814  // Update the list of weak dipoles. This is needed to setup the PS correctly.
815  vector<pair<int,int> > updateWeakDipoles(vector<pair<int,int> > &dipoles,
816  map<int,int>& stateTransfer);
817 
818  // Setup the hard process information needed for calculating weak
819  // probabilities and setting up the shower.
820  void setupWeakHard(vector<int>& mode, vector<int>& fermionLines,
821  vector<Vec4>& mom);
822 
823  // Functions to retrieve scale information from external showers.
824  double getShowerPluginScale(const Event& event, int rad, int emt, int rec,
825  string key, double scalePythia);
826 
827  //----------------------------------------------------------------------//
828  // Class members.
829  //----------------------------------------------------------------------//
830 
831  // The state of the event correponding to this step in the
832  // reconstruction.
833  Event state;
834 
835  // The previous step from which this step has been clustered. If
836  // null, this is the initial step with the n-jet state generated by
837  // the matrix element.
838  History * mother;
839 
840  // The different steps corresponding to possible clusterings of this
841  // state.
842  vector<History *> children;
843 
844  // After a path is selected, store the child index.
845  int selectedChild;
846 
847  // The different paths which have been reconstructed indexed with
848  // the (incremental) corresponding probability. This map is empty
849  // unless this is the initial step (mother == 0).
850  map<double,History *> paths;
851 
852  // The sum of the probabilities of the full paths. This is zero
853  // unless this is the initial step (mother == 0).
854  double sumpath;
855 
856  // The different allowed paths after projection, indexed with
857  // the (incremental) corresponding probability. This map is empty
858  // unless this is the initial step (mother == 0).
859  map<double,History *> goodBranches, badBranches;
860  // The sum of the probabilities of allowed paths after projection. This is
861  // zero unless this is the initial step (mother == 0).
862  double sumGoodBranches, sumBadBranches;
863 
864  // This is set true if an ordered (and complete) path has been found
865  // and inserted in paths.
866  bool foundOrderedPath;
867 
868  // This is set true if a strongly ordered (and complete) path has been found
869  // and inserted in paths.
870  bool foundStronglyOrderedPath;
871 
872  // This is set true if an allowed (according to a user criterion) path has
873  // been found and inserted in paths.
874  bool foundAllowedPath;
875 
876  // This is set true if a complete (with the required number of
877  // clusterings) path has been found and inserted in paths.
878  bool foundCompletePath;
879 
880  // The scale of this step, corresponding to clustering which
881  // constructed the corresponding state (or the merging scale in case
882  // mother == 0).
883  double scale;
884 
885  // Flag indicating if a clustering in the construction of all histories is
886  // the next clustering demanded by inout clusterings in LesHouches 2.0
887  // accord.
888  bool nextInInput;
889 
890  // The probability associated with this step and the previous steps.
891  double prob;
892 
893  // The partons and scale of the last clustering.
894  Clustering clusterIn;
895  int iReclusteredOld, iReclusteredNew;
896 
897  // Flag to include the path amongst allowed paths.
898  bool doInclude;
899 
900  // Pointer to MergingHooks object to get all the settings.
901  MergingHooks* mergingHooksPtr;
902 
903  // The default constructor is private.
904  History() {}
905 
906  // The copy-constructor is private.
907  History(const History &) {}
908 
909  // The assignment operator is private.
910  History & operator=(const History &) {
911  return *this;
912  }
913 
914  // BeamParticle to get access to PDFs
915  BeamParticle beamA;
916  BeamParticle beamB;
917  // ParticleData needed to initialise the shower AND to get the
918  // correct masses of partons needed in calculation of probability
919  ParticleData* particleDataPtr;
920 
921  // Info object to have access to all information read from LHE file
922  Info* infoPtr;
923 
924  // Class for calculation weak shower ME.
925  WeakShowerMEs weakShowerMEs;
926 
927  // Pointer to showers, to simplify external clusterings.
928  PartonLevel* showers;
929 
930  // Pointer to standard model couplings.
931  CoupSM* coupSMPtr;
932 
933  // Minimal scalar sum of pT used in Herwig to choose history
934  double sumScalarPT;
935 
936 };
937 
938 //==========================================================================
939 
940 } // end namespace Pythia8
941 
942 #endif // end Pythia8_History_H
Definition: AgUStep.h:26