Skip to content

Commit

Permalink
Include en_range in instruction file name (#129)
Browse files Browse the repository at this point in the history
* adding en_range for instr_file_name

* placeholder en_range

* adding en_range

* debug name

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
FaroutYLq and pre-commit-ci[bot] authored Apr 23, 2024
1 parent b048cb6 commit 249b23e
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions saltax/instructions/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from tqdm import tqdm


DEFAULT_EN_RANGE = (0.2, 15.0) # in unit of keV
SALT_TIME_INTERVAL = 2e7 # in unit of ns. The number should be way bigger then full drift time
Z_RANGE = (-148.15, 0) # in unit of cm
R_RANGE = (0, 66.4) # in unit of cm
Expand Down Expand Up @@ -165,7 +166,13 @@ def get_run_start_end(runid):


def instr_file_name(
recoil, generator_name, mode, runid=None, rate=1e9 / SALT_TIME_INTERVAL, base_dir=BASE_DIR
recoil,
generator_name,
mode,
runid=None,
en_range=DEFAULT_EN_RANGE,
rate=1e9 / SALT_TIME_INTERVAL,
base_dir=BASE_DIR,
):
"""Generate the instruction file name based on the runid, recoil,
generator_name, mode, and rate.
Expand All @@ -176,15 +183,19 @@ def instr_file_name(
:param runid: run number in integer, default: None, which means we
are loading data and instruction doesn't matter (strax lineage
unaffected)
:param en_range: (en_min, en_max) in keV, default: DEFAULT_EN_RANGE as a placeholder
:param rate: rate of events in Hz
:param base_dir: base directory to save the instruction file,
default: BASE_DIR
:return: instruction file name
"""
if en_range is not None:
en_range = str(en_range[0]) + "_" + str(en_range[1])
else:
raise RuntimeError("en_range must be specified, and it can even be placeholder (0,0)")
# FIXME: this will shoot errors if we are on OSG rather than midway
if runid is None:
return "Data-loading only, no instruction file needed."

# FIXME: this will shoot errors if we are on OSG rather than midway
else:
if base_dir[-1] != "/":
base_dir += "/"
Expand All @@ -199,6 +210,8 @@ def instr_file_name(
+ "-"
+ generator_name
+ "-"
+ en_range
+ "-"
+ mode
+ "-"
+ str(rate)
Expand Down Expand Up @@ -370,7 +383,7 @@ def generator_ambe(

def generator_flat(
runid,
en_range=(0.2, 15.0),
en_range=DEFAULT_EN_RANGE,
recoil=8,
n_tot=None,
rate=1e9 / SALT_TIME_INTERVAL,
Expand Down

0 comments on commit 249b23e

Please sign in to comment.