Skip to content
Snippets Groups Projects
Commit aa544865 authored by Dmitry Kalinkin's avatar Dmitry Kalinkin
Browse files

calo_pid: pass input files via a list file

parent c0b6c57d
Branches
No related tags found
No related merge requests found
...@@ -64,22 +64,25 @@ exec env DETECTOR_CONFIG={wildcards.DETECTOR_CONFIG} \ ...@@ -64,22 +64,25 @@ exec env DETECTOR_CONFIG={wildcards.DETECTOR_CONFIG} \
""" """
rule calo_pid: rule calo_pid_input_list:
input: input:
electrons=expand( electrons=expand(
"sim_output/calo_pid/{{DETECTOR_CONFIG}}/{PARTICLE}/{ENERGY}/{PHASE_SPACE}/{PARTICLE}_{ENERGY}_{PHASE_SPACE}.{INDEX:04d}.eicrecon.tree.edm4eic.root", "sim_output/calo_pid/{{DETECTOR_CONFIG}}/{{PARTICLE}}/{ENERGY}/{PHASE_SPACE}/{{PARTICLE}}_{ENERGY}_{PHASE_SPACE}.{INDEX:04d}.eicrecon.tree.edm4eic.root",
PARTICLE=["e-"],
ENERGY=["100MeVto20GeV"],
PHASE_SPACE=["130to177deg"],
INDEX=range(100),
),
pions=expand(
"sim_output/calo_pid/{{DETECTOR_CONFIG}}/{PARTICLE}/{ENERGY}/{PHASE_SPACE}/{PARTICLE}_{ENERGY}_{PHASE_SPACE}.{INDEX:04d}.eicrecon.tree.edm4eic.root",
PARTICLE=["pi-"],
ENERGY=["100MeVto20GeV"], ENERGY=["100MeVto20GeV"],
PHASE_SPACE=["130to177deg"], PHASE_SPACE=["130to177deg"],
INDEX=range(100), INDEX=range(100),
), ),
output:
"listing/calo_pid/{DETECTOR_CONFIG}/{PARTICLE}.lst",
run:
with open(output[0], "wt") as fp:
fp.write("\n".join(input))
rule calo_pid:
input:
electrons="listing/calo_pid/{DETECTOR_CONFIG}/e-.lst",
pions="listing/calo_pid/{DETECTOR_CONFIG}/pi-.lst",
matplotlibrc=".matplotlibrc", matplotlibrc=".matplotlibrc",
script="benchmarks/calo_pid/calo_pid.py", script="benchmarks/calo_pid/calo_pid.py",
output: output:
......
...@@ -32,8 +32,8 @@ vector.register_awkward() ...@@ -32,8 +32,8 @@ vector.register_awkward()
#+begin_src jupyter-python :results silent #+begin_src jupyter-python :results silent
DETECTOR_CONFIG=os.environ.get("DETECTOR_CONFIG") DETECTOR_CONFIG=os.environ.get("DETECTOR_CONFIG")
PLOT_TITLE=os.environ.get("PLOT_TITLE") PLOT_TITLE=os.environ.get("PLOT_TITLE")
INPUT_PIONS=os.environ.get("INPUT_PIONS", "").split(" ") INPUT_PIONS=os.environ.get("INPUT_PIONS")
INPUT_ELECTRONS=os.environ.get("INPUT_ELECTRONS", "").split(" ") INPUT_ELECTRONS=os.environ.get("INPUT_ELECTRONS")
output_dir=Path(os.environ.get("OUTPUT_DIR", "./")) output_dir=Path(os.environ.get("OUTPUT_DIR", "./"))
output_dir.mkdir(parents=True, exist_ok=True) output_dir.mkdir(parents=True, exist_ok=True)
...@@ -75,8 +75,13 @@ def filter_pointing(events): ...@@ -75,8 +75,13 @@ def filter_pointing(events):
cond = (part_momentum.eta[:,0] > -3.5) & (part_momentum.eta[:,0] < -2.) cond = (part_momentum.eta[:,0] > -3.5) & (part_momentum.eta[:,0] < -2.)
return events[cond] return events[cond]
e = filter_pointing(uproot.concatenate({filename: "events" for filename in INPUT_ELECTRONS}, filter_name=["MCParticles.*", "*EcalEndcapN*"])) def readlist(path):
pi = filter_pointing(uproot.concatenate({filename: "events" for filename in INPUT_PIONS}, filter_name=["MCParticles.*", "*EcalEndcapN*"])) with open(path, "rt") as fp:
paths = [line.rstrip() for line in fp.readlines()]
return paths
e = filter_pointing(uproot.concatenate({filename: "events" for filename in readlist(INPUT_ELECTRONS)}, filter_name=["MCParticles.*", "*EcalEndcapN*"]))
pi = filter_pointing(uproot.concatenate({filename: "events" for filename in readlist(INPUT_PIONS)}, filter_name=["MCParticles.*", "*EcalEndcapN*"]))
e_train = e[:len(pi)//2] e_train = e[:len(pi)//2]
pi_train = pi[:len(pi)//2] pi_train = pi[:len(pi)//2]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment