10 #ifndef Pythia8_BeamParticle_H
11 #define Pythia8_BeamParticle_H
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"
37 class ResolvedParton {
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) { }
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;}
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));}
108 double mRes, factorRes;
124 BeamParticle() : nInit(0) {resolved.resize(0); Q2ValFracSav = -1.;}
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);
133 void initPDFPtr(PDF* pdfInPtr, PDF* pdfHardInPtr) {
134 pdfBeamPtr = pdfInPtr; pdfHardBeamPtr = pdfHardInPtr; }
137 void initUnres(PDF* pdfUnresInPtr);
140 void newValenceContent();
143 void newPzE(
double pzIn,
double eIn) {pBeam = Vec4( 0., 0., pzIn, eIn);}
146 void newM(
double mIn) { mBeam = mIn; }
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;}
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;}
170 double xMax(
int iSkip = -1);
173 double xfHard(
int idIn,
double x,
double Q2)
174 {
return pdfHardBeamPtr->xf(idIn, x, Q2);}
177 double xfMax(
int idIn,
double x,
double Q2)
178 {
return pdfHardBeamPtr->xfMax(idIn, x, Q2);}
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);}
190 double xfSame(
int idIn,
double x,
double Q2)
191 {
return pdfHardBeamPtr->xfSame(idIn, x, Q2);}
194 double xf(
int idIn,
double x,
double Q2)
195 {
return pdfBeamPtr->xf(idIn, x, Q2);}
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);}
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);}
211 bool insideBounds(
double x,
double Q2)
212 {
return pdfBeamPtr->insideBounds(x,Q2);}
215 double alphaS(
double Q2) {
return pdfBeamPtr->alphaS(Q2);}
218 double mQuarkPDF(
int idIn) {
return pdfBeamPtr->mQuarkPDF(idIn);}
221 int nMembers() {
return pdfBeamPtr->nMembers();}
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(); }
232 int pickValSeaComp();
238 ResolvedParton& operator[](
int i) {
return resolved[i];}
239 const ResolvedParton& operator[](
int i)
const {
return resolved[i];}
242 int size()
const {
return resolved.size();}
243 int sizeInit()
const {
return nInit;}
246 void clear() {resolved.resize(0); nInit = 0;}
249 void resetGamma() {iGamVal = -1; iPosVal = -1; pT2gm2qqbar = 0.;
250 isResolvedGamma = (gammaMode == 1) ?
true :
false;}
253 void resetGammaInLepton() {xGm = 1.; kTgamma = 0.; phiGamma = 0.;}
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;}
261 void popBack() {
int iComp = resolved.back().companion();
262 resolved.pop_back();
if ( iComp >= 0 ) { iSkipSave = iComp;
263 idSave = resolved[iComp].id(); pickValSeaComp(); } }
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];
275 bool isUnresolvedLepton();
278 bool remnantFlavours(
Event& event,
bool isDIS =
false);
281 bool remnantColours(
Event& event, vector<int>& colFrom,
285 double xRemnant(
int i);
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;}
293 bool pickGluon(
double mDiff);
297 int pickRemnant()
const {
return idVal2;}
301 double zShare(
double mDiff,
double m1,
double m2);
302 double pxShare()
const {
return pxRel;}
303 double pyShare()
const {
return pyRel;}
306 bool remnantFlavoursNew(
Event& event);
309 void findColSetup(
Event& event);
312 void setInitialCol(
Event & event);
315 void updateCol(vector<pair<int,int> > colourChanges);
317 vector<pair <int,int> > getColUpdates() {
return colUpdates;}
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; }
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; }
336 void setVMDstate(
bool isVMDIn,
int idIn,
double mIn,
double scaleIn,
337 bool reassignState =
false) {
338 hasVMDstateInBeam = isVMDIn;
341 scaleVMDBeam = scaleIn;
345 pdfBeamPtr->setVMDscale(scaleVMDBeam);
350 void pT2gamma2qqbar(
double pT2in) { pT2gm2qqbar = pT2in; }
351 double pT2gamma2qqbar() {
return pT2gm2qqbar; }
354 void pTMPI(
double pTminMPIin) { pTminMPI = pTminMPIin; }
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);
363 double remnantMass(
int idIn);
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); }
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; }
381 double Q2minPDF() {
return pdfHardBeamPtr->getQ2min(); }
382 double xGammaMin() {
return pdfHardBeamPtr->getXmin(); }
383 double xGammaHadr() {
return pdfHardBeamPtr->getXhadr(); }
384 double gammaFluxNorm() {
return pdfHardBeamPtr->getGammaFluxNorm(); }
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; }
395 void xPom(
double xpom = -1.0)
396 {
if ( pdfBeamPtr ) pdfBeamPtr->xPom(xpom); }
399 double sampleXgamma(
double xMinIn)
400 { xGm = pdfHardBeamPtr->sampleXgamma(xMinIn);
return xGm; }
401 double sampleQ2gamma(
double Q2min)
402 { Q2gm = pdfHardBeamPtr->sampleQ2gamma(Q2min);
return Q2gm;}
407 static const double XMINUNRESOLVED, POMERONMASS, XMAXCOMPANION, TINYZREL;
408 static const int NMAX, NRANDOMTRIES;
414 ParticleData* particleDataPtr;
424 PDF* pdfUnresBeamPtr;
426 PDF* pdfHardBeamPtrSave;
429 StringFlav* flavSelPtr;
432 bool allowJunction, beamJunction;
433 int maxValQuark, companionPower;
434 double valencePowerMeson, valencePowerUinP, valencePowerDinP,
435 valenceDiqEnhance, pickQuarkNorm, pickQuarkPower,
436 diffPrimKTwidth, diffLargeMassSuppress, beamSat, gluonPower,
440 int idBeam, idBeamAbs, idVMDBeam;
442 double mBeam, mVMDBeam, scaleVMDBeam;
445 bool isUnresolvedBeam, isLeptonBeam, isHadronBeam, isMesonBeam,
446 isBaryonBeam, isGammaBeam;
447 int nValKinds, idVal[3], nVal[3];
450 int idSave, iSkipSave, nValLeft[3];
451 double xqgTot, xqVal, xqgSea, xqCompSum;
454 bool doISR, doMPI, doND, isResolvedGamma, hasResGammaInBeam,
455 isResUnres, hasVMDstateInBeam;
456 double pTminISR, pTminMPI, pT2gm2qqbar;
457 int iGamVal, iPosVal, gammaMode;
460 double xGm, Q2gm, kTgamma, phiGamma;
463 vector<ResolvedParton> resolved;
467 bool hasJunctionBeam;
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;
479 double xfModified(
int iSkip,
int idIn,
double x,
double Q2);
482 double xValFrac(
int j,
double Q2);
483 double Q2ValFracSav, uValInt, dValInt;
486 double xCompFrac(
double xs);
489 double xCompDist(
double xc,
double xs);
492 int idVal1, idVal2, idVal3;
493 double zRel, pxRel, pyRel;
496 void updateSingleCol(
int oldCol,
int newCol);
500 int findSingleCol(
Event& event,
bool isAcol,
bool useHardScatters);
508 #endif // Pythia8_BeamParticle_H