Skip to content

Commit 1548c7c

Browse files
committed
Cleanup and rename campaign scripts
1 parent 69b8dd3 commit 1548c7c

9 files changed

+69
-8
lines changed
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55

66

77
help_txt = """
8-
convert_lambda.py run csv_mcpart_lambda.cxx on every *.edm4eic.root file
8+
convert_edm4eic.py - run csv_mcpart_lambda.cxx on every *.edm4eic.root file
99
1010
Usage:
11-
python3 convert_lambda.py [directory] [macro]
11+
python3 convert_edm4eic.py [directory] [macro]
1212
1313
Arguments (all optional)
1414
directory : where to search for ROOT files

csv_convert/convert_edm4hep.py

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
#!/usr/bin/env python3
2+
import subprocess
3+
import sys
4+
from pathlib import Path
5+
6+
7+
help_txt = """
8+
runs csv_*.cxx on every *.edm4hep.root file
9+
10+
Usage:
11+
python3 convert_edm4hep.py [directory]
12+
13+
Arguments (all optional)
14+
directory : where to search for ROOT files
15+
"""
16+
17+
18+
# --- Config ---
19+
20+
if len(sys.argv) < 2:
21+
print("Provide directory path as an argument.")
22+
print(help_txt)
23+
exit(1)
24+
25+
input_dir = Path(sys.argv[1])
26+
macros = [
27+
"csv_edm4hep_acceptance_npi0.cxx",
28+
"csv_edm4hep_acceptance_ppim.cxx",
29+
]
30+
31+
32+
# --- Find files ---
33+
root_files = sorted(input_dir.glob("*.edm4hep.root"))
34+
file_count = len(root_files)
35+
if file_count == 0:
36+
sys.exit(f"[ERROR] No *.edm4hep.root files found in {input_dir}")
37+
38+
print(f"[INFO] Found {file_count} .edm4hep.root files in {input_dir}\n")
39+
40+
# ------------------------------------------------------------------ run loop
41+
for idx, file_path in enumerate(root_files, start=1):
42+
print(f"[{idx}/{file_count}] ============================================")
43+
for macro in macros:
44+
macro_base_name = macro.replace("csv_", "").replace(".cxx", "")
45+
out_file = file_path.with_name(file_path.name.replace(".edm4hep.root", f".{macro_base_name}.csv"))
46+
if out_file.exists():
47+
print(f"[SKIP] {out_file.name} already exists, skipping")
48+
continue
49+
50+
print(f"|{macro}| {file_path.name}{out_file.name}")
51+
cmd = [
52+
"root", "-x", "-l", "-b", "-q",
53+
f'{macro}("{file_path}","{out_file}")'
54+
]
55+
try:
56+
subprocess.run(cmd, check=True)
57+
except subprocess.CalledProcessError as e:
58+
print(f"[ERROR] Failed on {file_path.name}: exit code {e.returncode}")
59+
sys.exit(1)
60+
print(f"---> Finished converting: {file_path.name}")
61+
print(f"\n[OK] Successfully processed {file_count} files. Output CSVs are alongside the ROOT files.")
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -134,11 +134,8 @@ def main():
134134
config = load_config()
135135
energies = config.get('energies', [])
136136

137-
print("="*80)
138-
print("CSV CONVERSION PIPELINE")
139-
print("="*80)
140-
print(f"Energies to process: {energies}")
141-
print("")
137+
print(f"{'='*80}\n CSV CONVERSION PIPELINE\n{'='*80}")
138+
print(f"Energies to process: {energies}\n")
142139

143140
# Process each energy
144141
for energy in energies:

full-sim-pipeline/config-campaign-2025-10.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,13 @@ afterburner_output: "${base_dir}/afterburner/${energy}${priority}"
3939

4040

4141
# DD4Hep jobs
42+
# afterburner_output is input here
4243
dd4hep_output: "${base_dir}/dd4hep/${energy}${priority}"
4344

44-
# DD4Hep jobs
45+
# EICrecon jobs
46+
# dd4hep_output is input here
4547
eicrecon_output: "${base_dir}/reco/${energy}${priority}"
4648

4749
# Where to put CSV output
50+
# eicrecon_output and dd4hep_output are inputs here
4851
csv_output: "${base_dir}/csv/${energy}${priority}"

0 commit comments

Comments
 (0)