Skip to content

Commit 0dffb3d

Browse files
authored
Merge pull request #113 from legend-exp/raw
Fix for #105, updates to raw_fcio.py
2 parents 0a2b304 + 3829fec commit 0dffb3d

File tree

4 files changed

+6
-55
lines changed

4 files changed

+6
-55
lines changed

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

+3-14
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
"""
1212

1313
import argparse
14-
from pathlib import Path
1514

1615
import numexpr as ne
1716
import numpy as np
@@ -111,12 +110,6 @@ def build_tier_raw_blind() -> None:
111110
# gets events that should not be blinded
112111
tokeep = allind[np.logical_not(np.isin(allind, toblind))]
113112

114-
# make some temp file to write the output to before renaming it
115-
rng = np.random.default_rng()
116-
rand_num = f"{rng.integers(0,99999):05d}"
117-
temp_output = f"{args.output}.{rand_num}"
118-
Path(temp_output).parent.mkdir(parents=True, exist_ok=True)
119-
120113
for channel in all_channels:
121114
try:
122115
chnum = int(channel[2::])
@@ -126,7 +119,7 @@ def build_tier_raw_blind() -> None:
126119
store.write_object(
127120
chobj,
128121
channel,
129-
lh5_file=temp_output,
122+
lh5_file=args.output,
130123
wo_mode="w",
131124
**hdf_settings,
132125
)
@@ -139,7 +132,7 @@ def build_tier_raw_blind() -> None:
139132
chobj,
140133
group=channel,
141134
name="raw",
142-
lh5_file=temp_output,
135+
lh5_file=args.output,
143136
wo_mode="w",
144137
**hdf_settings,
145138
)
@@ -157,11 +150,7 @@ def build_tier_raw_blind() -> None:
157150
blinded_chobj,
158151
group=channel,
159152
name="raw",
160-
lh5_file=temp_output,
153+
lh5_file=args.output,
161154
wo_mode="w",
162155
**hdf_settings,
163156
)
164-
165-
# rename the temp file
166-
Path(args.output).parent.mkdir(parents=True, exist_ok=True)
167-
Path(temp_output).rename(args.output)

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

+1-23
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import argparse
2-
from copy import deepcopy
32
from pathlib import Path
43

5-
import numpy as np
64
from daq2lh5 import build_raw
75
from dbetto import TextDB
86
from dbetto.catalog import Props
@@ -36,24 +34,11 @@ def build_tier_raw_fcio() -> None:
3634
channel_dict = channel_dict.out_spec
3735
all_config = Props.read_from(channel_dict.gen_config)
3836

39-
chmap = (
40-
TextDB(args.chan_maps, lazy=True).channelmaps.on(args.timestamp).group("system")
41-
)
42-
4337
if "geds_config" in channel_dict:
4438
raise NotImplementedError()
4539

4640
if "spms_config" in channel_dict:
4741
spm_config = Props.read_from(channel_dict.spms_config)
48-
spm_channels = chmap.spms.map("daq.rawid")
49-
50-
for rawid, chinfo in spm_channels.items():
51-
cfg_block = deepcopy(spm_config["FCEventDecoder"]["__output_table_name__"])
52-
cfg_block["key_list"] = [chinfo.daq.fc_channel]
53-
spm_config["FCEventDecoder"][f"ch{rawid:07d}/raw"] = cfg_block
54-
55-
spm_config["FCEventDecoder"].pop("__output_table_name__")
56-
5742
Props.add_to(all_config, spm_config)
5843

5944
if "auxs_config" in channel_dict:
@@ -62,11 +47,4 @@ def build_tier_raw_fcio() -> None:
6247
if "muon_config" in channel_dict:
6348
raise NotImplementedError()
6449

65-
rng = np.random.default_rng()
66-
rand_num = f"{rng.integers(0,99999):05d}"
67-
temp_output = f"{args.output}.{rand_num}"
68-
69-
build_raw(args.input, out_spec=all_config, filekey=temp_output, **settings)
70-
71-
# rename the temp file
72-
Path(temp_output).rename(args.output)
50+
build_raw(args.input, out_spec=all_config, filekey=args.output, **settings)

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

+1-9
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import logging
33
from pathlib import Path
44

5-
import numpy as np
65
from daq2lh5 import build_raw
76
from dbetto import TextDB
87
from dbetto.catalog import Props
@@ -100,11 +99,4 @@ def build_tier_raw_orca() -> None:
10099
)
101100
Props.add_to(all_config, muon_config)
102101

103-
rng = np.random.default_rng()
104-
rand_num = f"{rng.integers(0,99999):05d}"
105-
temp_output = f"{args.output}.{rand_num}"
106-
107-
build_raw(args.input, out_spec=all_config, filekey=temp_output, **settings)
108-
109-
# rename the temp file
110-
Path(temp_output).rename(args.output)
102+
build_raw(args.input, out_spec=all_config, filekey=args.output, **settings)

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

+1-9
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import argparse
2-
from pathlib import Path
32

43
import lgdo.lh5 as lh5
5-
import numpy as np
64
from daq2lh5.orca import orca_flashcam
75
from dbetto import TextDB
86
from dbetto.catalog import Props
@@ -28,10 +26,6 @@ def build_tier_tcm() -> None:
2826

2927
settings = Props.read_from(config_dict["inputs"]["config"])
3028

31-
rng = np.random.default_rng()
32-
temp_output = f"{args.output}.{rng.integers(0, 99999):05d}"
33-
Path(args.output).parent.mkdir(parents=True, exist_ok=True)
34-
3529
# get the list of channels by fcid
3630
ch_list = lh5.ls(args.input, "/ch*")
3731
fcid_channels = {}
@@ -46,10 +40,8 @@ def build_tier_tcm() -> None:
4640
for fcid, fcid_dict in fcid_channels.items():
4741
build_tcm(
4842
[(args.input, fcid_dict)],
49-
out_file=temp_output,
43+
out_file=args.output,
5044
out_name=f"hardware_tcm_{fcid}",
5145
wo_mode="o",
5246
**settings,
5347
)
54-
55-
Path(temp_output).rename(args.output)

0 commit comments

Comments
 (0)