Skip to content

Commit ad52ef6

Browse files
authored
Merge pull request #102 from icecube/gen-sim
Gen2 geometry and effvol extension
2 parents cc31010 + 32a1ad8 commit ad52ef6

18 files changed

Lines changed: 22121 additions & 6165 deletions

.github/workflows/coverage.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,6 @@ jobs:
4444
- name: Install ASTERIA
4545
run: |
4646
pip install ".[dev]"
47-
- name: Set ASTERIA environment
48-
run: |
49-
echo "ASTERIA=${{ github.workspace }}" >> "$GITHUB_ENV"
5047
- name: Run tests with coverage
5148
run: |
5249
pytest --cov

.github/workflows/tests.yml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,6 @@ jobs:
4949
- name: Install ASTERIA
5050
run: |
5151
pip install ".[dev]"
52-
- name: Set ASTERIA environment
53-
run: |
54-
echo "ASTERIA=${{ github.workspace }}" >> "$GITHUB_ENV"
55-
if: runner.os != 'Windows'
56-
- name: Set ASTERIA environment for Windows
57-
run: |
58-
echo "ASTERIA=${{ github.workspace }}" | Out-File -FilePath $env:GITHUB_ENV -Append
59-
if: runner.os == 'Windows'
6052
- name: Run unit tests with pytest
6153
run: |
6254
pytest

docs/scratch/sim_tester.ipynb

Lines changed: 0 additions & 146 deletions
This file was deleted.

docs/source/nb/detector_hits.ipynb

Lines changed: 0 additions & 361 deletions
This file was deleted.
Lines changed: 356 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,356 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"id": "115a4e1c-1ab6-40f9-ba0d-1be45e0bbd4d",
6+
"metadata": {},
7+
"source": [
8+
"# Detector Hits in IceCube-Gen2\n",
9+
"\n",
10+
"Demonstrate detector hits in the IC86 + Gen2 configuration of IceCube.\n",
11+
"\n",
12+
"This includes both mDOMs and WLS modules."
13+
]
14+
},
15+
{
16+
"cell_type": "code",
17+
"execution_count": null,
18+
"id": "e2eb397f-92c2-40d2-932f-5816b85cf46b",
19+
"metadata": {},
20+
"outputs": [],
21+
"source": [
22+
"from astropy import units as u\n",
23+
"\n",
24+
"import numpy as np\n",
25+
"import matplotlib as mpl\n",
26+
"import matplotlib.pyplot as plt\n",
27+
"\n",
28+
"from snewpy.neutrino import Flavor\n",
29+
"\n",
30+
"from asteria.simulation import Simulation\n",
31+
"from asteria import set_rcparams\n",
32+
"from asteria import interactions\n",
33+
"\n",
34+
"from importlib.resources import files\n",
35+
"\n",
36+
"set_rcparams(verbose=False)"
37+
]
38+
},
39+
{
40+
"cell_type": "markdown",
41+
"id": "7af47266-c61c-45a7-b572-b865a1092864",
42+
"metadata": {},
43+
"source": [
44+
"## Configure an mDOM Gen2 Simulation\n",
45+
"\n",
46+
"Set up a progenitor 10 kpc from Earth and generate simulated hits.\n",
47+
"\n",
48+
"To simulate the Gen2 detector, add the argument `detector_scope='Gen2'` when initializing the simulation."
49+
]
50+
},
51+
{
52+
"cell_type": "code",
53+
"execution_count": null,
54+
"id": "1dff7931-b55f-4563-ab3b-12cf5e78e2bb",
55+
"metadata": {},
56+
"outputs": [],
57+
"source": [
58+
"model = {'name': 'Nakazato_2013',\n",
59+
" 'param':{\n",
60+
" 'progenitor_mass': 13 * u.Msun,\n",
61+
" 'revival_time': 300 * u.ms,\n",
62+
" 'metallicity': 0.004,\n",
63+
" 'eos': 'shen'}\n",
64+
" }\n",
65+
"\n",
66+
"sim = Simulation(model=model,\n",
67+
" distance=10 * u.kpc, \n",
68+
" Emin=0*u.MeV, Emax=100*u.MeV, dE=1*u.MeV,\n",
69+
" tmin=-1*u.s, tmax=1*u.s, dt=1*u.ms,\n",
70+
" detector_scope='Gen2')\n",
71+
"sim.run()"
72+
]
73+
},
74+
{
75+
"cell_type": "markdown",
76+
"id": "3052237c-8160-44b7-ac0e-bb2c4e986ee2",
77+
"metadata": {},
78+
"source": [
79+
"## Plot the Energy Deposit"
80+
]
81+
},
82+
{
83+
"cell_type": "code",
84+
"execution_count": null,
85+
"id": "8252ebd0-52b8-4504-915e-3f36189f5419",
86+
"metadata": {},
87+
"outputs": [],
88+
"source": [
89+
"fig, ax = plt.subplots(1,1, figsize=(8,6), tight_layout=True)\n",
90+
"\n",
91+
"for flavor in sim.flavors:\n",
92+
" ax.plot(sim.time, sim.E_per_V[flavor], label=flavor.to_tex())\n",
93+
"ax.legend()\n",
94+
"ax.set(xlabel=r'$t-t_\\mathrm{bounce}$ [s]',\n",
95+
" ylabel='energy deposit [Mev m$^{-3}$])',\n",
96+
" xlim=(-0.15, 0.75));"
97+
]
98+
},
99+
{
100+
"cell_type": "markdown",
101+
"id": "fe116039-a071-467a-8bd6-06aa2a812468",
102+
"metadata": {},
103+
"source": [
104+
"## Plot Detector Response\n",
105+
"\n",
106+
"### Expected Signal from Each Subdetector\n",
107+
"\n",
108+
"Set a time resolution `dt`. Using the `sim.detector_signal()` function we can read out the detector signal for each subdetector class. Separately plot hits from the main IceCube strings and DeepCore."
109+
]
110+
},
111+
{
112+
"cell_type": "code",
113+
"execution_count": null,
114+
"id": "d90d09cf-5ecc-475c-bbc5-178c95e4e2c2",
115+
"metadata": {},
116+
"outputs": [],
117+
"source": [
118+
"dt = 2 * u.ms\n",
119+
"t, sim_i3 = sim.detector_signal(subdetector='i3', dt=dt)\n",
120+
"t, sim_dc = sim.detector_signal(subdetector='dc', dt=dt)\n",
121+
"t, sim_md = sim.detector_signal(subdetector='md', dt=dt)"
122+
]
123+
},
124+
{
125+
"cell_type": "code",
126+
"execution_count": null,
127+
"id": "52d3c595-17e0-4df0-9746-af9d47e77a35",
128+
"metadata": {},
129+
"outputs": [],
130+
"source": [
131+
"fig, ax = plt.subplots(1,1, figsize=(8,6), tight_layout=True)\n",
132+
"ax.plot(t, sim_i3, label='IceCube DOM')\n",
133+
"ax.plot(t, sim_dc, label='HQE DOM (DeepCore)')\n",
134+
"ax.plot(t, sim_md, label='mDOM (Gen2)')\n",
135+
"ax.legend(fontsize=14)\n",
136+
"ax.set(xlabel=r'$t-t_\\mathrm{bounce}$ [s]',\n",
137+
" ylabel=f'detector hits',\n",
138+
" xlim=(-0.15, 0.75),\n",
139+
" ylim=(0,10000));"
140+
]
141+
},
142+
{
143+
"cell_type": "markdown",
144+
"id": "5854b46f-9889-48fd-bdef-d69678b5c147",
145+
"metadata": {},
146+
"source": [
147+
"### Generated Hits from Signal Only"
148+
]
149+
},
150+
{
151+
"cell_type": "code",
152+
"execution_count": null,
153+
"id": "c29ae3a0-b978-4ada-8580-a0a167d89dba",
154+
"metadata": {},
155+
"outputs": [],
156+
"source": [
157+
"t, hits_i3 = sim.detector_hits(subdetector='i3', dt=dt)\n",
158+
"t, hits_dc = sim.detector_hits(subdetector='dc', dt=dt)\n",
159+
"t, hits_md = sim.detector_signal(subdetector='md', dt=dt)"
160+
]
161+
},
162+
{
163+
"cell_type": "code",
164+
"execution_count": null,
165+
"id": "fb6a1409-3da3-4071-ab48-e9a8d5bfdfef",
166+
"metadata": {},
167+
"outputs": [],
168+
"source": [
169+
"fig, ax = plt.subplots(1,1, figsize=(8,6), tight_layout=True)\n",
170+
"ax.plot(t, hits_i3, label='IceCube DOM')\n",
171+
"ax.plot(t, hits_dc, label='HQE DOM (DeepCore)')\n",
172+
"ax.plot(t, hits_md, label='mDOM (Gen2)')\n",
173+
"\n",
174+
"ax.legend(fontsize=14)\n",
175+
"ax.set(xlabel=r'$t-t_\\mathrm{bounce}$ [s]',\n",
176+
" ylabel=f'detector hits',\n",
177+
" xlim=(-0.15, 0.75),\n",
178+
" ylim=(0,10000));"
179+
]
180+
},
181+
{
182+
"cell_type": "markdown",
183+
"id": "0f3f7030-fb90-4a89-b98f-d0d0e9787446",
184+
"metadata": {},
185+
"source": [
186+
"### Generated Hits from Signal + Background\n",
187+
"\n",
188+
"Separately compute the background hits and signal from each subdetector and add them."
189+
]
190+
},
191+
{
192+
"cell_type": "code",
193+
"execution_count": null,
194+
"id": "a2f39f58-504e-42ca-8f0f-8a72f7dd8eb2",
195+
"metadata": {},
196+
"outputs": [],
197+
"source": [
198+
"bkg_i3 = sim.detector.i3_bg(dt, size=hits_i3.size)\n",
199+
"bkg_dc = sim.detector.dc_bg(dt, size=hits_dc.size)\n",
200+
"bkg_md = sim.detector.md_bg(dt, size=hits_md.size)\n",
201+
"\n",
202+
"bkg = bkg_i3 + bkg_dc + bkg_md\n",
203+
"hits = hits_i3 + hits_dc + hits_md"
204+
]
205+
},
206+
{
207+
"cell_type": "code",
208+
"execution_count": null,
209+
"id": "f4df03ef-e5f6-40a4-a2cd-1f0c94c51d46",
210+
"metadata": {},
211+
"outputs": [],
212+
"source": [
213+
"fig, ax = plt.subplots(1,1, figsize=(8,6), tight_layout=True)\n",
214+
"ax.plot(t, hits_i3 + bkg_i3, label='IceCube DOM')\n",
215+
"ax.plot(t, hits_dc + bkg_dc, label='HQE DOM (DeepCore)')\n",
216+
"ax.plot(t, hits_md + bkg_md, label='mDOM (Gen2)')\n",
217+
"ax.plot(t, hits + bkg, label='Total hits')\n",
218+
"\n",
219+
"ax.legend(loc='center right', fontsize=14)\n",
220+
"ax.set(xlabel=r'$t-t_\\mathrm{bounce}$ [s]',\n",
221+
" ylabel=f'detector hits',\n",
222+
" xlim=(-0.15, 0.75),\n",
223+
" ylim=(0,65000)\n",
224+
");"
225+
]
226+
},
227+
{
228+
"cell_type": "markdown",
229+
"id": "e03521b3-ec42-4bd9-87ce-d289bd8a1591",
230+
"metadata": {},
231+
"source": [
232+
"## Add WLS Modules\n",
233+
"\n",
234+
"In the Gen2 detector scope, using the `add_wls=True` argument will add wavelength-shifting modules to the Gen2 detector response.\n",
235+
"\n",
236+
"The hits can be accessed as the `ws` subdetector."
237+
]
238+
},
239+
{
240+
"cell_type": "code",
241+
"execution_count": null,
242+
"id": "7cebd2b2-7533-4d1f-a074-d5299a2f00df",
243+
"metadata": {},
244+
"outputs": [],
245+
"source": [
246+
"sim_ws = Simulation(model=model,\n",
247+
" distance=10 * u.kpc, \n",
248+
" Emin=0*u.MeV, Emax=100*u.MeV, dE=1*u.MeV,\n",
249+
" tmin=-1*u.s, tmax=1*u.s, dt=1*u.ms,\n",
250+
" detector_scope='Gen2',\n",
251+
" add_wls=True)\n",
252+
"sim_ws.run()"
253+
]
254+
},
255+
{
256+
"cell_type": "code",
257+
"execution_count": null,
258+
"id": "2c8de85b-f01a-41f1-99cd-7cd79a296ad0",
259+
"metadata": {},
260+
"outputs": [],
261+
"source": [
262+
"t, hits_i3 = sim_ws.detector_hits(subdetector='i3', dt=dt)\n",
263+
"t, hits_dc = sim_ws.detector_hits(subdetector='dc', dt=dt)\n",
264+
"t, hits_md = sim_ws.detector_signal(subdetector='md', dt=dt)\n",
265+
"t, hits_ws = sim_ws.detector_signal(subdetector='ws', dt=dt)"
266+
]
267+
},
268+
{
269+
"cell_type": "code",
270+
"execution_count": null,
271+
"id": "00ac3f74-787d-4098-bd3b-24f2d394eb39",
272+
"metadata": {},
273+
"outputs": [],
274+
"source": [
275+
"fig, ax = plt.subplots(1,1, figsize=(8,6), tight_layout=True)\n",
276+
"ax.plot(t, hits_i3, label='IceCube DOM')\n",
277+
"ax.plot(t, hits_dc, label='HQE DOM (DeepCore)')\n",
278+
"ax.plot(t, hits_md, label='mDOM (Gen2)')\n",
279+
"ax.plot(t, hits_ws, label='mDOM+WLS (Gen2)')\n",
280+
"\n",
281+
"ax.legend(fontsize=14)\n",
282+
"ax.set(xlabel=r'$t-t_\\mathrm{bounce}$ [s]',\n",
283+
" ylabel=f'detector hits',\n",
284+
" xlim=(-0.15, 0.75),\n",
285+
" ylim=(0,10000));"
286+
]
287+
},
288+
{
289+
"cell_type": "markdown",
290+
"id": "286dd290-371f-4672-92d5-0a54eb7fb77b",
291+
"metadata": {},
292+
"source": [
293+
"### Plot the Sum of Signal + Background"
294+
]
295+
},
296+
{
297+
"cell_type": "code",
298+
"execution_count": null,
299+
"id": "1c2d27df-8173-45c6-84ad-5c63214a681c",
300+
"metadata": {},
301+
"outputs": [],
302+
"source": [
303+
"bkg_i3 = sim.detector.i3_bg(dt, size=hits_i3.size)\n",
304+
"bkg_dc = sim.detector.dc_bg(dt, size=hits_dc.size)\n",
305+
"bkg_md = sim.detector.md_bg(dt, size=hits_md.size)\n",
306+
"bkg_ws = sim.detector.ws_bg(dt, size=hits_ws.size)\n",
307+
"\n",
308+
"bkg = bkg_i3 + bkg_dc + bkg_md + bkg_ws\n",
309+
"hits = hits_i3 + hits_dc + hits_md + hits_ws"
310+
]
311+
},
312+
{
313+
"cell_type": "code",
314+
"execution_count": null,
315+
"id": "8a6fe116-4718-46b8-8991-a2d6cb0db220",
316+
"metadata": {},
317+
"outputs": [],
318+
"source": [
319+
"fig, ax = plt.subplots(1,1, figsize=(8,6), tight_layout=True)\n",
320+
"ax.plot(t, hits_i3 + bkg_i3, label='IceCube DOM')\n",
321+
"ax.plot(t, hits_dc + bkg_dc, label='HQE DOM (DeepCore)')\n",
322+
"ax.plot(t, hits_md + bkg_md, label='mDOM (Gen2)')\n",
323+
"ax.plot(t, hits_ws + bkg_ws, label='mDOM+WLS (Gen2)')\n",
324+
"ax.plot(t, hits + bkg, label='Total hits')\n",
325+
"\n",
326+
"ax.legend(loc='center', ncol=2, fontsize=14)\n",
327+
"ax.set(xlabel=r'$t-t_\\mathrm{bounce}$ [s]',\n",
328+
" ylabel=f'detector hits',\n",
329+
" xlim=(-0.15, 0.75),\n",
330+
" ylim=(0,75000)\n",
331+
");"
332+
]
333+
}
334+
],
335+
"metadata": {
336+
"kernelspec": {
337+
"display_name": "Python 3 (ipykernel)",
338+
"language": "python",
339+
"name": "python3"
340+
},
341+
"language_info": {
342+
"codemirror_mode": {
343+
"name": "ipython",
344+
"version": 3
345+
},
346+
"file_extension": ".py",
347+
"mimetype": "text/x-python",
348+
"name": "python",
349+
"nbconvert_exporter": "python",
350+
"pygments_lexer": "ipython3",
351+
"version": "3.11.11"
352+
}
353+
},
354+
"nbformat": 4,
355+
"nbformat_minor": 5
356+
}

0 commit comments

Comments
 (0)