diff --git a/python/Generators/GeneratorBase.py b/python/Generators/GeneratorBase.py index 61ab3a2..8011808 100644 --- a/python/Generators/GeneratorBase.py +++ b/python/Generators/GeneratorBase.py @@ -56,6 +56,12 @@ def write_analysis(self): else: return "" analysis += "-i {0}.edm4hep -o {0}.root\n".format(self.GeneratorDatacardBase) + if self.settings.IsRivet(): + yodaout = self.settings.yodaoutput + f"/{self.procinfo.get('procname')}.yoda" + analysis += f"rivet" + for ana in self.settings.analysisname: + analysis += f" -a {ana}" + analysis+=f" -o {yodaout} {self.procinfo.get('procname')}.{self.procinfo.get('output_format')}\n" return analysis def write_GeneratorDatacard(self, content): diff --git a/python/Generators/SherpaProcDB.py b/python/Generators/SherpaProcDB.py index 286e3b6..3c1fe32 100644 --- a/python/Generators/SherpaProcDB.py +++ b/python/Generators/SherpaProcDB.py @@ -17,12 +17,15 @@ def write_DBInfo(self): self.write_Difermion() if label == "15_15": self.write_Difermion() + self.runout += " MASSIVE[15] 1\n" if label == "16_16": self.write_Difermion() if label == "12_12": self.write_Difermion() - elif label == "23_25": + if label == "23_25": self.write_run_ZH() + if label == "5_5": + self.runout = " MASSIVE[5] 1\n" def write_Difermion(self): self.runout = "" diff --git a/python/Input.py b/python/Input.py index 70827ef..85cacec 100644 --- a/python/Input.py +++ b/python/Input.py @@ -9,6 +9,7 @@ class Input: def __init__(self, file): self.file = file self.settings = None + self.anatool = None if not os.path.isfile(file): raise FileNotFoundError(file) else: @@ -29,6 +30,7 @@ def __init__(self, file): setattr(self, key.lower(), value) self.LoadCuts() self.CheckDefaults() + self.LoadAnalysis() def load_file(self): with open(self.file, "r") as file: @@ -161,6 +163,41 @@ def LoadCuts(self): name.lower(), self.settings["selectors"][name] ) + def LoadAnalysis(self): + self.anasettings = self.get_block("analysis") + if self.anasettings is not None: + self.anasettings = {k.lower(): v for k, v in self.anasettings.items()} + self.anatool = self.anasettings["tool"] + self.anatool = self.anatool.lower() + if self.anatool=="rivet": + # check for rivet path + if "RIVET_ANALYSIS_PATH" in os.environ: + self.rivetpath = os.environ["RIVET_ANALYSIS_PATH"] + if "rivetpath" in self.settings: + self.rivetpath = self.anasettings["rivetpath"] + else: + try: + self.rivetpath = self.anasettings["rivetpath"] + except: + print("Rivet Analysis path has not been found") + self.anatool=None + # Set the analysis name + try: + self.analysisname = self.anasettings["rivetanalysis"] + except: + print("No rivet analysis specified. Using MC_XS instead.") + print("Set an analysis with Analysis: RivetAnalysis: Name") + self.analysisname = ["MC_XS"] + # Set yoda info + try: + self.yodaoutput = self.anasettings["yodaoutdir"] + except: + self.yodaoutput = os.getcwd()+"/yodafiles" + if not os.path.isdir(self.yodaoutput): + os.mkdir(self.yodaoutput) + + def IsRivet(self): + return self.anatool=="rivet" class ECMSInput: """Class for loading YAML files with center of mass energies""" diff --git a/python/main.py b/python/main.py index abfb7a3..0720ac6 100644 --- a/python/main.py +++ b/python/main.py @@ -118,8 +118,10 @@ def executeFiles(files, sqrts, rndmSeedFallback=4711, events=-1): for yaml_file in files: settings = Settings.Input(yaml_file) + # ana = analysis.Analysis(settings) + if settings.IsRivet(): + print("Rivet enabled") if events != -1: - print(events) settings.set("events", events) settings.gens() processes = settings.get_processes(sqrts)