From 698c0fe6c8b7ae3d64daeaffbe9aaf83b6ee64cb Mon Sep 17 00:00:00 2001
From: "Ewelina.Maria.Lobodzinska" <ewelina.maria.lobodzinska@cern.ch>
Date: Fri, 12 Feb 2021 17:06:04 +0100
Subject: [PATCH] correct QGSJet in analoguos way to Epos and move Pythia8B
 common fragments to correct location

---
 Generators/Pythia8B_i/CMakeLists.txt          |  2 +-
 .../share/{ => common}/BPDGCodes.py           |  0
 .../share/{ => common}/BsToJpsimu0mu0phi.py   |  0
 .../share/{ => common}/BuJpsiK_EvtGen.py      |  0
 .../share/{ => common}/CloseAntiBDecays.py    |  0
 .../share/{ => common}/CloseBDecays.py        |  0
 .../share/{ => common}/OpenBJpsiDecays.py     |  0
 .../common/Pythia8B_A14_CTEQ6L1_Common.py     | 40 ++++++++++++
 .../Pythia8B_A14_CTEQ6L1_EvtGen_Common.py     |  9 +++
 .../common/Pythia8B_A14_NNPDF23LO_Common.py   | 44 +++++++++++++
 .../Pythia8B_A14_NNPDF23LO_EvtGen_Common.py   |  9 +++
 .../share/common/Pythia8B_BPDGCodes.py        |  6 ++
 .../share/common/Pythia8B_Base_Fragment.py    | 16 +++++
 .../common/Pythia8B_Bottomonium_Common.py     | 29 +++++++++
 .../common/Pythia8B_Charmonium_Common.py      | 27 ++++++++
 .../share/common/Pythia8B_CloseAntiBDecays.py | 15 +++++
 .../share/common/Pythia8B_CloseBDecays.py     | 15 +++++
 .../share/common/Pythia8B_EvtGen.py           | 11 ++++
 .../share/common/Pythia8B_OpenBJpsiDecays.py  | 62 +++++++++++++++++++
 .../share/common/Pythia8B_Photospp.py         |  8 +++
 .../common/Pythia8B_exclusiveAntiB_Common.py  | 22 +++++++
 .../common/Pythia8B_exclusiveB_Common.py      | 22 +++++++
 .../Pythia8B_inclusiveAntiBJpsi_Common.py     | 27 ++++++++
 .../common/Pythia8B_inclusiveBJpsi_Common.py  | 26 ++++++++
 .../share/{ => common}/TestPythia8B.py        |  0
 .../share/{ => common}/bbToJpsimu4mu4.py      |  0
 .../share/{ => common}/bbTomu15mu0.py         |  0
 .../share/{ => common}/bbTomu4mu4.py          |  0
 .../share/{ => common}/ccTomu4mu4.py          |  0
 .../share/{ => common}/checkCloningFactor.py  |  0
 .../share/{ => common}/ppToJpsimu0mu0.py      |  0
 .../share/{ => common}/ppToJpsimu4mu4.py      |  0
 Generators/QGSJet_i/CMakeLists.txt            |  3 +-
 Generators/QGSJet_i/QGSJet_i/QGSJet.h         |  7 +--
 .../share/{ => file}/qgsjet_crmc.param        |  0
 Generators/QGSJet_i/src/QGSJet.cxx            |  9 +--
 36 files changed, 399 insertions(+), 10 deletions(-)
 rename Generators/Pythia8B_i/share/{ => common}/BPDGCodes.py (100%)
 rename Generators/Pythia8B_i/share/{ => common}/BsToJpsimu0mu0phi.py (100%)
 rename Generators/Pythia8B_i/share/{ => common}/BuJpsiK_EvtGen.py (100%)
 rename Generators/Pythia8B_i/share/{ => common}/CloseAntiBDecays.py (100%)
 rename Generators/Pythia8B_i/share/{ => common}/CloseBDecays.py (100%)
 rename Generators/Pythia8B_i/share/{ => common}/OpenBJpsiDecays.py (100%)
 create mode 100644 Generators/Pythia8B_i/share/common/Pythia8B_A14_CTEQ6L1_Common.py
 create mode 100644 Generators/Pythia8B_i/share/common/Pythia8B_A14_CTEQ6L1_EvtGen_Common.py
 create mode 100644 Generators/Pythia8B_i/share/common/Pythia8B_A14_NNPDF23LO_Common.py
 create mode 100644 Generators/Pythia8B_i/share/common/Pythia8B_A14_NNPDF23LO_EvtGen_Common.py
 create mode 100644 Generators/Pythia8B_i/share/common/Pythia8B_BPDGCodes.py
 create mode 100644 Generators/Pythia8B_i/share/common/Pythia8B_Base_Fragment.py
 create mode 100644 Generators/Pythia8B_i/share/common/Pythia8B_Bottomonium_Common.py
 create mode 100644 Generators/Pythia8B_i/share/common/Pythia8B_Charmonium_Common.py
 create mode 100644 Generators/Pythia8B_i/share/common/Pythia8B_CloseAntiBDecays.py
 create mode 100644 Generators/Pythia8B_i/share/common/Pythia8B_CloseBDecays.py
 create mode 100644 Generators/Pythia8B_i/share/common/Pythia8B_EvtGen.py
 create mode 100644 Generators/Pythia8B_i/share/common/Pythia8B_OpenBJpsiDecays.py
 create mode 100644 Generators/Pythia8B_i/share/common/Pythia8B_Photospp.py
 create mode 100644 Generators/Pythia8B_i/share/common/Pythia8B_exclusiveAntiB_Common.py
 create mode 100644 Generators/Pythia8B_i/share/common/Pythia8B_exclusiveB_Common.py
 create mode 100644 Generators/Pythia8B_i/share/common/Pythia8B_inclusiveAntiBJpsi_Common.py
 create mode 100644 Generators/Pythia8B_i/share/common/Pythia8B_inclusiveBJpsi_Common.py
 rename Generators/Pythia8B_i/share/{ => common}/TestPythia8B.py (100%)
 rename Generators/Pythia8B_i/share/{ => common}/bbToJpsimu4mu4.py (100%)
 rename Generators/Pythia8B_i/share/{ => common}/bbTomu15mu0.py (100%)
 rename Generators/Pythia8B_i/share/{ => common}/bbTomu4mu4.py (100%)
 rename Generators/Pythia8B_i/share/{ => common}/ccTomu4mu4.py (100%)
 rename Generators/Pythia8B_i/share/{ => common}/checkCloningFactor.py (100%)
 rename Generators/Pythia8B_i/share/{ => common}/ppToJpsimu0mu0.py (100%)
 rename Generators/Pythia8B_i/share/{ => common}/ppToJpsimu4mu4.py (100%)
 rename Generators/QGSJet_i/share/{ => file}/qgsjet_crmc.param (100%)

diff --git a/Generators/Pythia8B_i/CMakeLists.txt b/Generators/Pythia8B_i/CMakeLists.txt
index d55fb351f1f7..22fda1c198df 100644
--- a/Generators/Pythia8B_i/CMakeLists.txt
+++ b/Generators/Pythia8B_i/CMakeLists.txt
@@ -31,5 +31,5 @@ atlas_add_component( Pythia8B_i
                      LINK_LIBRARIES ${Boost_LIBRARIES} ${PYTHIA8_LIBRARIES} ${LHAPDF_LIBRARIES} ${CLHEP_LIBRARIES} AtlasHepMCLib AthenaBaseComps GaudiKernel Pythia8_iLib GeneratorObjects Pythia8B_iLib )
 
 # Install files from the package:
-atlas_install_joboptions( share/*.py )
+atlas_install_joboptions( share/common/*.py )
 
diff --git a/Generators/Pythia8B_i/share/BPDGCodes.py b/Generators/Pythia8B_i/share/common/BPDGCodes.py
similarity index 100%
rename from Generators/Pythia8B_i/share/BPDGCodes.py
rename to Generators/Pythia8B_i/share/common/BPDGCodes.py
diff --git a/Generators/Pythia8B_i/share/BsToJpsimu0mu0phi.py b/Generators/Pythia8B_i/share/common/BsToJpsimu0mu0phi.py
similarity index 100%
rename from Generators/Pythia8B_i/share/BsToJpsimu0mu0phi.py
rename to Generators/Pythia8B_i/share/common/BsToJpsimu0mu0phi.py
diff --git a/Generators/Pythia8B_i/share/BuJpsiK_EvtGen.py b/Generators/Pythia8B_i/share/common/BuJpsiK_EvtGen.py
similarity index 100%
rename from Generators/Pythia8B_i/share/BuJpsiK_EvtGen.py
rename to Generators/Pythia8B_i/share/common/BuJpsiK_EvtGen.py
diff --git a/Generators/Pythia8B_i/share/CloseAntiBDecays.py b/Generators/Pythia8B_i/share/common/CloseAntiBDecays.py
similarity index 100%
rename from Generators/Pythia8B_i/share/CloseAntiBDecays.py
rename to Generators/Pythia8B_i/share/common/CloseAntiBDecays.py
diff --git a/Generators/Pythia8B_i/share/CloseBDecays.py b/Generators/Pythia8B_i/share/common/CloseBDecays.py
similarity index 100%
rename from Generators/Pythia8B_i/share/CloseBDecays.py
rename to Generators/Pythia8B_i/share/common/CloseBDecays.py
diff --git a/Generators/Pythia8B_i/share/OpenBJpsiDecays.py b/Generators/Pythia8B_i/share/common/OpenBJpsiDecays.py
similarity index 100%
rename from Generators/Pythia8B_i/share/OpenBJpsiDecays.py
rename to Generators/Pythia8B_i/share/common/OpenBJpsiDecays.py
diff --git a/Generators/Pythia8B_i/share/common/Pythia8B_A14_CTEQ6L1_Common.py b/Generators/Pythia8B_i/share/common/Pythia8B_A14_CTEQ6L1_Common.py
new file mode 100644
index 000000000000..082c3923884e
--- /dev/null
+++ b/Generators/Pythia8B_i/share/common/Pythia8B_A14_CTEQ6L1_Common.py
@@ -0,0 +1,40 @@
+## Config for Py8B tune A14 with CTEQ6L1
+include("Pythia8B_i/Pythia8B_Base_Fragment.py")
+
+ver =  os.popen("cmt show versions External/Pythia8").read()
+print "Pythia8 version: " + ver
+if 'Pythia8-01' in ver[:50]:
+  genSeq.Pythia8B.Commands += [
+    "Tune:ee = 7", 
+    "Tune:pp = 14",
+    "PDF:useLHAPDF = on",
+    "PDF:LHAPDFset = cteq6ll",
+    "SpaceShower:rapidityOrder = on",
+    "SigmaProcess:alphaSvalue = 0.144",
+    "SpaceShower:pT0Ref = 1.30",
+    "SpaceShower:pTmaxFudge = 0.95",
+    "SpaceShower:pTdampFudge = 1.21",
+    "SpaceShower:alphaSvalue = 0.125",
+    "TimeShower:alphaSvalue = 0.126",
+    "BeamRemnants:primordialKThard = 1.72",
+    "MultipartonInteractions:pT0Ref = 1.98",
+    "MultipartonInteractions:alphaSvalue = 0.118",
+    "BeamRemnants:reconnectRange = 2.08"]
+else:
+  genSeq.Pythia8B.Commands += [
+    "Tune:ee = 7", 
+    "Tune:pp = 14",
+    "PDF:pSet=LHAPDF6:cteq6l1",
+    "SpaceShower:rapidityOrder = on",
+    "SigmaProcess:alphaSvalue = 0.144",
+    "SpaceShower:pT0Ref = 1.30",
+    "SpaceShower:pTmaxFudge = 0.95",
+    "SpaceShower:pTdampFudge = 1.21",
+    "SpaceShower:alphaSvalue = 0.125",
+    "TimeShower:alphaSvalue = 0.126",
+    "BeamRemnants:primordialKThard = 1.72",
+    "MultipartonInteractions:pT0Ref = 1.98",
+    "MultipartonInteractions:alphaSvalue = 0.118",
+    "ColourReconnection:range = 2.08"]
+
+evgenConfig.tune = "A14 CTEQ6L1"
diff --git a/Generators/Pythia8B_i/share/common/Pythia8B_A14_CTEQ6L1_EvtGen_Common.py b/Generators/Pythia8B_i/share/common/Pythia8B_A14_CTEQ6L1_EvtGen_Common.py
new file mode 100644
index 000000000000..b30ef3775b63
--- /dev/null
+++ b/Generators/Pythia8B_i/share/common/Pythia8B_A14_CTEQ6L1_EvtGen_Common.py
@@ -0,0 +1,9 @@
+## Config for Py8B tune A14 with CTEQ6L1 
+## The default version of this tune fragment include EvtGen for standardised b fragmentation
+
+# Reference the non-standard version without EvtGen
+include("Pythia8B_i/Pythia8B_A14_CTEQ6L1_Common.py")
+
+# Add EvtGen for b fragmentation as default.  No EvtGen is available in "nonStandard"
+include("Pythia8B_i/Pythia8B_EvtGen.py")
+
diff --git a/Generators/Pythia8B_i/share/common/Pythia8B_A14_NNPDF23LO_Common.py b/Generators/Pythia8B_i/share/common/Pythia8B_A14_NNPDF23LO_Common.py
new file mode 100644
index 000000000000..f46bd11440b2
--- /dev/null
+++ b/Generators/Pythia8B_i/share/common/Pythia8B_A14_NNPDF23LO_Common.py
@@ -0,0 +1,44 @@
+## Config for Py8B tune A14 with NNPDF23LO
+## This is the version without EvtGen, and as such is not the standard.  
+## The default version is available in common/Pythia8B/Pythia8B_A14_NNPDF23LO_EvtGen_Common.py
+
+include("Pythia8B_i/Pythia8B_Base_Fragment.py")
+
+# todo - replace BeamRemnants with new ColourReconnection syntax once Pythia 8.201 is in place
+ver =  os.popen("cmt show versions External/Pythia8").read()
+print "Pythia8 version: " + ver
+if 'Pythia8-01' in ver[:50]:
+  genSeq.Pythia8B.Commands += [
+    "Tune:ee = 7", 
+    "Tune:pp = 14",
+    "PDF:useLHAPDF = on",
+    "PDF:LHAPDFset = NNPDF23_lo_as_0130_qed",
+    "SpaceShower:rapidityOrder = on",
+    "SigmaProcess:alphaSvalue = 0.140",
+    "SpaceShower:pT0Ref = 1.56",
+    "SpaceShower:pTmaxFudge = 0.91",
+    "SpaceShower:pTdampFudge = 1.05",
+    "SpaceShower:alphaSvalue = 0.127",
+    "TimeShower:alphaSvalue = 0.127",
+    "BeamRemnants:primordialKThard = 1.88",
+    "MultipartonInteractions:pT0Ref = 2.09",
+    "MultipartonInteractions:alphaSvalue = 0.126",
+    "BeamRemnants:reconnectRange  = 1.71"]
+else:
+  genSeq.Pythia8B.Commands += [
+    "Tune:ee = 7",
+    "Tune:pp = 14",
+    "PDF:pSet=LHAPDF6:NNPDF23_lo_as_0130_qed",
+    "SpaceShower:rapidityOrder = on",
+    "SigmaProcess:alphaSvalue = 0.140",
+    "SpaceShower:pT0Ref = 1.56",
+    "SpaceShower:pTmaxFudge = 0.91",
+    "SpaceShower:pTdampFudge = 1.05",
+    "SpaceShower:alphaSvalue = 0.127",
+    "TimeShower:alphaSvalue = 0.127",
+    "BeamRemnants:primordialKThard = 1.88",
+    "MultipartonInteractions:pT0Ref = 2.09",
+    "MultipartonInteractions:alphaSvalue = 0.126",
+    "ColourReconnection:range = 1.71"]
+
+evgenConfig.tune = "A14 NNPDF23LO"
diff --git a/Generators/Pythia8B_i/share/common/Pythia8B_A14_NNPDF23LO_EvtGen_Common.py b/Generators/Pythia8B_i/share/common/Pythia8B_A14_NNPDF23LO_EvtGen_Common.py
new file mode 100644
index 000000000000..3c8d517564e1
--- /dev/null
+++ b/Generators/Pythia8B_i/share/common/Pythia8B_A14_NNPDF23LO_EvtGen_Common.py
@@ -0,0 +1,9 @@
+## Config for Py8B tune A14 with NNPDF23LO
+## The default version of this tune fragment include EvtGen for standardised b fragmentation
+
+# Reference the non-standard version without EvtGen
+include("Pythia8B_i/Pythia8B_A14_NNPDF23LO_Common.py")
+
+# Add EvtGen for b fragmentation as default.  No EvtGen is available in "nonStandard"
+include("Pythia8B_i/Pythia8B_EvtGen.py")
+
diff --git a/Generators/Pythia8B_i/share/common/Pythia8B_BPDGCodes.py b/Generators/Pythia8B_i/share/common/Pythia8B_BPDGCodes.py
new file mode 100644
index 000000000000..85d5c2ae4440
--- /dev/null
+++ b/Generators/Pythia8B_i/share/common/Pythia8B_BPDGCodes.py
@@ -0,0 +1,6 @@
+######################################################
+# BPDGCodes.py
+# List of B-species PDG codes
+######################################################
+
+genSeq.Pythia8B.BPDGCodes = [511,521,531,541,5122,5132,5232,5332,-511,-521,-531,-541,-5122,-5132,-5232,-5332]
diff --git a/Generators/Pythia8B_i/share/common/Pythia8B_Base_Fragment.py b/Generators/Pythia8B_i/share/common/Pythia8B_Base_Fragment.py
new file mode 100644
index 000000000000..10a79d0df97a
--- /dev/null
+++ b/Generators/Pythia8B_i/share/common/Pythia8B_Base_Fragment.py
@@ -0,0 +1,16 @@
+## Base config for Pythia8B
+from Pythia8B_i.Pythia8B_iConf import Pythia8B_i
+genSeq += Pythia8B_i("Pythia8B")
+evgenConfig.generators += ["Pythia8B"]
+
+genSeq.Pythia8B.Commands += [
+    "Main:timesAllowErrors = 500",
+    "6:m0 = 172.5",
+    "23:m0 = 91.1876",
+    "23:mWidth = 2.4952",
+    "24:m0 = 80.399",
+    "24:mWidth = 2.085",
+    "StandardModel:sin2thetaW = 0.23113",
+    "StandardModel:sin2thetaWbar = 0.23146",
+    "ParticleDecays:limitTau0 = on",
+    "ParticleDecays:tau0Max = 10.0"]
diff --git a/Generators/Pythia8B_i/share/common/Pythia8B_Bottomonium_Common.py b/Generators/Pythia8B_i/share/common/Pythia8B_Bottomonium_Common.py
new file mode 100644
index 000000000000..758eea0c2e92
--- /dev/null
+++ b/Generators/Pythia8B_i/share/common/Pythia8B_Bottomonium_Common.py
@@ -0,0 +1,29 @@
+##############################################################
+# Pythia8B_Bottomonium_Common.py
+#
+# Common job options for direct bottomonium production using
+# Pythia8B.
+##############################################################
+
+# Hard process
+genSeq.Pythia8B.Commands += ['PhaseSpace:pTHatMin = 1.'] # Equivalent of CKIN3
+genSeq.Pythia8B.Commands += ['ParticleDecays:mixB = off']
+genSeq.Pythia8B.Commands += ['HadronLevel:all = off']
+
+# Quarkonia production mode
+genSeq.Pythia8B.Commands += ['Bottomonium:all = on']
+genSeq.Pythia8B.Commands += ['PhaseSpace:pTHatMinDiverge = 0.5']
+genSeq.Pythia8B.SuppressSmallPT = True
+genSeq.Pythia8B.pT0timesMPI = 1.
+genSeq.Pythia8B.numberAlphaS = 3.
+genSeq.Pythia8B.useSameAlphaSasMPI = False
+genSeq.Pythia8B.SelectBQuarks = False
+genSeq.Pythia8B.SelectCQuarks = False
+genSeq.Pythia8B.VetoDoubleBEvents = False
+genSeq.Pythia8B.VetoDoubleCEvents = False
+
+# Number of repeat-hadronization loops
+genSeq.Pythia8B.NHadronizationLoops = 1
+
+# List of B-species - for counting purposes (no effect on generation)
+include("Pythia8B_i/Pythia8B_BPDGCodes.py")
diff --git a/Generators/Pythia8B_i/share/common/Pythia8B_Charmonium_Common.py b/Generators/Pythia8B_i/share/common/Pythia8B_Charmonium_Common.py
new file mode 100644
index 000000000000..963bdb364719
--- /dev/null
+++ b/Generators/Pythia8B_i/share/common/Pythia8B_Charmonium_Common.py
@@ -0,0 +1,27 @@
+##############################################################
+# Common job options for direct Pythia8B charmonium production
+##############################################################
+
+# Hard process
+genSeq.Pythia8B.Commands += ['PhaseSpace:pTHatMin = 1.'] # Equivalent of CKIN3
+genSeq.Pythia8B.Commands += ['ParticleDecays:mixB = off']
+genSeq.Pythia8B.Commands += ['HadronLevel:all = off']
+
+# Quarkonia production mode
+genSeq.Pythia8B.Commands += ['Charmonium:all = on']
+genSeq.Pythia8B.Commands += ['PhaseSpace:pTHatMinDiverge = 0.5']
+genSeq.Pythia8B.SuppressSmallPT = True
+genSeq.Pythia8B.pT0timesMPI = 1.
+genSeq.Pythia8B.numberAlphaS = 3.
+genSeq.Pythia8B.useSameAlphaSasMPI = False
+genSeq.Pythia8B.SelectBQuarks = False
+genSeq.Pythia8B.SelectCQuarks = False
+genSeq.Pythia8B.VetoDoubleBEvents = False
+genSeq.Pythia8B.VetoDoubleCEvents = False
+
+# Number of repeat-hadronization loops
+genSeq.Pythia8B.NHadronizationLoops = 1
+
+# List of B-species - for counting purposes (no effect on generation)
+#include("Pythia8B_i/BPDGCodes.py") NB: Not working in MC15, is it a problem??
+
diff --git a/Generators/Pythia8B_i/share/common/Pythia8B_CloseAntiBDecays.py b/Generators/Pythia8B_i/share/common/Pythia8B_CloseAntiBDecays.py
new file mode 100644
index 000000000000..6b44faf0fd72
--- /dev/null
+++ b/Generators/Pythia8B_i/share/common/Pythia8B_CloseAntiBDecays.py
@@ -0,0 +1,15 @@
+######################################################
+# CloseAntiBDecays.py
+# Pythia8_i commands to switch off decays of B 
+# Should be used when exclusive decays are needed from 
+# the anti-B-hadron but not the B-hadron
+######################################################
+
+genSeq.Pythia8B.Commands += ['511:onMode = 2']
+genSeq.Pythia8B.Commands += ['521:onMode = 2']
+genSeq.Pythia8B.Commands += ['531:onMode = 2']
+genSeq.Pythia8B.Commands += ['541:onMode = 2']
+genSeq.Pythia8B.Commands += ['5122:onMode = 3']
+genSeq.Pythia8B.Commands += ['5132:onMode = 3']
+genSeq.Pythia8B.Commands += ['5232:onMode = 3']
+genSeq.Pythia8B.Commands += ['5332:onMode = 3']
diff --git a/Generators/Pythia8B_i/share/common/Pythia8B_CloseBDecays.py b/Generators/Pythia8B_i/share/common/Pythia8B_CloseBDecays.py
new file mode 100644
index 000000000000..12755677141b
--- /dev/null
+++ b/Generators/Pythia8B_i/share/common/Pythia8B_CloseBDecays.py
@@ -0,0 +1,15 @@
+######################################################
+# CloseBDecays.py
+# Pythia8_i commands to switch off decays of anti-B 
+# Should be used when exclusive decays are needed from 
+# the B-hadron but not the anti-B-hadron
+######################################################
+
+genSeq.Pythia8B.Commands += ['511:onMode = 3']
+genSeq.Pythia8B.Commands += ['521:onMode = 3']
+genSeq.Pythia8B.Commands += ['531:onMode = 3']
+genSeq.Pythia8B.Commands += ['541:onMode = 3']
+genSeq.Pythia8B.Commands += ['5122:onMode = 2']
+genSeq.Pythia8B.Commands += ['5132:onMode = 2']
+genSeq.Pythia8B.Commands += ['5232:onMode = 2']
+genSeq.Pythia8B.Commands += ['5332:onMode = 2']
diff --git a/Generators/Pythia8B_i/share/common/Pythia8B_EvtGen.py b/Generators/Pythia8B_i/share/common/Pythia8B_EvtGen.py
new file mode 100644
index 000000000000..9122b249421a
--- /dev/null
+++ b/Generators/Pythia8B_i/share/common/Pythia8B_EvtGen.py
@@ -0,0 +1,11 @@
+## Run EvtGen afterburner on top of Pythia 8B
+assert hasattr(genSeq, "Pythia8B")
+include("EvtGen_i/EvtGen_Fragment.py")
+evgenConfig.auxfiles += ['inclusiveP8DsDPlus.pdt']
+#genSeq.EvtInclusiveDecay.pdtFile = "inclusiveP8.pdt"
+genSeq.EvtInclusiveDecay.pdtFile = "inclusiveP8DsDPlus.pdt"
+
+# FHerwig has problems with omega b* (5334), so not present in the base EvtGen fragment.  Add it here.
+genSeq.EvtInclusiveDecay.whiteList+=[-5334, 5334]
+
+
diff --git a/Generators/Pythia8B_i/share/common/Pythia8B_OpenBJpsiDecays.py b/Generators/Pythia8B_i/share/common/Pythia8B_OpenBJpsiDecays.py
new file mode 100644
index 000000000000..f52a9a482119
--- /dev/null
+++ b/Generators/Pythia8B_i/share/common/Pythia8B_OpenBJpsiDecays.py
@@ -0,0 +1,62 @@
+########################################################
+# OpenBJpsiDecays.py
+# Opens all B->charmonium decays
+# i.e. B->J/psi, psi(2S), chi_c0,1,2,h_c
+########################################################
+
+# B0
+genSeq.Pythia8B.Commands += ['511:onIfAny = 443']
+genSeq.Pythia8B.Commands += ['511:onIfAny = 100443']
+genSeq.Pythia8B.Commands += ['511:onIfAny = 445']
+genSeq.Pythia8B.Commands += ['511:onIfAny = 10441']
+genSeq.Pythia8B.Commands += ['511:onIfAny = 10443']
+genSeq.Pythia8B.Commands += ['511:onIfAny = 20443']
+# B+/-
+genSeq.Pythia8B.Commands += ['521:onIfAny = 443']
+genSeq.Pythia8B.Commands += ['521:onIfAny = 100443']
+genSeq.Pythia8B.Commands += ['521:onIfAny = 445']
+genSeq.Pythia8B.Commands += ['521:onIfAny = 10441']
+genSeq.Pythia8B.Commands += ['521:onIfAny = 10443']
+genSeq.Pythia8B.Commands += ['521:onIfAny = 20443']
+# Bs
+genSeq.Pythia8B.Commands += ['531:onIfAny = 443']
+genSeq.Pythia8B.Commands += ['531:onIfAny = 100443']
+genSeq.Pythia8B.Commands += ['531:onIfAny = 445']
+genSeq.Pythia8B.Commands += ['531:onIfAny = 10441']
+genSeq.Pythia8B.Commands += ['531:onIfAny = 10443']
+genSeq.Pythia8B.Commands += ['531:onIfAny = 20443']
+# Bc
+genSeq.Pythia8B.Commands += ['541:onIfAny = 443']
+genSeq.Pythia8B.Commands += ['541:onIfAny = 100443']
+genSeq.Pythia8B.Commands += ['541:onIfAny = 445']
+genSeq.Pythia8B.Commands += ['541:onIfAny = 10441']
+genSeq.Pythia8B.Commands += ['541:onIfAny = 10443']
+genSeq.Pythia8B.Commands += ['541:onIfAny = 20443']
+# LambdaB
+genSeq.Pythia8B.Commands += ['5122:onIfAny = 443']
+genSeq.Pythia8B.Commands += ['5122:onIfAny = 100443']
+genSeq.Pythia8B.Commands += ['5122:onIfAny = 445']
+genSeq.Pythia8B.Commands += ['5122:onIfAny = 10441']
+genSeq.Pythia8B.Commands += ['5122:onIfAny = 10443']
+genSeq.Pythia8B.Commands += ['5122:onIfAny = 20443']
+# Xb+/-
+genSeq.Pythia8B.Commands += ['5132:onIfAny = 443']
+genSeq.Pythia8B.Commands += ['5132:onIfAny = 100443']
+genSeq.Pythia8B.Commands += ['5132:onIfAny = 445']
+genSeq.Pythia8B.Commands += ['5132:onIfAny = 10441']
+genSeq.Pythia8B.Commands += ['5132:onIfAny = 10443']
+genSeq.Pythia8B.Commands += ['5132:onIfAny = 20443']
+# Xb
+genSeq.Pythia8B.Commands += ['5232:onIfAny = 443']
+genSeq.Pythia8B.Commands += ['5232:onIfAny = 100443']
+genSeq.Pythia8B.Commands += ['5232:onIfAny = 445']
+genSeq.Pythia8B.Commands += ['5232:onIfAny = 10441']
+genSeq.Pythia8B.Commands += ['5232:onIfAny = 10443']
+genSeq.Pythia8B.Commands += ['5232:onIfAny = 20443']
+# Omega_b+/-
+genSeq.Pythia8B.Commands += ['5332:onIfAny = 443']
+genSeq.Pythia8B.Commands += ['5332:onIfAny = 100443']
+genSeq.Pythia8B.Commands += ['5332:onIfAny = 445']
+genSeq.Pythia8B.Commands += ['5332:onIfAny = 10441']
+genSeq.Pythia8B.Commands += ['5332:onIfAny = 10443']
+genSeq.Pythia8B.Commands += ['5332:onIfAny = 20443']
diff --git a/Generators/Pythia8B_i/share/common/Pythia8B_Photospp.py b/Generators/Pythia8B_i/share/common/Pythia8B_Photospp.py
new file mode 100644
index 000000000000..7fbf65596564
--- /dev/null
+++ b/Generators/Pythia8B_i/share/common/Pythia8B_Photospp.py
@@ -0,0 +1,8 @@
+## Photos++ QED config for Pythia8B
+
+## Disable native QED FSR
+assert hasattr(genSeq, "Pythia8B")
+genSeq.Pythia8B.Commands += ["TimeShower:QEDshowerByL = off"]
+
+## Enable Photos++
+include("Photospp_i/Photospp_Fragment.py")
diff --git a/Generators/Pythia8B_i/share/common/Pythia8B_exclusiveAntiB_Common.py b/Generators/Pythia8B_i/share/common/Pythia8B_exclusiveAntiB_Common.py
new file mode 100644
index 000000000000..8bb1feb3d7cf
--- /dev/null
+++ b/Generators/Pythia8B_i/share/common/Pythia8B_exclusiveAntiB_Common.py
@@ -0,0 +1,22 @@
+##############################################################
+# Pythia8B_exclusiveAntiB_Common.py
+#
+# Common job options for exclusive bbar production using
+# Pythia8B.
+##############################################################
+
+# Hard process
+genSeq.Pythia8B.Commands += ['HardQCD:all = on'] # Equivalent of MSEL1
+genSeq.Pythia8B.Commands += ['ParticleDecays:mixB = off']
+genSeq.Pythia8B.Commands += ['HadronLevel:all = off']
+
+# Event selection
+genSeq.Pythia8B.SelectBQuarks = True
+genSeq.Pythia8B.SelectCQuarks = False
+genSeq.Pythia8B.VetoDoubleBEvents = True
+
+# Close B decays and open antiB decays
+include ("Pythia8B_i/Pythia8B_CloseAntiBDecays.py")
+
+# List of B-species
+include("Pythia8B_i/Pythia8B_BPDGCodes.py")
diff --git a/Generators/Pythia8B_i/share/common/Pythia8B_exclusiveB_Common.py b/Generators/Pythia8B_i/share/common/Pythia8B_exclusiveB_Common.py
new file mode 100644
index 000000000000..1b70ccd5f842
--- /dev/null
+++ b/Generators/Pythia8B_i/share/common/Pythia8B_exclusiveB_Common.py
@@ -0,0 +1,22 @@
+##############################################################
+# Pythia8B_exclusiveB_Common.py
+#
+# Common job options for exclusive b production using
+# Pythia8B.
+##############################################################
+
+# Hard process
+genSeq.Pythia8B.Commands += ['HardQCD:all = on'] # Equivalent of MSEL1
+genSeq.Pythia8B.Commands += ['ParticleDecays:mixB = off']
+genSeq.Pythia8B.Commands += ['HadronLevel:all = off']
+
+# Event selection
+genSeq.Pythia8B.SelectBQuarks = True
+genSeq.Pythia8B.SelectCQuarks = False
+genSeq.Pythia8B.VetoDoubleBEvents = True
+
+# Close B decays and open antiB decays
+include("Pythia8B_i/Pythia8B_CloseBDecays.py")
+
+# List of B-species
+include("Pythia8B_i/Pythia8B_BPDGCodes.py")
diff --git a/Generators/Pythia8B_i/share/common/Pythia8B_inclusiveAntiBJpsi_Common.py b/Generators/Pythia8B_i/share/common/Pythia8B_inclusiveAntiBJpsi_Common.py
new file mode 100644
index 000000000000..7d0a6d97b98f
--- /dev/null
+++ b/Generators/Pythia8B_i/share/common/Pythia8B_inclusiveAntiBJpsi_Common.py
@@ -0,0 +1,27 @@
+##############################################################
+# Pythia8B_inclusiveAntiBJpsi_Common.py
+#
+# Common job options for inclusive anti-b->J/psi production using
+# Pythia8B.
+##############################################################
+
+# Hard process
+genSeq.Pythia8B.Commands += ['HardQCD:all = on'] # Equivalent of MSEL1
+genSeq.Pythia8B.Commands += ['ParticleDecays:mixB = off']
+genSeq.Pythia8B.Commands += ['HadronLevel:all = off']
+
+# Event selection
+genSeq.Pythia8B.SelectBQuarks = True
+genSeq.Pythia8B.SelectCQuarks = False
+genSeq.Pythia8B.VetoDoubleBEvents = True
+genSeq.Pythia8B.UserSelection = 'BJPSIINCLUSIVE'
+genSeq.Pythia8B.UserSelectionVariables = [ -1 ]
+
+# Close B decays and open antiB decays
+include ("Pythia8B_i/Pythia8B_CloseAntiBDecays.py")
+
+# Open inclusive B->J/psi decays
+include ("Pythia8B_i/Pythia8B_OpenBJpsiDecays.py")
+
+# List of B-species
+include("Pythia8B_i/Pythia8B_BPDGCodes.py")
diff --git a/Generators/Pythia8B_i/share/common/Pythia8B_inclusiveBJpsi_Common.py b/Generators/Pythia8B_i/share/common/Pythia8B_inclusiveBJpsi_Common.py
new file mode 100644
index 000000000000..bef29b03ef97
--- /dev/null
+++ b/Generators/Pythia8B_i/share/common/Pythia8B_inclusiveBJpsi_Common.py
@@ -0,0 +1,26 @@
+##############################################################
+# Pythia8B_inclusiveBJpsi_Common.py
+#
+# Common job options for inclusive b->J/psi production using
+# Pythia8B.
+##############################################################
+
+# Hard process
+genSeq.Pythia8B.Commands += ['HardQCD:all = on'] # Equivalent of MSEL1
+genSeq.Pythia8B.Commands += ['ParticleDecays:mixB = off']
+genSeq.Pythia8B.Commands += ['HadronLevel:all = off']
+
+# Event selection
+genSeq.Pythia8B.SelectBQuarks = True
+genSeq.Pythia8B.SelectCQuarks = False
+genSeq.Pythia8B.VetoDoubleBEvents = True
+genSeq.Pythia8B.UserSelection = 'BJPSIINCLUSIVE'
+
+# Close B decays and open antiB decays
+include ("Pythia8B_i/Pythia8B_CloseBDecays.py")
+
+# Open inclusive B->J/psi decays
+include ("Pythia8B_i/Pythia8B_OpenBJpsiDecays.py")
+
+# List of B-species
+include("Pythia8B_i/Pythia8B_BPDGCodes.py")
diff --git a/Generators/Pythia8B_i/share/TestPythia8B.py b/Generators/Pythia8B_i/share/common/TestPythia8B.py
similarity index 100%
rename from Generators/Pythia8B_i/share/TestPythia8B.py
rename to Generators/Pythia8B_i/share/common/TestPythia8B.py
diff --git a/Generators/Pythia8B_i/share/bbToJpsimu4mu4.py b/Generators/Pythia8B_i/share/common/bbToJpsimu4mu4.py
similarity index 100%
rename from Generators/Pythia8B_i/share/bbToJpsimu4mu4.py
rename to Generators/Pythia8B_i/share/common/bbToJpsimu4mu4.py
diff --git a/Generators/Pythia8B_i/share/bbTomu15mu0.py b/Generators/Pythia8B_i/share/common/bbTomu15mu0.py
similarity index 100%
rename from Generators/Pythia8B_i/share/bbTomu15mu0.py
rename to Generators/Pythia8B_i/share/common/bbTomu15mu0.py
diff --git a/Generators/Pythia8B_i/share/bbTomu4mu4.py b/Generators/Pythia8B_i/share/common/bbTomu4mu4.py
similarity index 100%
rename from Generators/Pythia8B_i/share/bbTomu4mu4.py
rename to Generators/Pythia8B_i/share/common/bbTomu4mu4.py
diff --git a/Generators/Pythia8B_i/share/ccTomu4mu4.py b/Generators/Pythia8B_i/share/common/ccTomu4mu4.py
similarity index 100%
rename from Generators/Pythia8B_i/share/ccTomu4mu4.py
rename to Generators/Pythia8B_i/share/common/ccTomu4mu4.py
diff --git a/Generators/Pythia8B_i/share/checkCloningFactor.py b/Generators/Pythia8B_i/share/common/checkCloningFactor.py
similarity index 100%
rename from Generators/Pythia8B_i/share/checkCloningFactor.py
rename to Generators/Pythia8B_i/share/common/checkCloningFactor.py
diff --git a/Generators/Pythia8B_i/share/ppToJpsimu0mu0.py b/Generators/Pythia8B_i/share/common/ppToJpsimu0mu0.py
similarity index 100%
rename from Generators/Pythia8B_i/share/ppToJpsimu0mu0.py
rename to Generators/Pythia8B_i/share/common/ppToJpsimu0mu0.py
diff --git a/Generators/Pythia8B_i/share/ppToJpsimu4mu4.py b/Generators/Pythia8B_i/share/common/ppToJpsimu4mu4.py
similarity index 100%
rename from Generators/Pythia8B_i/share/ppToJpsimu4mu4.py
rename to Generators/Pythia8B_i/share/common/ppToJpsimu4mu4.py
diff --git a/Generators/QGSJet_i/CMakeLists.txt b/Generators/QGSJet_i/CMakeLists.txt
index 0f71dd037f34..428131090d84 100644
--- a/Generators/QGSJet_i/CMakeLists.txt
+++ b/Generators/QGSJet_i/CMakeLists.txt
@@ -29,7 +29,8 @@ atlas_add_component( QGSJet_i
                      LINK_LIBRARIES ${CRMC_LIBRARIES} ${CLHEP_LIBRARIES} AtlasHepMCLib AtlasHepMCfioLib GeneratorModulesLib AthenaKernel GaudiKernel TruthUtils QGSJet_iLib )
 
 # Install files from the package:
-atlas_install_runtime( share/qgsjet_crmc.param )
+# atlas_install_joboptions( share/common/*.py )
+atlas_install_runtime( share/file/qgsjet_crmc.param )
 
 atlas_install_runtime( ${CRMC_LCGROOT}/tabs/sectnu-II-04
    ${CRMC_LCGROOT}/tabs/qgsdat-II-04.lzma )
diff --git a/Generators/QGSJet_i/QGSJet_i/QGSJet.h b/Generators/QGSJet_i/QGSJet_i/QGSJet.h
index d15def94eeb4..3f26ce899ef2 100644
--- a/Generators/QGSJet_i/QGSJet_i/QGSJet.h
+++ b/Generators/QGSJet_i/QGSJet_i/QGSJet.h
@@ -1,11 +1,12 @@
 /*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 
 #ifndef GENERATORMODULESQGSJET_H
 #define GENERATORMODULESQGSJET_H
 
 #include "GeneratorModules/GenModule.h"
+#include "AtlasHepMC/HEPEVT_Wrapper.h"
 
 /**
 @class Epos
@@ -51,9 +52,7 @@ protected:
   int         m_ilheout;
   int         m_nEvents;
 
-    // max number of particles MUST BE EQUAL TO THE NUMBER SET IN crmc-aaa.f! (it is max. number allowed by HepMC2.6 now)
- static const size_t kMaxParticles = 10000; 
-//  static const size_t kMaxParticles = HEPEVT_SIZE_REPLACE;
+  static const size_t kMaxParticles = HEPEVT_EntriesAllocation; 
   int   m_partID[ kMaxParticles ];
   double m_partPx[ kMaxParticles ];
   double m_partPy[ kMaxParticles ];
diff --git a/Generators/QGSJet_i/share/qgsjet_crmc.param b/Generators/QGSJet_i/share/file/qgsjet_crmc.param
similarity index 100%
rename from Generators/QGSJet_i/share/qgsjet_crmc.param
rename to Generators/QGSJet_i/share/file/qgsjet_crmc.param
diff --git a/Generators/QGSJet_i/src/QGSJet.cxx b/Generators/QGSJet_i/src/QGSJet.cxx
index 5ebdae65e64e..03dcec3ae657 100644
--- a/Generators/QGSJet_i/src/QGSJet.cxx
+++ b/Generators/QGSJet_i/src/QGSJet.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 
 // ---------------------------------------------------------------------- 
@@ -19,7 +19,6 @@
 #include "CLHEP/Random/RandFlat.h"
 #include "AthenaKernel/IAtRndmGenSvc.h"
 
-#include "AtlasHepMC/HEPEVT_Wrapper.h"
 #include "AtlasHepMC/IO_HEPEVT.h"
 
 
@@ -210,7 +209,9 @@ StatusCode QGSJet::genInitialize()
 
   std::cout << "parameters " << m_nEvents << " " << iSeed << " " << m_beamMomentum << " " << m_targetMomentum << " " << m_primaryParticle << " " << m_targetParticle << " " << m_model << " " << m_itab << " " << m_ilheout << " " <<  m_lheout.c_str()<< " " <<  m_paramFile.c_str() << std::endl;
 
-  crmc_set_f_(m_nEvents, iSeed, m_beamMomentum, m_targetMomentum, m_primaryParticle, m_targetParticle, m_model, m_itab, m_ilheout,  m_paramFile.c_str() ); 
+//  crmc_set_f_(m_nEvents, iSeed, m_beamMomentum, m_targetMomentum, m_primaryParticle, m_targetParticle, m_model, m_itab, m_ilheout,  m_paramFile.c_str() ); 
+
+  crmc_set_f_(m_nEvents, iSeed, m_beamMomentum, m_targetMomentum, m_primaryParticle, m_targetParticle, m_model, m_itab, m_ilheout, (m_paramFile + " ").c_str() );
 
     // initialize QGSJet
   //  crmc_init_f_( iSeed, m_beamMomentum, m_targetMomentum, m_primaryParticle, m_targetParticle, m_model, m_paramFile.c_str() );
@@ -228,7 +229,7 @@ StatusCode QGSJet::genInitialize()
 #else
     HepMC::HEPEVT_Wrapper::set_sizeof_int(sizeof( int ));
     HepMC::HEPEVT_Wrapper::set_sizeof_real( 8 );
-    HepMC::HEPEVT_Wrapper::set_max_number_entries(10000);    // as used in crmc-aaa.f!!!
+    HepMC::HEPEVT_Wrapper::set_max_number_entries(kMaxParticles);
 #endif
 
   m_events = 0;
-- 
GitLab