Skip to content

Commit c0c1c5f

Browse files
authored
Merge pull request #116 from legend-exp/raw_bzip
Raw bzip
2 parents c7a281b + 9a6f955 commit c0c1c5f

File tree

6 files changed

+53
-20
lines changed

6 files changed

+53
-20
lines changed

.pre-commit-config.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ repos:
7878
rev: "v2.3.0"
7979
hooks:
8080
- id: codespell
81-
args: ["-L", "nd,unparseable,compiletime,livetime,fom,puls"]
81+
args: ["-L", "nd,unparseable,compiletime,livetime,fom,puls,crate"]
8282

8383
- repo: https://github.com/shellcheck-py/shellcheck-py
8484
rev: "v0.10.0.1"

workflow/rules/raw.smk

+10
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,16 @@ rule build_raw_orca:
4848
"{params.ro_input} {output}"
4949

5050

51+
use rule build_raw_orca as build_raw_orca_bz2 with:
52+
input:
53+
get_pattern_tier_daq(config, extension="orca.bz2"),
54+
55+
56+
use rule build_raw_orca as build_raw_orca_gz with:
57+
input:
58+
get_pattern_tier_daq(config, extension="orca.gz"),
59+
60+
5161
rule build_raw_fcio:
5262
"""
5363
This rule runs build_raw, it takes in a file.{daq_ext} and outputs a raw file

workflow/src/legenddataflow/FileKey.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,12 @@ def regex_from_filepattern(filepattern):
3232
f.append(f"(?P={wildcard})")
3333
else:
3434
wildcards.append(wildcard)
35-
f.append(f"(?P<{wildcard}>.+)")
35+
if wildcard == "ext":
36+
f.append(
37+
f"(?P<{wildcard}>.*)"
38+
) # this means ext will capture everything after 1st dot
39+
else:
40+
f.append(f"(?P<{wildcard}>" + r"[^\.\/]+)")
3641
last = match.end()
3742
f.append(re.escape(filepattern[last:]))
3843
f.append("$")

workflow/src/legenddataflow/create_pars_keylist.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,14 @@ def generate_par_keylist(keys):
5353

5454
@staticmethod
5555
def match_entries(entry1, entry2):
56-
datatype2 = ProcessingFileKey.get_filekey_from_filename(entry2.file[0]).datatype
56+
datatype2 = ProcessingFileKey.get_filekey_from_filename(
57+
Path(entry2.file[0]).name
58+
).datatype
5759
for entry in entry1.file:
58-
if ProcessingFileKey.get_filekey_from_filename(entry).datatype == datatype2:
60+
if (
61+
ProcessingFileKey.get_filekey_from_filename(Path(entry).name).datatype
62+
== datatype2
63+
):
5964
pass
6065
else:
6166
entry2.file.append(entry)

workflow/src/legenddataflow/scripts/tier/raw_fcio.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,10 @@ def build_tier_raw_fcio() -> None:
4747
if "muon_config" in channel_dict:
4848
raise NotImplementedError()
4949

50-
build_raw(args.input, out_spec=all_config, filekey=args.output, **settings)
50+
build_raw(
51+
args.input,
52+
out_spec=all_config,
53+
in_stream_type="Flashcam",
54+
filekey=args.output,
55+
**settings,
56+
)

workflow/src/legenddataflow/scripts/tier/raw_orca.py

+22-15
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def build_tier_raw_orca() -> None:
2727

2828
configs = TextDB(args.configs, lazy=True)
2929
config_dict = configs.on(args.timestamp, system=args.datatype)["snakemake_rules"][
30-
"tier_raw"
30+
"tier_raw_orca"
3131
]
3232

3333
build_log(config_dict, args.log)
@@ -63,11 +63,25 @@ def build_tier_raw_orca() -> None:
6363
spm_config[next(iter(spm_config))]["spms"]["key_list"] = sorted(spm_channels)
6464
Props.add_to(all_config, spm_config)
6565

66+
if "muon_config" in list(channel_dict):
67+
muon_config = Props.read_from(channel_dict["muon_config"])
68+
muon_channels = list(
69+
chmap.channelmaps.on(args.timestamp)
70+
.map("system", unique=False)["muon"]
71+
.map("daq.rawid")
72+
)
73+
top_key = next(iter(muon_config))
74+
muon_config[top_key][next(iter(muon_config[top_key]))]["key_list"] = sorted(
75+
muon_channels
76+
)
77+
Props.add_to(all_config, muon_config)
78+
6679
if "auxs_config" in list(channel_dict):
6780
aux_config = Props.read_from(channel_dict["auxs_config"])
6881
aux_channels = list(
6982
chmap.channelmaps.on(args.timestamp)
7083
.map("system", unique=False)["auxs"]
84+
.map("daq.crate", unique=False)[1]
7185
.map("daq.rawid")
7286
)
7387
aux_channels += list(
@@ -86,17 +100,10 @@ def build_tier_raw_orca() -> None:
86100
)
87101
Props.add_to(all_config, aux_config)
88102

89-
if "muon_config" in list(channel_dict):
90-
muon_config = Props.read_from(channel_dict["muon_config"])
91-
muon_channels = list(
92-
chmap.channelmaps.on(args.timestamp)
93-
.map("system", unique=False)["muon"]
94-
.map("daq.rawid")
95-
)
96-
top_key = next(iter(muon_config))
97-
muon_config[top_key][next(iter(muon_config[top_key]))]["key_list"] = sorted(
98-
muon_channels
99-
)
100-
Props.add_to(all_config, muon_config)
101-
102-
build_raw(args.input, out_spec=all_config, filekey=args.output, **settings)
103+
build_raw(
104+
args.input,
105+
out_spec=all_config,
106+
in_stream_type="ORCA",
107+
filekey=args.output,
108+
**settings,
109+
)

0 commit comments

Comments
 (0)