Skip to content

Commit

Permalink
prepare structure of variable filling for modularity
Browse files Browse the repository at this point in the history
  • Loading branch information
dirkzerwas authored Dec 20, 2024
1 parent e86d041 commit 98e2b52
Showing 1 changed file with 19 additions and 12 deletions.
31 changes: 19 additions & 12 deletions python/Generators/GeneratorBase.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import os, stat


class GeneratorBase:
"""GeneratorBase class"""

Expand Down Expand Up @@ -41,22 +40,30 @@ def __init__(self, procinfo, settings, name, inputFileExtension):
# composition of file+directory
self.GeneratorDatacard = f"{self.outdir}/{self.GeneratorDatacardName}"

# set up for key4hep run of event generation
self.key4hep_config = "#!/usr/bin/env bash\n"
self.key4hep_config += 'if [ -z "${KEY4HEP_STACK}" ]; then\n'
self.key4hep_config += (
" source /cvmfs/sw-nightlies.hsf.org/key4hep/setup.sh\n"
)
self.key4hep_config += "fi\n\n"

# three types of global variables for the file content
self.datacardContent = ""
self.key4hepContent = ""
self.analysisContent = ""

# the analysis depends only on the procss, not on the generator, so we can prepare it at the initialization stage:

# the KEY4HEP environment setup is independent of the generator, so we can prepare it at the initialization stage:
self.prepare_key4hepContent()

# the analysis depends only on the process, not on the generator, so we can prepare it at the initialization stage:
self.prepare_analysisContent()

def prepare_key4hepContent(self):

# set up for key4hep run of event generation
key4hep_config = "#!/usr/bin/env bash\n"
key4hep_config += 'if [ -z "${KEY4HEP_STACK}" ]; then\n'
key4hep_config += (
" source /cvmfs/sw-nightlies.hsf.org/key4hep/setup.sh\n"
)
key4hep_config += "fi\n\n"
#
self.key4hep_config = key4hep_config
self.key4hepContent = key4hep_config

def prepare_analysisContent(self):

# write the EDM4HEP analysis part based on the final state
Expand All @@ -76,7 +83,7 @@ def prepare_analysisContent(self):
analysis+=f" -o {yodaout} {self.procinfo.get('procname')}.{self.procinfo.get('output_format')}\n"

self.analysisContent = analysis

def write_GeneratorDatacard(self, content):
with open(self.GeneratorDatacard, "w+") as file:
file.write(content)
Expand Down

0 comments on commit 98e2b52

Please sign in to comment.