I have written a Snakefile “prepare_tuples.smk” having prepare_tuples
as my head rule.
The input is defined as the output of the rule hadd_tuples
.
When I run snakemake prepare_tuples -F -c20
I get the following error message:
Missing input files for rule prepare_tuples:
affected files:
/ceph/users/jmainusch/data/Bs2MuMu/2024_data_stripped.root
/ceph/users/jmainusch/simulation/Bs2MuMu/2024_data_stripped_truth-matched.root
/ceph/users/jmainusch/simulation/Bs2JpsiPhi/2024_data_stripped_truth-matched.root
/ceph/users/jmainusch/simulation/Bu2JpsiK/2024_data_stripped_truth-matched.root
/ceph/users/jmainusch/data/Bd2MuMu/2024_data_stripped.root
/ceph/users/jmainusch/data/Bs2JpsiPhi/2024_data_stripped.root
/ceph/users/jmainusch/data/Bs2KK/2024_data_stripped.root
/ceph/users/jmainusch/simulation/Bd2MuMu/2024_data_stripped_truth-matched.root
/ceph/users/jmainusch/simulation/Bd2KPi/2024_data_stripped_truth-matched.root
/ceph/users/jmainusch/data/Bd2KPi/2024_data_stripped.root
/ceph/users/jmainusch/simulation/Bd2PiPi/2024_data_stripped_truth-matched.root
/ceph/users/jmainusch/data/Bu2JpsiK/2024_data_stripped.root
/ceph/users/jmainusch/simulation/Bs2KK/2024_data_stripped_truth-matched.root
/ceph/users/jmainusch/data/Bd2PiPi/2024_data_stripped.root
/ceph/users/jmainusch/simulation/Bs2KPi/2024_data_stripped_truth-matched.root
/ceph/users/jmainusch/data/Bs2KPi/2024_data_stripped.root
On a side note: “prepare_tuples.smk” is part of a bigger Snakefile. I dont expect this as a problem, but mention it for completeness.
From my understanding, Snakemake should recognize that the desired file is produced in “hadd_tuples” and proceed with its production, but it does not.
configfile: "config/config.yaml"
path = config["repopath"]
inpath = config["cephpath"]
outpath = config["userpath"]
dataset = config["dataset"]
configfile: path + "/1_prepare_tuples/configs/tuples.yaml"
wildcard_constraints:
src = "data|simulation",
tuple = "^B.*"
rule prepare_tuples:
input:
data = expand(outpath + "data/{tuple}/2024_data_stripped.root", tuple = config["tuples"].keys()),
sim = expand(outpath + "simulation/{tuple}/2024_data_stripped_truth-matched.root", tuple = config["tuples"].keys()),
rule cut:
input:
script = path + "1_prepare_tuples/scripts/cut.py",
in_data = inpath + "{src}/{tuple}/2024/{magnet}/data.root",
cuts = path + "1_prepare_tuples/configs/cuts.yaml",
truth_vars = path + "1_prepare_tuples/configs/truth-match.yaml",
control_vars = path + "3_control_plots/configs/channels/{tuple}/plots.yaml",
BDTS_vars = path + "4_BDTS/configs/variables.yaml",
params:
eff_path = "results/efficiencies.yaml",
tuple_config = path + "/1_prepare_tuples/configs/tuples.yaml",
output:
out_data = outpath + "{src}/{tuple}/{magnet}/2024_data_stripped.root",
shell:
"""
python {input.script}
--path {input.in_data}
--channel {wildcards.tuple}
--tuple_config {params.tuple_config}
--source {wildcards.src}
--magnet {wildcards.magnet}
--outpath {output.out_data}
--effpath {params.eff_path}
--cuts {input.cuts}
--truth_vars {input.truth_vars}
--control_vars {input.control_vars}
--BDTS_vars {input.BDTS_vars}
"""
rule truthmatch:
input:
script = path + "1_prepare_tuples/scripts/truthmatch.py",
in_data = outpath + "simulation/{tuple}/{magnet}/2024_data_stripped.root",
cuts = path + "1_prepare_tuples/configs/truth-match.yaml",
cut_vars = path + "1_prepare_tuples/configs/cuts.yaml",
control_vars = path + "3_control_plots/configs/channels/{tuple}/plots.yaml",
BDTS_vars = path + "4_BDTS/configs/variables.yaml",
params:
eff_path = "results/efficiencies.yaml",
tuple_config = path + "/1_prepare_tuples/configs/tuples.yaml",
output:
out_data = outpath + "simulation/{tuple}/{magnet}/2024_data_stripped_truth-matched.root",
shell:
"""
python {input.script}
--path {input.in_data}
--channel {wildcards.tuple}
--tuple_config {params.tuple_config}
--magnet {wildcards.magnet}
--outpath {output.out_data}
--effpath {params.eff_path}
--cuts {input.cuts}
--cut_vars {input.cut_vars}
--control_vars {input.control_vars}
--BDTS_vars {input.BDTS_vars}
"""
rule hadd_tuples:
input:
up = outpath + "{src}/{tuple}/MagUp/2024_data_{mod}.root",
down = outpath + "{src}/{tuple}/MagDown/2024_data_{mod}.root"
output:
outpath + "{src}/{tuple}/2024_data_{mod}.root",
shell:
"hadd {output} {input.up} {input.down}"