Skip to content
Snippets Groups Projects
Commit 1f4a1136 authored by Johannes Schumann's avatar Johannes Schumann
Browse files

Restructuring of the jobcard functions

parent 598fa4f0
No related branches found
No related tags found
1 merge request!1Merge python environment
......@@ -14,6 +14,9 @@ __status__ = "Development"
INPUT_PATH = "/opt/buuinput2019/"
_PROCESS_LOOKUP = {"cc": 2, "nc": 3, "anticc": -2, "antinc": -3}
_FLAVOUR_LOOKUP = {"electron": 1, "muon": 2, "tau": 3}
class Jobcard(object):
"""
......@@ -25,45 +28,11 @@ class Jobcard(object):
The input path pointing to the GiBUU lookup data which should be used
"""
def __init__(self, input_path=INPUT_PATH):
self.input_path = input_path
self.input_path = "'%s'" % input_path
self._groups = {}
# Default [input]
self.add_property("input", "path_to_input", input_path)
self.add_property("input", "numTimeSteps", 0)
self.add_property("input", "numEnsembles", 100000)
self.add_property("input", "delta_T", 0.2)
self.add_property("input", "num_runs_SameEnergy", 1)
# Default [target]
self.add_property("target", "Z", 1)
self.add_property("target", "A", 1)
def set_target(self, Z, A):
"""
Set the interaction target nucleus
Parameters
----------
A: int
Number of nucleons in the nucleus
Z: int
Number of protons in the nucleus
"""
self.add_property("target", "Z", Z)
self.add_property("target", "A", A)
@property
def timesteps(self):
"""
input/numTimeSteps property
"""
return self._groups["input"]["numTimeSteps"]
@timesteps.setter
def timesteps(self, timesteps):
self._groups["input"]["numTimeSteps"] = timesteps
def add_property(self, group, name, value):
""" Add a property to the jobcard
def set_property(self, group, name, value):
""" Set a property to the jobcard
Parameters
----------
......@@ -78,6 +47,11 @@ class Jobcard(object):
self._groups[group] = {}
self._groups[group][name] = value
def remove_property(self, group, name):
del self._groups[group][name]
if len(self._groups[group]) == 0:
del self._groups[group]
def __str__(self):
retval = ""
for group, attrs in self._groups.items():
......@@ -85,27 +59,52 @@ class Jobcard(object):
continue
retval += "&%s\n" % group
for attr, value in attrs.items():
if type(value) is str:
retval += "\t%s = '%s'\n" % (attr, value)
elif type(value) is bool:
retval += "\t%s = .%s.\n" % (attr, value)
if type(value) is bool:
retval += "\t%s = .%s.\n" % (attr, str(value).lower())
else:
retval += "\t%s = %s\n" % (attr, value)
retval += "/\n\n"
return retval
class NeutrinoJobcard(Jobcard):
def generate_neutrino_jobcard(process,
flavour,
energy,
target,
input_path=INPUT_PATH):
"""
Jobcard object for neutrino interactions
Generate a jobcard for neutrino interaction
Parameters
----------
process: str
Interaction channel ["CC", "NC", "antiCC", "antiNC"]
flavour: str
Flavour ["electron", "muon", "tau"]
energy: float
Initial energy of the neutrino in GeV
target: (int, int)
(Z, A) describing the target nukleon
input_path: str
The input path pointing to the GiBUU lookup data which should be used
"""
def __init__(self, input_path=INPUT_PATH):
super(NeutrinoJobcard, self).__init__(input_path)
## Default [input]
self.add_property("input", "eventtype", 5)
self.add_property("input", "localEnsemble", True)
jc = Jobcard(input_path)
# NEUTRINO
jc.set_property("neutrino_inducted", "process_ID",
_PROCESS_LOOKUP[process.lower()])
jc.set_property("neutrino_inducted", "flavour_ID",
_FLAVOUR_LOOKUP[flavour.lower()])
jc.set_property("neutrino_inducted", "nuXsectionMode", 6)
jc.set_property("neutrino_inducted", "includeDIS", True)
jc.set_property("neutrino_inducted", "printAbsorptionXS", "T")
# INPUT
jc.set_property("input", "numTimeSteps", 0)
jc.set_property("input", "eventtype", 5)
jc.set_property("input", "numEnsembles", 100000)
jc.set_property("input", "delta_T", 0.2)
jc.set_property("input", "localEnsemble", True)
jc.set_property("input", "num_runs_SameEnergy", 1)
# TARGET
jc.set_property("target", "Z", target[0])
jc.set_property("target", "A", target[1])
return jc
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment