7 #ifndef Pythia8_PythiaCascade_H 8 #define Pythia8_PythiaCascade_H 10 #include "Pythia8/Pythia.h" 124 bool init(
double eKinMinIn = 0.3,
double enhanceSDtargetIn = 0.5,
125 string initFile =
"../share/Pythia8/setups/InitDefaultMPI.cmnd",
126 bool rapidDecaysIn =
false,
double smallTau0In = 1e-10,
127 bool slowDecays =
true,
bool listFinalOnlyIn =
false) {
131 enhanceSDtarget = enhanceSDtargetIn;
132 rapidDecays = rapidDecaysIn;
133 smallTau0 = smallTau0In;
134 listFinalOnly = listFinalOnlyIn;
142 pythiaMain.
readString(
"ProcessLevel:all = off");
149 pythiaMain.
settings.
flag(
"ParticleDecays:limitTau0", rapidDecays);
150 pythiaMain.
settings.parm(
"ParticleDecays:tau0Max", smallTau0);
154 pythiaMain.
readString(
"Stat:showProcessLevel = off");
155 pythiaMain.
readString(
"Stat:showPartonLevel = off");
158 if (!pythiaMain.
init())
return false;
162 if ( !pythiaColl.
readString(
"include = " + initFile)) {
163 cout <<
"\n Abort: failed to find or read MPI initialization file" 169 pythiaColl.
readString(
"Beams:allowVariableEnergy = on");
170 pythiaColl.
readString(
"Beams:allowIDAswitch = on");
173 eCMMax = pythiaColl.
settings.parm(
"Beams:eCMMaxMPI");
174 pythiaColl.
settings.parm(
"Beams:eCM", eCMMax);
177 pythiaColl.
readString(
"SoftQCD:inelastic = on");
178 pythiaColl.
readString(
"LowEnergyQCD:inelastic = on");
190 pythiaColl.
readString(
"HadronLevel:Decay = off");
195 pythiaColl.
readString(
"Check:epTolErr = 0.01");
196 pythiaColl.
readString(
"Check:epTolWarn = 0.0001");
197 pythiaColl.
readString(
"Check:mTolErr = 0.01");
200 pythiaColl.
readString(
"Stat:showProcessLevel = off");
201 pythiaColl.
readString(
"Stat:showPartonLevel = off");
204 return pythiaColl.
init();
219 static const int nA = 16;
220 static const int tabA[] = {
221 1, 2, 4, 9, 12, 14, 16, 27, 40, 56, 63, 84, 107, 129, 197, 208};
222 static const double tabOffset[] = {
223 0.0000, 0.0510, 0.1164, 0.2036, 0.2328, 0.2520, 0.2624, 0.3190,
224 0.3562, 0.3898, 0.3900, 0.3446, 0.3496, 0.3504, 0.3484, 0.3415 };
225 static const double tabSlope[] = {
226 0.0000,0.00187,0.00496, 0.0107, 0.0136, 0.0152, 0.0169, 0.0243,
227 0.0314, 0.0385, 0.0415, 0.0506, 0.0581, 0.0644, 0.0806, 0.0830 };
228 static const double tabSlopeLo[] = {
229 0.0000,0.00361,0.00884, 0.0174, 0.0210, 0.0233, 0.0252, 0.0340,
230 0.0418, 0.0496, 0.0524, 0.0600, 0.0668, 0.0727, 0.0873, 0.0893 };
232 for (
int i = 0; i < nA; ++i) {
234 return min( 1. + tabSlopeLo[i] * sigmaNow,
235 1. + tabOffset[i] + tabSlope[i] * sigmaNow);
236 }
else if (A < tabA[i]) {
237 double nColl1 = min( tabSlopeLo[i - 1] * sigmaNow,
238 tabOffset[i - 1] + tabSlope[i - 1] * sigmaNow);
239 double nColl2 = min( tabSlopeLo[i] * sigmaNow,
240 tabOffset[i] + tabSlope[i] * sigmaNow);
241 double wt1 = double(tabA[i] - A) / double(tabA[i] - tabA[i - 1]);
242 return 1. + wt1 * pow( A / tabA[i - 1], 2./3.) * nColl1
243 + (1. - wt1) * pow( A / tabA[i], 2./3.) * nColl2;
247 return numeric_limits<double>::quiet_NaN();
258 if (pNowIn.e() - mNowIn < eKinMin)
return false;
261 eCMNow = (pNowIn +
Vec4(0, 0, 0, mp)).mCalc();
262 if (eCMNow > eCMMax) {
263 logger.ERROR_MSG(
"too high energy");
274 sigmaNow = pythiaColl.
getSigmaTotal(idNow, 2212, eCMNow, mNow, mp)
276 if (sigmaNow < 0.001) {
277 if (eCMNow - mNow - mp > eKinMin)
278 logger.WARNING_MSG(
"vanishing cross section");
296 if (A < 1 || A > 208) {
297 logger.ERROR_MSG(
"A is outside of valid range (1 <= A <= 208)");
325 if (Anow < 1 || Anow > 208) {
326 logger.ERROR_MSG(
"A is outside of valid range (1 <= A <= 208)");
331 eventMain.
append(90, -11, 0, 0, 1, 1, 0, 0, pNow, mNow);
332 int iHad = eventMain.
append(idNow, 12, 0, 0, 0, 0, 0, 0, pNow, mNow);
333 eventMain[iHad].vProd(vNow);
337 int nn = Anow - Znow;
340 Vec4 dirNow = pNow / pNow.pAbs();
344 double probMore = (Anow == 2) ?
nCollAvg(Anow) - 1.
349 for (
int iColl = 1; iColl <= Anow; ++iColl) {
350 if (iColl > 1 && rndm.
flat() > probMore)
break;
359 for (
int i = sizeOld; i < sizeNew; ++i)
360 if ( eventMain[i].isFinal() && eventMain[i].isHadron()) {
361 double pp =
dot3(dirNow, eventMain[i].p());
370 || eventMain[iProj].e() - eventMain[iProj].
m() < eKinMin)
break;
374 int idProj = eventMain[iProj].id();
375 bool doProton = rndm.
flat() < (np / double(np + nn));
376 if (doProton) np -= 1;
378 int idNuc = (doProton) ? 2212 : 2112;
381 Vec4 pProj = eventMain[iProj].p();
382 double mTarg = (doProton) ? mp : mn;
383 Vec4 pTarg( 0., 0., 0., mTarg);
384 double eCMPT = (pProj + pTarg).mCalc();
389 mProjMax = max(eventMain[iProj].
m(), pythiaMain.
particleData.m0(idProj));
390 if (sqrt(pProj.pAbs2() +
pow2(mProjMax)) - mProjMax < eKinMin)
break;
397 int codeNow = (iColl > 1 && rndm.
flat() < enhanceSDtarget) ? 4 : 0;
398 if (!pythiaColl.
next(codeNow)) {
404 if (iColl == 1) codeFirstColl = pythiaColl.
info.code();
405 if (iColl == 1) nMPIsave = pythiaColl.
info.
nMPI();
410 eventColl.rotbst( MtoLab);
414 int statusNuc = (iColl == 1) ? -181 : -182;
415 int iNuc = eventMain.
append( idNuc, statusNuc, 0, iProj, 0, 0, 0, 0,
417 eventMain[iNuc].vProdAdd(vNow);
420 eventMain[0].e( eventMain[0].e() + mTarg);
421 eventMain[0].m( eventMain[0].p().mCalc() );
425 sizeOld = eventMain.
size();
426 for (
int iSub = 3; iSub < eventColl.
size(); ++iSub) {
427 if (!eventColl[iSub].isFinal())
continue;
428 int iNew = eventMain.
append(eventColl[iSub]);
429 eventMain[iNew].mothers(iNuc, iProj);
430 eventMain[iNew].vProdAdd(vNow);
432 sizeNew = eventMain.
size();
435 eventMain[iProj].daughters(sizeOld, sizeNew - 1);
436 eventMain[iNuc].daughters(sizeOld, sizeNew - 1);
437 eventMain[iProj].statusNeg();
438 eventMain[iProj].tau(0.);
476 eventColl.
append(90, -11, 0, 0, 1, 1, 0, 0, pNow, mNow);
477 int iHad = eventColl.
append(idNow, 12, 0, 0, 0, 0, 0, 0, pNow, mNow);
478 eventColl[iHad].vProd(vNow);
481 if (!pythiaColl.
moreDecays(iHad))
return eventMain;
482 eventMain = eventColl;
505 int sizeOld = eventMain.
size();
510 for (
int i = 1; i < sizeOld; ++i)
if (eventMain[i].isFinal()) {
511 eventMain[sizeNew] = eventMain[i];
512 eventMain[sizeNew].mothers( 0, 0);
513 eventMain[sizeNew].daughters( 0, 0);
518 eventMain.
popBack( sizeOld - sizeNew);
539 int firstCollisionCode() {
return codeFirstColl;}
541 int firstCollisionMPI() {
return nMPIsave;}
550 Rndm& rndm() {
return pythiaMain.
rndm;}
559 Pythia pythiaMain, pythiaColl;
565 bool rapidDecays, listFinalOnly;
566 int idNow, nCollAcc, codeFirstColl, nMPIsave;
567 double eKinMin, enhanceSDtarget, smallTau0, mp, mn, eCMMax, mNow, mProjMax,
constexpr double pow2(const double &x)
Powers of small integers - for balance speed/code clarity.
Definition: PythiaStdlib.h:175
double nCollAvg(int A)
Definition: PythiaCascade.h:214
bool flag(string keyIn)
Give back current value, with check that key exists.
Definition: Settings.cc:1615
PythiaCascade()=default
Default constructor; all setup is done in init().
Rndm rndm
Random number generator.
Definition: Pythia.h:392
bool readString(string line, bool warn=true, int subrun=SUBRUNDEFAULT)
Read in one update for a setting or particle data from a single line.
Definition: Pythia.h:99
ParticleData particleData
ParticleData: the particle data table/database.
Definition: Pythia.h:389
The Event class holds all info on the generated event.
Definition: Event.h:408
int nMPI() const
Number of multiparton interactions, with code and pT for them.
Definition: Info.h:274
Settings settings
Settings: databases of flags/modes/parms/words to control run.
Definition: Pythia.h:386
void clear()
Clear event record.
Definition: Event.h:428
bool setKinematics(double eCMIn)
Switch beam kinematics.
Definition: Pythia.cc:1387
Event event
The event record for the complete event history.
Definition: Pythia.h:377
bool init()
Initialize.
Definition: Pythia.cc:422
double dot3(const Vec4 &v1, const Vec4 &v2)
Scalar and cross product of 3-vector parts.
Definition: Basics.cc:617
bool moreDecays(bool allowPartons=false)
Special routine to allow more decays if on/off switches changed.
Definition: Pythia.h:304
void stat()
Summary of aborts, errors and warnings.
Definition: PythiaCascade.h:526
double sigmahA(int A)
Definition: PythiaCascade.h:293
bool setBeamIDs(int idAin, int idBin=0)
Switch to new beam particle identities; for similar hadrons only.
Definition: Pythia.cc:1365
int append(Particle entryIn)
Put a new particle at the end of the event record; return index.
Definition: Event.h:462
Event & nextDecay(int idNowIn, Vec4 pNowIn, double mNowIn, Vec4 vNow=Vec4())
Definition: PythiaCascade.h:460
bool sigmaSetuphN(int idNowIn, Vec4 pNowIn, double mNowIn)
Definition: PythiaCascade.h:255
int nCollisions()
Definition: PythiaCascade.h:537
Intended flow:
Definition: PythiaCascade.h:78
void stat()
Main routine to provide final statistics on generation.
Definition: Pythia.cc:1705
void popBack(int nRemove=1)
Remove last n entries.
Definition: Event.h:516
int size() const
Event record size.
Definition: Event.h:459
bool init(double eKinMinIn=0.3, double enhanceSDtargetIn=0.5, string initFile="../share/Pythia8/setups/InitDefaultMPI.cmnd", bool rapidDecaysIn=false, double smallTau0In=1e-10, bool slowDecays=true, bool listFinalOnlyIn=false)
Initialize PythiaCascade for a given maximal incoming energy.
Definition: PythiaCascade.h:124
double getSigmaTotal()
Get total cross section for two hadrons in the event record or standalone.
Definition: Pythia.h:319
Header for classes to set beam momentum and interaction vertex spread.
Definition: Analysis.h:20
The Pythia class contains the top-level routines to generate an event.
Definition: Pythia.h:72
double m(const Vec4 &v1)
Invariant mass and its square.
Definition: Basics.cc:587
void compress()
Definition: PythiaCascade.h:501
double getSigmaPartial(int procTypeIn)
Definition: Pythia.h:335
const Info & info
Public information and statistic on the generation.
Definition: Pythia.h:380
ParticleData & particleData()
Definition: PythiaCascade.h:548
bool next()
Generate the next event.
Definition: Pythia.h:276
double flat()
Generate next random number uniformly between 0 and 1.
Definition: Basics.cc:189
void errorStatistics() const
Print error statistics.
Definition: Logger.h:113
This class holds a map of all ParticleDataEntries.
Definition: ParticleData.h:423
Event & nextColl(int Znow, int Anow, Vec4 vNow=Vec4())
Definition: PythiaCascade.h:315
void fromCMframe(const Vec4 &, const Vec4 &, bool flip=false)
Definition: Basics.cc:984