Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
b1acfc0
Add Option to read and ouput NV informations
HenningSE Jan 23, 2024
0f41f65
Bugfixing
HenningSE Jan 23, 2024
ece6952
Add empty NeutronVetoHitlets Plugin
HenningSE Jan 23, 2024
f3fca20
Add nveto plugin to init files
HenningSE Jan 23, 2024
7122eeb
Update nvhitlets.py
LayosDaniel Apr 3, 2024
3fde86f
Add files via upload
LayosDaniel Apr 3, 2024
f7f1de0
Update nvhitlets.py
LayosDaniel Apr 8, 2024
5566586
Update nvhitlets.py
LayosDaniel Apr 13, 2024
8e62509
Update nvhitlets.py
LayosDaniel Apr 14, 2024
85ed172
Delete fuse/plugins/neutron_veto/Testing_nv_hitlet.ipynb
LayosDaniel Apr 14, 2024
c490b83
Add files via upload
LayosDaniel Apr 14, 2024
5c08fbd
Update nvhitlets.py
LayosDaniel Apr 15, 2024
3bdfcdd
Added option to select different sciencerun configs (currently sr0, sr1)
Jan 28, 2025
751c376
getting rid of awkward arrays and using only numpy arrays
Feb 10, 2025
f10a94b
selecting only NV PMTs
Feb 10, 2025
aabe102
Merge branch 'main' into nv_plugins
HenningSE Feb 13, 2025
3d2bcb7
Move code
HenningSE Feb 13, 2025
6a069d3
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 13, 2025
c656347
code (commented) for json input spe files
Feb 14, 2025
af6b2ce
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 14, 2025
c83bb4b
fix some awkward code
HenningSE Feb 14, 2025
1e376df
handling input nv spe files in json format
Feb 14, 2025
7500038
tentative urlconfig setup for nv qe and spe inputs
Feb 14, 2025
1da4ed3
fix typo
Feb 14, 2025
0d4d075
Fixing missing brackets in nvhitlets.py
deisting Feb 25, 2025
02bcb6e
Merge branch 'main' into nv_plugins
HenningSE May 23, 2025
bd92920
Resolving merge problems
HenningSE May 23, 2025
ee2822b
Clean up NeutronVetoHitlets code
HenningSE May 23, 2025
10d0050
Merge branch 'main' into nv_plugins
HenningSE May 23, 2025
d332b17
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] May 29, 2025
7e86d43
Merge branch 'main' into nv_plugins
cfuselli Jul 22, 2025
7290e78
Speed up things and make URLConfigs work.
HenningSE Sep 22, 2025
68e1ac7
resolve conflicts
cfuselli Sep 22, 2025
cd51503
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 23, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 65 additions & 25 deletions fuse/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,44 +26,84 @@
)


@numba.njit()
def dynamic_chunking(data, scale, n_min):
idx_sort = stable_argsort(data)
idx_undo_sort = stable_argsort(idx_sort)
@numba.njit(cache=True)
def dynamic_chunking(
time_gaps,
file_size_limit,
min_gap_length,
n_bytes_per_interaction,
):

data_size_mb = 0
clusters_index = []

running_index = 0

for g in time_gaps:

data_size_mb += n_bytes_per_interaction / 1e6

if data_size_mb < file_size_limit:
clusters_index.append(running_index)
continue

if g >= min_gap_length:
running_index += 1
data_size_mb = 0
clusters_index.append(running_index)
else:
clusters_index.append(running_index)

return np.array(clusters_index)


@numba.njit(cache=True)
def dynamic_chunking_two_outputs(
combined_time_gaps,
combined_types,
file_size_limit,
min_gap_length,
n_bytes_per_interaction_TPC,
n_bytes_per_interaction_NV,
):
"""Function to split the TPC and NV data into chunks based on the time gaps
between the interactions."""

data_size_mb_tpc = 0
data_size_mb_nv = 0

data_sorted = data[idx_sort]
combined_cluster_index = []
running_index = 0

diff = data_sorted[1:] - data_sorted[:-1]
for i, (interaction_type, delta_t) in enumerate(zip(combined_types, combined_time_gaps)):

clusters = [0]
c = 0
n_cluster = 0
for value in diff:
if value <= scale:
clusters.append(c)
n_cluster += 1
elif n_cluster + 1 < n_min:
clusters.append(c)
n_cluster += 1
elif value > scale:
c = c + 1
clusters.append(c)
n_cluster = 0
if interaction_type == 0:
# TPC interaction
data_size_mb_tpc += n_bytes_per_interaction_TPC / 1e6
elif interaction_type == 1:
# NV interaction
data_size_mb_nv += n_bytes_per_interaction_NV / 1e6

clusters = np.array(clusters)
clusters_undo_sort = clusters[idx_undo_sort]
if (data_size_mb_tpc < file_size_limit) & (data_size_mb_nv < file_size_limit):
combined_cluster_index.append(running_index)
continue

return clusters_undo_sort
if delta_t >= min_gap_length:
running_index += 1
data_size_mb_tpc = data_size_mb_nv = 0
combined_cluster_index.append(running_index)
else:
combined_cluster_index.append(running_index)
return np.array(combined_cluster_index)


def full_array_to_numpy(array, dtype):
len_output = len(awkward_to_flat_numpy(array["x"]))
len_output = len(awkward_to_flat_numpy(array[array.fields[0]]))

numpy_data = np.zeros(len_output, dtype=dtype)

for field in array.fields:
numpy_data[field] = awkward_to_flat_numpy(array[field])

return numpy_data


Expand Down
34 changes: 34 additions & 0 deletions fuse/context_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import straxen
from straxen import URLConfig
from copy import deepcopy
from scipy import interpolate
import logging

logging.basicConfig(handlers=[logging.StreamHandler()])
Expand Down Expand Up @@ -200,3 +201,36 @@ def apply_mc_overrides(context, config_file):
log.debug(f"[mc_overrides] Set '{key}' to '{value}'")
except Exception as e:
raise ValueError(f"[mc_overrides] Failed to apply overrides from {config_file}: {e}") from e


@URLConfig.register("nveto_pmt_qe")
def nveto_pmt_qe_dict(data):
"""Get NV PMT quantum efficiecny values and interpolate."""

QE_array_n = []
# nVeto
for i in np.arange(2000, 2120):
QE_array_n.append(
interpolate.interp1d(
data["nv_pmt_qe_wavelength"],
data["nv_pmt_qe"][str(i)],
bounds_error=False,
fill_value=0,
)
)

pmt_id = list(np.arange(2000, 2120))
QE_array = QE_array_n

return QE_array
# pd_dict = {"pmt_id": pmt_id, "QE": QE_array}

# return pd_dict


@URLConfig.register("nveto_spe")
def nveto_spe_dict(data_spe):
"""Get dictionary with NV SPE parameters."""

data_dict = {entry["pmtID"]: entry for entry in data_spe}
return data_dict
23 changes: 23 additions & 0 deletions fuse/dtypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,26 @@
(("ID of the cluster creating the photon", "cluster_id"), np.int32),
(("Type of the photon. S1 (1), S2 (2) or PMT AP (0)", "photon_type"), np.int8),
]


# @ Experts: Please add a description of the fields in the dtype
# See fields above for inspiration.
# Is float64 necessary? Switch to float32 if possible to save space.
neutron_veto_hitlet_dtype = [
("area", np.float64),
("amplitude", np.float64),
("time_amplitude", np.int16),
("entropy", np.float64),
("range_50p_area", np.float64),
("range_80p_area", np.float64),
("left_area", np.float64),
("low_left_area", np.float64),
("range_hdr_50p_area", np.float64),
("range_hdr_80p_area", np.float64),
("left_hdr", np.float64),
("low_left_hdr", np.float64),
("fwhm", np.float64),
("left", np.float64),
("fwtm", np.float64),
("low_left", np.float64),
]
3 changes: 3 additions & 0 deletions fuse/plugins/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
from . import pmt_and_daq
from .pmt_and_daq import *

from . import neutron_veto
from .neutron_veto import *

from . import truth_information
from .truth_information import *

Expand Down
Loading
Loading