Skip to content

Commit

Permalink
Refactor match_peaks (#100)
Browse files Browse the repository at this point in the history
* trying to refactormatch_peaks

* docstr

* load_peaks

* fraction options

* fraction options

* debug

* debug

* debug

* redo example events

* removed outputs

* scatter debug

* updated range

* get_available_runs

* debug

* debug

* debug

* sort runs]

* blanck line

* daq cuts for peaks

* updated example_peaks
  • Loading branch information
FaroutYLq authored Apr 6, 2024
1 parent 1677c1e commit cf00f05
Show file tree
Hide file tree
Showing 5 changed files with 794 additions and 283 deletions.
2 changes: 1 addition & 1 deletion notebooks/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ These are notebooks for hopefully pedagogical purpose. Due to the sensitive info
An example of using this framework to sprinkle events into real data, with followed analysis functions defined in this package.

## `example_peaks.ipynb`
An example of using this framework to sprinkle single electron peaks into real data, with followed analysis functions defined in this package.
An example of using this framework to sprinkle single electron peaks (with realistic timestamps and XY information passing SE selection, based on bootstrapping data SEs) into real data, with followed analysis functions defined in this package.
86 changes: 45 additions & 41 deletions notebooks/example_events.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@
{
"cell_type": "markdown",
"id": "e034079b-cae9-4586-9ba4-0122e2ef4c8d",
"metadata": {
"jp-MarkdownHeadingCollapsed": true
},
"metadata": {},
"source": [
"# Preparation"
]
Expand Down Expand Up @@ -123,9 +121,7 @@
{
"cell_type": "markdown",
"id": "06bc9312-c74d-4d2d-9ea8-6a97d4b7cb9d",
"metadata": {
"jp-MarkdownHeadingCollapsed": true
},
"metadata": {},
"source": [
"# Overview of simulation only"
]
Expand All @@ -137,13 +133,14 @@
"source": [
"This dataset should be considered without any ambience interference. The cuts considered are\n",
"```python\n",
"AmBe_CUTS_EXCEPT_S2PatternS1Width = np.array([\n",
"AmBe_CUTS_EXCEPT_S2Pattern = np.array([\n",
" 'cut_daq_veto',\n",
" 'cut_interaction_exists',\n",
" 'cut_main_is_valid_triggering_peak',\n",
" 'cut_run_boundaries',\n",
" 'cut_s1_area_fraction_top',\n",
" 'cut_s1_max_pmt',\n",
" 'cut_s1_width'\n",
" 'cut_s1_pattern_bottom',\n",
" 'cut_s1_pattern_top',\n",
" 'cut_s1_single_scatter',\n",
Expand All @@ -166,7 +163,7 @@
"source": [
"mask_simu_only_cut = apply_cut_lists(\n",
" events_simu,\n",
" AmBe_CUTS_EXCEPT_S2PatternS1Width # Compromise based on waveform simulation quality\n",
" AmBe_CUTS_EXCEPT_S2Pattern # Compromise based on waveform simulation quality\n",
")\n",
"mask_simu_only_min = apply_cut_lists(\n",
" events_simu,\n",
Expand All @@ -187,7 +184,7 @@
"plt.scatter(\n",
" events_simu[mask_simu_only_cut]['cs1'], events_simu[mask_simu_only_cut]['cs2'], \n",
" color='tab:red', s=2, \n",
" label='After AmBe_CUTS_EXCEPT_S2PatternS1Width'\n",
" label='After AmBe_CUTS_EXCEPT_S2Pattern'\n",
")\n",
"plt.xlim(0,100)\n",
"plt.ylim(0,6500)\n",
Expand Down Expand Up @@ -219,7 +216,7 @@
"plt.scatter(\n",
" events_simu[mask_simu_only_cut]['x'], events_simu[mask_simu_only_cut]['y'], \n",
" color='tab:red', s=2, \n",
" label='After AmBe_CUTS_EXCEPT_S2PatternS1Width'\n",
" label='After AmBe_CUTS_EXCEPT_S2Pattern'\n",
")\n",
"plt.xlim(-70,70)\n",
"plt.ylim(-70,70)\n",
Expand Down Expand Up @@ -252,7 +249,7 @@
" events_simu[mask_simu_only_cut]['x']**2+events_simu[mask_simu_only_cut]['y']**2, \n",
" events_simu[mask_simu_only_cut]['z'],\n",
" color='tab:red', s=2, \n",
" label='After AmBe_CUTS_EXCEPT_S2PatternS1Width'\n",
" label='After AmBe_CUTS_EXCEPT_S2Pattern'\n",
")\n",
"plt.xlim(0,4900)\n",
"plt.ylim(-150,0)\n",
Expand All @@ -273,9 +270,7 @@
{
"cell_type": "markdown",
"id": "ce788c14-de84-4b01-8dc6-945ea5a2f991",
"metadata": {
"jp-MarkdownHeadingCollapsed": true
},
"metadata": {},
"source": [
"## Analysis wrapper"
]
Expand Down Expand Up @@ -429,19 +424,21 @@
" events_salt_matched_to_simu[mask_salt_cut&mask_simu_cut], \n",
" events_simu_matched_to_salt[mask_salt_cut&mask_simu_cut], \n",
" title='After Cuts Ambience Interference in SR1 AmBe HEV', \n",
" fraction=True,\n",
" coord='s1_area', \n",
" s1s2='S1', \n",
" s1s2='s1', \n",
" n_bins=16, \n",
" ylim=(-2,10)\n",
" ylim=(-10,30)\n",
" )\n",
" show_area_bias(\n",
" events_salt_matched_to_simu[mask_salt_cut&mask_simu_cut], \n",
" events_simu_matched_to_salt[mask_salt_cut&mask_simu_cut], \n",
" title='After Cuts Ambience Interference in SR1 AmBe HEV', \n",
" fraction=True,\n",
" coord='s2_area', \n",
" s1s2='S2', \n",
" s1s2='s2', \n",
" n_bins=16, \n",
" ylim=(-2,500)\n",
" ylim=(-10,30)\n",
" )\n",
" #show_area_bias(\n",
" # events_salt_matched_to_simu[mask_salt_cut&mask_simu_cut], \n",
Expand All @@ -457,9 +454,7 @@
{
"cell_type": "markdown",
"id": "506840f2-af84-4d1c-8c75-db5e07e1a9cd",
"metadata": {
"jp-MarkdownHeadingCollapsed": true
},
"metadata": {},
"source": [
"## Event building efficiency"
]
Expand Down Expand Up @@ -490,6 +485,23 @@
" 'cut_main_is_valid_triggering_peak', \n",
" 'cut_run_boundaries',\n",
"])\n",
"AmBe_CUTS_EXCEPT_S2Pattern = np.array([\n",
" 'cut_daq_veto',\n",
" 'cut_interaction_exists',\n",
" 'cut_main_is_valid_triggering_peak',\n",
" 'cut_run_boundaries',\n",
" 'cut_s1_area_fraction_top',\n",
" 'cut_s1_max_pmt',\n",
" 'cut_s1_pattern_bottom',\n",
" 'cut_s1_pattern_top',\n",
" 'cut_s1_single_scatter',\n",
" 'cut_s1_tightcoin_3fold',\n",
" 'cut_s1_width',\n",
" 'cut_s2_recon_pos_diff',\n",
" 'cut_s2_single_scatter',\n",
" 'cut_s2_width',\n",
" 'cut_cs2_area_fraction_top',\n",
"])\n",
"```"
]
},
Expand Down Expand Up @@ -845,9 +857,7 @@
{
"cell_type": "markdown",
"id": "bf0b4653-485a-4f7d-95df-432d9610e6c8",
"metadata": {
"jp-MarkdownHeadingCollapsed": true
},
"metadata": {},
"source": [
"## Physical S1/S2 downgraded to alt_S1/alt_S2"
]
Expand Down Expand Up @@ -906,9 +916,7 @@
{
"cell_type": "markdown",
"id": "88cdab16-eb1f-438e-9fcf-20ed876cb7f6",
"metadata": {
"jp-MarkdownHeadingCollapsed": true
},
"metadata": {},
"source": [
"## Lost or split"
]
Expand Down Expand Up @@ -982,9 +990,7 @@
{
"cell_type": "markdown",
"id": "cc6e87e5-ff7e-4a49-bf54-01b0f97b92d3",
"metadata": {
"jp-MarkdownHeadingCollapsed": true
},
"metadata": {},
"source": [
"## Z Error"
]
Expand Down Expand Up @@ -1029,9 +1035,7 @@
{
"cell_type": "markdown",
"id": "529e4883-1a72-4fe6-9626-259b47a11061",
"metadata": {
"jp-MarkdownHeadingCollapsed": true
},
"metadata": {},
"source": [
"## Match events time"
]
Expand Down Expand Up @@ -1066,7 +1070,9 @@
"cell_type": "code",
"execution_count": null,
"id": "00806ed9-be8a-40af-8d97-dc237aef737b",
"metadata": {},
"metadata": {
"scrolled": true
},
"outputs": [],
"source": [
"super_mega_analysis(events_salt_matched_to_simu, events_simu_matched_to_salt)"
Expand All @@ -1075,9 +1081,7 @@
{
"cell_type": "markdown",
"id": "5d63e958-ad28-434a-b19f-14db212d7d58",
"metadata": {
"jp-MarkdownHeadingCollapsed": true
},
"metadata": {},
"source": [
"## Match S1 time"
]
Expand Down Expand Up @@ -1119,7 +1123,9 @@
"cell_type": "code",
"execution_count": null,
"id": "47e7914f-4be9-40c5-894f-03f79686fe92",
"metadata": {},
"metadata": {
"scrolled": true
},
"outputs": [],
"source": [
"# Mimic what happen if we only use minimal cuts (no 3-fold tc though) + NV tagging\n",
Expand Down Expand Up @@ -1240,9 +1246,7 @@
{
"cell_type": "markdown",
"id": "f3198748-3aa3-44e9-9565-9f089dab9fa9",
"metadata": {
"jp-MarkdownHeadingCollapsed": true
},
"metadata": {},
"source": [
"# Waveform Viewer"
]
Expand Down
Loading

0 comments on commit cf00f05

Please sign in to comment.