StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
BeamParticle.h
1 // BeamParticle.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 // Header file for information on incoming beams.
7 // ResolvedParton: an initiator or remnant in beam.
8 // BeamParticle: contains partons, parton densities, etc.
9 
10 #ifndef Pythia8_BeamParticle_H
11 #define Pythia8_BeamParticle_H
12 
13 #include "Pythia8/Basics.h"
14 #include "Pythia8/Event.h"
15 #include "Pythia8/FragmentationFlavZpT.h"
16 #include "Pythia8/Info.h"
17 #include "Pythia8/ParticleData.h"
18 #include "Pythia8/PartonDistributions.h"
19 #include "Pythia8/PythiaStdlib.h"
20 #include "Pythia8/Settings.h"
21 
22 namespace Pythia8 {
23 
24 //==========================================================================
25 
26 // This class holds info on a parton resolved inside the incoming beam,
27 // i.e. either an initiator (part of a hard or a multiparton interaction)
28 // or a remnant (part of the beam remnant treatment).
29 
30 // The companion code is -1 from onset and for g, is -2 for an unmatched
31 // sea quark, is >= 0 for a matched sea quark, with the number giving the
32 // companion position, and is -3 for a valence quark.
33 
34 // Rescattering partons properly do not belong here, but bookkeeping is
35 // simpler with them, so they are stored with companion code -10.
36 
37 class ResolvedParton {
38 
39 public:
40 
41  // Constructor.
42  ResolvedParton( int iPosIn = 0, int idIn = 0, double xIn = 0.,
43  int companionIn = -1) : iPosRes(iPosIn), idRes(idIn), xRes(xIn),
44  companionRes(companionIn), xqCompRes(0.), mRes(0.), factorRes(1.),
45  colRes(0), acolRes(0) { }
46 
47  // Set info on initiator or remnant parton.
48  void iPos( int iPosIn) {iPosRes = iPosIn;}
49  void id( int idIn) {idRes = idIn;}
50  void x( double xIn) {xRes = xIn;}
51  void update( int iPosIn, int idIn, double xIn) {iPosRes = iPosIn;
52  idRes = idIn; xRes = xIn;}
53  void companion( int companionIn) {companionRes = companionIn;}
54  void xqCompanion( double xqCompIn) {xqCompRes = xqCompIn;}
55  void p(Vec4 pIn) {pRes = pIn;}
56  void px(double pxIn) {pRes.px(pxIn);}
57  void py(double pyIn) {pRes.py(pyIn);}
58  void pz(double pzIn) {pRes.pz(pzIn);}
59  void e(double eIn) {pRes.e(eIn);}
60  void m(double mIn) {mRes = mIn;}
61  void col(int colIn) {colRes = colIn;}
62  void acol(int acolIn) {acolRes = acolIn;}
63  void cols(int colIn = 0,int acolIn = 0)
64  {colRes = colIn; acolRes = acolIn;}
65  void scalePT( double factorIn) {pRes.px(factorIn * pRes.px());
66  pRes.py(factorIn * pRes.py()); factorRes *= factorIn;}
67  void scaleX( double factorIn) {xRes *= factorIn;}
68 
69  // Get info on initiator or remnant parton.
70  int iPos() const {return iPosRes;}
71  int id() const {return idRes;}
72  double x() const {return xRes;}
73  int companion() const {return companionRes;}
74  bool isValence() const {return (companionRes == -3);}
75  bool isUnmatched() const {return (companionRes == -2);}
76  bool isCompanion() const {return (companionRes >= 0);}
77  bool isFromBeam() const {return (companionRes > -10);}
78  double xqCompanion() const {return xqCompRes;}
79  Vec4 p() const {return pRes;}
80  double px() const {return pRes.px();}
81  double py() const {return pRes.py();}
82  double pz() const {return pRes.pz();}
83  double e() const {return pRes.e();}
84  double m() const {return mRes;}
85  double pT() const {return pRes.pT();}
86  double mT2() const {return (mRes >= 0.)
87  ? mRes*mRes + pRes.pT2() : - mRes*mRes + pRes.pT2();}
88  double pPos() const {return pRes.e() + pRes.pz();}
89  double pNeg() const {return pRes.e() - pRes.pz();}
90  int col() const {return colRes;}
91  int acol() const {return acolRes;}
92  double pTfactor() const {return factorRes;}
93  bool hasCol() const {return (idRes == 21 || (idRes > 0 && idRes < 9)
94  || (-idRes > 1000 && -idRes < 10000 && (-idRes/10)%10 == 0));}
95  bool hasAcol() const {return (idRes == 21 || (-idRes > 0 && -idRes < 9)
96  || (idRes > 1000 && idRes < 10000 && (idRes/10)%10 == 0));}
97 
98 private:
99 
100  // Properties of a resolved parton.
101  int iPosRes, idRes;
102  double xRes;
103  // Companion code and distribution value, if any.
104  int companionRes;
105  double xqCompRes;
106  // Four-momentum and mass; for remnant kinematics construction.
107  Vec4 pRes;
108  double mRes, factorRes;
109  // Colour codes.
110  int colRes, acolRes;
111 
112 };
113 
114 //==========================================================================
115 
116 // This class holds info on a beam particle in the evolution of
117 // initial-state radiation and multiparton interactions.
118 
119 class BeamParticle {
120 
121 public:
122 
123  // Constructor.
124  BeamParticle() : nInit(0) {resolved.resize(0); Q2ValFracSav = -1.;}
125 
126  // Initialize data on a beam particle and save pointers.
127  void init( int idIn, double pzIn, double eIn, double mIn,
128  Info* infoPtrIn, Settings& settings, ParticleData* particleDataPtrIn,
129  Rndm* rndmPtrIn, PDF* pdfInPtr, PDF* pdfHardInPtr, bool isUnresolvedIn,
130  StringFlav* flavSelPtrIn);
131 
132  // Initialize only the two pdf pointers.
133  void initPDFPtr(PDF* pdfInPtr, PDF* pdfHardInPtr) {
134  pdfBeamPtr = pdfInPtr; pdfHardBeamPtr = pdfHardInPtr; }
135 
136  // Initialize additional PDF pointer for unresolved beam.
137  void initUnres(PDF* pdfUnresInPtr);
138 
139  // For mesons like pi0 valence content varies from event to event.
140  void newValenceContent();
141 
142  // Set new pZ and E, but keep the rest the same.
143  void newPzE( double pzIn, double eIn) {pBeam = Vec4( 0., 0., pzIn, eIn);}
144 
145  // Set new mass. Used with photons when virtuality is sampled.
146  void newM( double mIn) { mBeam = mIn; }
147 
148  // Member functions for output.
149  int id() const {return idBeam;}
150  int idVMD() const {return idVMDBeam;}
151  Vec4 p() const {return pBeam;}
152  double px() const {return pBeam.px();}
153  double py() const {return pBeam.py();}
154  double pz() const {return pBeam.pz();}
155  double e() const {return pBeam.e();}
156  double m() const {return mBeam;}
157  double mVMD() const {return mVMDBeam;}
158  double scaleVMD() const {return scaleVMDBeam;}
159  bool isLepton() const {return isLeptonBeam;}
160  bool isUnresolved() const {return isUnresolvedBeam;}
161  // As hadrons here we only count those we know how to handle remnants for.
162  bool isHadron() const {return isHadronBeam;}
163  bool isMeson() const {return isMesonBeam;}
164  bool isBaryon() const {return isBaryonBeam;}
165  bool isGamma() const {return isGammaBeam;}
166  bool hasResGamma() const {return hasResGammaInBeam;}
167  bool hasVMDstate() const {return hasVMDstateInBeam;}
168 
169  // Maximum x remaining after previous MPI and ISR, plus safety margin.
170  double xMax(int iSkip = -1);
171 
172  // Special hard-process parton distributions (can agree with standard ones).
173  double xfHard(int idIn, double x, double Q2)
174  {return pdfHardBeamPtr->xf(idIn, x, Q2);}
175 
176  // Overestimate for PDFs. Same as normal except photons inside leptons.
177  double xfMax(int idIn, double x, double Q2)
178  {return pdfHardBeamPtr->xfMax(idIn, x, Q2);}
179 
180  // Accurate and approximated photon flux and PDFs.
181  double xfFlux(int idIn, double x, double Q2)
182  {return pdfHardBeamPtr->xfFlux(idIn, x, Q2);}
183  double xfApprox(int idIn, double x, double Q2)
184  {return pdfHardBeamPtr->xfApprox(idIn, x, Q2);}
185  double xfGamma(int idIn, double x, double Q2)
186  {return pdfHardBeamPtr->xfGamma(idIn, x, Q2);}
187 
188  // Do not sample the x_gamma value to get correct cross section with
189  // possible second call.
190  double xfSame(int idIn, double x, double Q2)
191  {return pdfHardBeamPtr->xfSame(idIn, x, Q2);}
192 
193  // Standard parton distributions.
194  double xf(int idIn, double x, double Q2)
195  {return pdfBeamPtr->xf(idIn, x, Q2);}
196 
197  // Ditto, split into valence and sea parts (where gluon counts as sea).
198  double xfVal(int idIn, double x, double Q2)
199  {return pdfBeamPtr->xfVal(idIn, x, Q2);}
200  double xfSea(int idIn, double x, double Q2)
201  {return pdfBeamPtr->xfSea(idIn, x, Q2);}
202 
203  // Rescaled parton distributions, as needed for MPI and ISR.
204  // For ISR also allow split valence/sea, and only return relevant part.
205  double xfMPI(int idIn, double x, double Q2)
206  {return xfModified(-1, idIn, x, Q2);}
207  double xfISR(int indexMPI, int idIn, double x, double Q2)
208  {return xfModified( indexMPI, idIn, x, Q2);}
209 
210  // Check whether x and Q2 values fall inside the fit bounds (LHAPDF6 only).
211  bool insideBounds(double x, double Q2)
212  {return pdfBeamPtr->insideBounds(x,Q2);}
213 
214  // Access the running alpha_s of a PDF set (LHAPDF6 only).
215  double alphaS(double Q2) {return pdfBeamPtr->alphaS(Q2);}
216 
217  // Return quark masses used in the PDF fit (LHAPDF6 only).
218  double mQuarkPDF(int idIn) {return pdfBeamPtr->mQuarkPDF(idIn);}
219 
220  // Return number of members in PDF family (LHAPDF6 only).
221  int nMembers() {return pdfBeamPtr->nMembers();}
222 
223  // Calculate envelope of PDF predictions
224  void calcPDFEnvelope(int idNow, double xNow, double Q2Now, int valSea) {
225  pdfBeamPtr->calcPDFEnvelope(idNow,xNow,Q2Now,valSea);}
226  void calcPDFEnvelope(pair<int,int> idNows, pair<double,double> xNows,
227  double Q2Now, int valSea) {
228  pdfBeamPtr->calcPDFEnvelope(idNows,xNows,Q2Now,valSea);}
229  PDF::PDFEnvelope getPDFEnvelope() { return pdfBeamPtr->getPDFEnvelope(); }
230 
231  // Decide whether chosen quark is valence, sea or companion.
232  int pickValSeaComp();
233 
234  // Initialize kind of incoming beam particle.
235  void initBeamKind();
236 
237  // Overload index operator to access a resolved parton from the list.
238  ResolvedParton& operator[](int i) {return resolved[i];}
239  const ResolvedParton& operator[](int i) const {return resolved[i];}
240 
241  // Total number of partons extracted from beam, and initiators only.
242  int size() const {return resolved.size();}
243  int sizeInit() const {return nInit;}
244 
245  // Clear list of resolved partons.
246  void clear() {resolved.resize(0); nInit = 0;}
247 
248  // Reset variables related to photon beam.
249  void resetGamma() {iGamVal = -1; iPosVal = -1; pT2gm2qqbar = 0.;
250  isResolvedGamma = (gammaMode == 1) ? true : false;}
251 
252  // Reset variables related to photon beam inside a lepton.
253  void resetGammaInLepton() {xGm = 1.; kTgamma = 0.; phiGamma = 0.;}
254 
255  // Add a resolved parton to list.
256  int append( int iPos, int idIn, double x, int companion = -1)
257  {resolved.push_back( ResolvedParton( iPos, idIn, x, companion) );
258  return resolved.size() - 1;}
259 
260  // Remove the last particle from the beam. Reset companion code if needed.
261  void popBack() { int iComp = resolved.back().companion();
262  resolved.pop_back(); if ( iComp >= 0 ) { iSkipSave = iComp;
263  idSave = resolved[iComp].id(); pickValSeaComp(); } }
264 
265  // Print extracted parton list; for debug mainly.
266  void list() const;
267 
268  // How many different flavours, and how many quarks of given flavour.
269  int nValenceKinds() const {return nValKinds;}
270  int nValence(int idIn) const {for (int i = 0; i < nValKinds; ++i)
271  if (idIn == idVal[i]) return nVal[i];
272  return 0;}
273 
274  // Test whether a lepton is to be considered as unresolved.
275  bool isUnresolvedLepton();
276 
277  // Add extra remnant flavours to make valence and sea come out right.
278  bool remnantFlavours(Event& event, bool isDIS = false);
279 
280  // Correlate all initiators and remnants to make a colour singlet.
281  bool remnantColours(Event& event, vector<int>& colFrom,
282  vector<int>& colTo);
283 
284  // Pick unrescaled x of remnant parton (valence or sea).
285  double xRemnant(int i);
286 
287  // Tell whether a junction has been resolved, and its junction colours.
288  bool hasJunction() const {return hasJunctionBeam;}
289  int junctionCol(int i) const {return junCol[i];}
290  void junctionCol(int i, int col) {junCol[i] = col;}
291 
292  // For a diffractive system, decide whether to kick out gluon or quark.
293  bool pickGluon(double mDiff);
294 
295  // Pick a valence quark at random, and provide the remaining flavour.
296  int pickValence();
297  int pickRemnant() const {return idVal2;}
298 
299  // Share lightcone momentum between two remnants in a diffractive system.
300  // At the same time generate a relative pT for the two.
301  double zShare( double mDiff, double m1, double m2);
302  double pxShare() const {return pxRel;}
303  double pyShare() const {return pyRel;}
304 
305  // Add extra remnant flavours to make valence and sea come out right.
306  bool remnantFlavoursNew(Event& event);
307 
308  // Find the colour setup of the removed partons from the scatterings.
309  void findColSetup(Event& event);
310 
311  // Set initial colours.
312  void setInitialCol(Event & event);
313 
314  // Update colours.
315  void updateCol(vector<pair<int,int> > colourChanges);
316 
317  vector<pair <int,int> > getColUpdates() {return colUpdates;}
318 
319  // Set valence content for photon beams and position of first valence quark.
320  bool gammaInitiatorIsVal(int iResolved, int id, double x, double Q2);
321  bool gammaInitiatorIsVal(int iResolved, double Q2);
322  int getGammaValFlavour() { return abs(idVal[0]); }
323  int gammaValSeaComp(int iResolved);
324  void posVal(int iPosValIn) { iPosVal = iPosValIn; }
325  void gamVal(int iGamValIn) { iGamVal = iGamValIn; }
326  int gamVal() { return iGamVal; }
327 
328  // Set and get the state (resolved and/or unresolved) of photon beam.
329  void resolvedGamma(bool isResolved) { isResolvedGamma = isResolved; }
330  bool resolvedGamma() { return isResolvedGamma; }
331  void setGammaMode(int gammaModeIn);
332  int getGammaMode() { return gammaMode; }
333  bool isResolvedUnresolved() { return isResUnres; }
334 
335  // Set state of VMD inside gamma.
336  void setVMDstate(bool isVMDIn, int idIn, double mIn, double scaleIn,
337  bool reassignState = false) {
338  hasVMDstateInBeam = isVMDIn;
339  idVMDBeam = idIn;
340  mVMDBeam = mIn;
341  scaleVMDBeam = scaleIn;
342  if (reassignState) {
343  idBeam = idVMDBeam;
344  mBeam = mVMDBeam;
345  pdfBeamPtr->setVMDscale(scaleVMDBeam);
346  }
347  }
348 
349  // Store the pT2 value of gamma->qqbar splitting.
350  void pT2gamma2qqbar(double pT2in) { pT2gm2qqbar = pT2in; }
351  double pT2gamma2qqbar() { return pT2gm2qqbar; }
352 
353  // Store the pT value for the latest MPI.
354  void pTMPI(double pTminMPIin) { pTminMPI = pTminMPIin; }
355 
356  // Check whether room for beam remnants.
357  bool roomFor1Remnant(double eCM);
358  bool roomFor1Remnant(int id1, double x1, double eCM);
359  bool roomFor2Remnants(int id1, double x1, double eCM);
360  bool roomForRemnants(BeamParticle beamOther);
361 
362  // Evaluate the remnant mass with initiator idIn.
363  double remnantMass(int idIn);
364 
365  // Functions to approximate pdfs for ISR.
366  double gammaPDFxDependence(int flavour, double x)
367  { return pdfBeamPtr->gammaPDFxDependence(flavour, x); }
368  double gammaPDFRefScale(int flavour)
369  { return pdfBeamPtr->gammaPDFRefScale(flavour); }
370  double xIntegratedPDFs(double Q2)
371  { return pdfBeamPtr->xfIntegratedTotal(Q2); }
372 
373  // Save the x_gamma value after latest PDF call or set it later if ND.
374  void xGammaPDF() { xGm = pdfHardBeamPtr->xGamma(); }
375  void xGamma(double xGmIn) { xGm = xGmIn; }
376  void Q2Gamma(double Q2GmIn) { Q2gm = Q2GmIn; }
377  void newGammaKTPhi(double kTIn, double phiIn)
378  { kTgamma = kTIn; phiGamma = phiIn; }
379 
380  // Get the kinematic limits for photons emitted by the beam.
381  double Q2minPDF() { return pdfHardBeamPtr->getQ2min(); }
382  double xGammaMin() { return pdfHardBeamPtr->getXmin(); }
383  double xGammaHadr() { return pdfHardBeamPtr->getXhadr(); }
384  double gammaFluxNorm() { return pdfHardBeamPtr->getGammaFluxNorm(); }
385 
386  // Get the kinematics related photons form lepton beams.
387  double xGamma() const { return xGm; }
388  double Q2Gamma() const { return Q2gm; }
389  double gammaKTx() const { return kTgamma*cos(phiGamma); }
390  double gammaKTy() const { return kTgamma*sin(phiGamma); }
391  double gammaKT() const { return kTgamma; }
392  double gammaPhi() const { return phiGamma; }
393 
394  // Keep track of pomeron momentum fraction.
395  void xPom(double xpom = -1.0)
396  { if ( pdfBeamPtr ) pdfBeamPtr->xPom(xpom); }
397 
398  // Sample x and Q2 for emitted photons according to flux.
399  double sampleXgamma(double xMinIn)
400  { xGm = pdfHardBeamPtr->sampleXgamma(xMinIn); return xGm; }
401  double sampleQ2gamma(double Q2min)
402  { Q2gm = pdfHardBeamPtr->sampleQ2gamma(Q2min); return Q2gm;}
403 
404 private:
405 
406  // Constants: could only be changed in the code itself.
407  static const double XMINUNRESOLVED, POMERONMASS, XMAXCOMPANION, TINYZREL;
408  static const int NMAX, NRANDOMTRIES;
409 
410  // Pointer to various information on the generation.
411  Info* infoPtr;
412 
413  // Pointer to the particle data table.
414  ParticleData* particleDataPtr;
415 
416  // Pointer to the random number generator.
417  Rndm* rndmPtr;
418 
419  // Pointers to PDF sets.
420  PDF* pdfBeamPtr;
421  PDF* pdfHardBeamPtr;
422 
423  // Pointer to unresolved PDF and two others to save the resolved ptrs.
424  PDF* pdfUnresBeamPtr;
425  PDF* pdfBeamPtrSave;
426  PDF* pdfHardBeamPtrSave;
427 
428  // Pointer to class for flavour generation.
429  StringFlav* flavSelPtr;
430 
431  // Initialization data, normally only set once.
432  bool allowJunction, beamJunction;
433  int maxValQuark, companionPower;
434  double valencePowerMeson, valencePowerUinP, valencePowerDinP,
435  valenceDiqEnhance, pickQuarkNorm, pickQuarkPower,
436  diffPrimKTwidth, diffLargeMassSuppress, beamSat, gluonPower,
437  xGluonCutoff;
438 
439  // Basic properties of a beam particle.
440  int idBeam, idBeamAbs, idVMDBeam;
441  Vec4 pBeam;
442  double mBeam, mVMDBeam, scaleVMDBeam;
443 
444  // Beam kind. Valence flavour content for hadrons.
445  bool isUnresolvedBeam, isLeptonBeam, isHadronBeam, isMesonBeam,
446  isBaryonBeam, isGammaBeam;
447  int nValKinds, idVal[3], nVal[3];
448 
449  // Current parton density, by valence, sea and companion.
450  int idSave, iSkipSave, nValLeft[3];
451  double xqgTot, xqVal, xqgSea, xqCompSum;
452 
453  // Variables related to photon beams (also inside lepton).
454  bool doISR, doMPI, doND, isResolvedGamma, hasResGammaInBeam,
455  isResUnres, hasVMDstateInBeam;
456  double pTminISR, pTminMPI, pT2gm2qqbar;
457  int iGamVal, iPosVal, gammaMode;
458 
459  // Variables for photon from lepton.
460  double xGm, Q2gm, kTgamma, phiGamma;
461 
462  // The list of resolved partons.
463  vector<ResolvedParton> resolved;
464 
465  // Status after all initiators have been accounted for. Junction content.
466  int nInit;
467  bool hasJunctionBeam;
468  int junCol[3];
469 
470  // Variables for new colour reconnection;
471  pair <int,int> colSetup;
472  vector<int> acols, cols;
473  vector<bool> usedCol,usedAcol;
474  vector< pair<int,int> > colUpdates;
475  int nJuncs, nAjuncs, nDiffJuncs;
476  bool allowBeamJunctions;
477 
478  // Routine to calculate pdf's given previous interactions.
479  double xfModified( int iSkip, int idIn, double x, double Q2);
480 
481  // Fraction of hadron momentum sitting in a valence quark distribution.
482  double xValFrac(int j, double Q2);
483  double Q2ValFracSav, uValInt, dValInt;
484 
485  // Fraction of hadron momentum sitting in a companion quark distribution.
486  double xCompFrac(double xs);
487 
488  // Value of companion quark PDF, also given the sea quark x.
489  double xCompDist(double xc, double xs);
490 
491  // Valence quark subdivision for diffractive systems.
492  int idVal1, idVal2, idVal3;
493  double zRel, pxRel, pyRel;
494 
495  // Update a single (anti-) colour of the event.
496  void updateSingleCol(int oldCol, int newCol);
497 
498  // Find a single (anti-) colour in the beam,
499  // if a beam remnant is set the new colour.
500  int findSingleCol(Event& event, bool isAcol, bool useHardScatters);
501 
502 };
503 
504 //==========================================================================
505 
506 } // end namespace Pythia8
507 
508 #endif // Pythia8_BeamParticle_H
Definition: AgUStep.h:26