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) 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 // 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 "Basics.h"
14 #include "BeamParticle.h"
15 #include "Event.h"
16 #include "Info.h"
17 #include "ParticleData.h"
18 #include "PythiaStdlib.h"
19 #include "Settings.h"
20 #include "PartonLevel.h"
21 
22 namespace Pythia8 {
23 
24 //==========================================================================
25 
26 // Declaration of Clustering class.
27 // This class holds information about one radiator, recoiler, emitted system.
28 // This class is a container class for History class use.
29 
30 class Clustering {
31 
32 public:
33 
34  // The emitted parton location.
35  int emitted;
36  // The emittor parton
37  int emittor;
38  // The recoiler parton.
39  int recoiler;
40  // The colour connected recoiler (Can be different for ISR)
41  int partner;
42  // The scale associated with this clustering.
43  double pTscale;
44 
45  // Default constructor
46  Clustering(){
47  emitted = 0;
48  emittor = 0;
49  recoiler = 0;
50  partner = 0;
51  pTscale = 0.0;
52  }
53 
54  // Default destructor
55  ~Clustering(){}
56 
57  // Copy constructor
58  Clustering( const Clustering& inSystem ){
59  emitted = inSystem.emitted;
60  emittor = inSystem.emittor;
61  recoiler = inSystem.recoiler;
62  partner = inSystem.partner;
63  pTscale = inSystem.pTscale;
64  }
65 
66  // Constructor with input
67  Clustering( int emtIn, int radIn, int recIn, int partnerIn,
68  double pTscaleIn ){
69  emitted = emtIn;
70  emittor = radIn;
71  recoiler = recIn;
72  partner = partnerIn;
73  pTscale = pTscaleIn;
74  }
75 
76  // Function to return pythia pT scale of clustering
77  double pT() const { return pTscale; }
78 
79  // print for debug
80  void list() const;
81 
82 };
83 
84 //==========================================================================
85 
86 // Declaration of History class
87 //
88 // A History object represents an event in a given step in the CKKW-L
89 // clustering procedure. It defines a tree-like recursive structure,
90 // where the root node represents the state with n jets as given by
91 // the matrix element generator, and is characterized by the member
92 // variable mother being null. The leaves on the tree corresponds to a
93 // fully clustered paths where the original n-jets has been clustered
94 // down to the Born-level state. Also states which cannot be clustered
95 // down to the Born-level are possible - these will be called
96 // incomplete. The leaves are characterized by the vector of children
97 // being empty.
98 
99 class History {
100 
101 public:
102 
103  // The only constructor. Default arguments are used when creating
104  // the initial history node. The \a depth is the maximum number of
105  // clusterings requested. \a scalein is the scale at which the \a
106  // statein was clustered (should be set to the merging scale for the
107  // initial history node. \a beamAIn and beamBIn are needed to
108  // calcutate PDF ratios, \a particleDataIn to have access to the
109  // correct masses of particles. If \a isOrdered is true, the previous
110  // clusterings has been ordered. \a is the PDF ratio for this
111  // clustering (=1 for FSR clusterings). \a probin is the accumulated
112  // probabilities for the previous clusterings, and \ mothin is the
113  // previous history node (null for the initial node).
114  History( int depth,
115  double scalein,
116  Event statein,
117  Clustering c,
118  MergingHooks* mergingHooksPtrIn,
119  BeamParticle beamAIn,
120  BeamParticle beamBIn,
121  ParticleData* particleDataPtrIn,
122  Info* infoPtrIn,
123  bool isOrdered,
124  bool isStronglyOrdered,
125  double probin,
126  History * mothin);
127 
128  // The destructor deletes each child.
129  ~History() {
130  for ( int i = 0, N = children.size(); i < N; ++i ) delete children[i];
131  }
132 
133  // In the initial history node, select one of the paths according to
134  // the probabilities. This function should be called for the initial
135  // history node.
136  // IN trialShower* : Previously initialised trialShower object,
137  // to perform trial showering and as
138  // repository of pointers to initialise alphaS
139  // PartonSystems* : PartonSystems object needed to initialise
140  // shower objects
141  // OUT double : (Sukadov) , (alpha_S ratios) , (PDF ratios)
142  double weightTREE(PartonLevel* trial, AlphaStrong * asFSR,
143  AlphaStrong * asISR, double RN);
144 
145  // Function to set the state with complete scales for evolution
146  void getStartingConditions( const double RN, Event& outState );
147 
148  // Function to get the lowest multiplicity reclustered event
149  Event lowestMultProc( const double RN) {
150  // Return lowest multiplicity state
151  return (select(RN)->state);
152  }
153 
154  // Calculate and return pdf ratio
155  double getPDFratio( int side, bool forSudakov,
156  int flavNum, double xNum, double muNum,
157  int flavDen, double xDen, double muDen);
158 
159 private:
160 
161  // Function to set all scales in the sequence of states. This is a
162  // wrapper routine for setScales and setEventScales methods
163  void setScalesInHistory();
164 
165  // Function to find the index (in the mother histories) of the
166  // child history, thus providing a way access the path from both
167  // initial history (mother == 0) and final history (all children == 0)
168  // IN vector<int> : The index of each child in the children vector
169  // of the current history node will be saved in
170  // this vector
171  // NO OUTPUT
172  void findPath(vector<int>& out);
173 
174  // Functions to set the parton production scales and enforce
175  // ordering on the scales of the respective clusterings stored in
176  // the History node:
177  // Method will start from lowest multiplicity state and move to
178  // higher states, setting the production scales the shower would
179  // have used.
180  // When arriving at the highest multiplicity, the method will switch
181  // and go back in direction of lower states to check and enforce
182  // ordering for unordered histories.
183  // IN vector<int> : Vector of positions of the chosen child
184  // in the mother history to allow to move
185  // in direction initial->final along path
186  // bool : True: Move in direction low->high
187  // multiplicity and set production scales
188  // False: Move in direction high->low
189  // multiplicity and check and enforce
190  // ordering
191  // NO OUTPUT
192  void setScales( vector<int> index, bool forward);
193 
194  // Function to find a particle in all higher multiplicity events
195  // along the history path and set its production scale to the input
196  // scale
197  // IN int iPart : Parton in refEvent to be checked / rescaled
198  // Event& refEvent : Reference event for iPart
199  // double scale : Scale to be set as production scale for
200  // unchanged copies of iPart in subsequent steps
201  void scaleCopies(int iPart, const Event& refEvent, double rho);
202 
203  // Functions to set the OVERALL EVENT SCALES [=state.scale()] to
204  // the scale of the last clustering
205  // NO INPUT
206  // NO OUTPUT
207  void setEventScales();
208 
209  void printScales() {
210  if( mother ) mother->printScales();
211  cout << " scale " << scale
212  << " clusterIn " << clusterIn.pT()
213  << " state.scale() " << state.scale()
214  << endl;
215  }
216 
217  // Functions to return the z value of the last ISR splitting
218  // NO INPUT
219  // OUTPUT double : z value of last ISR splitting in history
220  double zISR();
221 
222  // Functions to return the z value of the last FSR splitting
223  // NO INPUT
224  // OUTPUT double : z value of last FSR splitting in history
225  double zFSR();
226 
227  // Functions to return the pT scale of the last ISR splitting
228  // NO INPUT
229  // OUTPUT double : pT scale of last ISR splitting in history
230  double pTISR();
231 
232  // Functions to return the pT scale of the last FSR splitting
233  // NO INPUT
234  // OUTPUT double : pT scale of last FSR splitting in history
235  double pTFSR();
236 
237  // Function to choose a path from all paths in the tree
238  // according to their splitting probabilities
239  // IN double : Random number
240  // OUT History* : Leaf of history path chosen
241  History * select(double rnd);
242 
243  // For a full path, find the weight calculated from the ratio of
244  // couplings, the no-emission probabilities, and possible PDF
245  // ratios. This function should only be called for the last history
246  // node of a full path.
247  // IN TimeShower : Already initialised shower object to be used as
248  // trial shower
249  // double : alpha_s value used in ME calculation
250  // double : Maximal mass scale of the problem (e.g. E_CM)
251  // AlphaStrong: Initialised shower alpha_s object for FSR alpha_s
252  // ratio calculation
253  // AlphaStrong: Initialised shower alpha_s object for ISR alpha_s
254  // ratio calculation (can be different from previous)
255  double weightTree(PartonLevel* trial, double as0, double maxscale,
256  AlphaStrong * asFSR, AlphaStrong * asISR, double& asWeight,
257  double& pdfWeight);
258 
259 
260  // Perform a trial shower using the \a pythia object between
261  // maxscale down to this scale and return the corresponding Sudakov
262  // form factor.
263  // IN trialShower : Shower object used as trial shower
264  // double : Maximum scale for trial shower branching
265  // OUT 0.0 : trial shower emission outside allowed pT range
266  // 1.0 : trial shower successful (any emission was below
267  // the minimal scale )
268  double doTrialShower(PartonLevel* trial, double maxscale);
269 
270  // Check if a ordered (and complete) path has been found in the
271  // initial node, in which case we will no longer be interested in
272  // any unordered paths.
273  bool onlyOrderedPaths();
274 
275  // Check if a strongly ordered (and complete) path has been found in the
276  // initial node, in which case we will no longer be interested in
277  // any unordered paths.
278  bool onlyStronglyOrderedPaths();
279 
280  // When a full path has been found, register it with the initial
281  // history node.
282  // IN History : History to be registered as path
283  // bool : Specifying if clusterings so far were ordered
284  // bool : Specifying if path is complete down to 2->2 process
285  // OUT true if History object forms a plausible path (eg prob>0 ...)
286  bool registerPath(History & l, bool isOrdered, bool isStronglyOrdered,
287  bool isComplete);
288 
289  // For the history-defining state (and if necessary interfering
290  // states), find all possible clusterings.
291  // NO INPUT
292  // OUT vector of all (rad,rec,emt) systems
293  vector<Clustering> getAllClusterings();
294 
295  // For one given state, find all possible clusterings.
296  // IN Event : state to be investigated
297  // OUT vector of all (rad,rec,emt) systems in the state
298  vector<Clustering> getClusterings( const Event& event);
299 
300  // Function to construct (rad,rec,emt) triples from the event
301  // IN int : Position of Emitted in event record for which
302  // dipoles should be constructed
303  // int : Colour topogy to be tested
304  // 1= g -> qqbar, causing 2 -> 2 dipole splitting
305  // 2= q(bar) -> q(bar) g && g -> gg,
306  // causing a 2 -> 3 dipole splitting
307  // Event : event record to be checked for ptential partners
308  // OUT vector of all allowed radiator+recoiler+emitted triples
309  vector<Clustering> findTriple (int EmtTagIn, int colTopIn,
310  const Event& event,
311  vector<int> PosFinalPartn,
312  vector <int> PosInitPartn );
313 
314  // Calculate and return the probability of a clustering.
315  // IN Clustering : rad,rec,emt - System for which the splitting
316  // probability should be calcuated
317  // OUT splitting probability
318  double getProb(const Clustering & SystemIn);
319 
320  // Set up the beams (fill the beam particles with the correct
321  // current incoming particles) to allow calculation of splitting
322  // probability.
323  // For interleaved evolution, set assignments dividing PDFs into
324  // sea and valence content. This assignment is, until a history path
325  // is chosen and a first trial shower performed, not fully correct
326  // (since content is chosen form too high x and too low scale). The
327  // assignment used for reweighting will be corrected after trial
328  // showering
329  void setupBeams();
330 
331  // Calculate the PDF ratio used in the argument of the no-emission
332  // probability
333  double pdfForSudakov();
334 
335  // Perform the clustering of the current state and return the
336  // clustered state.
337  // IN Clustering : rad,rec,emt triple to be clustered to two partons
338  // OUT clustered state
339  Event cluster(const Clustering & inSystem);
340 
341  // Function to get the flavour of the radiator before the splitting
342  // for clustering
343  // IN int : Position of the radiator after the splitting, in the event
344  // int : Position of the emitted after the splitting, in the event
345  // Event : Reference event
346  // OUT int : Flavour of the radiator before the splitting
347  int getRadBeforeFlav(const int RadAfter, const int EmtAfter,
348  const Event& event);
349 
350  // Function to get the colour of the radiator before the splitting
351  // for clustering
352  // IN int : Position of the radiator after the splitting, in the event
353  // int : Position of the emitted after the splitting, in the event
354  // Event : Reference event
355  // OUT int : Colour of the radiator before the splitting
356  int getRadBeforeCol(const int RadAfter, const int EmtAfter,
357  const Event& event);
358 
359  // Function to get the anticolour of the radiator before the splitting
360  // for clustering
361  // IN int : Position of the radiator after the splitting, in the event
362  // int : Position of the emitted after the splitting, in the event
363  // Event : Reference event
364  // OUT int : Anticolour of the radiator before the splitting
365  int getRadBeforeAcol(const int RadAfter, const int EmtAfter,
366  const Event& event);
367 
368  // Function to get the parton connected to in by a colour line
369  // IN int : Position of parton for which partner should be found
370  // Event : Reference event
371  // OUT int : If a colour line connects the "in" parton with another
372  // parton, return the Position of the partner, else return 0
373  int getColPartner(const int in, const Event& event);
374 
375  // Function to get the parton connected to in by an anticolour line
376  // IN int : Position of parton for which partner should be found
377  // Event : Reference event
378  // OUT int : If an anticolour line connects the "in" parton with another
379  // parton, return the Position of the partner, else return 0
380  int getAcolPartner(const int in, const Event& event);
381 
382  // Function to get the list of partons connected to the particle
383  // formed by reclusterinf emt and rad by colour and anticolour lines
384  // IN int : Position of radiator in the clustering
385  // IN int : Position of emitted in the clustering
386  // Event : Reference event
387  // OUT vector<int> : List of positions of all partons that are connected
388  // to the parton that will be formed
389  // by clustering emt and rad.
390  vector<int> getReclusteredPartners(const int rad, const int emt,
391  const Event& event);
392 
393  // Function to extract a chain of colour-connected partons in
394  // the event
395  // IN int : Type of parton from which to start extracting a
396  // parton chain. If the starting point is a quark
397  // i.e. flavType = 1, a chain of partons that are
398  // consecutively connected by colour-lines will be
399  // extracted. If the starting point is an antiquark
400  // i.e. flavType =-1, a chain of partons that are
401  // consecutively connected by anticolour-lines
402  // will be extracted.
403  // IN int : Position of the parton from which a
404  // colour-connected chain should be derived
405  // IN Event : Refernence event
406  // IN/OUT vector<int> : Partons that should be excluded from the search.
407  // OUT vector<int> : Positions of partons along the chain
408  // OUT bool : Found singlet / did not find singlet
409  bool getColSinglet(const int flavType, const int iParton,
410  const Event& event, vector<int>& exclude,
411  vector<int>& colSinglet);
412 
413  // Function to check that a set of partons forms a colour singlet
414  // IN Event : Reference event
415  // IN vector<int> : Positions of the partons in the set
416  // OUT bool : Is a colour singlet / is not
417  bool isColSinglet( const Event& event, vector<int> system);
418  // Function to check that a set of partons forms a flavour singlet
419  // IN Event : Reference event
420  // IN vector<int> : Positions of the partons in the set
421  // IN int : Flavour of all the quarks in the set, if
422  // all quarks in a set should have a fixed flavour
423  // OUT bool : Is a flavour singlet / is not
424  bool isFlavSinglet( const Event& event,
425  vector<int> system, int flav=0);
426 
427  // Function to properly colour-connect the radiator to the rest of
428  // the event, as needed during clustering
429  // IN Particle& : Particle to be connected
430  // Particle : Recoiler forming a dipole with Radiator
431  // Event : event to which Radiator shall be appended
432  // OUT true : Radiator could be connected to the event
433  // false : Radiator could not be connected to the
434  // event or the resulting event was
435  // non-valid
436  bool connectRadiator( Particle& Radiator, const int RadType,
437  const Particle& Recoiler, const int RecType,
438  const Event& event );
439 
440  // Function to find a colour (anticolour) index in the input event
441  // IN int col : Colour tag to be investigated
442  // int iExclude1 : Identifier of first particle to be excluded
443  // from search
444  // int iExclude2 : Identifier of second particle to be excluded
445  // from search
446  // Event event : event to be searched for colour tag
447  // int type : Tag to define if col should be counted as
448  // colour (type = 1) [->find anti-colour index
449  // contracted with col]
450  // anticolour (type = 2) [->find colour index
451  // contracted with col]
452  // OUT int : Position of particle in event record
453  // contraced with col [0 if col is free tag]
454  int FindCol(int col, int iExclude1, int iExclude2,
455  const Event& event, int type, bool isHardIn);
456 
457  // Function to in the input event find a particle with quantum
458  // numbers matching those of the input particle
459  // IN Particle : Particle to be searched for
460  // Event : Event to be searched in
461  // OUT int : > 0 : Position of matching particle in event
462  // < 0 : No match in event
463  int FindParticle(const Particle& particle, const Event& event);
464 
465  // Function to check if rad,emt,rec triple is allowed for clustering
466  // IN int rad,emt,rec,partner : Positions (in event record) of the three
467  // particles considered for clustering, and the
468  // correct colour-connected recoiler (=partner)
469  // Event event : Reference event
470  bool allowedClustering( int rad, int emt, int rec, int partner,
471  const Event& event );
472 
473  // Function to check if rad,emt,rec triple is results in
474  // colour singlet radBefore+recBefore
475  // IN int rad,emt,rec : Positions (in event record) of the three
476  // particles considered for clustering
477  // Event event : Reference event
478  bool isSinglett( int rad, int emt, int rec, const Event& event );
479 
480  // Function to check if event is sensibly constructed: Meaning
481  // that all colour indices are contracted and that the charge in
482  // initial and final states matches
483  // IN event : event to be checked
484  // OUT TRUE : event is properly construced
485  // FALSE : event not valid
486  bool validEvent( const Event& event );
487 
488  // Function to check whether two clusterings are identical, used
489  // for finding the history path in the mother -> children direction
490  bool equalClustering( Clustering clus1 , Clustering clus2 );
491 
492  // Chose dummy scale for event construction. By default, choose
493  // sHat for 2->Boson(->2)+ n partons processes and
494  // M_Boson for 2->Boson(->) processes
495  double choseHardScale( const Event& event ) const;
496 
497  // If the state has an incoming hadron return the flavour of the
498  // parton entering the hard interaction. Otherwise return 0
499  int getCurrentFlav(const int) const;
500 
501  // If the state has an incoming hadron return the x-value for the
502  // parton entering the hard interaction. Otherwise return 0.
503  double getCurrentX(const int) const;
504 
505  double getCurrentZ(const int rad, const int rec, const int emt) const;
506 
507  // Function to compute "pythia pT separation" from Particle input
508  double pTLund(const Particle& RadAfterBranch, const Particle& EmtAfterBranch,
509  const Particle& RecAfterBranch, int ShowerType);
510 
511 private:
512 
513  // The state of the event correponding to this step in the
514  // reconstruction.
515  Event state;
516 
517  // The previous step from which this step has been clustered. If
518  // null, this is the initial step with the n-jet state generated by
519  // the matrix element.
520  History * mother;
521 
522  // The different steps corresponding to possible clusterings of this
523  // state.
524  vector<History *> children;
525 
526  // The different paths which have been reconstructed indexed with
527  // the (incremental) corresponding probability. This map is empty
528  // unless this is the initial step (mother == 0).
529  map<double,History *> paths;
530 
531  // The sum of the probabilities of the full paths. This is zero
532  // unless this is the initial step (mother == 0).
533  double sumpath;
534 
535  // This is set true if an ordered (and complete) path has been found
536  // and inserted in paths.
537  bool foundOrderedPath;
538 
539  // This is set true if a strongly ordered (and complete) path has been found
540  // and inserted in paths.
541  bool foundStronglyOrderedPath;
542 
543  // This is set true if a complete (with the required number of
544  // clusterings) path has been found and inserted in paths.
545  bool foundCompletePath;
546 
547  // The scale of this step, corresponding to clustering which
548  // constructed the corresponding state (or the merging scale in case
549  // mother == 0).
550  double scale;
551 
552  // The probability associated with this step and the previous steps.
553  double prob;
554 
555  // The partons and scale of the last clustering
556  Clustering clusterIn;
557 
558  // Pointer to MergingHooks object to get all the settings
559  MergingHooks* mergingHooksPtr;
560 
561  // The default constructor is private.
562  History() {}
563 
564  // The copy-constructor is private.
565  History(const History &) {}
566 
567  // The assignment operator is private.
568  History & operator=(const History &) {
569  return *this;
570  }
571 
572  // BeamParticle to get access to PDFs
573  BeamParticle beamA;
574  BeamParticle beamB;
575  // ParticleData needed to initialise the shower AND to get the
576  // correct masses of partons needed in calculation of probability
577  ParticleData* particleDataPtr;
578 
579  // Info object to have access to all information read from LHE file
580  Info* infoPtr;
581 
582  // Minimal scalar sum of pT used in Herwig to choose history
583  double sumScalarPT;
584 
585 };
586 
587 //==========================================================================
588 
589 } // end namespace Pythia8
590 
591 #endif // end Pythia8_History_H