Skip to content

Commit 9d7303a

Browse files
committed
hit debug
1 parent 7070639 commit 9d7303a

File tree

6 files changed

+66
-82
lines changed

6 files changed

+66
-82
lines changed

Diff for: workflow/rules/hit_pars_geds.smk

+21-8
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ rule build_qc:
3636
timestamp="{timestamp}",
3737
datatype="cal",
3838
channel="{channel}",
39+
dsp_table_name=lambda wildcards: get_table_name(
40+
metadata, config, "cal", wildcards.timestamp, wildcards.channel, "dsp"
41+
),
3942
output:
4043
qc_file=temp(get_pattern_pars_tmp_channel(config, "hit", "qc")),
4144
plot_file=temp(get_pattern_plts_tmp_channel(config, "hit", "qc")),
@@ -51,7 +54,7 @@ rule build_qc:
5154
"--timestamp {params.timestamp} "
5255
"--channel {params.channel} "
5356
"--configs {configs} "
54-
"--metadata {meta} "
57+
"--table-name {params.dsp_table_name} "
5558
"--plot-path {output.plot_file} "
5659
"--save-path {output.qc_file} "
5760
"--pulser-file {input.pulser} "
@@ -78,6 +81,9 @@ rule build_energy_calibration:
7881
timestamp="{timestamp}",
7982
datatype="cal",
8083
channel="{channel}",
84+
dsp_table_name=lambda wildcards: get_table_name(
85+
metadata, config, "cal", wildcards.timestamp, wildcards.channel, "dsp"
86+
),
8187
output:
8288
ecal_file=temp(get_pattern_pars_tmp_channel(config, "hit", "energy_cal")),
8389
results_file=temp(
@@ -99,6 +105,7 @@ rule build_energy_calibration:
99105
"--channel {params.channel} "
100106
"--configs {configs} "
101107
"--metadata {meta} "
108+
"--table-name {params.dsp_table_name} "
102109
"--plot-path {output.plot_file} "
103110
"--results-path {output.results_file} "
104111
"--save-path {output.ecal_file} "
@@ -125,6 +132,9 @@ rule build_aoe_calibration:
125132
timestamp="{timestamp}",
126133
datatype="cal",
127134
channel="{channel}",
135+
dsp_table_name=lambda wildcards: get_table_name(
136+
metadata, config, "cal", wildcards.timestamp, wildcards.channel, "dsp"
137+
),
128138
output:
129139
hit_pars=temp(get_pattern_pars_tmp_channel(config, "hit", "aoe_cal")),
130140
aoe_results=temp(
@@ -142,15 +152,15 @@ rule build_aoe_calibration:
142152
shell:
143153
execenv_pyexe(config, "par-geds-hit-aoe") + "--log {log} "
144154
"--configs {configs} "
145-
"--metadata {meta} "
146155
"--datatype {params.datatype} "
147156
"--timestamp {params.timestamp} "
148-
"--inplots {input.inplots} "
149157
"--channel {params.channel} "
158+
"--table-name {params.dsp_table_name} "
150159
"--aoe-results {output.aoe_results} "
151-
"--eres-file {input.eres_file} "
152160
"--hit-pars {output.hit_pars} "
153161
"--plot-file {output.plot_file} "
162+
"--inplots {input.inplots} "
163+
"--eres-file {input.eres_file} "
154164
"--pulser-file {input.pulser} "
155165
"--ecal-file {input.ecal_file} "
156166
"{input.files}"
@@ -172,6 +182,9 @@ rule build_lq_calibration:
172182
timestamp="{timestamp}",
173183
datatype="cal",
174184
channel="{channel}",
185+
dsp_table_name=lambda wildcards: get_table_name(
186+
metadata, config, "cal", wildcards.timestamp, wildcards.channel, "dsp"
187+
),
175188
output:
176189
hit_pars=temp(get_pattern_pars_tmp_channel(config, "hit")),
177190
lq_results=temp(
@@ -187,15 +200,15 @@ rule build_lq_calibration:
187200
shell:
188201
execenv_pyexe(config, "par-geds-hit-lq") + "--log {log} "
189202
"--configs {configs} "
190-
"--metadata {meta} "
191203
"--datatype {params.datatype} "
192204
"--timestamp {params.timestamp} "
193-
"--inplots {input.inplots} "
194205
"--channel {params.channel} "
195-
"--lq-results {output.lq_results} "
196-
"--eres-file {input.eres_file} "
206+
"--table-name {params.dsp_table_name} "
197207
"--hit-pars {output.hit_pars} "
198208
"--plot-file {output.plot_file} "
209+
"--lq-results {output.lq_results} "
199210
"--pulser-file {input.pulser} "
200211
"--ecal-file {input.ecal_file} "
212+
"--inplots {input.inplots} "
213+
"--eres-file {input.eres_file} "
201214
"{input.files}"

Diff for: workflow/src/legenddataflow/scripts/par/geds/hit/aoe.py

+3-11
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,9 @@
1212
from pygama.pargen.AoE_cal import CalAoE, Pol1, SigmaFit, aoe_peak
1313
from pygama.pargen.utils import load_data
1414

15+
from .....convert_np import convert_dict_np_to_float
1516
from .....log import build_log
16-
from ....convert_np import convert_dict_np_to_float
1717
from ....pulser_removal import get_pulser_mask
18-
from ....table_name import get_table_name
1918

2019
warnings.filterwarnings(action="ignore", category=RuntimeWarning)
2120

@@ -62,11 +61,11 @@ def par_geds_hit_aoe() -> None:
6261

6362
argparser.add_argument("--configs", help="configs", type=str, required=True)
6463
argparser.add_argument("--log", help="log_file", type=str)
65-
argparser.add_argument("--metadata", help="metadata", type=str, required=True)
6664

6765
argparser.add_argument("--datatype", help="Datatype", type=str, required=True)
6866
argparser.add_argument("--timestamp", help="Timestamp", type=str, required=True)
6967
argparser.add_argument("--channel", help="Channel", type=str, required=True)
68+
argparser.add_argument("--table-name", help="table name", type=str, required=True)
7069

7170
argparser.add_argument("--plot-file", help="plot_file", type=str, required=False)
7271
argparser.add_argument("--hit-pars", help="hit_pars", type=str)
@@ -80,8 +79,6 @@ def par_geds_hit_aoe() -> None:
8079

8180
log = build_log(config_dict, args.log)
8281

83-
channel = get_table_name(args.metadata, args.timestamp, args.datatype, args.channel)
84-
8582
channel_dict = config_dict["inputs"]["aoecal_config"][args.channel]
8683
kwarg_dict = Props.read_from(channel_dict)
8784

@@ -148,7 +145,7 @@ def eres_func(x):
148145
# load data in
149146
data, threshold_mask = load_data(
150147
files,
151-
f"{channel}/dsp",
148+
args.table_name,
152149
cal_dict,
153150
params=params,
154151
threshold=kwarg_dict.pop("threshold"),
@@ -157,11 +154,6 @@ def eres_func(x):
157154

158155
mask = get_pulser_mask(
159156
pulser_file=args.pulser_file,
160-
tcm_filelist=args.tcm_filelist,
161-
channel=channel,
162-
pulser_multiplicity_threshold=kwarg_dict.get(
163-
"pulser_multiplicity_threshold"
164-
),
165157
)
166158

167159
data["is_pulser"] = mask[threshold_mask]

Diff for: workflow/src/legenddataflow/scripts/par/geds/hit/ecal.py

+9-14
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,9 @@
2323
from pygama.pargen.utils import load_data
2424
from scipy.stats import binned_statistic
2525

26+
from .....convert_np import convert_dict_np_to_float
2627
from .....log import build_log
27-
from ....convert_np import convert_dict_np_to_float
2828
from ....pulser_removal import get_pulser_mask
29-
from ....table_name import get_table_name
3029

3130
mpl.use("agg")
3231
sto = lh5.LH5Store()
@@ -451,12 +450,13 @@ def par_geds_hit_ecal() -> None:
451450
argparser.add_argument("--in-hit-dict", help="in_hit_dict", required=False)
452451
argparser.add_argument("--inplot-dict", help="inplot_dict", required=False)
453452

454-
argparser.add_argument("--configs", help="config", type=str, required=True)
455453
argparser.add_argument("--datatype", help="Datatype", type=str, required=True)
456454
argparser.add_argument("--timestamp", help="Timestamp", type=str, required=True)
457455
argparser.add_argument("--channel", help="Channel", type=str, required=True)
458-
argparser.add_argument("--tier", help="tier", type=str, default="hit")
456+
argparser.add_argument("--table-name", help="table name", type=str, required=True)
459457

458+
argparser.add_argument("--tier", help="tier", type=str, default="hit")
459+
argparser.add_argument("--configs", help="config", type=str, required=True)
460460
argparser.add_argument("--metadata", help="metadata path", type=str, required=True)
461461

462462
argparser.add_argument("--log", help="log_file", type=str)
@@ -469,7 +469,7 @@ def par_geds_hit_ecal() -> None:
469469
args = argparser.parse_args()
470470

471471
configs = TextDB(args.configs, lazy=True).on(args.timestamp, system=args.datatype)
472-
config_dict = configs.on(args.timestamp, system=args.datatype)["snakemake_rules"]
472+
config_dict = configs["snakemake_rules"]
473473
if args.tier == "hit":
474474
config_dict = config_dict["pars_hit_ecal"]
475475
elif args.tier == "pht":
@@ -480,8 +480,6 @@ def par_geds_hit_ecal() -> None:
480480

481481
build_log(config_dict, args.log)
482482

483-
channel = get_table_name(args.metadata, args.timestamp, args.datatype, args.channel)
484-
485483
chmap = LegendMetadata(args.metadata).channelmap(
486484
args.timestamp, system=args.datatype
487485
)
@@ -498,7 +496,7 @@ def par_geds_hit_ecal() -> None:
498496

499497
database_dic = Props.read_from(db_files)
500498

501-
hit_dict.update(database_dic[channel]["ctc_params"])
499+
hit_dict.update(database_dic[args.channel]["ctc_params"])
502500

503501
channel_dict = config_dict["inputs"]["ecal_config"][args.channel]
504502
kwarg_dict = Props.read_from(channel_dict)
@@ -519,7 +517,7 @@ def par_geds_hit_ecal() -> None:
519517
# load data in
520518
data, threshold_mask = load_data(
521519
files,
522-
f"{channel}/dsp",
520+
args.table_name,
523521
hit_dict,
524522
params=[
525523
*kwarg_dict["energy_params"],
@@ -534,9 +532,6 @@ def par_geds_hit_ecal() -> None:
534532

535533
mask = get_pulser_mask(
536534
pulser_file=args.pulser_file,
537-
tcm_filelist=args.tcm_filelist,
538-
channel=channel,
539-
pulser_multiplicity_threshold=kwarg_dict.get("pulser_multiplicity_threshold"),
540535
)
541536

542537
data["is_pulser"] = mask[threshold_mask]
@@ -722,14 +717,14 @@ def par_geds_hit_ecal() -> None:
722717

723718
if "monitoring_parameters" in kwarg_dict:
724719
monitor_dict = monitor_parameters(
725-
files, f"{channel}/dsp", kwarg_dict["monitoring_parameters"]
720+
files, args.table_name, kwarg_dict["monitoring_parameters"]
726721
)
727722
results_dict.update({"monitoring_parameters": monitor_dict})
728723

729724
# get baseline plots and save all plots to file
730725
if args.plot_path:
731726
common_dict = baseline_tracking_plots(
732-
sorted(files), f"{channel}/dsp", plot_options=bl_plots
727+
sorted(files), args.table_name, plot_options=bl_plots
733728
)
734729

735730
for plot in list(common_dict):

Diff for: workflow/src/legenddataflow/scripts/par/geds/hit/lq.py

+4-12
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,9 @@
1414
from pygama.pargen.lq_cal import LQCal
1515
from pygama.pargen.utils import load_data
1616

17+
from .....convert_np import convert_dict_np_to_float
1718
from .....log import build_log
18-
from ....convert_np import convert_dict_np_to_float
1919
from ....pulser_removal import get_pulser_mask
20-
from ....table_name import get_table_name
2120

2221
warnings.filterwarnings(action="ignore", category=RuntimeWarning)
2322

@@ -60,12 +59,12 @@ def par_geds_hit_lq() -> None:
6059
argparser.add_argument("--inplots", help="in_plot_path", type=str, required=False)
6160

6261
argparser.add_argument("--configs", help="configs", type=str, required=True)
63-
argparser.add_argument("--metadata", help="metadata", type=str, required=True)
6462
argparser.add_argument("--log", help="log_file", type=str)
6563

6664
argparser.add_argument("--datatype", help="Datatype", type=str, required=True)
6765
argparser.add_argument("--timestamp", help="Timestamp", type=str, required=True)
6866
argparser.add_argument("--channel", help="Channel", type=str, required=True)
67+
argparser.add_argument("--table-name", help="table name", type=str, required=True)
6968

7069
argparser.add_argument("--plot-file", help="plot_file", type=str, required=False)
7170
argparser.add_argument("--hit-pars", help="hit_pars", type=str)
@@ -79,8 +78,6 @@ def par_geds_hit_lq() -> None:
7978

8079
log = build_log(config_dict, args.log)
8180

82-
channel = get_table_name(args.metadata, args.timestamp, args.datatype, args.channel)
83-
8481
channel_dict = config_dict["inputs"]["lqcal_config"][args.channel]
8582
kwarg_dict = Props.read_from(channel_dict)
8683

@@ -126,7 +123,7 @@ def eres_func(x):
126123
# load data in
127124
data, threshold_mask = load_data(
128125
files,
129-
f"{channel}/dsp",
126+
args.table_name,
130127
cal_dict,
131128
params=params,
132129
threshold=kwarg_dict.pop("threshold"),
@@ -135,11 +132,6 @@ def eres_func(x):
135132

136133
mask = get_pulser_mask(
137134
pulser_file=args.pulser_file,
138-
tcm_filelist=args.tcm_filelist,
139-
channel=channel,
140-
pulser_multiplicity_threshold=kwarg_dict.get(
141-
"pulser_multiplicity_threshold"
142-
),
143135
)
144136

145137
data["is_pulser"] = mask[threshold_mask]
@@ -151,7 +143,7 @@ def eres_func(x):
151143
eres_func,
152144
cdf,
153145
selection_string=f"{kwarg_dict.pop('cut_field')}&(~is_pulser)",
154-
debug_mode=args.debug_mode | kwarg_dict.get("debug_mode", False),
146+
debug_mode=args.debug | kwarg_dict.get("debug_mode", False),
155147
)
156148

157149
data["LQ_Ecorr"] = np.divide(data["lq80"], data[kwarg_dict["energy_param"]])

0 commit comments

Comments
 (0)