diff --git a/.github/workflows/test_suite.yml b/.github/workflows/test_suite.yml index 60b68a30..3b3ed6c4 100644 --- a/.github/workflows/test_suite.yml +++ b/.github/workflows/test_suite.yml @@ -28,6 +28,9 @@ jobs: run: | cd .. git clone https://github.com/next-exp/IC.git + cd IC + git checkout origin/v2 + cd .. - name: Run tests diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..6a4dae10 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.DS_Store +__pycache__ diff --git a/conf/next-100/kr_he.conf b/conf/next-100/kr_he.conf new file mode 100644 index 00000000..3f0f83cb --- /dev/null +++ b/conf/next-100/kr_he.conf @@ -0,0 +1,95 @@ +folder = '{folderin}' +file_in = '{filein}' +file_bootstrap_map = '$ICARO/maps/next-100/rough_geometry_map_v0.h5' +file_out_map = '{fileoutmap}' +file_out_hists = '{fileouthist}' + +# High Energy Configuration File: +ref_Z_histogram = dict( + ref_histo_file = '$ICARO/reference_files/next-100/krhe_zhist.h5', + key_Z_histo = 'histo_Z_dst' ) + +# run number 0 is for MC +run_number = '{runnumber}' + + +diff_band_lower = lambda dt: -0.7 + 0.030 * (dt-20) +diff_band_upper = lambda dt: 2.6 + 0.036 * (dt-20) + +diff_band_eff_min = 0 +diff_band_eff_max = 1 + +diff_histo_params = dict( + n_bins = 100, + range_hist = ((0, 1300), (0, 50)), + norm = False, +) + +# event selector control + +quality_ranges = dict( + r_max = 480 ) # Max R for initial quality cuts + +nS1_eff_min = 0. # Min nS1==1 eff. to continue map production. +nS1_eff_max = 1. # Max nS1==1 eff. to continue map production. + +nS2_eff_min = 0. # Min nS2==1 eff. to continue map production. +nS2_eff_max = 1. # Max nS2==1 eff. to continue map production. + +nsigmas_Zdst = 1000 # Number of sigmas to consider Z dst correct. + +n_dev_rate = 500 # Number of rel. dev. to consider rate dst correct. + +band_sel_params = dict( + range_Z = (50, 1300) , # Z range to apply selection. + range_E = (8.0e+3,1.0e+4), # Energy range to apply sel. + nbins_z = 80 , # Number of bins in Z axis. + nbins_e = 80 , # Number of bins in energy axis. + nsigma_sel = 3.5 , # Number of sigmas to apply sel. + eff_min = 0. , # Min eff. to continue map prod. + eff_max = 1. ) # Max eff. to continue map prod. + +# get automatic binning +thr_evts_for_sel_map_bins = 1e6 # Threshold to use 50 or 100 bins. +default_n_bins = None # If not specified: n_bins=50 or 100. + +### Histograms params +ns1_histo_params = dict( + nbins_hist = 10 , + range_hist = (0,10), + norm = True ) + +ns2_histo_params = dict( + nbins_hist = 10 , + range_hist = (0,10), + norm = True ) + +rate_histo_params = dict( + bin_size = 180 , + normed = False) + +## Map parameters +map_params = dict( + nbins_z = 15 , + nbins_e = 25 , + z_range = (20, 1350) , + e_range = (2000, 10000) , + chi2_range = (0,100) , + lt_range = (5000, 55000) , + nmin = 20 , + maxFailed = 1000 , + r_max = 480 , + x_range = (-500, 500) , + y_range = (-500, 500) ) + +krevol_params = dict( + r_fid = 200, + nStimeprofile = 3600 * 2, + zslices_lt = 50, + zrange_lt = (50, 1300), + nbins_dv = 50, + zrange_dv = (1300, 1450), + x_range = map_params["x_range"], + y_range = map_params["y_range"], + detector = "next100", +) diff --git a/conf/next-100/kr_only.conf b/conf/next-100/kr_only.conf new file mode 100644 index 00000000..6f547abd --- /dev/null +++ b/conf/next-100/kr_only.conf @@ -0,0 +1,101 @@ +folder = '{folderin}' +file_in = '{filein}' +file_bootstrap_map = '$ICARO/maps/next-100/rough_geometry_map_v2.h5' +file_out_map = '{fileoutmap}' +file_out_hists = '{fileouthist}' + +# High Energy Configuration File: +ref_Z_histogram = dict( + ref_histo_file = '$ICARO/reference_files/next-100/kronly_zhist.h5', + key_Z_histo = 'histo_Z_dst' ) + +# run number 0 is for MC +run_number = '{runnumber}' + +select_diffusion_band = True +diff_band_lower = lambda dt: -0.7 + 0.030 * (dt-20) +diff_band_upper = lambda dt: 2.6 + 0.036 * (dt-20) + +diff_band_eff_min = 0 +diff_band_eff_max = 1 + +diff_histo_params = dict( + n_bins = 100, + range_hist = ((0, 1300), (0, 50)), + norm = False, +) + +# event selector control + +quality_ranges = dict( + r_max = 480 ) # Max R for initial quality cuts + +nS1_eff_min = 0. # Min nS1==1 eff. to continue map production. +nS1_eff_max = 1. # Max nS1==1 eff. to continue map production. + +nS2_eff_min = 0. # Min nS2==1 eff. to continue map production. +nS2_eff_max = 1. # Max nS2==1 eff. to continue map production. + +nsigmas_Zdst = 1000 # Number of sigmas to consider Z dst correct. + +n_dev_rate = 500 # Number of rel. dev. to consider rate dst correct. + +band_sel_params = dict( + range_Z = (50, 1300) , # Z range to apply selection. + range_E = (7.5e+3,9.5e+3), # Energy range to apply sel. + nbins_z = 80 , # Number of bins in Z axis. + nbins_e = 80 , # Number of bins in energy axis. + nsigma_sel = 3.5 , # Number of sigmas to apply sel. + eff_min = 0. , # Min eff. to continue map prod. + eff_max = 1. ) # Max eff. to continue map prod. + +# get automatic binning +thr_evts_for_sel_map_bins = 1e6 # Threshold to use 50 or 100 bins. +default_n_bins = None # If not specified: n_bins=50 or 100. + +### Histograms params +ns1_histo_params = dict( + nbins_hist = 10 , + range_hist = (0,10), + norm = True ) + +ns2_histo_params = dict( + nbins_hist = 10 , + range_hist = (0,10), + norm = True ) + +rate_histo_params = dict( + bin_size = 180 , + normed = False) + +## Map parameters +map_params = dict( + nbins_z = 15 , + nbins_e = 25 , + z_range = (20, 1350) , + e_range = (2000, 10000) , + chi2_range = (0,100) , + lt_range = (5000, 55000) , + nmin = 50 , + maxFailed = 2000 , + dv_maxFailed = 2000 , + r_max = 480 , + x_range = (-500, 500) , + y_range = (-500, 500) ) + + +norm_options = dict( + origin = (-125/2, 3*125/2), + radius = 4*15.55) + +krevol_params = dict( + r_fid = 200, + nStimeprofile = 2*3600, + zslices_lt = 50, + zrange_lt = (50, 1300), + nbins_dv = 50, + zrange_dv = (1300, 1450), + detector = "next100", + norm_strategy = region, + **norm_options, +) diff --git a/krcal/map_builder/config_HEcal.conf b/conf/next-white/config_HEcal.conf similarity index 85% rename from krcal/map_builder/config_HEcal.conf rename to conf/next-white/config_HEcal.conf index b67cca60..0985e03f 100644 --- a/krcal/map_builder/config_HEcal.conf +++ b/conf/next-white/config_HEcal.conf @@ -66,7 +66,22 @@ map_params = dict( nmin = 100 , maxFailed = 600 , r_max = 200 , - r_fid = 100 , - nStimeprofile = 1800 , x_range = (-200,200) , - y_range = (-200,200) ) + y_range = (-200,200) , + dv_maxFailed = 0.5 , +) + +krevol_params = dict( + r_fid = 100, + nStimeprofile = 1800, + zslices_lt = 50, + zrange_lt = (0, 550), + nbins_dv = 35, + zrange_dv = (500, 625), # or 640 + x_range = map_params["x_range"], + y_range = map_params["y_range"], + detector = "new", +) + + +select_diffusion_band = False diff --git a/krcal/map_builder/config_HEcal_HighKrRate.conf b/conf/next-white/config_HEcal_HighKrRate.conf similarity index 84% rename from krcal/map_builder/config_HEcal_HighKrRate.conf rename to conf/next-white/config_HEcal_HighKrRate.conf index 24d46f88..90f9da48 100644 --- a/krcal/map_builder/config_HEcal_HighKrRate.conf +++ b/conf/next-white/config_HEcal_HighKrRate.conf @@ -60,13 +60,29 @@ map_params = dict( nbins_z = 15 , nbins_e = 25 , z_range = (10, 550) , - e_range = (2000, 18000) , + e_range = (1000, 15000) , chi2_range = (0,10) , lt_range = (1000, 15000) , nmin = 100 , maxFailed = 600 , r_max = 200 , - r_fid = 100 , - nStimeprofile = 1800 , x_range = (-200,200) , - y_range = (-200,200) ) + y_range = (-200,200) , + dv_maxFailed = 0.5 , +) + +krevol_params = dict( + r_fid = 100, + nStimeprofile = 1800, + zslices_lt = 50, + zrange_lt = (0, 550), + nbins_dv = 35, + zrange_dv = (500, 625), # or 640 + x_range = map_params["x_range"], + y_range = map_params["y_range"], + detector = "new", +) + + + +select_diffusion_band = False diff --git a/krcal/map_builder/config_LBphys.conf b/conf/next-white/config_LBphys.conf similarity index 83% rename from krcal/map_builder/config_LBphys.conf rename to conf/next-white/config_LBphys.conf index 1bbdd93c..adcc1bf2 100644 --- a/krcal/map_builder/config_LBphys.conf +++ b/conf/next-white/config_LBphys.conf @@ -6,7 +6,7 @@ file_out_hists = '{fileouthist}' # Low Background Configuration File: ref_Z_histogram = dict( - ref_histo_file = '$ICARO/krcal/map_builder/reference_files/z_dst_LB_mean_ref.h5', + ref_histo_file = '$ICARO/reference_files/next-white/z_dst_LB_mean_ref.h5', key_Z_histo = 'histo_Z_dst' ) # run number 0 is for MC @@ -66,8 +66,21 @@ map_params = dict( nmin = 50 , maxFailed = 600 , r_max = 200 , - r_fid = 100 , - nStimeprofile = 1800 , x_range = (-200,200) , y_range = (-200,200) , - dv_maxFailed = 0.5 ) + dv_maxFailed = 0.5 , +) + +krevol_params = dict( + r_fid = 100, + nStimeprofile = 1800, + zslices_lt = 50, + zrange_lt = (0, 550), + nbins_dv = 35, + zrange_dv = (500, 625), # or 640 + x_range = map_params["x_range"], + y_range = map_params["y_range"], + detector = "new", +) + +select_diffusion_band = False diff --git a/krcal/map_builder/config_LBphys_run4.conf b/conf/next-white/config_LBphys_run4.conf similarity index 84% rename from krcal/map_builder/config_LBphys_run4.conf rename to conf/next-white/config_LBphys_run4.conf index 6b13710c..dd2d75dc 100644 --- a/krcal/map_builder/config_LBphys_run4.conf +++ b/conf/next-white/config_LBphys_run4.conf @@ -63,10 +63,26 @@ map_params = dict( e_range = (2000, 18000) , chi2_range = (0,10000) , lt_range = (1000, 15000) , - nmin = 50 , + nmin = 50 , maxFailed = 600 , r_max = 200 , - r_fid = 100 , - nStimeprofile = 1800 , x_range = (-200,200) , - y_range = (-200,200) ) + y_range = (-200,200) , + dv_maxFailed = 0.5 , +) + +krevol_params = dict( + r_fid = 100, + nStimeprofile = 1800, + zslices_lt = 50, + zrange_lt = (0, 550), + nbins_dv = 35, + zrange_dv = (500, 625), # or 640 + x_range = map_params["x_range"], + y_range = map_params["y_range"], + detector = "new", +) + + + +select_diffusion_band = False diff --git a/krcal/map_builder/config_NoChecks.conf b/conf/next-white/config_NoChecks.conf similarity index 84% rename from krcal/map_builder/config_NoChecks.conf rename to conf/next-white/config_NoChecks.conf index 169cd9ac..71982911 100644 --- a/krcal/map_builder/config_NoChecks.conf +++ b/conf/next-white/config_NoChecks.conf @@ -55,6 +55,7 @@ rate_histo_params = dict( bin_size = 180 , normed = False) +## Map parameters ## Map parameters map_params = dict( nbins_z = 15 , @@ -66,7 +67,23 @@ map_params = dict( nmin = 100 , maxFailed = 600 , r_max = 200 , - r_fid = 100 , - nStimeprofile = 1800 , x_range = (-200,200) , - y_range = (-200,200) ) + y_range = (-200,200) , + dv_maxFailed = 0.5 , +) + +krevol_params = dict( + r_fid = 100, + nStimeprofile = 1800, + zslices_lt = 50, + zrange_lt = (0, 550), + nbins_dv = 35, + zrange_dv = (500, 625), # or 640 + x_range = map_params["x_range"], + y_range = map_params["y_range"], + detector = "new", +) + + + +select_diffusion_band = False diff --git a/krcal/core/correction_functions.py b/krcal/core/correction_functions.py index 9b23d799..fae7bb0b 100644 --- a/krcal/core/correction_functions.py +++ b/krcal/core/correction_functions.py @@ -7,12 +7,13 @@ from invisible_cities.reco.corrections import get_normalization_factor -def e0_xy_correction(map : ASectorMap, - norm_strategy: NormStrategy = NormStrategy.max): +def e0_xy_correction(map : ASectorMap, + norm_strategy : NormStrategy, + **norm_options : dict): """ Temporal function to perfrom IC geometric corrections only """ - normalization = get_normalization_factor(map , norm_strategy) + normalization = get_normalization_factor(map , norm_strategy, **norm_options) get_xy_corr_fun = maps_coefficient_getter (map.mapinfo, map.e0) def geo_correction_factor(x : np.array, y : np.array) -> np.array: diff --git a/krcal/core/fit_functions.py b/krcal/core/fit_functions.py index eed69704..779c08dd 100644 --- a/krcal/core/fit_functions.py +++ b/krcal/core/fit_functions.py @@ -1,5 +1,5 @@ """Module fit_functions. -This module includes general fit functions +This module includes general fit functions Notes ----- @@ -335,10 +335,11 @@ def sigmoid(x : np.array, def compute_drift_v(zdata : np.array, - nbins : int = 35, - zrange : Tuple[float, float] = (500, 640), + nbins : int, + zrange : Tuple[float, float], + detector : str, seed : Tuple[float, float, float, float] = None, - detector : str = 'new')->Tuple[float, float]: + )->Tuple[float, float]: """ Computes the drift velocity for a given distribution using the sigmoid function to get the cathode edge. @@ -371,7 +372,10 @@ def compute_drift_v(zdata : np.array, if seed is None: seed = np.max(y), np.mean(zrange), 0.5, np.min(y) - z_cathode = DB.DetectorGeo(detector).ZMAX[0] + if detector == "new": + z_cathode = DB.DetectorGeo(detector).ZMAX[0] + elif detector == "next100": + z_cathode = 1187 # TEMPORARY try: f = fitf.fit(sigmoid, x, y, seed, sigma=poisson_sigma(y), fit_range=zrange) dv = z_cathode/f.values[1] diff --git a/krcal/core/fit_functions_test.py b/krcal/core/fit_functions_test.py index 805b3d60..138b4721 100644 --- a/krcal/core/fit_functions_test.py +++ b/krcal/core/fit_functions_test.py @@ -335,14 +335,13 @@ def test_compute_drift_v_when_moving_edge(): Nevents = 100 * 1000 data = np.random.uniform(450, edge, Nevents) data = np.random.normal(data, 1) - dv, dvu = compute_drift_v(data, 60, [500,600], - [1500, 550,1,0], 'new') + dv, dvu = compute_drift_v(data, 60, [500,600], "new", [1500, 550,1,0]) dv_th = DB.DetectorGeo('new').ZMAX[0]/edge assert dv_th == approx(dv, abs=5*dvu) def test_sigmoid_failing_fit_return_nan(): dst = np.random.rand(1000) - dv_vect = compute_drift_v(dst) + dv_vect = compute_drift_v(dst, nbins=35, zrange=(500, 640), seed=None, detector="new") nans = np.array([np.nan, np.nan]) assert dv_vect, nans diff --git a/krcal/core/fit_lt_functions.py b/krcal/core/fit_lt_functions.py index 4fa72d84..331c4060 100644 --- a/krcal/core/fit_lt_functions.py +++ b/krcal/core/fit_lt_functions.py @@ -96,9 +96,9 @@ class FitCollection2(FitCollection): range2 = range_e) if fit == FitType.profile: - fp, fp2, fr = fit_lifetime_profile(z, e, nbins_z, range_z) + fp, fp2, fr = fit_lifetime_profile(z, e, nbins_z, range_z) else: - fp, fp2, fr = fit_lifetime_unbined(z, e, nbins_z, range_z) + fp, fp2, fr, _ = fit_lifetime_unbined(z, e, nbins_z, range_z) return FitCollection2(fp = fp, fp2 = fp2, hp = hp, fr = fr) logging.debug(f' fp ={fp}, fp2 ={fp2} ') @@ -194,7 +194,7 @@ class FitResult: def fit_lifetime_unbined(z : np.array, e : np.array, nbins_z : int, - range_z : Tuple[float,float])->Tuple[FitPar, FitPar, FitResult]: + range_z : Tuple[float,float])->Tuple[FitPar, FitPar, FitResult, bool]: """ Based on @@ -223,7 +223,7 @@ def fit_lifetime_unbined(z : np.array, FitPar : Fit parameters (arrays of fitted values and errors, fit function) FitPar : Fit parameters FirResults: Fit results (lt, e0, errors, chi2) - + valid: a boolean indicating whether the fit was successful """ logging.debug(' fit_liftime_unbined') @@ -275,6 +275,10 @@ def fit_lifetime_unbined(z : np.array, valid = False except SystemError: + logging.warn(f'SystemError error found in fit_lifetime_unbined: not enough events for fit') + valid = False + + except LinAlgError: logging.warn(f'LinAlgError error found in fit_lifetime_unbined: not enough events for fit') valid = False @@ -283,7 +287,7 @@ def fit_lifetime_unbined(z : np.array, chi2 = c2, valid = valid) - return fp, fp2, fr + return fp, fp2, fr, valid def pars_from_fcs(fcs : List[FitCollection])->Tuple[List[Measurement], diff --git a/krcal/core/fit_lt_functions_test.py b/krcal/core/fit_lt_functions_test.py index cad6274d..cd78d61b 100644 --- a/krcal/core/fit_lt_functions_test.py +++ b/krcal/core/fit_lt_functions_test.py @@ -175,8 +175,8 @@ def test_fit_lt_unbined_uses_correct_zrange(): z_range = (0, max_z) nbins_z = 50 - _, _, pars = fit_lifetime_unbined(z , es , nbins_z, z_range); - _, _, pars_new = fit_lifetime_unbined(z_new, es_new, nbins_z, z_range); + _, _, pars , _ = fit_lifetime_unbined(z , es , nbins_z, z_range); + _, _, pars_new , _ = fit_lifetime_unbined(z_new, es_new, nbins_z, z_range); lt , e0 = pars.par ltu, e0u = pars.err lt_new , e0_new = pars_new.par diff --git a/krcal/core/io_functions.py b/krcal/core/io_functions.py index c3d2ca38..f0045cdc 100644 --- a/krcal/core/io_functions.py +++ b/krcal/core/io_functions.py @@ -50,3 +50,41 @@ def compute_and_save_hist_as_pd(values : np.array , out_file.put(hist_name, table, format='table', data_columns=True) return + +def compute_and_save_hist2d_as_pd(values : np.array , + out_file : pd.HDFStore , + hist_name : str , + n_bins : int , + range_hist : Tuple[float, float], + norm : bool = False )->None: + """ + Computes 1d-histogram and saves it in a file. + The name of the table inside the file must be provided. + Parameters + ---------- + values : np.array + Array with values to be plotted. + out_file: pd.HDFStore + File where histogram will be saved. + hist_name: string + Name of the pd.Dataframe to contain the histogram. + n_bins: int + Number of bins to make the histogram. + range_hist: length-2 tuple (optional) + Range of the histogram. + norm: bool + If True, histogram will be normalized. + """ + n, bx, by = np.histogram2d(*values, bins = n_bins, + range = range_hist, + density = norm) + bx = shift_to_bin_centers(np.unique(bx)) + by = shift_to_bin_centers(np.unique(by)) + bx, by = map(np.ravel, np.meshgrid(bx, by, indexing="ij")) + table = pd.DataFrame({'entries': n.flatten(), + 'magnitude_x': bx, + 'magnitude_y': by, + }) + out_file.put(hist_name, table, format='table', data_columns=True) + + return diff --git a/krcal/core/kr_parevol_functions.py b/krcal/core/kr_parevol_functions.py index c69ef482..c6528b37 100644 --- a/krcal/core/kr_parevol_functions.py +++ b/krcal/core/kr_parevol_functions.py @@ -42,14 +42,17 @@ def get_number_of_time_bins(nStimeprofile: int, return ntimebins -def computing_kr_parameters(data : pd.DataFrame, - ts : float, - emaps : ASectorMap, - zslices_lt : int, - zrange_lt : Tuple[float,float] = (0, 550), - nbins_dv : int = 35, - zrange_dv : Tuple[float, float] = (500, 625), - detector : str = 'new')->pd.DataFrame: +def computing_kr_parameters(data : pd.DataFrame, + ts : float, + emaps : ASectorMap, + bootstrap_map : ASectorMap, + norm_strategy : NormStrategy, + zslices_lt : int, + zrange_lt : Tuple[float,float], + nbins_dv : int, + zrange_dv : Tuple[float, float], + detector : str, + **norm_options : dict)->pd.DataFrame: """ Computes some average parameters (e0, lt, drift v, energy @@ -63,11 +66,11 @@ def computing_kr_parameters(data : pd.DataFrame, ts: float Central time of the distribution. emaps: correction map - Allows geometrical correction of the energy. - xr_map, yr_map: length-2 tuple - Set the X/Y-coordinate range of the correction map. - nx_map, ny_map: int - Set the number of X/Y-coordinate bins for the correction map. + Map for self-correcting data in parameter estimation of resolution. + bootstrap_map : correction map + Reference map for setting the energy scale and monitor its evolution. + norm_strategy: NormStrategy + Chosen approach for normalization purposes. zslices_lt: int Number of Z-coordinate bins for doing the exponential fit to compute the lifetime. @@ -83,6 +86,7 @@ def computing_kr_parameters(data : pd.DataFrame, detector: string (optional) Used to get the cathode position from DB for the drift velocity computation. + Returns ------- pars: DataFrame @@ -90,13 +94,13 @@ def computing_kr_parameters(data : pd.DataFrame, """ ## lt and e0 - geo_correction_factor = e0_xy_correction(map = emaps, - norm_strategy = NormStrategy.max) + geo_correction_factor = e0_xy_correction(map = bootstrap_map, + norm_strategy = norm_strategy, + **norm_options) _, _, fr = fit_lifetime_profile(data.Z, - data.S2e.values*geo_correction_factor( - data.X.values, - data.Y.values), + data.S2e.values*geo_correction_factor(data.X.values, + data.Y.values), zslices_lt, zrange_lt) e0, lt = fr.par e0u, ltu = fr.err @@ -106,16 +110,19 @@ def computing_kr_parameters(data : pd.DataFrame, zrange=zrange_dv, detector=detector) ## energy resolution and error - tot_corr_factor = apply_all_correction(maps = emaps, - apply_temp=False) + tot_corr_factor = apply_all_correction(maps = emaps, + apply_temp = False) nbins = int((len(data.S2e))**0.5) - f = quick_gauss_fit(data.S2e.values*tot_corr_factor( - data.X.values, - data.Y.values, - data.Z.values, - data.time.values), - bins=nbins) - R = resolution(f.values, f.errors, 41.5) + ecorr = data.S2e .values * tot_corr_factor(data.X .values, + data.Y .values, + data.Z .values, + data.time.values) + try: + f = quick_gauss_fit(ecorr, bins=nbins) + R = resolution(f.values, f.errors, 41.5) + except: + R = resolution((np.nan,)*3, (np.nan,)*3, 41.5) + resol, err_resol = R[0][0], R[0][1] ## average values parameters = ['S1w', 'S1h', 'S1e', @@ -123,7 +130,7 @@ def computing_kr_parameters(data : pd.DataFrame, 'Nsipm', 'Xrms', 'Yrms'] mean_d, var_d = {}, {} for parameter in parameters: - data_value = getattr(data, parameter) + data_value = getattr(data, parameter) mean_d[parameter] = np.mean(data_value) var_d [parameter] = (np.var(data_value)/len(data_value))**0.5 @@ -147,19 +154,18 @@ def computing_kr_parameters(data : pd.DataFrame, return pars -def kr_time_evolution(ts : np.array, - masks_time : List[np.array], - dst : pd.DataFrame, - emaps : ASectorMap, - xr_map : Tuple[float, float], - yr_map : Tuple[float, float], - nx_map : int, - ny_map : int, - zslices_lt : int = 50, - zrange_lt : Tuple[float,float] = (0, 550), - nbins_dv : int = 35, - zrange_dv : Tuple[float, float] = (500, 625), - detector : str = 'new')->pd.DataFrame: +def kr_time_evolution(ts : np.array, + masks_time : List[np.array], + dst : pd.DataFrame, + emaps : ASectorMap, + bootstrap_map : ASectorMap, + norm_strategy : NormStrategy, + zslices_lt : int, + zrange_lt : Tuple[float,float], + nbins_dv : int, + zrange_dv : Tuple[float, float], + detector : str, + **norm_options)->pd.DataFrame: """ Computes some average parameters (e0, lt, drift v, S1w, S1h, S1e, S2w, S2h, S2e, S2q, Nsipm, 'Xrms, Yrms) @@ -206,11 +212,17 @@ def kr_time_evolution(ts : np.array, frames = [] for index in range(len(masks_time)): sel_dst = dst[masks_time[index]] - pars = computing_kr_parameters(sel_dst, ts[index], - emaps, - zslices_lt, zrange_lt, - nbins_dv, zrange_dv, - detector) + pars = computing_kr_parameters(data = sel_dst, + ts = ts[index], + emaps = emaps, + bootstrap_map = bootstrap_map, + norm_strategy = norm_strategy, + zslices_lt = zslices_lt, + zrange_lt = zrange_lt, + nbins_dv = nbins_dv, + zrange_dv = zrange_dv, + detector = detector, + **norm_options) frames.append(pars) total_pars = pd.concat(frames, ignore_index=True) diff --git a/krcal/core/map_functions.py b/krcal/core/map_functions.py index 9e84adad..b36c9f1c 100644 --- a/krcal/core/map_functions.py +++ b/krcal/core/map_functions.py @@ -94,10 +94,11 @@ class SectorMapTS: def amap_from_tsmap(tsMap : SectorMapTS, - ts : int = 0, - range_e : Tuple[float, float] = (5000, 13000), - range_chi2 : Tuple[float, float] = ( 0, 3), - range_lt : Tuple[float, float] = (1800, 3000)) -> ASectorMap: + ts : int, + range_e : Tuple[float, float], + range_chi2 : Tuple[float, float], + range_lt : Tuple[float, float], + )-> ASectorMap: """ Obtain the correction maps for time bin ts. diff --git a/krcal/core/selection_functions.py b/krcal/core/selection_functions.py index a861e76e..67eb3036 100644 --- a/krcal/core/selection_functions.py +++ b/krcal/core/selection_functions.py @@ -97,9 +97,9 @@ def get_time_series_df(time_bins : Number, return shift_to_bin_centers(ip), masks -def select_xy_sectors_df(dst : DataFrame, - bins_x : np.array, - bins_y : np.array)-> Dict[int, List[DataFrame]]: +def select_xy_sectors_df(dst : DataFrame, + bins_x : np.array, + bins_y : np.array)-> Dict[int, List[DataFrame]]: """ Return a DataFrameMap of selections organized by xy sector DataFrameMap = Dict[int, List[DataFrame]] @@ -130,14 +130,14 @@ def select_xy_sectors_df(dst : DataFrame, return dstMap -def selection_in_band(z : np.array, - e : np.array, - range_z : Range, - range_e : Range, - nbins_z : int = 50, - nbins_e : int = 100, - nsigma : float = 3.5) ->Tuple[np.array, FitPar, FitPar, - HistoPar2, ProfilePar]: +def selection_in_band(z : np.array, + e : np.array, + range_z : Range, + range_e : Range, + nbins_z : int = 50, + nbins_e : int = 100, + nsigma : float = 3.5) ->Tuple[np.array, FitPar, FitPar, + HistoPar2, ProfilePar]: """ This returns a selection of the events that are inside the Kr E vz Z returns: np.array(bool) """ @@ -148,18 +148,21 @@ def selection_in_band(z : np.array, zc = shift_to_bin_centers(zbins) sel_e = in_range(e, *range_e) - mean, sigma, chi2, ok = fit_slices_1d_gauss(z[sel_e], e[sel_e], zbins, ebins, min_entries=5e2) + mean, sigma, chi2, ok = fit_slices_1d_gauss(z[sel_e], e[sel_e], zbins, ebins, min_entries=1e2) e_mean = mean.value e_sigma = sigma.value # 1. Profile of mean values of e in bins of z #zc, e_mean, e_sigma = fitf.profileX(z, e, nbins_z, range_z, range_e) #2. Fit two exponentials to e_mmean +- ns_igma * e_sigma defining a band - y = e_mean + nsigma * e_sigma - fph, _, _ = fit_lifetime_unbined(zc, y, nbins_z, range_z) - y = e_mean - nsigma * e_sigma - fpl, _, _ = fit_lifetime_unbined(zc, y, nbins_z, range_z) + y = e_mean + nsigma * e_sigma + fph, _, _, validh = fit_lifetime_unbined(zc[ok], y[ok], nbins_z, range_z) + + y = e_mean - nsigma * e_sigma + fpl, _, _, validl = fit_lifetime_unbined(zc[ok], y[ok], nbins_z, range_z) # 3. Select events in the range defined by the band - sel_inband = in_range(e, fpl.f(z), fph.f(z)) + sel_inband = in_range( e + , fpl.f(z) if validl else 0. + , fph.f(z) if validh else np.inf) hp = HistoPar2(var = z, nbins = nbins_z, @@ -171,4 +174,3 @@ def selection_in_band(z : np.array, pp = ProfilePar(x = zc, xu = zerror, y = e_mean, yu = e_sigma) return sel_inband, fpl, fph, hp, pp - diff --git a/krcal/map_builder/checking_functions.py b/krcal/map_builder/checking_functions.py index 8b46e4ab..44e67415 100644 --- a/krcal/map_builder/checking_functions.py +++ b/krcal/map_builder/checking_functions.py @@ -44,10 +44,10 @@ def get_core(nbins,rmax, rfid): return mask def check_failed_fits(maps : ASectorMap, - maxFailed : float = 600, - nbins : int = 100, - rmax : float = 200, - rfid : float = 200): + maxFailed : float , + nbins : int , + rmax : float , + rfid : float ): inner_core_mask = get_core(nbins=nbins, rmax=rmax, rfid=rfid) map_values_in_core = maps.lt.values[inner_core_mask] numFailed = np.count_nonzero(np.isnan(map_values_in_core)) diff --git a/krcal/map_builder/config.conf b/krcal/map_builder/config.conf deleted file mode 100644 index 8f808c75..00000000 --- a/krcal/map_builder/config.conf +++ /dev/null @@ -1,72 +0,0 @@ -folder = '' -file_in = '' -file_bootstrap_map = '' -file_out_map = '' -file_out_hists = '' - -# High Energy Configuration File: -ref_Z_histogram = dict( - ref_histo_file = '$ICARO/krcal/map_builder/reference_files/z_dst_HE_mean_ref.h5', - key_Z_histo = 'histo_Z_dst' ) - -# run number 0 is for MC -run_number = 7506 - -# event selector control - -quality_ranges = dict( - r_max = 200 ) # Max R for initial quality cuts - -nS1_eff_min = 0.7 # Min nS1==1 eff. to continue map production. -nS1_eff_max = 0.9 # Max nS1==1 eff. to continue map production. - -nS2_eff_min = 0.63 # Min nS2==1 eff. to continue map production. -nS2_eff_max = 0.83 # Max nS2==1 eff. to continue map production. - -nsigmas_Zdst = 10 # Number of sigmas to consider Z dst correct. - -n_dev_rate = 5 # Number of rel. dev. to consider rate dst correct. - -band_sel_params = dict( - range_Z = (10, 550) , # Z range to apply selection. - range_E = (10.0e+3,14e+3), # Energy range to apply sel. - nbins_z = 50 , # Number of bins in Z axis. - nbins_e = 50 , # Number of bins in energy axis. - nsigma_sel = 3.5 , # Number of sigmas to apply sel. - eff_min = 0.38 , # Min eff. to continue map prod. - eff_max = 0.58 ) # Max eff. to continue map prod. - -# get automatic binning -thr_evts_for_sel_map_bins = 1e6 # Threshold to use 50 or 100 bins. -default_n_bins = None # If not specified: n_bins=50 or 100. - -### Histograms params -ns1_histo_params = dict( - nbins_hist = 10 , - range_hist = (0,10), - norm = True ) - -ns2_histo_params = dict( - nbins_hist = 10 , - range_hist = (0,10), - norm = True ) - -rate_histo_params = dict( - bin_size = 180 , - normed = False) - -## Map parameters -map_params = dict( - nbins_z = 15 , - nbins_e = 25 , - z_range = (10, 550) , - e_range = (2000, 18000) , - c2_range = (0,5) , - lt_range = (1000, 15000) , - nmin = 100 , - maxFailed = 600 , - x2range = (0, 2) , - r_fid = 100 , - nStimeprofile = 1800 , - x_range = (-200,200) , - y_range = (-200,200) ) diff --git a/krcal/map_builder/map_builder_functions.py b/krcal/map_builder/map_builder_functions.py index ce6a5620..f5363163 100644 --- a/krcal/map_builder/map_builder_functions.py +++ b/krcal/map_builder/map_builder_functions.py @@ -1,4 +1,5 @@ from typing import Tuple +from typing import Callable from dataclasses import dataclass from copy import deepcopy @@ -26,6 +27,7 @@ from .. core.kr_parevol_functions import get_number_of_time_bins from .. core.io_functions import write_complete_maps from .. core.io_functions import compute_and_save_hist_as_pd +from .. core.io_functions import compute_and_save_hist2d_as_pd from .. core.histo_functions import compute_similar_histo from .. core.histo_functions import normalize_histo_and_poisson_error from .. core.histo_functions import ref_hist @@ -117,14 +119,14 @@ def load_data(input_path : str , return dst_filtered, bootstrap_map, ref_histos -def selection_nS_mask_and_checking(dst : pd.DataFrame , - column : type_of_signal , - interval : Tuple[float, float] , - output_f : pd.HDFStore , - input_mask : np.array = None , - nbins_hist : int = 10 , - range_hist : Tuple[float, float] = (0,10), - norm : bool = True)->np.array: +def selection_nS_mask_and_checking(dst : pd.DataFrame , + column : type_of_signal , + interval : Tuple[float, float], + output_f : pd.HDFStore , + nbins_hist : int , + range_hist : Tuple[float, float], + input_mask : np.array = None , + norm : bool = True )->np.array: """ Selects nS1(or nS2) == 1 for a given kr dst and returns the mask. It also computes selection efficiency, @@ -156,7 +158,7 @@ def selection_nS_mask_and_checking(dst : pd.DataFrame , """ if input_mask is None: input_mask = [True] * len(dst) - else: pass; + mask = np.zeros_like(input_mask) mask[input_mask] = getattr(dst[input_mask], column.value) == 1 nevts_after = dst[mask] .event.nunique() @@ -249,6 +251,7 @@ def check_rate_and_hist(times : np.array , """ min_time = times.min() max_time = times.max() + ntimebins = get_number_of_time_bins(bin_size, min_time, max_time) @@ -275,17 +278,16 @@ def check_rate_and_hist(times : np.array , raising_message = message ) return; -def band_selector_and_check(dst : pd.DataFrame, - boot_map : ASectorMap, - norm_strat : NormStrategy = NormStrategy.max, - input_mask : np.array = None, - range_Z : Tuple[np.array, np.array] = (10, 550), - range_E : Tuple[np.array, np.array] = (10.0e+3,14e+3), - nbins_z : int = 50, - nbins_e : int = 50, - nsigma_sel : float = 3.5, - eff_min : float = 0.4, - eff_max : float = 0.6 +def band_selector_and_check(dst : pd.DataFrame , + boot_map : ASectorMap , + range_Z : Tuple[np.array, np.array], + range_E : Tuple[np.array, np.array], + nbins_z : int , + nbins_e : int , + nsigma_sel : float , + eff_min : float , + eff_max : float , + input_mask : np.array = None )->np.array: """ This function returns a selection of the events that @@ -326,7 +328,7 @@ def band_selector_and_check(dst : pd.DataFrame, input_mask = [True] * len(dst) else: pass; - emaps = e0_xy_correction(boot_map, norm_strategy = norm_strat) + emaps = e0_xy_correction(boot_map, NormStrategy.max) E0 = dst[input_mask].S2e.values * emaps(dst[input_mask].X.values, dst[input_mask].Y.values) @@ -382,10 +384,10 @@ def calculate_map(dst : pd.DataFrame, e_range : Tuple[float, float], chi2_range: Tuple[float, float], lt_range: Tuple[float, float], - fit_type: FitType = FitType.unbined, - nmin : int = 100, - x_range : Tuple[float, float] = (-200,200), - y_range : Tuple[float, float] = (-200,200) + fit_type: FitType, + nmin : int, + x_range : Tuple[float, float], + y_range : Tuple[float, float], ): """ Calculates and outputs correction map @@ -479,9 +481,10 @@ def regularize_map(maps : ASectorMap, x2range : Tuple[float, float] = (0, 2) ): return amap def remove_peripheral(map : ASectorMap, - nbins : int = 100, - rmax : float = 200, - rfid : float = 200) -> ASectorMap: + nbins : int , + rmax : float , + rfid : float , + ) -> ASectorMap: new_map = deepcopy(map) mask_core = get_core(nbins,rmax, rfid) @@ -492,15 +495,19 @@ def remove_peripheral(map : ASectorMap, return new_map -def add_krevol(maps : ASectorMap, - dst : pd.DataFrame, - masks_cuts : masks_container, - r_fid : float, - nStimeprofile: int, - x_range : Tuple[float, float], - y_range : Tuple[float, float], - XYbins : Tuple[int, int], - **kwargs ) -> None: +def add_krevol(maps : ASectorMap, + dst : pd.DataFrame, + masks_cuts : masks_container, + r_fid : float, + nStimeprofile : int, + bootstrap_map : ASectorMap, + norm_strategy : NormStrategy, + zslices_lt : int, + zrange_lt : Tuple[float, float], + nbins_dv : int, + zrange_dv : Tuple[float, float], + detector : str, + **norm_options): """ Adds time evolution dataframe to the map @@ -539,14 +546,18 @@ def add_krevol(maps : ASectorMap, dst = dst) masks_timef = [mask[fmask] for mask in masks_time] - pars = kr_time_evolution(ts = ts, - masks_time = masks_timef, - dst = dstf, - emaps = maps, - xr_map = x_range, - yr_map = y_range, - nx_map = XYbins[0], - ny_map = XYbins[1]) + pars = kr_time_evolution(ts = ts, + masks_time = masks_timef, + dst = dstf, + emaps = maps, + bootstrap_map = bootstrap_map, + norm_strategy = norm_strategy, + zslices_lt = zslices_lt, + zrange_lt = zrange_lt, + nbins_dv = nbins_dv, + zrange_dv = zrange_dv, + detector = detector, + **norm_options) pars_ec = cut_time_evolution(masks_time = masks_time, dst = dst, @@ -563,9 +574,7 @@ def add_krevol(maps : ASectorMap, return -def check_drift_v_computation(drift_v : np.ndarray , - dv_maxFailed : float = 0.5, - **kwargs ) -> None: +def check_drift_v_computation(drift_v: np.ndarray, dv_maxFailed: float): """ Checks if drift velocity computation has failed in too many temporal bins. If that is the case, map computation will abort. @@ -603,13 +612,13 @@ def compute_map(dst : pd.DataFrame, e_range : Tuple[float, float], chi2_range : Tuple[float, float], lt_range : Tuple[float, float], - fit_type : FitType = FitType.unbined, - nmin : int = 100, - maxFailed : int = 600, - r_max : float = 200, - x_range : Tuple[float, float] = (-200,200), - y_range : Tuple[float, float] = (-200,200), - **kwargs ) -> ASectorMap: + fit_type : FitType, + nmin : int, + maxFailed : int, + r_max : float, + x_range : Tuple[float, float], + y_range : Tuple[float, float], + dv_maxFailed : float) -> ASectorMap: maps = calculate_map (dst = dst, XYbins = XYbins, @@ -646,6 +655,41 @@ def compute_map(dst : pd.DataFrame, return no_peripheral + +def select_physical_events(dst : pd.DataFrame, + lower : Callable, + upper : Callable, + eff_interval : Tuple[float, float], + output : pd.HDFStore, + diff_histo_params: dict) -> (pd.DataFrame, np.ndarray): + n0 = dst.event.nunique() + mask = in_range(dst.Zrms**2, lower(dst.DT), upper(dst.DT)) + dst = dst[mask].copy() + n1 = dst.event.nunique() + eff = n1/n0 + compute_and_save_hist2d_as_pd(values = (dst.DT, dst.Zrms), + out_file = output, + hist_name = "DTrms2_vs_DT", + **diff_histo_params) + + message = f"Selection efficiency of diffusion band ({eff}) out of range:" + message += f"({eff_interval[0]} - {eff_interval[1]})" + check_if_values_in_interval(np.array(eff), *eff_interval, message) + + return dst, mask + + +def recompute_npeaks(dst): + events = dst.groupby("event") + ns1 = events.s1_peak.nunique().values + ns2 = events.s2_peak.nunique().values + n = events.s1_peak.count ().values + dst = dst.copy() + dst.loc[:, "nS1"] = np.repeat(ns1, n) + dst.loc[:, "nS2"] = np.repeat(ns2, n) + return dst + + def apply_cuts(dst : pd.DataFrame , S1_signal : type_of_signal , nS1_eff_interval : Tuple[float, float], @@ -659,7 +703,7 @@ def apply_cuts(dst : pd.DataFrame , nsigmas_Zdst : float , bootstrapmap : ASectorMap , band_sel_params : dict , - ) -> pd.DataFrame: + ) -> (pd.DataFrame, masks_container): n0 = dst.event.nunique() mask1 = selection_nS_mask_and_checking(dst = dst , column = S1_signal , @@ -692,6 +736,7 @@ def apply_cuts(dst : pd.DataFrame , band = mask3) return dst[mask3], masks + def map_builder(config): print("Map builder starting...") @@ -718,7 +763,24 @@ def map_builder(config): n_dev = config.n_dev_rate, **config.rate_histo_params ) - dst_passed_cut, masks = apply_cuts(dst = dst , + if config.select_diffusion_band: + dst_phys, mask = select_physical_events(dst, + config.diff_band_lower , + config.diff_band_upper , + (config.diff_band_eff_min, + config.diff_band_eff_max), + store_hist , + config.diff_histo_params ) + else: + dst_phys = dst + + dst_phys = recompute_npeaks(dst_phys) + + nev_phys = dst_phys.event.nunique() + ratio = nev_phys / nev_before * 100 + print(" Number of physical events before cuts: {0} ({1:2.2f}%)".format(nev_phys, ratio)) + + dst_passed_cut, masks = apply_cuts(dst = dst_phys , S1_signal = type_of_signal.nS1 , nS1_eff_interval = (config.nS1_eff_min , config.nS1_eff_max) , @@ -730,10 +792,10 @@ def map_builder(config): store_hist_s2 = store_hist , ns2_histo_params = config.ns2_histo_params, nsigmas_Zdst = config.nsigmas_Zdst , - ref_Z_histo = ref_histos. - Z_dist_hist, + ref_Z_histo = ref_histos.Z_dist_hist , bootstrapmap = bootstrapmap , - band_sel_params = config.band_sel_params ) + band_sel_params = config.band_sel_params + ) check_rate_and_hist(times = dst_passed_cut.time, output_f = store_hist , @@ -742,7 +804,7 @@ def map_builder(config): **config.rate_histo_params ) nev_after = dst_passed_cut.event.nunique() - ratio = nev_after/nev_before*100 + ratio = nev_after/nev_phys*100 print(" Number of events passing the cuts: {0} ({1:2.2f}%)".format(nev_after, ratio)) @@ -757,17 +819,16 @@ def map_builder(config): run_number = config.run_number, XYbins = (number_of_bins , number_of_bins) , + fit_type = FitType.unbined , **config.map_params ) - add_krevol(maps = final_map, - dst = dst, - masks_cuts = masks, - XYbins = (number_of_bins , - number_of_bins) , - **config.map_params) + add_krevol(maps = final_map, + dst = dst_phys, + masks_cuts = masks, + bootstrap_map = bootstrapmap, + **config.krevol_params) - check_drift_v_computation(final_map.t_evol.dv, - **config.map_params) + check_drift_v_computation(final_map.t_evol.dv, config.map_params["dv_maxFailed"]) write_complete_maps(asm = final_map , filename = config.file_out_map) diff --git a/krcal/map_builder/map_builder_functions_test.py b/krcal/map_builder/map_builder_functions_test.py index 80fa1616..97ac04c4 100644 --- a/krcal/map_builder/map_builder_functions_test.py +++ b/krcal/map_builder/map_builder_functions_test.py @@ -31,9 +31,6 @@ this_script_logger = logging.getLogger(__name__) this_script_logger.setLevel(logging.INFO) -@fixture(scope="module") -def t_evol_table(MAPSDIR): - return os.path.join(MAPSDIR, 'time_evol_table.h5') @mark.timeout(None) @mark.dependency() @@ -48,18 +45,21 @@ def test_scrip_runs_and_produces_correct_outputs(folder_test_dst , histo_file_out = os.path.join(output_maps_tmdir, 'test_out_histo.h5') default_n_bins = 15 run_number = 7517 - config = configure('maps $ICARO/krcal/map_builder/config_LBphys.conf'.split()) - map_params_new = copy.copy(config.as_namespace.map_params) - map_params_new['nmin'] = 100 - map_params_new['nStimeprofile'] = 1200 - map_params_new['z_range'] = (0, 10000) - config.update(dict(folder = folder_test_dst, - file_in = test_dst_file , - file_out_map = map_file_out , - file_out_hists = histo_file_out , - default_n_bins = default_n_bins , - run_number = run_number , - map_params = map_params_new )) + config = configure('maps $ICARO/conf/next-white/config_LBphys.conf'.split()) + map_params_new = copy.copy(config.as_namespace. map_params) + krevol_params_new = copy.copy(config.as_namespace.krevol_params) + map_params_new ['nmin'] = 100 + map_params_new ['z_range'] = (0, 10000) + krevol_params_new['nStimeprofile'] = 1200 + config.update(dict(folder = folder_test_dst , + file_in = test_dst_file , + file_out_map = map_file_out , + file_out_hists = histo_file_out , + default_n_bins = default_n_bins , + run_number = run_number , + map_params = map_params_new , + krevol_params = krevol_params_new)) + map_builder(config.as_namespace) maps = read_maps(map_file_out) assert type(maps)==ASectorMap @@ -69,6 +69,8 @@ def test_scrip_runs_and_produces_correct_outputs(folder_test_dst , assert_dataframes_close(maps.e0u, old_maps.e0u, rtol=1e-1) assert_dataframes_close(maps.lt , old_maps.lt , rtol=1e-5) assert_dataframes_close(maps.ltu, old_maps.ltu, rtol=1e-1) + assert_dataframes_close(maps.t_evol, old_maps.t_evol, rtol=1e-4) + @mark.dependency(depends="test_scrip_runs_and_produces_correct_outputs") def test_time_evol_table_correct_elements(output_maps_tmdir): @@ -103,13 +105,6 @@ def test_time_evol_eff_less_one(output_maps_tmdir): assert np.all(emaps.t_evol.S2eff <= 1.) assert np.all(emaps.t_evol.Bandeff <= 1.) -@mark.dependency(depends="test_scrip_runs_and_produces_correct_outputs") -def test_time_evol_table_exact_numbers(t_evol_table, output_maps_tmdir): - map_file_out = os.path.join(output_maps_tmdir, 'test_out_map.h5') - emaps = read_maps(map_file_out) - t_evol = pd.pandas.read_hdf(t_evol_table, 't_evol') - assert_dataframes_close(emaps.t_evol, t_evol, rtol=1e-4) - @composite def xy_pos(draw, elements=floats(min_value=-200, max_value=200)): size = draw(integers(min_value=1, max_value=10)) @@ -165,7 +160,7 @@ def test_correct_map_with_unsorted_dst(folder_test_dst , default_n_bins = 15 run_number = 7517 - config = configure('maps $ICARO/krcal/map_builder/config_LBphys.conf'.split()) + config = configure('maps $ICARO/conf/next-white/config_LBphys.conf'.split()) map_params_new = config.as_namespace.map_params map_params_new['nmin'] = 100 map_params_new['z_range'] = (0, 10000) @@ -189,7 +184,7 @@ def test_exception_s1(folder_test_dst, test_dst_file, output_maps_tmdir): """ This test checks if exception raises when ns1=1 efficiency is out of range. """ - conf = configure('maps $ICARO/krcal/map_builder/config_LBphys.conf'.split()) + conf = configure('maps $ICARO/conf/next-white/config_LBphys.conf'.split()) map_file_out = os.path.join(output_maps_tmdir, 'test_out_map_s1.h5' ) histo_file_out = os.path.join(output_maps_tmdir, 'test_out_histo_s1.h5') min_eff_test = 0. @@ -211,7 +206,7 @@ def test_exception_s2(folder_test_dst, test_dst_file, output_maps_tmdir): """ This test checks if exception raises when nS2=1 efficiency is out of range. """ - conf = configure('maps $ICARO/krcal/map_builder/config_LBphys.conf'.split()) + conf = configure('maps $ICARO/conf/next-white/config_LBphys.conf'.split()) map_file_out = os.path.join(output_maps_tmdir, 'test_out_map_s2.h5' ) histo_file_out = os.path.join(output_maps_tmdir, 'test_out_histo_s2.h5') min_eff_test = 0. @@ -233,7 +228,7 @@ def test_exception_rate(folder_test_dst, test_dst_file, output_maps_tmdir): """ This test checks if exception raises when rate distribution is not flat enough. """ - conf = configure('maps $ICARO/krcal/map_builder/config_LBphys.conf'.split()) + conf = configure('maps $ICARO/conf/next-white/config_LBphys.conf'.split()) map_file_out = os.path.join(output_maps_tmdir, 'test_out_map_rate.h5' ) histo_file_out = os.path.join(output_maps_tmdir, 'test_out_histo_rate.h5') n_dev_rate = 0.5 @@ -254,7 +249,7 @@ def test_exception_Zdst(folder_test_dst, test_dst_file, output_maps_tmdir): This test checks if exception raises when Z distribution is not similar enough to the reference one. """ - conf = configure('maps $ICARO/krcal/map_builder/config_LBphys.conf'.split()) + conf = configure('maps $ICARO/conf/next-white/config_LBphys.conf'.split()) map_file_out = os.path.join(output_maps_tmdir, 'test_out_map_Z.h5' ) histo_file_out = os.path.join(output_maps_tmdir, 'test_out_histo_Z.h5') nsigmas_Zdst = 0.5 @@ -275,7 +270,7 @@ def test_exception_bandsel(folder_test_dst, test_dst_file, output_maps_tmdir): This test checks if exception raises when band selection efficiency is out of a given range. """ - conf = configure('maps $ICARO/krcal/map_builder/config_LBphys.conf'.split()) + conf = configure('maps $ICARO/conf/next-white/config_LBphys.conf'.split()) map_file_out = os.path.join(output_maps_tmdir, 'test_out_map_bandsel.h5' ) histo_file_out = os.path.join(output_maps_tmdir, 'test_out_histo_bandsel.h5') band_sel_params_new = copy.copy(conf.as_namespace.band_sel_params) @@ -297,12 +292,11 @@ def test_exception_drift_v(folder_test_dst, test_dst_file, output_maps_tmdir): This test checks that exception raises if drift_v fit fails in too many temporal bins. """ - conf = configure('maps $ICARO/krcal/map_builder/config_LBphys.conf'.split()) + conf = configure('maps $ICARO/conf/next-white/config_LBphys.conf'.split()) map_file_out = os.path.join(output_maps_tmdir, 'test_out_map_driftv.h5' ) histo_file_out = os.path.join(output_maps_tmdir, 'test_out_histo_driftv.h5') map_params_new = copy.copy(conf.as_namespace.map_params) map_params_new['dv_maxFailed'] = 0.01 - map_params_new['nStimeprofile'] = 100 run_number = 7517 conf.update(dict(folder = folder_test_dst, file_in = test_dst_file , diff --git a/maps/next-100/rough_geometry_map_v0.h5 b/maps/next-100/rough_geometry_map_v0.h5 new file mode 100644 index 00000000..7b8d3662 --- /dev/null +++ b/maps/next-100/rough_geometry_map_v0.h5 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b746db153677ca88e87f4c775bdf33379b782a2d12f1769e1ce4238bcd9f9991 +size 440296 diff --git a/maps/next-100/rough_geometry_map_v2.h5 b/maps/next-100/rough_geometry_map_v2.h5 new file mode 100644 index 00000000..d209f944 --- /dev/null +++ b/maps/next-100/rough_geometry_map_v2.h5 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a0a9b0813fc41ccbfb15ab89fbf65b0826fba1d908b376de92c619d65756b03f +size 440296 diff --git a/maps/kr_emap_xy_100_100_r_6581.h5 b/maps/next-white/kr_emap_xy_100_100_r_6581.h5 similarity index 100% rename from maps/kr_emap_xy_100_100_r_6581.h5 rename to maps/next-white/kr_emap_xy_100_100_r_6581.h5 diff --git a/maps/kr_emap_xy_100_100_r_6582.h5 b/maps/next-white/kr_emap_xy_100_100_r_6582.h5 similarity index 100% rename from maps/kr_emap_xy_100_100_r_6582.h5 rename to maps/next-white/kr_emap_xy_100_100_r_6582.h5 diff --git a/maps/kr_emap_xy_50_50_mc.h5 b/maps/next-white/kr_emap_xy_50_50_mc.h5 similarity index 100% rename from maps/kr_emap_xy_50_50_mc.h5 rename to maps/next-white/kr_emap_xy_50_50_mc.h5 diff --git a/maps/kr_emap_xy_50_50_r_6590.h5 b/maps/next-white/kr_emap_xy_50_50_r_6590.h5 similarity index 100% rename from maps/kr_emap_xy_50_50_r_6590.h5 rename to maps/next-white/kr_emap_xy_50_50_r_6590.h5 diff --git a/reference_files/next-100/krhe_zhist.h5 b/reference_files/next-100/krhe_zhist.h5 new file mode 100644 index 00000000..ae59e474 --- /dev/null +++ b/reference_files/next-100/krhe_zhist.h5 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f234682cfbd6294ad501a7af851c5d191e9e4f0b10675dfe2a80570c670408eb +size 54690 diff --git a/reference_files/next-100/kronly_zhist.h5 b/reference_files/next-100/kronly_zhist.h5 new file mode 100644 index 00000000..6888b96a --- /dev/null +++ b/reference_files/next-100/kronly_zhist.h5 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:371a466410c449aaa6dd662eefcbe02d02b2e62ca8485fe15e735689a614c49c +size 54614 diff --git a/krcal/map_builder/reference_files/z_dst_HE_HKr_mean_ref.h5 b/reference_files/next-white/z_dst_HE_HKr_mean_ref.h5 similarity index 100% rename from krcal/map_builder/reference_files/z_dst_HE_HKr_mean_ref.h5 rename to reference_files/next-white/z_dst_HE_HKr_mean_ref.h5 diff --git a/krcal/map_builder/reference_files/z_dst_HE_mean_ref.h5 b/reference_files/next-white/z_dst_HE_mean_ref.h5 similarity index 100% rename from krcal/map_builder/reference_files/z_dst_HE_mean_ref.h5 rename to reference_files/next-white/z_dst_HE_mean_ref.h5 diff --git a/krcal/map_builder/reference_files/z_dst_HE_ref_7439.h5 b/reference_files/next-white/z_dst_HE_ref_7439.h5 similarity index 100% rename from krcal/map_builder/reference_files/z_dst_HE_ref_7439.h5 rename to reference_files/next-white/z_dst_HE_ref_7439.h5 diff --git a/krcal/map_builder/reference_files/z_dst_LB_mean_ref.h5 b/reference_files/next-white/z_dst_LB_mean_ref.h5 similarity index 100% rename from krcal/map_builder/reference_files/z_dst_LB_mean_ref.h5 rename to reference_files/next-white/z_dst_LB_mean_ref.h5 diff --git a/krcal/map_builder/reference_files/z_dst_LB_ref_7506.h5 b/reference_files/next-white/z_dst_LB_ref_7506.h5 similarity index 100% rename from krcal/map_builder/reference_files/z_dst_LB_ref_7506.h5 rename to reference_files/next-white/z_dst_LB_ref_7506.h5 diff --git a/krcal/map_builder/reference_files/z_dst_LB_run4_mean_ref.h5 b/reference_files/next-white/z_dst_LB_run4_mean_ref.h5 similarity index 100% rename from krcal/map_builder/reference_files/z_dst_LB_run4_mean_ref.h5 rename to reference_files/next-white/z_dst_LB_run4_mean_ref.h5 diff --git a/test_data/maps/test_map_nan.h5 b/test_data/maps/test_map_nan.h5 index 534f50b3..89e151a2 100644 --- a/test_data/maps/test_map_nan.h5 +++ b/test_data/maps/test_map_nan.h5 @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:3f811779717ed4d5ff53ea793019c4bee30ccee93bf5512b619661d503efc01c +oid sha256:258fa45167015f6f73f6ab4cd0adee707c5beec8c2cd90067a4ee8040fba69c5 size 42600 diff --git a/test_data/maps/time_evol_table.h5 b/test_data/maps/time_evol_table.h5 deleted file mode 100644 index 339635ad..00000000 --- a/test_data/maps/time_evol_table.h5 +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:eee5dd986a3526a2a0c5948a9ef51f5316fc11a3c7c0f529f53499593cd73b54 -size 7040