Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

URLConfigs, Volume Plugins, S1 Plugin Split, Removal of electron_cloud data_kind #35

Merged
merged 37 commits into from
Jun 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
4e614ca
use URLConfigs for ElectronDrift plugin
HenningSE May 9, 2023
17288f6
BugFix
HenningSE May 9, 2023
437d22b
URLConfigs for microphysics
HenningSE May 9, 2023
0400c72
URLConfig for bools, floats, integer and strings in detector_physics …
HenningSE May 10, 2023
8a36176
Move remaining configs to URLConfig
HenningSE May 10, 2023
993d2f6
Add missing code to notebook
HenningSE May 10, 2023
094dddc
Move config value assignment to a context
HenningSE May 12, 2023
0ee0b5f
BugFix
HenningSE May 17, 2023
40d29ae
BugFix
HenningSE May 17, 2023
c58dd7e
Remove epix detector thing from ElectricField plugin
HenningSE May 17, 2023
84b4c2a
Add VerticalMergerPlugin to concatenate outputs of different plugins.…
HenningSE May 20, 2023
ef27e7e
Remove epix dependency in merge_cluster by introduction of VolumePlugins
HenningSE May 20, 2023
faa899c
Cleanup
HenningSE May 20, 2023
696b68e
Update README.md
HenningSE May 20, 2023
1f825b0
Update Simulation_Refactor.ipynb
HenningSE May 20, 2023
5d6c0cb
Merge branch 'config_change' of https://github.com/XENONnT/fuse into …
HenningSE May 20, 2023
de7c131
Bugfixes
HenningSE May 20, 2023
57916e0
Code Cleanup
HenningSE May 20, 2023
192798b
Code Cleanup
HenningSE May 20, 2023
5594bf1
Split S1 plugin (#37)
HenningSE May 20, 2023
96e6a27
Remove last strax.takes_config things
HenningSE May 22, 2023
f190aeb
remove electron_cloud data_kind, so this data can be loaded with inte…
HenningSE May 22, 2023
10e88ef
BugFix
HenningSE May 22, 2023
f188ef8
BugFix
HenningSE May 22, 2023
61060ab
BugFix
HenningSE May 22, 2023
8db2c11
Name changes
HenningSE May 22, 2023
e20cd91
Do not track debug option
HenningSE May 22, 2023
964cbc1
Update README.md
HenningSE May 22, 2023
d111c95
Remove unnecessary config
HenningSE May 22, 2023
36f2d20
Remove dependency on local private_nt_aux_files
HenningSE May 22, 2023
8c1def9
BugFix
HenningSE May 22, 2023
0ac9f8c
Update Notebook
HenningSE May 22, 2023
a6bd8d1
Remove path to private_nt_aux_files
HenningSE May 30, 2023
d245baf
Switch to pyproject.toml and remove some imports
HenningSE May 31, 2023
e45040c
BugFix
HenningSE May 31, 2023
8e18367
Revert "BugFix"
HenningSE May 31, 2023
3d1de13
Revert "Switch to pyproject.toml and remove some imports"
HenningSE May 31, 2023
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
143 changes: 71 additions & 72 deletions Notebooks/Simulation_Refactor.ipynb

Large diffs are not rendered by default.

20 changes: 0 additions & 20 deletions Notebooks/sr0_epix_detectorconfig.ini

This file was deleted.

5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,11 @@ At the moment the intallation procedure is not very advanced. I would recommend

1. Clone the fuse repository.
2. Clone the private_nt_aux_files repository to the same directory as you cloned fuse.
3. Install fuse using `pip install -e .` in the fuse directory.
2. Install fuse using `pip install -e .` in the fuse directory.


## Plugin Structure

The full simulation chain in split into multiple plugins. An overview of the simulation structure can be found below.

![Simulation_Refactor_Plugins](https://user-images.githubusercontent.com/27280678/235156990-7fa63aae-21c4-45b5-9b71-a42a4173f0da.jpg)

![Simulation Refactor](https://github.com/XENONnT/fuse/assets/27280678/2604ff67-ae7b-4d5b-968a-206af6d3e34a)
7 changes: 6 additions & 1 deletion fuse/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
from . import plugins
from .plugins import *
from .plugins import *

from .context import *

from .vertical_merger_plugin import *
from .volume_plugin import *
100 changes: 44 additions & 56 deletions fuse/common.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,34 @@
import numpy as np
import awkward as ak
import straxen
import strax
import numba
from copy import deepcopy


@numba.njit()
def dynamic_chunking(data, scale, n_min):

idx_sort = np.argsort(data)
idx_undo_sort = np.argsort(idx_sort)

data_sorted = data[idx_sort]

diff = data_sorted[1:] - data_sorted[:-1]

clusters = np.array([0])
c = 0
for value in diff:
if value <= scale:
clusters = np.append(clusters, c)

elif len(clusters[clusters == c]) < n_min:
clusters = np.append(clusters, c)

elif value > scale:
c = c + 1
clusters = np.append(clusters, c)

clusters_undo_sort = clusters[idx_undo_sort]

return clusters_undo_sort


def full_array_to_numpy(array, dtype):
Expand All @@ -17,63 +42,26 @@ def full_array_to_numpy(array, dtype):

return numpy_data

#WFSim functions

def make_map(map_file, fmt=None, method='WeightedNearestNeighbors'):
"""Fetch and make an instance of InterpolatingMap based on map_file
Alternatively map_file can be a list of ["constant dummy", constant: int, shape: list]
return an instance of DummyMap"""
#This is a modified version of the corresponding WFsim code....
@numba.njit()
def uniform_to_pe_arr(p, channel, __uniform_to_pe_arr):
indices = np.int64(p * 2000) + 1
return __uniform_to_pe_arr[channel, indices]

if isinstance(map_file, list):
assert map_file[0] == 'constant dummy', ('Alternative file input can only be '
'("constant dummy", constant: int, shape: list')
return DummyMap(map_file[1], map_file[2])

elif isinstance(map_file, str):
if fmt is None:
fmt = parse_extension(map_file)

#log.debug(f'Initialize map interpolator for file {map_file}')
map_data = straxen.get_resource(map_file, fmt=fmt)
return straxen.InterpolatingMap(map_data, method=method)

else:
raise TypeError("Can't handle map_file except a string or a list")

def make_patternmap(map_file, fmt=None, method='WeightedNearestNeighbors', pmt_mask=None):
""" This is special interpretation of the of previous make_map(), but designed
for pattern map loading with provided PMT mask. This way simplifies both S1 and S2
cases
"""
# making tests not failing, we can probably overwrite it completel
if isinstance(map_file, list):
#log.warning(f'Using dummy map with pattern mask! This has no effect here!')
assert map_file[0] == 'constant dummy', ('Alternative file input can only be '
'("constant dummy", constant: int, shape: list')
return DummyMap(map_file[1], map_file[2])
elif isinstance(map_file, str):
if fmt is None:
fmt = parse_extension(map_file)
map_data = deepcopy(straxen.get_resource(map_file, fmt=fmt))
# XXX: straxed deals with pointers and caches resources, it means that resources are global
# what is bad, so we make own copy here and modify it locally
if 'compressed' in map_data:
compressor, dtype, shape = map_data['compressed']
map_data['map'] = np.frombuffer(
strax.io.COMPRESSORS[compressor]['decompress'](map_data['map']),
dtype=dtype).reshape(*shape)
del map_data['compressed']
if 'quantized' in map_data:
map_data['map'] = map_data['quantized']*map_data['map'].astype(np.float32)
del map_data['quantized']
if not (pmt_mask is None):
assert (map_data['map'].shape[-1]==pmt_mask.shape[0]), "Error! Pattern map and PMT gains must have same dimensions!"
map_data['map'][..., ~pmt_mask]=0.0
return straxen.InterpolatingMap(map_data, method=method)
else:
raise TypeError("Can't handle map_file except a string or a list")
#In WFSim uniform_to_pe_arr is called inside a loop over the channels
#I needed to change the code to run on all channels at once
@numba.njit()
def loop_uniform_to_pe_arr(p, channel, __uniform_to_pe_arr):
result = []
for i in range(len(p)):
result.append(uniform_to_pe_arr(p[i],
channel=channel[i],
__uniform_to_pe_arr=__uniform_to_pe_arr) )
return np.array(result)


#WFSim functions
def parse_extension(name):
"""Get the extention from a file name. If zipped or tarred, can contain a dot"""
split_name = name.split('.')
Expand Down
Loading