Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
42 changes: 42 additions & 0 deletions invisible_cities/cities/irene_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
from .. types.symbols import SiPMThreshold

from .. database.load_db import DetDB
from .. database.load_db import DataSiPM
from .. io .pmaps_io import load_pmaps

from . irene import irene
Expand Down Expand Up @@ -495,3 +496,44 @@ def test_irene_other_sample_widths(ICDATADIR, config_tmpdir):
got = getattr( output_file.root, table)
expected = getattr(true_output_file.root, table)
assert_tables_equality(got, expected)


@ignore_warning.no_config_group
def test_irene_masked_sipms_pyrrha(ICDIR, config_tmpdir):
# Test that masked SiPMs are handled in Pyrrha
run_number = 16016

PATH_IN = os.path.join(ICDIR, 'database/test_data/', 'run_16016_0000_ldc1_trg0.waveforms_1evt.h5')
PATH_OUT = os.path.join(config_tmpdir, 'run_16016_0000_ldc1_trg0.waveforms_1evt_pmaps.h5')

nrequired = 1

conf = configure('dummy invisible_cities/config/irene_pyrrha.conf'.split())
cutting_params = conf['cutting_params'].copy()
cutting_params.update(run_number = run_number,
detector_db = DetDB.next100)
conf.update(dict(run_number = run_number,
detector_db = DetDB.next100,
files_in = PATH_IN,
file_out = PATH_OUT,
event_range = (0, nrequired),
cutting_params = cutting_params))

cnt = irene(**conf)
assert cnt.events_in > 0

# Find masked SiPMs in DB and compare to the PMAP output
detector_info = DataSiPM(DetDB.next100, run_number)
active_sipms = np.array(detector_info.Active).astype(bool)
masked_ids = set(np.where(~active_sipms)[0])

pmaps_out = load_pmaps(PATH_OUT)

found_masked = []
for evt, pmap in pmaps_out.items():
for s2si in pmap.s2s:
for sipm_id in s2si.sipms.ids:
if sipm_id in masked_ids:
found_masked.append((evt, sipm_id))

assert not found_masked, (f"Masked SiPMs leaked through pyrrha: {found_masked}")
Git LFS file not shown
8 changes: 4 additions & 4 deletions invisible_cities/reco/wfm_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,9 +318,10 @@ def spatial_selection_method(wfs : np.ndarray,
selected_ids : Array of shape (n_sipms,) containing the indices of the selected SiPMs.
selected_wfs : 2D array of shape (n_selected_sipms, n_time_bins) with the waveforms of the selected SiPMs.
"""
detector_info = load_db.DataSiPM(detector_db, run_number)
sipm_x = np.array(detector_info.X)
sipm_y = np.array(detector_info.Y)
detector_info = load_db.DataSiPM(detector_db, run_number)
active_sipms = detector_info.Active.values.astype(bool)
sipm_x = detector_info.X.values[active_sipms]
sipm_y = detector_info.Y.values[active_sipms]

if selection_method is SiPMSelectionMethod.median_std_method:
starting_ids = median_std_method(wfs, **selection_kwargs)
Expand All @@ -347,4 +348,3 @@ def spatial_selection_method(wfs : np.ndarray,
selected_wfs = wfs[selected_ids]

return selected_ids, selected_wfs

Loading