File indexing completed on 2025-01-18 10:06:18
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef Pythia8_BeamParticle_H
0011 #define Pythia8_BeamParticle_H
0012
0013 #include "Pythia8/Basics.h"
0014 #include "Pythia8/Event.h"
0015 #include "Pythia8/FragmentationFlavZpT.h"
0016 #include "Pythia8/Info.h"
0017 #include "Pythia8/ParticleData.h"
0018 #include "Pythia8/PartonDistributions.h"
0019 #include "Pythia8/PhysicsBase.h"
0020 #include "Pythia8/PythiaStdlib.h"
0021 #include "Pythia8/Settings.h"
0022
0023 namespace Pythia8 {
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038 class ResolvedParton {
0039
0040 public:
0041
0042
0043 ResolvedParton( int iPosIn = 0, int idIn = 0, double xIn = 0.,
0044 int companionIn = -1) : iPosRes(iPosIn), idRes(idIn), xRes(xIn),
0045 companionRes(companionIn), xqCompRes(0.), mRes(0.), factorRes(1.),
0046 colRes(0), acolRes(0) { }
0047
0048
0049 void iPos( int iPosIn) {iPosRes = iPosIn;}
0050 void id( int idIn) {idRes = idIn;}
0051 void x( double xIn) {xRes = xIn;}
0052 void update( int iPosIn, int idIn, double xIn) {iPosRes = iPosIn;
0053 idRes = idIn; xRes = xIn;}
0054 void companion( int companionIn) {companionRes = companionIn;}
0055 void xqCompanion( double xqCompIn) {xqCompRes = xqCompIn;}
0056 void p(Vec4 pIn) {pRes = pIn;}
0057 void px(double pxIn) {pRes.px(pxIn);}
0058 void py(double pyIn) {pRes.py(pyIn);}
0059 void pz(double pzIn) {pRes.pz(pzIn);}
0060 void e(double eIn) {pRes.e(eIn);}
0061 void m(double mIn) {mRes = mIn;}
0062 void col(int colIn) {colRes = colIn;}
0063 void acol(int acolIn) {acolRes = acolIn;}
0064 void cols(int colIn = 0,int acolIn = 0)
0065 {colRes = colIn; acolRes = acolIn;}
0066 void scalePT( double factorIn) {pRes.px(factorIn * pRes.px());
0067 pRes.py(factorIn * pRes.py()); factorRes *= factorIn;}
0068 void scaleX( double factorIn) {xRes *= factorIn;}
0069
0070
0071 int iPos() const {return iPosRes;}
0072 int id() const {return idRes;}
0073 double x() const {return xRes;}
0074 int companion() const {return companionRes;}
0075 bool isValence() const {return (companionRes == -3);}
0076 bool isUnmatched() const {return (companionRes == -2);}
0077 bool isCompanion() const {return (companionRes >= 0);}
0078 bool isFromBeam() const {return (companionRes > -10);}
0079 double xqCompanion() const {return xqCompRes;}
0080 Vec4 p() const {return pRes;}
0081 double px() const {return pRes.px();}
0082 double py() const {return pRes.py();}
0083 double pz() const {return pRes.pz();}
0084 double e() const {return pRes.e();}
0085 double m() const {return mRes;}
0086 double pT() const {return pRes.pT();}
0087 double mT2() const {return (mRes >= 0.)
0088 ? mRes*mRes + pRes.pT2() : - mRes*mRes + pRes.pT2();}
0089 double pPos() const {return pRes.e() + pRes.pz();}
0090 double pNeg() const {return pRes.e() - pRes.pz();}
0091 int col() const {return colRes;}
0092 int acol() const {return acolRes;}
0093 double pTfactor() const {return factorRes;}
0094 bool hasCol() const {return (idRes == 21 || (idRes > 0 && idRes < 9)
0095 || (-idRes > 1000 && -idRes < 10000 && (-idRes/10)%10 == 0));}
0096 bool hasAcol() const {return (idRes == 21 || (-idRes > 0 && -idRes < 9)
0097 || (idRes > 1000 && idRes < 10000 && (idRes/10)%10 == 0));}
0098
0099 private:
0100
0101
0102 int iPosRes, idRes;
0103 double xRes;
0104
0105 int companionRes;
0106 double xqCompRes;
0107
0108 Vec4 pRes;
0109 double mRes, factorRes;
0110
0111 int colRes, acolRes;
0112
0113 };
0114
0115
0116
0117
0118
0119
0120 typedef struct {
0121 double xValTot;
0122 double xValLeft;
0123 double xLeft;
0124 double xCompAdded;
0125 double rescaleGS;
0126 } xfModPrepData;
0127
0128
0129
0130
0131
0132
0133 class BeamParticle : public PhysicsBase {
0134
0135 public:
0136
0137
0138 BeamParticle() : pdfBeamPtr(), pdfHardBeamPtr(), pdfUnresBeamPtr(),
0139 pdfBeamPtrSave(), pdfHardBeamPtrSave(), pdfSavePtrs(),
0140 pdfSaveIdx(-1), flavSelPtr(), allowJunction(), beamJunction(),
0141 maxValQuark(), companionPower(), valencePowerMeson(), valencePowerUinP(),
0142 valencePowerDinP(), valenceDiqEnhance(), pickQuarkNorm(), pickQuarkPower(),
0143 diffPrimKTwidth(), diffLargeMassSuppress(), beamSat(), gluonPower(),
0144 xGluonCutoff(), heavyQuarkEnhance(), idBeam(), idBeamAbs(), idVMDBeam(),
0145 mBeam(), mVMDBeam(), scaleVMDBeam(), isUnresolvedBeam(), isLeptonBeam(),
0146 isHadronBeam(), isMesonBeam(), isBaryonBeam(), isGammaBeam(), nValKinds(),
0147 idVal(), nVal(), idSave(), iSkipSave(), nValLeft(), xqgTot(), xqVal(),
0148 xqgSea(), xqCompSum(), doISR(), doMPI(), doND(), isResolvedGamma(),
0149 hasResGammaInBeam(), isResUnres(), hasVMDstateInBeam(), initGammaBeam(),
0150 pTminISR(), pTminMPI(), pT2gm2qqbar(), iGamVal(), iPosVal(), gammaMode(),
0151 xGm(), Q2gm(), kTgamma(), phiGamma(), cPowerCache(-100), xsCache(-1),
0152 resCache(), resolved(), nInit(0), hasJunctionBeam(), junCol(), nJuncs(),
0153 nAjuncs(), nDiffJuncs(), allowBeamJunctions(), Q2ValFracSav(-1.),
0154 uValInt(), dValInt(), idVal1(), idVal2(), idVal3(), zRel(), pxRel(),
0155 pyRel() { }
0156
0157
0158 void init( int idIn, double pzIn, double eIn, double mIn,
0159 PDFPtr pdfInPtr, PDFPtr pdfHardInPtr, bool isUnresolvedIn,
0160 StringFlav* flavSelPtrIn);
0161
0162
0163 void initID( int idIn) { idBeam = idIn; initBeamKind();}
0164
0165
0166 void initPDFPtr(PDFPtr pdfInPtr, PDFPtr pdfHardInPtr) {
0167 pdfBeamPtr = pdfInPtr; pdfHardBeamPtr = pdfHardInPtr; }
0168
0169
0170 void initUnres(PDFPtr pdfUnresInPtr);
0171
0172
0173 void initSwitchID( const vector<PDFPtr>& pdfSavePtrsIn) {
0174 pdfSavePtrs = pdfSavePtrsIn; }
0175
0176
0177 void newValenceContent();
0178 void setValenceContent(int idq1, int idq2 = 0, int idq3 = 0);
0179
0180
0181 void setBeamID( int idIn, int iPDFin = -1) {idBeam = idIn;
0182 if ( iPDFin >= 0 && iPDFin < int(pdfSavePtrs.size())
0183 && iPDFin != pdfSaveIdx ) {
0184 pdfBeamPtr = pdfSavePtrs[iPDFin]; pdfHardBeamPtr = pdfBeamPtr;
0185 pdfSaveIdx = iPDFin; }
0186 mBeam = particleDataPtr->m0(idIn); pdfBeamPtr->setBeamID(idIn); }
0187
0188
0189 void newPzE( double pzIn, double eIn) {pBeam = Vec4( 0., 0., pzIn, eIn);}
0190
0191
0192 void newM( double mIn) { mBeam = mIn; }
0193
0194
0195 int id() const {return idBeam;}
0196 int idVMD() const {return idVMDBeam;}
0197 Vec4 p() const {return pBeam;}
0198 double px() const {return pBeam.px();}
0199 double py() const {return pBeam.py();}
0200 double pz() const {return pBeam.pz();}
0201 double e() const {return pBeam.e();}
0202 double m() const {return mBeam;}
0203 double mVMD() const {return mVMDBeam;}
0204 double scaleVMD() const {return scaleVMDBeam;}
0205 bool isLepton() const {return isLeptonBeam;}
0206 bool isUnresolved() const {return isUnresolvedBeam;}
0207
0208 bool isHadron() const {return isHadronBeam;}
0209 bool isMeson() const {return isMesonBeam;}
0210 bool isBaryon() const {return isBaryonBeam;}
0211 bool isGamma() const {return isGammaBeam;}
0212 bool hasResGamma() const {return hasResGammaInBeam;}
0213 bool hasVMDstate() const {return hasVMDstateInBeam;}
0214
0215
0216 double xMax(int iSkip = -1);
0217
0218
0219 double xfHard(int idIn, double x, double Q2)
0220 {return pdfHardBeamPtr->xf(idIn, x, Q2);}
0221
0222
0223 double xfMax(int idIn, double x, double Q2)
0224 {return pdfHardBeamPtr->xfMax(idIn, x, Q2);}
0225
0226
0227 double xfFlux(int idIn, double x, double Q2)
0228 {return pdfHardBeamPtr->xfFlux(idIn, x, Q2);}
0229 double xfApprox(int idIn, double x, double Q2)
0230 {return pdfHardBeamPtr->xfApprox(idIn, x, Q2);}
0231 double xfGamma(int idIn, double x, double Q2)
0232 {return pdfHardBeamPtr->xfGamma(idIn, x, Q2);}
0233
0234
0235
0236 double xfSame(int idIn, double x, double Q2)
0237 {return pdfHardBeamPtr->xfSame(idIn, x, Q2);}
0238
0239
0240 double xf(int idIn, double x, double Q2)
0241 {return pdfBeamPtr->xf(idIn, x, Q2);}
0242
0243
0244 double xfVal(int idIn, double x, double Q2)
0245 {return pdfBeamPtr->xfVal(idIn, x, Q2);}
0246 double xfSea(int idIn, double x, double Q2)
0247 {return pdfBeamPtr->xfSea(idIn, x, Q2);}
0248
0249
0250
0251 double xfMPI(int idIn, double x, double Q2, xfModPrepData& xfData)
0252 {return xfISR(-1, idIn, x, Q2, xfData);}
0253 double xfMPI(int idIn, double x, double Q2)
0254 {xfModPrepData xfData = xfModPrep(-1, Q2);
0255 return xfISR(-1, idIn, x, Q2, xfData);}
0256 double xfISR(int indexMPI, int idIn, double x, double Q2,
0257 xfModPrepData& xfData) {return xfModified( indexMPI, idIn, x, Q2, xfData);}
0258 double xfISR(int indexMPI, int idIn, double x, double Q2)
0259 {xfModPrepData xfData= xfModPrep(indexMPI, Q2);
0260 return xfModified( indexMPI, idIn, x, Q2, xfData);}
0261
0262
0263 bool insideBounds(double x, double Q2)
0264 {return pdfBeamPtr->insideBounds(x,Q2);}
0265
0266
0267 double alphaS(double Q2) {return pdfBeamPtr->alphaS(Q2);}
0268
0269
0270 double mQuarkPDF(int idIn) {return pdfBeamPtr->mQuarkPDF(idIn);}
0271
0272
0273 int nMembers() {return pdfBeamPtr->nMembers();}
0274
0275
0276 void calcPDFEnvelope(int idNow, double xNow, double Q2Now, int valSea) {
0277 pdfBeamPtr->calcPDFEnvelope(idNow,xNow,Q2Now,valSea);}
0278 void calcPDFEnvelope(pair<int,int> idNows, pair<double,double> xNows,
0279 double Q2Now, int valSea) {
0280 pdfBeamPtr->calcPDFEnvelope(idNows,xNows,Q2Now,valSea);}
0281 PDF::PDFEnvelope getPDFEnvelope() { return pdfBeamPtr->getPDFEnvelope(); }
0282
0283
0284 int pickValSeaComp();
0285
0286
0287 void initBeamKind();
0288
0289
0290 ResolvedParton& operator[](int i) {return resolved[i];}
0291 const ResolvedParton& operator[](int i) const {return resolved[i];}
0292
0293
0294 int size() const {return resolved.size();}
0295 int sizeInit() const {return nInit;}
0296
0297
0298 void clear() {resolved.resize(0); nInit = 0;}
0299
0300
0301 void resetGamma() {iGamVal = -1; iPosVal = -1; pT2gm2qqbar = 0.;
0302 isResolvedGamma = (gammaMode == 1) ? true : false;}
0303
0304
0305 void resetGammaInLepton() {xGm = 1.; kTgamma = 0.; phiGamma = 0.;}
0306
0307
0308 int append( int iPos, int idIn, double x, int companion = -1)
0309 {resolved.push_back( ResolvedParton( iPos, idIn, x, companion) );
0310 return resolved.size() - 1;}
0311
0312
0313 void popBack() { int iComp = resolved.back().companion();
0314 resolved.pop_back(); if ( iComp >= 0 ) { iSkipSave = iComp;
0315 idSave = resolved[iComp].id(); pickValSeaComp(); } }
0316
0317
0318 void list() const;
0319
0320
0321 int nValenceKinds() const {return nValKinds;}
0322 int nValence(int idIn) const {for (int i = 0; i < nValKinds; ++i)
0323 if (idIn == idVal[i]) return nVal[i];
0324 return 0;}
0325
0326
0327 bool isUnresolvedLepton();
0328
0329
0330 bool remnantFlavours(Event& event, bool isDIS = false);
0331
0332
0333 bool remnantColours(Event& event, vector<int>& colFrom,
0334 vector<int>& colTo);
0335
0336
0337 double xRemnant(int i);
0338
0339
0340 bool hasJunction() const {return hasJunctionBeam;}
0341 int junctionCol(int i) const {return junCol[i];}
0342 void junctionCol(int i, int col) {junCol[i] = col;}
0343
0344
0345 bool pickGluon(double mDiff);
0346
0347
0348 int pickValence();
0349 int pickRemnant() const {return idVal2;}
0350
0351
0352
0353 double zShare( double mDiff, double m1, double m2);
0354 double pxShare() const {return pxRel;}
0355 double pyShare() const {return pyRel;}
0356
0357
0358 bool remnantFlavoursNew(Event& event);
0359
0360
0361 void findColSetup(Event& event);
0362
0363
0364 void setInitialCol(Event & event);
0365
0366
0367 void updateCol(vector<pair<int,int> > colourChanges);
0368
0369 vector<pair <int,int> > getColUpdates() {return colUpdates;}
0370
0371
0372 bool gammaInitiatorIsVal(int iResolved, int id, double x, double Q2);
0373 bool gammaInitiatorIsVal(int iResolved, double Q2);
0374 int getGammaValFlavour() { return abs(idVal[0]); }
0375 int gammaValSeaComp(int iResolved);
0376 void posVal(int iPosValIn) { iPosVal = iPosValIn; }
0377 void gamVal(int iGamValIn) { iGamVal = iGamValIn; }
0378 int gamVal() { return iGamVal; }
0379
0380
0381 void resolvedGamma(bool isResolved) { isResolvedGamma = isResolved; }
0382 bool resolvedGamma() const { return isResolvedGamma; }
0383 void setGammaMode(int gammaModeIn);
0384 int getGammaMode() const { return gammaMode; }
0385 bool isResolvedUnresolved() const { return isResUnres; }
0386 void initGammaInBeam() { initGammaBeam = true; }
0387 bool gammaInBeam() const { return initGammaBeam; }
0388
0389
0390 void setVMDstate(bool isVMDIn, int idIn, double mIn, double scaleIn,
0391 bool reassignState = false) {
0392 hasVMDstateInBeam = isVMDIn;
0393 idVMDBeam = idIn;
0394 mVMDBeam = mIn;
0395 scaleVMDBeam = scaleIn;
0396 if (reassignState) {
0397 idBeam = idVMDBeam;
0398 mBeam = mVMDBeam;
0399 pdfBeamPtr->setVMDscale(scaleVMDBeam);
0400 }
0401 }
0402
0403
0404 void pT2gamma2qqbar(double pT2in) { pT2gm2qqbar = pT2in; }
0405 double pT2gamma2qqbar() { return pT2gm2qqbar; }
0406
0407
0408 void pTMPI(double pTminMPIin) { pTminMPI = pTminMPIin; }
0409
0410
0411 bool roomFor1Remnant(double eCM);
0412 bool roomFor1Remnant(int id1, double x1, double eCM);
0413 bool roomFor2Remnants(int id1, double x1, double eCM);
0414 bool roomForRemnants(BeamParticle beamOther);
0415
0416
0417 double remnantMass(int idIn);
0418
0419
0420 double gammaPDFxDependence(int flavour, double x)
0421 { return pdfBeamPtr->gammaPDFxDependence(flavour, x); }
0422 double gammaPDFRefScale(int flavour)
0423 { return pdfBeamPtr->gammaPDFRefScale(flavour); }
0424 double xIntegratedPDFs(double Q2)
0425 { return pdfBeamPtr->xfIntegratedTotal(Q2); }
0426
0427
0428 void xGammaPDF() { xGm = pdfHardBeamPtr->xGamma(); }
0429 void xGamma(double xGmIn) { xGm = xGmIn; }
0430 void Q2Gamma(double Q2GmIn) { Q2gm = Q2GmIn; }
0431 void newGammaKTPhi(double kTIn, double phiIn)
0432 { kTgamma = kTIn; phiGamma = phiIn; }
0433
0434
0435 double xGammaMin() { return pdfHardBeamPtr->getXmin(); }
0436 double xGammaHadr() { return pdfHardBeamPtr->getXhadr(); }
0437 double gammaFluxIntApprox() { return pdfHardBeamPtr->intFluxApprox(); }
0438
0439
0440 bool hasApproxGammaFlux() { return pdfHardBeamPtr->hasApproxGammaFlux(); }
0441
0442
0443 double xGamma() const { return xGm; }
0444 double Q2Gamma() const { return Q2gm; }
0445 double gammaKTx() const { return kTgamma*cos(phiGamma); }
0446 double gammaKTy() const { return kTgamma*sin(phiGamma); }
0447 double gammaKT() const { return kTgamma; }
0448 double gammaPhi() const { return phiGamma; }
0449
0450
0451 void xPom(double xpom = -1.0)
0452 { if ( pdfBeamPtr ) pdfBeamPtr->xPom(xpom); }
0453
0454
0455 double sampleXgamma(double xMinIn)
0456 { xGm = pdfHardBeamPtr->sampleXgamma(xMinIn); return xGm; }
0457 double sampleQ2gamma(double Q2min)
0458 { Q2gm = pdfHardBeamPtr->sampleQ2gamma(Q2min); return Q2gm;}
0459
0460
0461 xfModPrepData xfModPrep( int iSkip, double Q2);
0462
0463 private:
0464
0465
0466 static const double XMINUNRESOLVED, POMERONMASS, XMAXCOMPANION, TINYZREL;
0467 static const int NMAX, NRANDOMTRIES;
0468
0469
0470 PDFPtr pdfBeamPtr;
0471 PDFPtr pdfHardBeamPtr;
0472
0473
0474 PDFPtr pdfUnresBeamPtr;
0475 PDFPtr pdfBeamPtrSave;
0476 PDFPtr pdfHardBeamPtrSave;
0477
0478
0479 vector<PDFPtr> pdfSavePtrs;
0480 int pdfSaveIdx;
0481
0482
0483 StringFlav* flavSelPtr;
0484
0485
0486 bool allowJunction, beamJunction;
0487 int maxValQuark, companionPower;
0488 double valencePowerMeson, valencePowerUinP, valencePowerDinP,
0489 valenceDiqEnhance, pickQuarkNorm, pickQuarkPower,
0490 diffPrimKTwidth, diffLargeMassSuppress, beamSat, gluonPower,
0491 xGluonCutoff, heavyQuarkEnhance[6];
0492
0493
0494 int idBeam, idBeamAbs, idVMDBeam;
0495 Vec4 pBeam;
0496 double mBeam, mVMDBeam, scaleVMDBeam;
0497
0498
0499 bool isUnresolvedBeam, isLeptonBeam, isHadronBeam, isMesonBeam,
0500 isBaryonBeam, isGammaBeam;
0501 int nValKinds, idVal[3], nVal[3];
0502
0503
0504 int idSave, iSkipSave, nValLeft[3];
0505 double xqgTot, xqVal, xqgSea, xqCompSum;
0506
0507
0508 bool doISR, doMPI, doND, isResolvedGamma, hasResGammaInBeam,
0509 isResUnres, hasVMDstateInBeam, initGammaBeam;
0510 double pTminISR, pTminMPI, pT2gm2qqbar;
0511 int iGamVal, iPosVal, gammaMode;
0512
0513
0514 double xGm, Q2gm, kTgamma, phiGamma;
0515
0516
0517 int cPowerCache;
0518 double xsCache, resCache;
0519
0520
0521 vector<ResolvedParton> resolved;
0522
0523
0524 int nInit;
0525 bool hasJunctionBeam;
0526 int junCol[3];
0527
0528
0529 pair <int,int> colSetup;
0530 vector<int> acols, cols;
0531 vector<bool> usedCol,usedAcol;
0532 vector< pair<int,int> > colUpdates;
0533 int nJuncs, nAjuncs, nDiffJuncs;
0534 bool allowBeamJunctions;
0535
0536
0537 double xfModified( int iSkip, int idIn, double x, double Q2) {
0538 xfModPrepData xfData = xfModPrep(iSkip, Q2);
0539 return xfModified(iSkip, idIn, x, Q2, xfData);}
0540 double xfModified( int iSkip, int idIn, double x, double Q2,
0541 xfModPrepData& data);
0542
0543 double xfModified0( int iSkip, int idIn, double x, double Q2);
0544
0545
0546 double xValFrac(int j, double Q2);
0547 double Q2ValFracSav, uValInt, dValInt;
0548
0549
0550 double xCompFrac(double xs);
0551
0552
0553 double xCompDist(double xc, double xs);
0554
0555
0556 int idVal1, idVal2, idVal3;
0557 double zRel, pxRel, pyRel;
0558
0559
0560 void updateSingleCol(int oldCol, int newCol);
0561
0562
0563
0564 int findSingleCol(Event& event, bool isAcol, bool useHardScatters);
0565
0566 };
0567
0568
0569
0570 }
0571
0572 #endif