File indexing completed on 2025-01-18 10:06:40
0001
0002
0003
0004
0005
0006
0007 #ifndef Pythia8_PythiaCascade_H
0008 #define Pythia8_PythiaCascade_H
0009
0010 #include "Pythia8/Pythia.h"
0011
0012 namespace Pythia8 {
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061 class PythiaCascade {
0062
0063 public:
0064
0065
0066 PythiaCascade() = default;
0067
0068
0069
0070
0071
0072
0073
0074
0075
0076
0077
0078
0079
0080
0081
0082
0083
0084
0085
0086
0087
0088
0089 bool init(double eMaxIn = 1e9, bool listFinalIn = false,
0090 bool rapidDecaysIn = false, double smallTau0In = 1e-10,
0091 bool reuseMPI = true, string initFile = "pythiaCascade.mpi") {
0092
0093
0094 eMax = eMaxIn;
0095 listFinal = listFinalIn;
0096 rapidDecays = rapidDecaysIn;
0097 smallTau0 = smallTau0In;
0098
0099
0100 mp = pythiaMain.particleData.m0(2212);
0101
0102
0103
0104 pythiaMain.readString("ProcessLevel:all = off");
0105 pythiaMain.readString("13:mayDecay = on");
0106 pythiaMain.readString("211:mayDecay = on");
0107 pythiaMain.readString("321:mayDecay = on");
0108 pythiaMain.readString("130:mayDecay = on");
0109 pythiaMain.settings.flag("ParticleDecays:limitTau0", rapidDecays);
0110 pythiaMain.settings.parm("ParticleDecays:tau0Max", smallTau0);
0111
0112
0113 pythiaMain.readString("Stat:showProcessLevel = off");
0114 pythiaMain.readString("Stat:showPartonLevel = off");
0115
0116
0117 if (!pythiaMain.init()) return false;
0118
0119
0120
0121 pythiaColl.readString("Beams:allowVariableEnergy = on");
0122 pythiaColl.readString("Beams:allowIDAswitch = on");
0123
0124
0125 pythiaColl.readString("Beams:frameType = 3");
0126 pythiaColl.settings.parm("Beams:pzA", eMax);
0127 pythiaColl.readString("Beams:pzB = 0.");
0128
0129
0130 pythiaColl.readString("SoftQCD:all = on");
0131 pythiaColl.readString("LowEnergyQCD:all = on");
0132
0133
0134
0135 pythiaColl.readString("13:mayDecay = on");
0136 pythiaColl.readString("211:mayDecay = on");
0137 pythiaColl.readString("321:mayDecay = on");
0138 pythiaColl.readString("130:mayDecay = on");
0139
0140
0141 pythiaColl.readString("HadronLevel:Decay = off");
0142
0143
0144
0145 pythiaColl.readString("Print:quiet = on");
0146 pythiaColl.readString("Check:epTolErr = 0.01");
0147 pythiaColl.readString("Check:epTolWarn = 0.0001");
0148 pythiaColl.readString("Check:mTolErr = 0.01");
0149
0150
0151 pythiaColl.readString("Stat:showProcessLevel = off");
0152 pythiaColl.readString("Stat:showPartonLevel = off");
0153
0154
0155 if (reuseMPI)
0156 pythiaColl.readString("MultipartonInteractions:reuseInit = 3");
0157 else pythiaColl.readString("MultipartonInteractions:reuseInit = 1");
0158 pythiaColl.settings.word("MultipartonInteractions:initFile", initFile);
0159
0160
0161 if (!pythiaColl.init()) return false;
0162 return true;
0163
0164 }
0165
0166
0167
0168
0169
0170
0171
0172 double nCollAvg(int A) {
0173 for (int i = 0; i < nA; ++i) {
0174 if (A == tabA[i]) {
0175 return (sigmaNow < tabBorder) ? 1. + tabSlopeLo[i] * sigmaNow
0176 : 1. + tabOffset[i] + tabSlope[i] * sigmaNow;
0177 } else if (A < tabA[i]) {
0178 double nColl1 = (sigmaNow < tabBorder) ? tabSlopeLo[i - 1] * sigmaNow
0179 : tabOffset[i - 1] + tabSlope[i - 1] * sigmaNow;
0180 double nColl2 = (sigmaNow < tabBorder) ? tabSlopeLo[i] * sigmaNow
0181 : tabOffset[i] + tabSlope[i] * sigmaNow;
0182 double wt1 = (tabA[i] - A) / (tabA[i] - tabA[i - 1]);
0183 return 1. + wt1 * pow( A / tabA[i - 1], 2./3.) * nColl1
0184 + (1. - wt1) * pow( A / tabA[i], 2./3.) * nColl2;
0185 }
0186 }
0187
0188 return numeric_limits<double>::quiet_NaN();
0189 }
0190
0191
0192
0193
0194
0195
0196 bool sigmaSetuphN(int idNowIn, Vec4 pNowIn, double mNowIn) {
0197
0198
0199 if (pNowIn.e() - mNowIn < eKinMin) return false;
0200
0201
0202 if (pNowIn.e() > eMax) {
0203 logger.ERROR_MSG("too high energy");
0204 return false;
0205 }
0206
0207
0208 idNow = idNowIn;
0209 pNow = pNowIn;
0210 mNow = mNowIn;
0211
0212
0213
0214 eCMNow = (pNow + Vec4(0, 0, 0, mp)).mCalc();
0215 sigmaNow = pythiaColl.getSigmaTotal(idNow, 2212, eCMNow, mNow, mp);
0216 if (sigmaNow <= 0.) {
0217 if (eCMNow - mNow - mp > eKinMin)
0218 logger.ERROR_MSG("vanishing cross section");
0219 return false;
0220 }
0221
0222
0223 return true;
0224
0225 }
0226
0227
0228
0229
0230
0231
0232
0233 double sigmahA(int A) {
0234
0235
0236 if (A < 1 || A > 208) {
0237 logger.ERROR_MSG("A is outside of valid range (1 <= A <= 208)");
0238 return 0.;
0239 }
0240
0241
0242
0243 double sigmahA = A * sigmaNow / nCollAvg(A);
0244
0245
0246 return sigmahA;
0247
0248 }
0249
0250
0251
0252
0253
0254
0255 Event& nextColl(int Znow, int Anow, Vec4 vNow = Vec4() ) {
0256
0257
0258 Event& eventMain = pythiaMain.event;
0259 Event& eventColl = pythiaColl.event;
0260 eventMain.clear();
0261
0262
0263 if (Anow < 1 || Anow > 208) {
0264 logger.ERROR_MSG("A is outside of valid range (1 <= A <= 208)");
0265 return eventMain;
0266 }
0267
0268
0269 eventMain.append(90, -11, 0, 0, 1, 1, 0, 0, pNow, mNow);
0270 int iHad = eventMain.append(idNow, 12, 0, 0, 0, 0, 0, 0, pNow, mNow);
0271 eventMain[iHad].vProd(vNow);
0272
0273
0274 int np = Znow;
0275 int nn = Anow - Znow;
0276 int sizeOld = 0;
0277 int sizeNew = 0;
0278 Vec4 dirNow = pNow / pNow.pAbs();
0279 Rndm& rndm = pythiaMain.rndm;
0280
0281
0282 double probMore = 1. - 1. / nCollAvg(Anow);
0283
0284
0285 for (int iColl = 1; iColl <= Anow; ++iColl) {
0286 if (iColl > 1 && rndm.flat() > probMore) break;
0287
0288
0289 int iProj = iHad;
0290 int procType = 0;
0291
0292
0293 if (iColl > 1) {
0294 iProj = 0;
0295 double pMax = 0.;
0296 for (int i = sizeOld; i < sizeNew; ++i)
0297 if ( eventMain[i].isFinal() && eventMain[i].isHadron()) {
0298 double pp = dot3(dirNow, eventMain[i].p());
0299 if (pp > pMax) {
0300 iProj = i;
0301 pMax = pp;
0302 }
0303 }
0304
0305
0306 if ( iProj == 0 || eventMain[iProj].e() - eventMain[iProj].m()
0307 < eKinMin) break;
0308
0309
0310 double eCMSub = (eventMain[iProj].p() + Vec4(0, 0, 0, mp)).mCalc();
0311 if (eCMSub > 10.) procType = (rndm.flat() < probSD) ? 4 : 1;
0312 }
0313
0314
0315 int idProj = eventMain[iProj].id();
0316 bool doProton = rndm.flat() < (np / double(np + nn));
0317 if (doProton) np -= 1;
0318 else nn -= 1;
0319 int idNuc = (doProton) ? 2212 : 2112;
0320
0321
0322 pythiaColl.setBeamIDs(idProj, idNuc);
0323 pythiaColl.setKinematics(eventMain[iProj].p(), Vec4());
0324 if (!pythiaColl.next(procType)) {
0325 eventMain.clear();
0326 return eventMain;
0327 }
0328
0329
0330
0331 int statusNuc = (iColl == 1) ? -181 : -182;
0332 int iNuc = eventMain.append( idNuc, statusNuc, 0, iProj, 0, 0, 0, 0,
0333 0., 0., 0., mp, mp);
0334 eventMain[iNuc].vProdAdd(vNow);
0335
0336
0337 eventMain[0].e( eventMain[0].e() + mp);
0338 eventMain[0].m( eventMain[0].p().mCalc() );
0339
0340
0341
0342 sizeOld = eventMain.size();
0343 for (int iSub = 3; iSub < eventColl.size(); ++iSub) {
0344 if (!eventColl[iSub].isFinal()) continue;
0345 int iNew = eventMain.append(eventColl[iSub]);
0346 eventMain[iNew].mothers(iNuc, iProj);
0347 eventMain[iNew].vProdAdd(vNow);
0348 }
0349 sizeNew = eventMain.size();
0350
0351
0352 eventMain[iProj].daughters(sizeOld, sizeNew - 1);
0353 eventMain[iNuc].daughters(sizeOld, sizeNew - 1);
0354 eventMain[iProj].statusNeg();
0355 eventMain[iProj].tau(0.);
0356
0357
0358 }
0359
0360
0361 if (rapidDecays) pythiaMain.moreDecays();
0362
0363
0364 if (listFinal) compress();
0365
0366
0367 return eventMain;
0368
0369 }
0370
0371
0372
0373
0374
0375
0376 Event& nextDecay(int idNowIn, Vec4 pNowIn, double mNowIn,
0377 Vec4 vNow = Vec4() ) {
0378
0379
0380
0381 idNow = idNowIn;
0382 pNow = pNowIn;
0383 mNow = mNowIn;
0384
0385
0386 Event& eventMain = pythiaMain.event;
0387 Event& eventColl = pythiaColl.event;
0388 eventMain.clear();
0389 eventColl.clear();
0390
0391
0392 eventColl.append(90, -11, 0, 0, 1, 1, 0, 0, pNow, mNow);
0393 int iHad = eventColl.append(idNow, 12, 0, 0, 0, 0, 0, 0, pNow, mNow);
0394 eventColl[iHad].vProd(vNow);
0395
0396
0397 if (!pythiaColl.moreDecays(iHad)) return eventMain;
0398 eventMain = eventColl;
0399
0400
0401 if (rapidDecays) pythiaMain.moreDecays();
0402
0403
0404 if (listFinal) compress();
0405
0406
0407 return eventMain;
0408
0409 }
0410
0411
0412
0413
0414
0415
0416
0417 void compress() {
0418
0419
0420 Event& eventMain = pythiaMain.event;
0421 int sizeOld = eventMain.size();
0422 int sizeNew = 1;
0423
0424
0425
0426 for (int i = 1; i < sizeOld; ++i) if (eventMain[i].isFinal()) {
0427 eventMain[sizeNew] = eventMain[i];
0428 eventMain[sizeNew].mothers( 0, 0);
0429 eventMain[sizeNew].daughters( 0, 0);
0430 ++sizeNew;
0431 }
0432
0433
0434 eventMain.popBack( sizeOld - sizeNew);
0435
0436 }
0437
0438
0439
0440
0441
0442 void stat() {
0443 pythiaMain.stat();
0444 pythiaColl.stat();
0445 logger.errorStatistics();
0446 }
0447
0448
0449
0450
0451
0452
0453 ParticleData& particleData() {return pythiaMain.particleData;}
0454
0455 Rndm& rndm() {return pythiaMain.rndm;}
0456
0457
0458
0459 private:
0460
0461
0462
0463
0464 Pythia pythiaMain, pythiaColl;
0465
0466
0467 Logger logger;
0468
0469
0470 bool listFinal, rapidDecays;
0471 int idNow;
0472 double eMax, smallTau0, mp, mNow, eCMNow, sigmaNow;
0473 Vec4 pNow;
0474
0475
0476 static constexpr double probSD = 0.3;
0477
0478
0479
0480 static constexpr double eKinMin = 0.2;
0481
0482
0483
0484
0485 static constexpr int nA = 16;
0486 static constexpr double tabBorder = 20.;
0487 static const double tabA[nA];
0488 static const double tabOffset[nA];
0489 static const double tabSlope[nA];
0490 static const double tabSlopeLo[nA];
0491
0492 };
0493
0494
0495 const double PythiaCascade::tabA[] = {1, 2, 4, 9, 12, 14, 16, 27, 40, 56,
0496 63, 84, 107, 129, 197, 208};
0497 const double PythiaCascade::tabOffset[] = {0., 0.03, 0.08, 0.15, 0.20, 0.20,
0498 0.20, 0.26, 0.30, 0.34, 0.40, 0.40, 0.40, 0.50, 0.50, 0.60};
0499 const double PythiaCascade::tabSlope[] = {0., 0.0016, 0.0033, 0.0075, 0.0092,
0500 0.0105, 0.012, 0.017, 0.022, 0.027, 0.028, 0.034, 0.040, 0.044, 0.055,
0501 0.055};
0502 const double PythiaCascade::tabSlopeLo[] = {0., 0.0031, 0.0073, 0.015, 0.0192,
0503 0.0205, 0.022, 0.03, 0.037, 0.044, 0.048, 0.054, 0.06, 0.069, 0.08, 0.085};
0504
0505
0506
0507 }
0508
0509 #endif