Skip to content

Commit

Permalink
add PYTHIA to all processes
Browse files Browse the repository at this point in the history
  • Loading branch information
Dirk Zerwas committed Jul 9, 2024
1 parent b400946 commit 57d24eb
Show file tree
Hide file tree
Showing 20 changed files with 289 additions and 28 deletions.
1 change: 1 addition & 0 deletions examples/PhotonProduction.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Generators:
- Babayaga
- Whizard
- Madgraph
- Pythia

OutputFormat: hepmc3
OutDir: Run-Cards
Expand Down
1 change: 1 addition & 0 deletions examples/TTbarProduction.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ Generators:
- Sherpa
- Whizard
- Madgraph
- Pythia

OutputFormat: hepmc3
OutDir: Run-Cards
Expand Down
1 change: 1 addition & 0 deletions examples/ZHDecay.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ Generators:
- Sherpa
- Whizard
- Madgraph
- Pythia

OutputFormat: hepmc3
OutDir: Run-Cards
Expand Down
1 change: 1 addition & 0 deletions examples/ZHProduction.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ Generators:
- Sherpa
- Whizard
- Madgraph
- Pythia

OutputFormat: hepmc3
OutDir: Run-Cards
Expand Down
53 changes: 26 additions & 27 deletions python/Generators/Pythia.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,22 @@ def __init__(self, procinfo, settings):
def write_run(self):

self.run=""
self.add_run_option("Random:setSeed", "on")
self.add_run_option("Random:seed", self.procinfo.get_rndmSeed())
self.add_option("Random:setSeed", "on")
self.add_option("Random:seed", self.procinfo.get_rndmSeed())

self.add_run_option("Beams:eCM",self.procinfo.get("sqrts"))
self.add_option("Beams:eCM",self.procinfo.get("sqrts"))
beam1_pdg = self.procinfo.get_beam_flavour(1)
beam2_pdg = self.procinfo.get_beam_flavour(2)

self.add_run_option("Beams:idA", beam1_pdg)
self.add_run_option("Beams:idB", beam2_pdg)
self.add_option("Beams:idA", beam1_pdg)
self.add_option("Beams:idB", beam2_pdg)

if self.procinfo.get("isrmode"):
self.add_run_option("PartonLevel:ISR", "on")
self.add_option("PartonLevel:ISR", "on")
else:
self.add_run_option("PartonLevel:ISR", "off")
self.add_option("PartonLevel:ISR", "off")

self.add_run_option("Main:numberOfEvents", self.procinfo.get("events"))
self.add_option("Main:numberOfEvents", self.procinfo.get("events"))
self.run += "\n"
for p in self.procinfo.get_data_particles():
for attr in dir(p):
Expand All @@ -51,20 +51,19 @@ def write_run(self):
op_name = f"{p.get('pdg_code')}:{name}"
if op_name in self.procDB.get_run_out():
self.procDB.remove_option(op_name)
self.add_run_option(op_name, value)
self.add_option(op_name, value)

if "hepmc" in self.procinfo.get("output_format"):
self.add_run_option("Main:WriteHepMC", "on")
self.add_option("Main:WriteHepMC", "on")
outputFile = "{0}.{1}".format(self.GeneratorDatacardBase,self.procinfo.get("output_format"))
self.add_run_option("Main:HepMCFile",outputFile)
self.add_option("Main:HepMCFile",outputFile)

self.run += self.procDB.get_run_out()
self.run += self.procDB.get_proc_out()

if self.gen_settings is not None:
if "run" in self.gen_settings.keys():
for key,value in self.gen_settings["run"].items():
self.add_run_option(key, value)
for key,value in self.gen_settings.items():
self.add_option(key, value)

def write_decay(self):
if self.procinfo.get("decay"):
Expand Down Expand Up @@ -161,14 +160,16 @@ def add_decay(self):
# Pythia turn off parent, then turn on
decays=""
for parent in self.procinfo.get_final_pdg_list():
decays += f"{parent}:onMode off"
self.remove_option(f"{parent}:onMode")
self.remove_option(f"{parent}:onIfAny")
decays += f"{parent}:onMode off\n"
child = decay_opt[parent]
decays += f"{parent}:onIfAny "
for c in child:
decays += f"{c} "
decays+="\n"
self.ptext += "\n"
self.ptext += decays
self.run += "\n"
self.run += decays

def write_file(self):
self.write_run()
Expand All @@ -185,22 +186,20 @@ def write_key4hepfile(self):

self.write_Key4hepScript(key4hepRun)

def add_run_option(self, key, value):
def add_option(self, key, value):
if self.gen_settings is not None:
if "run" in self.gen_settings.keys():
if key in self.gen_settings["run"]:
value = self.gen_settings["run"][key]
if key in self.gen_settings.items():
value = self.gen_settings.items()[key]
if key in self.run:
if str(value) in self.run:
return
self.remove_option(key)
return
self.run += f"{key} = {value}\n"

def add_process_option(self, key, value):
if key in self.ptext:
print(f"{key} has already been defined in {self.name}.")
return
self.ptext += f"{key} = {value}\n"
def remove_option(self,opt):
lines = self.run.split("\n")
filter_lines = [line for line in lines if opt not in line]
self.run = "\n".join(filter_lines)

def is_pythia_particle_data(self, d):
name = None
Expand Down
7 changes: 6 additions & 1 deletion python/Generators/PythiaProcDB.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ def write_DBInfo(self):
self.write_Difermion(15)
elif label == "16_16":
self.write_Difermion(16)
elif label == "22_22":
self.write_Diphoton()
elif label == "23_25":
self.write_run_ZH()

Expand All @@ -58,13 +60,16 @@ def write_Difermion(self,pdg):
self.procout += "23:onMode = off\n"
self.procout += f"23:onIfAny = {pdg}\n"

def write_Diphoton(self):
self.procout = "PromptPhoton:ffbar2gammagamma = on\n"

def write_run_ZH(self):
self.procout = "HiggsSM:ffbar2HZ = on\n"
self.procout += "25:onMode = on\n"
self.procout += "23:onMode = on\n"

def write_Ditop(self):
self.procout = "Top:ffbar2ttbar = on\n"
self.procout = "Top:ffbar2ttbar(s:gmZ) = on\n"
self.procout += "6:onMode = on\n"

def get_run_out(self):
Expand Down
24 changes: 24 additions & 0 deletions test/ref-results/Pythia/Photon91.0/Photon91.0.dat
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
Random:setSeed = on
Random:seed = 4711
Beams:eCM = 91.0
Beams:idA = 11
Beams:idB = -11
PartonLevel:ISR = off
Main:numberOfEvents = 10000

23:m0 = 91.1876
23:mWidth = 2.4952
Main:WriteHepMC = on
Main:HepMCFile = Photon91.0.hepmc3
Main:timesAllowErrors = 5 ! allow a few failures before quitting
Init:showChangedSettings = on ! list changed settings
Init:showChangedParticleData = on ! list changed particle data
Next:numberCount = 1000 ! print message every n events
Next:numberShowInfo = 1 ! print event information n times
Next:numberShowProcess = 1 ! print process record n times
Next:numberShowEvent = 1 ! print event record n times
PDF:lepton = off ! no radiation off ficititious e+e-
211:mayDecay = true ! pi+-
321:mayDecay = true ! K+-
130:mayDecay = true ! K0_L
PromptPhoton:ffbar2gammagamma = on
7 changes: 7 additions & 0 deletions test/ref-results/Pythia/Photon91.0/Run_Photon91.0.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash
if [ -z "${KEY4HEP_STACK}" ]; then
source /cvmfs/sw-nightlies.hsf.org/key4hep/setup.sh
fi

$PYTHIA8RUNNER/pythiaRunner -f Photon91.0.dat
$CONVERTHEPMC2EDM4HEP/convertHepMC2EDM4HEP -i hepmc3 -o edm4hep Photon91.0.hepmc3 Photon91.0.edm4hep
7 changes: 7 additions & 0 deletions test/ref-results/Pythia/Top1000/Run_Top1000_ISR.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash
if [ -z "${KEY4HEP_STACK}" ]; then
source /cvmfs/sw-nightlies.hsf.org/key4hep/setup.sh
fi

$PYTHIA8RUNNER/pythiaRunner -f Top1000_ISR.dat
$CONVERTHEPMC2EDM4HEP/convertHepMC2EDM4HEP -i hepmc3 -o edm4hep Top1000_ISR.hepmc3 Top1000_ISR.edm4hep
27 changes: 27 additions & 0 deletions test/ref-results/Pythia/Top1000/Top1000_ISR.dat
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Random:setSeed = on
Random:seed = 42
Beams:eCM = 1000
Beams:idA = 11
Beams:idB = -11
PartonLevel:ISR = on
Main:numberOfEvents = 100000

23:m0 = 91.1876
23:mWidth = 2.4952
6:m0 = 173
6:mWidth = 1.4915
Main:WriteHepMC = on
Main:HepMCFile = Top1000_ISR.hepmc3
Main:timesAllowErrors = 5 ! allow a few failures before quitting
Init:showChangedSettings = on ! list changed settings
Init:showChangedParticleData = on ! list changed particle data
Next:numberCount = 1000 ! print message every n events
Next:numberShowInfo = 1 ! print event information n times
Next:numberShowProcess = 1 ! print process record n times
Next:numberShowEvent = 1 ! print event record n times
PDF:lepton = off ! no radiation off ficititious e+e-
211:mayDecay = true ! pi+-
321:mayDecay = true ! K+-
130:mayDecay = true ! K0_L
Top:ffbar2ttbar(s:gmZ) = on
6:onMode = on
7 changes: 7 additions & 0 deletions test/ref-results/Pythia/Top350/Run_Top350_ISR.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash
if [ -z "${KEY4HEP_STACK}" ]; then
source /cvmfs/sw-nightlies.hsf.org/key4hep/setup.sh
fi

$PYTHIA8RUNNER/pythiaRunner -f Top350_ISR.dat
$CONVERTHEPMC2EDM4HEP/convertHepMC2EDM4HEP -i hepmc3 -o edm4hep Top350_ISR.hepmc3 Top350_ISR.edm4hep
27 changes: 27 additions & 0 deletions test/ref-results/Pythia/Top350/Top350_ISR.dat
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Random:setSeed = on
Random:seed = 42
Beams:eCM = 350
Beams:idA = 11
Beams:idB = -11
PartonLevel:ISR = on
Main:numberOfEvents = 100000

23:m0 = 91.1876
23:mWidth = 2.4952
6:m0 = 173
6:mWidth = 1.4915
Main:WriteHepMC = on
Main:HepMCFile = Top350_ISR.hepmc3
Main:timesAllowErrors = 5 ! allow a few failures before quitting
Init:showChangedSettings = on ! list changed settings
Init:showChangedParticleData = on ! list changed particle data
Next:numberCount = 1000 ! print message every n events
Next:numberShowInfo = 1 ! print event information n times
Next:numberShowProcess = 1 ! print process record n times
Next:numberShowEvent = 1 ! print event record n times
PDF:lepton = off ! no radiation off ficititious e+e-
211:mayDecay = true ! pi+-
321:mayDecay = true ! K+-
130:mayDecay = true ! K0_L
Top:ffbar2ttbar(s:gmZ) = on
6:onMode = on
7 changes: 7 additions & 0 deletions test/ref-results/Pythia/ZH250/Run_ZH250_ISR.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash
if [ -z "${KEY4HEP_STACK}" ]; then
source /cvmfs/sw-nightlies.hsf.org/key4hep/setup.sh
fi

$PYTHIA8RUNNER/pythiaRunner -f ZH250_ISR.dat
$CONVERTHEPMC2EDM4HEP/convertHepMC2EDM4HEP -i hepmc3 -o edm4hep ZH250_ISR.hepmc3 ZH250_ISR.edm4hep
30 changes: 30 additions & 0 deletions test/ref-results/Pythia/ZH250/ZH250_ISR.dat
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
Random:setSeed = on
Random:seed = 4711
Beams:eCM = 250.0
Beams:idA = 11
Beams:idB = -11
PartonLevel:ISR = on
Main:numberOfEvents = 1000

25:m0 = 125
25:mWidth = 0
23:m0 = 91.1876
23:mWidth = 2.4952
24:m0 = 80.379
24:mWidth = 2.085
Main:WriteHepMC = on
Main:HepMCFile = ZH250_ISR.hepmc3
Main:timesAllowErrors = 5 ! allow a few failures before quitting
Init:showChangedSettings = on ! list changed settings
Init:showChangedParticleData = on ! list changed particle data
Next:numberCount = 1000 ! print message every n events
Next:numberShowInfo = 1 ! print event information n times
Next:numberShowProcess = 1 ! print process record n times
Next:numberShowEvent = 1 ! print event record n times
PDF:lepton = off ! no radiation off ficititious e+e-
211:mayDecay = true ! pi+-
321:mayDecay = true ! K+-
130:mayDecay = true ! K0_L
HiggsSM:ffbar2HZ = on
25:onMode = on
23:onMode = on
7 changes: 7 additions & 0 deletions test/ref-results/Pythia/ZH350/Run_ZH350_ISR.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash
if [ -z "${KEY4HEP_STACK}" ]; then
source /cvmfs/sw-nightlies.hsf.org/key4hep/setup.sh
fi

$PYTHIA8RUNNER/pythiaRunner -f ZH350_ISR.dat
$CONVERTHEPMC2EDM4HEP/convertHepMC2EDM4HEP -i hepmc3 -o edm4hep ZH350_ISR.hepmc3 ZH350_ISR.edm4hep
30 changes: 30 additions & 0 deletions test/ref-results/Pythia/ZH350/ZH350_ISR.dat
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
Random:setSeed = on
Random:seed = 42
Beams:eCM = 350
Beams:idA = 11
Beams:idB = -11
PartonLevel:ISR = on
Main:numberOfEvents = 1000

25:m0 = 125
25:mWidth = 0
23:m0 = 91.1876
23:mWidth = 2.4952
24:m0 = 80.379
24:mWidth = 2.085
Main:WriteHepMC = on
Main:HepMCFile = ZH350_ISR.hepmc3
Main:timesAllowErrors = 5 ! allow a few failures before quitting
Init:showChangedSettings = on ! list changed settings
Init:showChangedParticleData = on ! list changed particle data
Next:numberCount = 1000 ! print message every n events
Next:numberShowInfo = 1 ! print event information n times
Next:numberShowProcess = 1 ! print process record n times
Next:numberShowEvent = 1 ! print event record n times
PDF:lepton = off ! no radiation off ficititious e+e-
211:mayDecay = true ! pi+-
321:mayDecay = true ! K+-
130:mayDecay = true ! K0_L
HiggsSM:ffbar2HZ = on
25:onMode = on
23:onMode = on
7 changes: 7 additions & 0 deletions test/ref-results/Pythia/ZHDecay250/Run_ZHDecay250.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash
if [ -z "${KEY4HEP_STACK}" ]; then
source /cvmfs/sw-nightlies.hsf.org/key4hep/setup.sh
fi

$PYTHIA8RUNNER/pythiaRunner -f ZHDecay250.dat
$CONVERTHEPMC2EDM4HEP/convertHepMC2EDM4HEP -i hepmc3 -o edm4hep ZHDecay250.hepmc3 ZHDecay250.edm4hep
33 changes: 33 additions & 0 deletions test/ref-results/Pythia/ZHDecay250/ZHDecay250.dat
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
Random:setSeed = on
Random:seed = 42
Beams:eCM = 250
Beams:idA = 11
Beams:idB = -11
PartonLevel:ISR = off
Main:numberOfEvents = 10000

25:m0 = 125
25:mWidth = 0.00407
23:m0 = 91.1876
23:mWidth = 2.4952
24:m0 = 80.379
24:mWidth = 2.085
Main:WriteHepMC = on
Main:HepMCFile = ZHDecay250.hepmc3
Main:timesAllowErrors = 5 ! allow a few failures before quitting
Init:showChangedSettings = on ! list changed settings
Init:showChangedParticleData = on ! list changed particle data
Next:numberCount = 1000 ! print message every n events
Next:numberShowInfo = 1 ! print event information n times
Next:numberShowProcess = 1 ! print process record n times
Next:numberShowEvent = 1 ! print event record n times
PDF:lepton = off ! no radiation off ficititious e+e-
211:mayDecay = true ! pi+-
321:mayDecay = true ! K+-
130:mayDecay = true ! K0_L
HiggsSM:ffbar2HZ = on

23:onMode off
23:onIfAny 15 -15
25:onMode off
25:onIfAny 13 -13
7 changes: 7 additions & 0 deletions test/ref-results/Pythia/ZHDecay350/Run_ZHDecay350.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash
if [ -z "${KEY4HEP_STACK}" ]; then
source /cvmfs/sw-nightlies.hsf.org/key4hep/setup.sh
fi

$PYTHIA8RUNNER/pythiaRunner -f ZHDecay350.dat
$CONVERTHEPMC2EDM4HEP/convertHepMC2EDM4HEP -i hepmc3 -o edm4hep ZHDecay350.hepmc3 ZHDecay350.edm4hep
Loading

0 comments on commit 57d24eb

Please sign in to comment.