Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
180 commits
Select commit Hold shift + click to select a range
9f10f96
663 Upload DB
carmenromo Jul 31, 2019
d63a51b
Increase string length for creator process, according to nexus.
paolafer Aug 1, 2019
ccf72f3
Use new file for failing test.
paolafer Aug 2, 2019
e39dcbc
Cosmetics
andLaing Aug 2, 2019
bdd35f6
664 Increase string length for creator process, according to nexus
andLaing Aug 12, 2019
4d0253a
669 Upload database
carmenromo Sep 18, 2019
f835e99
670 Upload DB with new gain values from run 7572
carmenromo Oct 16, 2019
b34721a
Add functions to read only MC hits, to speed up loading file.
paolafer May 1, 2019
38e7861
Use the new function in load_mchits.
paolafer May 1, 2019
36cf1e7
Fix type hint in read_mchit_evt function.
paolafer Oct 18, 2019
0de434a
Reuse existing function, with an additional flag.
paolafer Oct 18, 2019
e9415fe
Reorganize code to make it more efficient.
paolafer Oct 19, 2019
3420d4f
Add type hint.
paolafer Oct 21, 2019
a065eba
654 Merge branch 'new-load-mc-hit-function'
mmkekic Oct 21, 2019
efa594e
Speed up corrections application
gonzaponte Nov 6, 2019
1bff7ba
673 Speed up corrections application
mmkekic Nov 7, 2019
cf24493
Change tests for modified Esmeralda
mmkekic Oct 21, 2019
8fdbd2a
Modify Esmeralda to pass tests
mmkekic Oct 21, 2019
9cf3327
Add test eventinfo table contains all events
mmkekic Oct 21, 2019
0405a57
Write event info and mc info without filtering in Esmeralda.
mmkekic Oct 21, 2019
50b5b06
Add test for load_event_summary in dst_functions.
mmkekic Oct 21, 2019
e5bf583
Add load_event_summary in dst_functions
mmkekic Oct 21, 2019
5cf6edd
Remove norm_strat from Esmeralda; hard code to 'kr'
mmkekic Oct 22, 2019
413157c
Add check for no-filter MC events inside table in esmeralda_test.
mmkekic Oct 23, 2019
3fb9a69
Remove time from PAOLINA/Summary in esmeralda
mmkekic Oct 23, 2019
7d76ab3
Add time from Run/events to load_event_summary DataFrame output
mmkekic Oct 23, 2019
75aff0b
Cast to HitsCollection type only current event in esmeralda reader.
mmkekic Oct 29, 2019
ee5c12c
Add test to show bug in overlap_blob_energy in esmeralda_test
mmkekic Oct 31, 2019
5be3d26
Fix bug in overlap_blob_energy in esmeralda
mmkekic Oct 31, 2019
b885ffe
Add test to show repeated indices in load_dsts and a fix.
mmkekic Oct 31, 2019
6346613
Adapt track_blob_info_extractor for hits with nan energy
mmkekic Nov 1, 2019
dbe8f2b
Add 'out_of_map' flag in sumamry table.
mmkekic Nov 1, 2019
cf3ad14
Adapt Esmeralda body for changed filtering of events
mmkekic Nov 1, 2019
8d877dd
Fix names in tests, adapts out_of_map test dataframe comparison
mmkekic Nov 1, 2019
51b569f
Add 'out_of_map' flag assertation for test out_of_map_hits
mmkekic Nov 1, 2019
9a99880
Add new test file and exact test comparison for esmeralda
mmkekic Nov 1, 2019
5126d45
Change test file in test load_event_summary.
mmkekic Nov 1, 2019
f09d953
Add comments in load_event_summary
mmkekic Nov 1, 2019
62ec5b5
Remove unnecesarry serial mark from tests.
mmkekic Nov 4, 2019
67f8a5d
Remove option to run Esmeralda with uncorrected energy.
mmkekic Nov 4, 2019
3806324
Rename threshold parameters in esmeralda.config
mmkekic Nov 4, 2019
f9cc526
Add r_max and r_ave in tracks table
mmkekic Nov 5, 2019
307387a
Adapt test for different PAOLINA/Tracks table structure
mmkekic Nov 5, 2019
e5576c6
Remove MC and event_info check in test with out_of_map_hits.
mmkekic Nov 5, 2019
3006400
Cosmetics
mmkekic Nov 5, 2019
51d4633
Restructure and rename load_paolina_summary.
mmkekic Nov 5, 2019
9f81255
Add test for list of files as input for load_paolina_summary.
mmkekic Nov 5, 2019
735f202
Replace file for Esmeralda exact table comparison
mmkekic Nov 5, 2019
4981484
Add get_track_energy to paolina functions and corresponding test
mmkekic Nov 5, 2019
d69c52a
Use get_track_energy from paolina_functions in Esmeralda
mmkekic Nov 5, 2019
72ba0cb
Prettyfy esmeralda a la Gonzalo.
mmkekic Nov 5, 2019
ee0540a
Prettify esmeralda_test a la Gonzalo
mmkekic Nov 5, 2019
1bb47a5
672 Modify esmeralda
gonzaponte Nov 8, 2019
62e4f2c
Add test drop_voxel not depends on voxel order.
mmkekic May 7, 2019
1906309
Change drop_voxel to redistribute energy to closest voxels.
mmkekic May 9, 2019
119efd6
Change exact comparison to np.isclose in merge_NN_hits.
mmkekic May 9, 2019
96d87e2
Change energies of voxels_without_hits fixture.
mmkekic May 15, 2019
04ec859
Fix typos in drop_end_point_voxels.
mmkekic May 15, 2019
506df92
Make drop_voxels more readable
mmkekic Nov 11, 2019
826f083
655 Fix drop voxels
gonzaponte Nov 11, 2019
5671ca3
Remove various duplicates
gonzaponte Nov 9, 2019
85f03cf
Add test for HitEnergy
gonzaponte Nov 9, 2019
8f94679
Add Ep attribute to HitEnergy
gonzaponte Nov 9, 2019
6ad1971
Remove meaningless parameters
gonzaponte Nov 9, 2019
73b9f98
cosmetics
gonzaponte Nov 9, 2019
b4a5da3
Remove unnecessary np.array conversion
gonzaponte Nov 9, 2019
5e84330
Extend test for Hit including Ep
gonzaponte Nov 9, 2019
979ca04
Add Ep to Hit
gonzaponte Nov 9, 2019
1c8e0c7
Allow initialization of HitCollection with hits
gonzaponte Nov 9, 2019
fb93061
Add test for nonempty HitCollection
gonzaponte Nov 9, 2019
cc705ff
Add Ep attribute in hits reader
gonzaponte Nov 9, 2019
9282806
Store Ep in hits table
gonzaponte Nov 9, 2019
ff087ab
Modify test to prove they pass when ignoring Ep
gonzaponte Nov 12, 2019
b64be1e
Replace test files with new ones
gonzaponte Nov 9, 2019
dafdad7
Revert "Modify test to prove they pass when ignoring Ep"
gonzaponte Nov 12, 2019
4810530
Remove useless parenthesis
gonzaponte Nov 9, 2019
9f9c47f
Add new variables to hit composite
gonzaponte Nov 12, 2019
2388c33
Parametrize test to use also Ep
gonzaponte Nov 12, 2019
9383a40
674 Add Ep attribute to hit type
gonzaponte Nov 12, 2019
e9fec80
DataFrame based readers for MC data
andLaing Sep 23, 2019
6bd4671
Column names changed to match suggestions
andLaing Nov 11, 2019
4333ad7
Name changes suggested by reviewer
andLaing Nov 12, 2019
880a397
Added tb.File version for load_mchits_df
andLaing Nov 13, 2019
775cdc9
Added test for get_sensor_binning
andLaing Nov 13, 2019
3046557
676 DataFrame based readers for MC data
jmunozv Nov 13, 2019
e6de304
Return dropped voxels in drop_end_point_voxels and refactor
gonzaponte Nov 9, 2019
e0a4bea
Adapt tests for new functions output
gonzaponte Nov 9, 2019
1a09b91
Adapt esmeralda to new function output
gonzaponte Nov 9, 2019
625bb4d
Add test to ensure dropped voxels have nan energy
gonzaponte Nov 12, 2019
e29e7c2
Set energy to nan in dropped voxels
gonzaponte Nov 12, 2019
54b40bb
Add more tests
gonzaponte Nov 12, 2019
43c7e6a
Add test to demonstrate nasty bug
gonzaponte Nov 13, 2019
7da82be
Fix bug in energy sharing of hits and voxels
gonzaponte Nov 13, 2019
38f2168
Smarter voxel comparator
gonzaponte Nov 15, 2019
7a04144
Add exhaustive test
gonzaponte Nov 15, 2019
20055ae
678 Return dropped voxels
mmkekic Nov 15, 2019
05b02f4
Make chi2 test flacky
bpalmeiro Nov 11, 2019
175b273
Remove test_diomira_fee_table
bpalmeiro Nov 11, 2019
13554fc
Remove test_event_number_from_input_file_name
bpalmeiro Nov 11, 2019
c919a9c
Remove test_dorothea_issue_347
bpalmeiro Nov 11, 2019
bcfb248
Remove test_dorothea_event_not_found
bpalmeiro Nov 11, 2019
9b6732f
Remove test_irene_electrons_40keV_pmt_active_is_correctly_set
bpalmeiro Nov 11, 2019
2ccfd01
Remove test_irene_split_trigger
bpalmeiro Nov 11, 2019
49babab
Remove test_penthesilea_event_not_found
bpalmeiro Nov 11, 2019
9ff89b2
Remove commented-out code
gonzaponte Nov 14, 2019
2e47455
Unskip tests
gonzaponte Nov 14, 2019
be58206
Fix test
gonzaponte Nov 14, 2019
ed1beda
Raise ValueError when attempting to trigger on masked channel
gonzaponte Nov 14, 2019
94db660
569 Fix skipped test
carmenromo Nov 18, 2019
6748fab
Test equal number of hits penthesilea and esmeralda
mmkekic Nov 11, 2019
724ec51
Remove outdated test_esmeralda_exact_result_old
mmkekic Nov 12, 2019
e58d897
Rename column names in summary dataframe
mmkekic Nov 12, 2019
20ecb2d
Temporarly adapt esmeralda tests to pass
mmkekic Nov 12, 2019
6d3ff8c
Revert make_event_summary to loop over hits instead of tracks
mmkekic Nov 12, 2019
71d5157
Modify loops in make_paolina_summary
mmkekic Nov 12, 2019
9762ffe
Rename tables output of esmeralda
mmkekic Nov 12, 2019
2e8242e
Modify test to pass with renamed tables
mmkekic Nov 12, 2019
578eacc
Add test showing duplicated hits bug in esmeralda
mmkekic Nov 12, 2019
e39a7c1
Fix bug of duplicated hits in esmeralda
mmkekic Nov 12, 2019
c95488a
Add function that copies Ec to Ep hit attribute
mmkekic Nov 12, 2019
91fd548
Adapt test for newly added Ep column
mmkekic Nov 12, 2019
296cd31
Hardcode Ep in paolina functions in esmeralda
mmkekic Nov 12, 2019
a1af6bf
Add copy_Ec_to_Ep component
gonzaponte Nov 13, 2019
12ba9a5
Add test for number of hits
mmkekic Nov 12, 2019
78bd4de
Fix types_dict in esmeralda
mmkekic Nov 15, 2019
342337f
Remove type comparison in esmeralda exact test
mmkekic Nov 15, 2019
e5453e9
fix not implemented S2qc to -1
mmkekic Nov 15, 2019
e649c8c
Use dictionary keys when defining empty dataframes in esmeralda
mmkekic Nov 15, 2019
89a1ed9
Change threshold_charge params names in esmeralda
mmkekic Nov 18, 2019
9b2902b
Cosmetics.
mmkekic Nov 18, 2019
a24c131
Fixed esmeralda city description
mmkekic Nov 18, 2019
8690133
Remove unnecessary load_paolina_summary.
mmkekic Nov 18, 2019
4db74f8
Cosmetics
mmkekic Nov 19, 2019
21ceda3
Replace test file for exact esmeralda output comparison
mmkekic Nov 19, 2019
fd7448f
675 Modify hit table output of Esmeralda
gonzaponte Nov 19, 2019
a9b44ac
Demonstrate filtering test too slow
andLaing Mar 28, 2019
6fd9711
Implement sipm s/N option for penthesilea
andLaing Apr 12, 2019
dea8472
fixed ccidental delete of imports
andLaing Jun 17, 2019
9f85f02
cosmetics
andLaing Nov 8, 2019
56bd1b3
Incorporate reviewer comments and rebase
andLaing Nov 17, 2019
65c509b
And the ones I forgot
andLaing Nov 17, 2019
e3b0913
Value tests for sipm_charge_array
andLaing Nov 18, 2019
23b25af
Ugly but verbose value comparison
andLaing Nov 18, 2019
1a21264
656 Penthesilea sn option
gonzaponte Nov 19, 2019
da092fa
Add max_num_hits condition in track_blob_info_extractor in esmeralda
mmkekic Nov 26, 2019
0f1c5ab
add mac_num_hits param in esmeralda.config
mmkekic Nov 26, 2019
bb08167
Adapt tests for new esmeralda parameter
mmkekic Nov 26, 2019
2af420f
Add test for filtering on max_num_events
mmkekic Nov 26, 2019
dc8d0a7
Fix docstrings and filter position in esmeralda flow.
mmkekic Nov 26, 2019
1e0631f
Modify test for inclusive summary table
mmkekic Nov 26, 2019
889bf80
Change esmeralda flow to write summary output before topology_filter
mmkekic Nov 26, 2019
f60798e
Cosmetics
mmkekic Nov 27, 2019
1fa5cf9
681 Add too-many-hits filter esmeralda
gonzaponte Nov 27, 2019
b4ba72d
Upload db with gains and pdfs from run 7641
carmenromo Dec 4, 2019
974a5c5
682 Upload db
carmenromo Dec 4, 2019
903dd6b
Upload demopp database
carmenromo Dec 10, 2019
eb6cbcf
684 Upload demopp database
carmenromo Dec 10, 2019
8387662
Add test to show non-sequential time bins in pmap
andLaing Dec 17, 2019
91d01c9
Added protection for rebin bin time
andLaing Jun 26, 2019
c9820ab
Changed test data for irene_exact_result
andLaing Jun 26, 2019
7af4958
Demonstrate fail when multiple negative charge bins
andLaing Dec 17, 2019
6422715
Patch to protect against multiple negative bins
andLaing Dec 17, 2019
d45b1e3
Added comment and moved any check
andLaing Dec 18, 2019
c44680b
Added explicative comment to new negative bins test
andLaing Dec 27, 2019
5984378
687 Protect rebin
carmenromo Dec 31, 2019
cdaeb28
688 Upload database with gain values for different SiPM voltages
carmenromo Jan 9, 2020
a996046
Add functionality to remove hard-coded parameters in peak_functions.
ausonandres Dec 12, 2019
c61a578
Add tests to check new functionality regarding sample frequency
ausonandres Dec 17, 2019
39256db
Add file for new tests
ausonandres Dec 17, 2019
2147df4
Modify tests according to new functionality
ausonandres Dec 17, 2019
0ff8023
Cosmetics
ausonandres Jan 9, 2020
3285ce9
686 Removing hard-coded parameters in irene
andLaing Jan 10, 2020
d73929d
689 Fix coverage version
jmbenlloch Jan 16, 2020
9b49473
Add new city for event selection.
paolafer Jan 24, 2020
4814723
Add tests for the new city.
paolafer Jan 24, 2020
d249385
Add configuration file example.
paolafer Jan 24, 2020
a1b92cd
Eliminate hard-coded paths.
paolafer Jan 24, 2020
8b60981
Add return for city.
paolafer Jan 24, 2020
f7bd748
Add missing test files.
paolafer Jan 24, 2020
c5797f2
Add another fixture to eliminate duplicated function.
paolafer Jan 24, 2020
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
113 changes: 65 additions & 48 deletions invisible_cities/cities/components.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,38 +17,41 @@
import pandas as pd
import inspect


from .. dataflow import dataflow as fl
from .. evm .ic_containers import SensorData
from .. evm .event_model import KrEvent
from .. evm .event_model import Hit
from .. evm .event_model import Cluster
from .. evm .event_model import HitCollection
from .. evm .event_model import MCInfo
from .. core.system_of_units_c import units
from .. core.exceptions import XYRecoFail
from .. core.exceptions import NoInputFiles
from .. core.exceptions import NoOutputFile
from .. core.exceptions import InvalidInputFileStructure
from .. core.configure import EventRange
from .. core.configure import event_range_help
from .. reco import calib_functions as cf
from .. reco import calib_sensors_functions as csf
from .. reco import peak_functions as pkf
from .. reco import pmaps_functions as pmf
from .. reco import hits_functions as hif
from .. reco.tbl_functions import get_mc_info
from .. reco.xy_algorithms import corona
from .. filters.s1s2_filter import S12Selector
from .. filters.s1s2_filter import pmap_filter
from .. database import load_db
from .. sierpe import blr
from .. io.pmaps_io import load_pmaps
from .. io. hits_io import load_hits
from .. io. dst_io import load_dst
from .. types.ic_types import xy
from .. types.ic_types import NN
from .. types.ic_types import NNN
from .. dataflow import dataflow as fl
from .. evm .ic_containers import SensorData
from .. evm .event_model import KrEvent
from .. evm .event_model import Hit
from .. evm .event_model import Cluster
from .. evm .event_model import HitCollection
from .. evm .event_model import MCInfo
from .. evm .pmaps import SiPMCharge
from .. core .system_of_units_c import units
from .. core .exceptions import XYRecoFail
from .. core .exceptions import NoInputFiles
from .. core .exceptions import NoOutputFile
from .. core .exceptions import InvalidInputFileStructure
from .. core .configure import EventRange
from .. core .configure import event_range_help
from .. core .random_sampling import NoiseSampler
from .. reco import calib_functions as cf
from .. reco import calib_sensors_functions as csf
from .. reco import peak_functions as pkf
from .. reco import pmaps_functions as pmf
from .. reco import hits_functions as hif
from .. reco .tbl_functions import get_mc_info
from .. reco .xy_algorithms import corona
from .. filters.s1s2_filter import S12Selector
from .. filters.s1s2_filter import pmap_filter
from .. database import load_db
from .. sierpe import blr
from .. io .pmaps_io import load_pmaps
from .. io .hits_io import hits_from_df
from .. io .dst_io import load_dst
from .. io .hits_io import load_hits
from .. io .dst_io import load_dst
from .. types .ic_types import xy
from .. types .ic_types import NN
from .. types .ic_types import NNN

NoneType = type(None)

Expand Down Expand Up @@ -284,8 +287,8 @@ def hits_and_kdst_from_files(paths: List[str]) -> Iterator[Dict[str,Union[HitCol
"""Reader of the files, yields HitsCollection, pandas DataFrame with kdst info, mc_info, run_number, event_number and timestamp"""
for path in paths:
try:
hits = load_hits(path)
kdst_df = load_dst (path, 'DST', 'Events')
hits_df = load_dst (path, 'RECO', 'Events')
kdst_df = load_dst (path, 'DST' , 'Events')
except tb.exceptions.NoSuchNodeError:
continue

Expand All @@ -297,10 +300,11 @@ def hits_and_kdst_from_files(paths: List[str]) -> Iterator[Dict[str,Union[HitCol
except (tb.exceptions.NoSuchNodeError, IndexError):
continue

check_lengths(event_info, hits)
check_lengths(event_info, hits_df.event.unique())

for evtinfo in event_info:
event_number, timestamp = evtinfo.fetch_all_fields()
hits = hits_from_df(hits_df.loc[hits_df.event == event_number])
yield dict(hits = hits[event_number], kdst = kdst_df.loc[kdst_df.event==event_number], mc=mc_info, run_number=run_number,
event_number=event_number, timestamp=timestamp)
# NB, the monte_carlo writer is different from the others:
Expand Down Expand Up @@ -389,11 +393,14 @@ def compute_z_and_dt(t_s2, t_s1, drift_v):
return z, dt


def build_pointlike_event(dbfile, run_number, drift_v, reco):
datasipm = load_db.DataSiPM(dbfile, run_number)
sipm_xs = datasipm.X.values
sipm_ys = datasipm.Y.values
sipm_xys = np.stack((sipm_xs, sipm_ys), axis=1)
def build_pointlike_event(dbfile, run_number, drift_v,
reco, charge_type = SiPMCharge.raw):
datasipm = load_db.DataSiPM(dbfile, run_number)
sipm_xs = datasipm.X.values
sipm_ys = datasipm.Y.values
sipm_xys = np.stack((sipm_xs, sipm_ys), axis=1)

sipm_noise = NoiseSampler(dbfile, run_number).signal_to_noise

def build_pointlike_event(pmap, selector_output, event_number, timestamp):
evt = KrEvent(event_number, timestamp * 1e-3)
Expand All @@ -420,7 +427,8 @@ def build_pointlike_event(pmap, selector_output, event_number, timestamp):
evt.S2t.append(peak.time_at_max_energy)

xys = sipm_xys[peak.sipms.ids ]
qs = peak.sipms.sum_over_times
qs = peak.sipm_charge_array(sipm_noise, charge_type,
single_point = True)
try:
clusters = reco(xys, qs)
except XYRecoFail:
Expand Down Expand Up @@ -450,12 +458,16 @@ def build_pointlike_event(pmap, selector_output, event_number, timestamp):
return build_pointlike_event


def hit_builder(dbfile, run_number, drift_v, reco, rebin_slices, rebin_method):
def hit_builder(dbfile, run_number, drift_v, reco,
rebin_slices, rebin_method,
charge_type = SiPMCharge.raw):
datasipm = load_db.DataSiPM(dbfile, run_number)
sipm_xs = datasipm.X.values
sipm_ys = datasipm.Y.values
sipm_xys = np.stack((sipm_xs, sipm_ys), axis=1)

sipm_noise = NoiseSampler(dbfile, run_number).signal_to_noise

barycenter = partial(corona,
all_sipms = datasipm,
Qthr = 0 * units.pes,
Expand Down Expand Up @@ -492,25 +504,30 @@ def build_hits(pmap, selector_output, event_number, timestamp):

peak = pmf.rebin_peak(peak, rebin_slices, rebin_method)

xys = sipm_xys[peak.sipms.ids ]
qs = peak.sipms.sum_over_times
xys = sipm_xys[peak.sipms.ids]
qs = peak.sipm_charge_array(sipm_noise, charge_type,
single_point = True)
try : cluster = barycenter(xys, qs)[0]
except XYRecoFail: xy_peak = xy(NN, NN)
else : xy_peak = xy(cluster.X, cluster.Y)

for slice_no, t_slice in enumerate(peak.times):
sipm_charge = peak.sipm_charge_array(sipm_noise ,
charge_type ,
single_point=False)
for slice_no, (t_slice, qs) in enumerate(zip(peak.times ,
sipm_charge)):
z_slice = (t_slice - s1_t) * units.ns * drift_v
e_slice = peak.pmts.sum_over_sensors[slice_no]
try:
xys = sipm_xys[peak.sipms.ids ]
qs = peak.sipms.time_slice(slice_no)
xys = sipm_xys[peak.sipms.ids]
clusters = reco(xys, qs)
es = hif.split_energy(e_slice, clusters)
for c, e in zip(clusters, es):
hit = Hit(peak_no, c, z_slice, e, xy_peak)
hitc.hits.append(hit)
except XYRecoFail:
hit = Hit(peak_no, empty_cluster(), z_slice, e_slice, xy_peak)
hit = Hit(peak_no, empty_cluster(), z_slice,
e_slice, xy_peak)
hitc.hits.append(hit)

return hitc
Expand Down
4 changes: 4 additions & 0 deletions invisible_cities/cities/diomira.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"""

from functools import partial
from itertools import compress

import numpy as np
import tables as tb
Expand Down Expand Up @@ -197,6 +198,9 @@ def do_nothing(*args, **kwargs):
max = s2_params["s2_lmax" ]),
rebin_stride = s2_params["s2_rebin_stride"])

for channel in channels:
if channel not in compress(datapmt.ChannelID, datapmt.Active.values):
raise ValueError("Cannot trigger on a masked PMT")

deconvolver = deconv_pmt(detector_db, run_number, n_baseline, IC_ids)

Expand Down
62 changes: 14 additions & 48 deletions invisible_cities/cities/diomira_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,38 +16,6 @@
from . diomira import diomira


@mark.skip(reason="Table not written in liquid cities anymore")
def test_diomira_fee_table(ICDATADIR):
"Test that FEE table reads back correctly with expected values."
RWF_file = os.path.join(ICDATADIR, 'electrons_40keV_z250_RWF.h5')

with tb.open_file(RWF_file, 'r') as e40rwf:
fee = tbl.read_FEE_table(e40rwf.root.FEE.FEE)
feep = fee.fee_param
eps = 1e-04
# Ignoring PEP8 to improve readability by making symmetry explicit.
assert len(fee.adc_to_pes) == e40rwf.root.RD.pmtrwf.shape[1]
assert len(fee.coeff_blr) == e40rwf.root.RD.pmtrwf.shape[1]
assert len(fee.coeff_c) == e40rwf.root.RD.pmtrwf.shape[1]
assert len(fee.pmt_noise_rms) == e40rwf.root.RD.pmtrwf.shape[1]
assert feep.NBITS == FEE.NBITS
assert abs(feep.FEE_GAIN - FEE.FEE_GAIN) < eps
assert abs(feep.LSB - FEE.LSB) < eps
assert abs(feep.NOISE_I - FEE.NOISE_I) < eps
assert abs(feep.NOISE_DAQ - FEE.NOISE_DAQ) < eps
assert abs(feep.C2/units.nF - FEE.C2/units.nF) < eps
assert abs(feep.C1/units.nF - FEE.C1/units.nF) < eps
assert abs(feep.R1/units.ohm - FEE.R1/units.ohm) < eps
assert abs(feep.ZIN/units.ohm - FEE.Zin/units.ohm) < eps
assert abs(feep.t_sample - FEE.t_sample) < eps
assert abs(feep.f_sample - FEE.f_sample) < eps
assert abs(feep.f_mc - FEE.f_mc) < eps
assert abs(feep.f_LPF1 - FEE.f_LPF1) < eps
assert abs(feep.f_LPF2 - FEE.f_LPF2) < eps
assert abs(feep.OFFSET - FEE.OFFSET) < eps
assert abs(feep.CEILING - FEE.CEILING) < eps


def test_diomira_identify_bug(ICDATADIR):
"""Read a one-event file in which the energy of PMTs is equal to zero and
asset it must be son. This test would fail for a normal file where there
Expand Down Expand Up @@ -112,16 +80,6 @@ def test_diomira_copy_mc_and_offset(ICDATADIR, config_tmpdir):
last_evt_number = h5out.root.MC.extents[-1][0]
assert first_evt_number != last_evt_number


@mark.skip(reason="Feature removed")
@mark.parametrize('filename first_evt'.split(),
(('dst_NEXT_v0_08_09_Co56_INTERNALPORTANODE_74_0_7bar_MCRD_10000.root.h5', 740000),
('NEXT_v0_08_09_Co56_2_0_7bar_MCRD_1000.root.h5' , 2000),
('electrons_40keV_z250_MCRD.h5' , 0)))
def test_event_number_from_input_file_name(filename, first_evt):
assert Diomira.event_number_from_input_file_name(filename) == first_evt


@mark.slow
def test_diomira_mismatch_between_input_and_database(ICDATADIR, output_tmpdir):
file_in = os.path.join(ICDATADIR , 'electrons_40keV_z250_MCRD.h5')
Expand All @@ -140,18 +98,26 @@ def test_diomira_mismatch_between_input_and_database(ICDATADIR, output_tmpdir):
assert cnt.events_in == 1


@mark.skip(reason="Trigger not implemented in liquid cities")
@mark.slow
def test_diomira_trigger_on_masked_pmt_raises_ValueError(ICDATADIR, output_tmpdir):
file_in = os.path.join(ICDATADIR , 'electrons_40keV_z250_MCRD.h5')
file_out = os.path.join(output_tmpdir, 'electrons_40keV_z250_RWF_test_trigger.h5')

conf = configure('diomira invisible_cities/config/diomira.conf'.split())
conf.update(dict(run_number = -4500, # Must be a run number with dead pmts
files_in = file_in,
file_out = file_out,
trigger_type = "S2",
tr_channels = (0,), # This is a masked PMT for this run
conf.update(dict(run_number = -4500, # Must be a run number with dead pmts
files_in = file_in,
file_out = file_out,
trigger_type = "S2",
trigger_params = dict(
tr_channels = (0,), # This is a masked PMT for this run
min_number_channels = 1 ,
data_mc_ratio = 1 ,
min_height = 0 ,
max_height = 1e6 ,
min_charge = 0 ,
max_charge = 1e6 ,
min_width = 0 ,
max_width = 1e6 ),
event_range = (0, 1)))

with raises(ValueError):
Expand Down
35 changes: 0 additions & 35 deletions invisible_cities/cities/dorothea_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,41 +103,6 @@ def test_dorothea_filter_events(config_tmpdir, Kr_pmaps_run4628_filename):
assert np.all(dst.s2_peak.values == s2_peak_pass)



@mark.skip(reason="The configuration of corona in dorothea can only return 1 cluster."
"The assertion of more than one cluster has been removed")
def test_dorothea_issue_347(Kr_pmaps_run4628_filename, config_tmpdir):
PATH_IN = Kr_pmaps_run4628_filename
PATH_OUT = os.path.join(config_tmpdir, 'KrDST.h5')
conf = configure('dummy invisible_cities/config/dorothea_with_corona.conf'.split())

# with this parameters Corona will find several clusters
conf.update(dict(run_number = 4628,
files_in = PATH_IN,
file_out = PATH_OUT,
lm_radius = 10.0,
new_lm_radius = 13.0,
msipm = 1))
cnt = dorothea(**conf)
assert cnt.n_events_more_than_1_cluster == 3


@mark.skip("This scenario is not possible in liquid cities")
def test_dorothea_event_not_found(ICDATADIR, output_tmpdir):
file_in = os.path.join(ICDATADIR , "kr_rwf_0_0_7bar_NEXT_v1_00_05_v0.9.2_20171011_krmc_irene_3evt.h5")
file_out = os.path.join(output_tmpdir, "test_dorothea_event_not_found.h5")

conf = configure('dummy invisible_cities/config/dorothea.conf'.split())
nevt = 3

conf.update(dict(files_in = file_in,
file_out = file_out,
event_range = (0, nevt)))

cnt = dorothea(**conf)
assert cnt.n_empty_pmaps == 1


def test_dorothea_exact_result(ICDATADIR, output_tmpdir):
file_in = os.path.join(ICDATADIR , "Kr83_nexus_v5_03_00_ACTIVE_7bar_3evts.PMP.h5")
file_out = os.path.join(output_tmpdir, "exact_result_dorothea.h5")
Expand Down
Loading