File indexing completed on 2026-04-17 07:51:06
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 import subprocess
0015 import os
0016
0017 INPUT_FILE="root://dtn-eic.jlab.org//volatile/eic/EPIC/EVGEN/BACKGROUNDS/MERGED/HEPMC_merger-1.0.2/10x100/1SignalPerFrame/HEPMC_merger-1.0.2_bgmerged_1SignalPerFrame_MinBias_pythia6_10x100_egas_bgas.hepmc3.tree.root"
0018 OUTPUT_BASE="background_py6_10x100_egas_bgas"
0019 DETECTOR_PATH = os.getenv('DETECTOR_PATH', '/opt/detector/epic-main/share/epic/')
0020 DETECTOR_FILE = f'{DETECTOR_PATH}/epic_craterlake_10x100.xml'
0021 STEERING_FILE = '/mnt/dd4hep-plugin/firebird_steering.py'
0022 EVENT_NUM = 10
0023
0024 def run_command(command):
0025 """
0026 Executes a given command in the shell and prints the output as it appears.
0027 Parameters: command (list): A list containing the command and its arguments.
0028 """
0029
0030 print("Executing:", " ".join(command))
0031
0032 process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
0033
0034
0035 while True:
0036 output = process.stdout.readline()
0037 if output == '' and process.poll() is not None:
0038 break
0039 if output:
0040 print(output.strip())
0041
0042
0043 err = process.stderr.read()
0044 if err:
0045 print("Error:", err)
0046
0047
0048 process.wait()
0049 print("Command completed with return code:", process.returncode)
0050 print("\n" + "-"*50 + "\n")
0051
0052 if __name__ == "__main__":
0053 print(f"INPUT_FILE :{INPUT_FILE}")
0054 print(f"OUTPUT_BASE :{OUTPUT_BASE}")
0055 print(f"DETECTOR_PATH :{DETECTOR_PATH}")
0056 print(f"DETECTOR_FILE :{DETECTOR_FILE}")
0057 print(f"STEERING_FILE :{STEERING_FILE}")
0058
0059
0060
0061 npsim_command = [
0062 "npsim",
0063 "--compactFile", DETECTOR_FILE,
0064 "-N", str(EVENT_NUM),
0065 "--inputFiles", INPUT_FILE,
0066 "--random.seed", "1",
0067 "--outputFile", f"{OUTPUT_BASE}.edm4hep.root",
0068 "--steeringFile", STEERING_FILE,
0069 ]
0070
0071
0072
0073
0074
0075 reconstruction_command = [
0076 "eicrecon",
0077 f"-Pjana:debug_plugin_loading=1",
0078 f"-Pdd4hep:xml_files={DETECTOR_FILE}",
0079 f"-Pjana:nevents={EVENT_NUM}",
0080 f"-Pjana:timeout=0",
0081 f"-Ppodio:output_file={OUTPUT_BASE}.edm4eic.root",
0082 f"{OUTPUT_BASE}.edm4hep.root"
0083 ]
0084
0085
0086
0087 run_command(["pyrobird", "smooth",
0088 f"{OUTPUT_BASE}.firebird.json",
0089 "-o", f"{OUTPUT_BASE}_smth.v04.firebird.json"
0090 ])
0091
0092
0093 run_command(["python3",
0094 "-m", "zipfile",
0095 "-c", f"{OUTPUT_BASE}_smth.v04.firebird.json.zip",
0096 f"{OUTPUT_BASE}_smth.v04.firebird.json"
0097 ])