Skip to content

Add functions to get 3D krypton maps#948

Open
mcidlaso wants to merge 167 commits intonext-exp:masterfrom
mcidlaso:ICAROS_3D
Open

Add functions to get 3D krypton maps#948
mcidlaso wants to merge 167 commits intonext-exp:masterfrom
mcidlaso:ICAROS_3D

Conversation

@mcidlaso
Copy link
Copy Markdown

@mcidlaso mcidlaso commented Dec 19, 2025

These scripts contain functions to:

  • Make cuts on the outputs from sophronia to get the selected events and the efficiencies of the cuts
  • Get the lifetime and drift velocity for each run
  • Compute 3D krypton maps and apply them to correct the data
  • Some tests for these functions (still have a lot of work to do)

Copy link
Copy Markdown
Collaborator

@gonzaponte gonzaponte left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First round




def normalization(krmap, method, x_low, x_high, y_low, y_high):
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The last 4 parameters need to be optional, since they are only relevant for method == "region". I also think it would be interesting to gather them in a dictionary to simplify the logic.


def normalization(krmap, method, x_low, x_high, y_low, y_high):

mu_values = krmap.mu
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since you are doing .dropna() everywhere, you can do it here already

Comment on lines +13 to +16
k, i, j = np.meshgrid(k_vals, i_vals, j_vals, indexing='ij')
k = k.ravel()
i = i.ravel()
j = j.ravel()
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
k, i, j = np.meshgrid(k_vals, i_vals, j_vals, indexing='ij')
k = k.ravel()
i = i.ravel()
j = j.ravel()
k, i, j = map(np.ravel,
np.meshgrid(k_vals, i_vals, j_vals, indexing='ij'))


"""

def create_NaN_map(xy_range, dt_range, xy_nbins, dt_nbins):
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def create_NaN_map(xy_range, dt_range, xy_nbins, dt_nbins):
def create_empty_map(xy_range, dt_range, xy_nbins, dt_nbins):

Comment on lines +27 to +34
xy_bins = np.linspace(xy_range[0], xy_range[1], xy_nbins + 1)
dt_bins = np.linspace(dt_range[0], dt_range[1], dt_nbins + 1)

#shift to bin centers invisible_cities.core.core_functions

i_range = np.arange(0, len(xy_bins)-1)
j_range = np.arange(0, len(xy_bins)-1)
k_range = np.arange(0, len(dt_bins)-1)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

xy_bins and dt_bins are only used to compute their length, which are given by the variables xy_nbins and dt_nbins

Comment on lines +89 to +90
range_S2t = (low_S2t, high_S2t)
sel_S2t = in_range(kdst.S2t, *range_S2t)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
range_S2t = (low_S2t, high_S2t)
sel_S2t = in_range(kdst.S2t, *range_S2t)
sel_S2t = in_range(kdst.S2t, low_S2t, high_S2t)



def select_DTrange(kdst, low_DT, high_DT):
df_DTrange = kdst[(kdst.DT >= low_DT) & (kdst.DT <= high_DT)]
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use in_range



def select_nsipm(kdst, low_nsipm, high_nsipm):
sel_nsipm = (kdst.Nsipm >= low_nsipm) & (kdst.Nsipm <= high_nsipm)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use in_range

Comment thread invisible_cities/icaros/selection_functions.py Outdated
Comment on lines +142 to +146
d = {'eff diffusion band': [eff_DT], 'eff X rays': [eff_Xrays], 'eff 1S1 & 1S2': [eff_1S1_1S2],
'eff S2 trigger time': [eff_S2t], 'eff Rmax': [eff_Rmax], 'eff range DT': [eff_DTrange],
'eff number of SiPMS': [eff_nsipm], 'total efficiency': [total_eff]}

df_efficiencies = pd.DataFrame(data = d)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can also have numbers in the dictionary (instead of lists of 1 element) and then add index=[0] when creating the dataframe

@gonzaponte
Copy link
Copy Markdown
Collaborator

Closes #860.
Closes #861.
Closes #862.
Closes #863.
Closes #864.

Copy link
Copy Markdown
Collaborator

@gonzaponte gonzaponte left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

another round of comments

Comment on lines +13 to +14
dtrms2_low = lambda dt: -0.7 + 0.030 * (dt-20) # Gonzalo's
dtrms2_upp = lambda dt: 2.6 + 0.036 * (dt-20) # Gonzalo's2
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that these are in the config file, you can remove them.


assert np.all(kdst_sel.nS1.values == 1)
assert np.all(kdst_sel.nS2.values == 1)
assert np.all((kdst_sel.nS1.values) & (kdst_sel.nS2.values)) == 1
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this line is probably not what you are trying to do. I'm surprised it even works.

Comment thread invisible_cities/icaros/lifetime_vdrift_functions.py
Comment thread invisible_cities/icaros/krmap_functions.py Outdated
Comment thread invisible_cities/icaros/krmap_functions.py Outdated
Comment thread invisible_cities/icaros/correction_functions.py
if method is NormMethod.median_region_anode:
E_median_region_anode = anode.mu.median()
return E_median_region_anode

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

raise an error here. The only way to get to the end of this function if is method is not a NormMethod

y : pd.core.series.Series,
E : pd.core.series.Series,
xy_params : dict = None,
keV : bool = False) -> pd.core.series.Series:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we discussed using an arbitraty unit instead of keV

Comment thread invisible_cities/icaros/correction_functions.py Outdated
Comment thread invisible_cities/cities/zemrude.py Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants