Skip to content
Snippets Groups Projects
Commit 095b465a authored by Dowling_Wong's avatar Dowling_Wong
Browse files

sync with jupyter server

parent 20a5bb1d
Branches
No related tags found
No related merge requests found
%% Cell type:markdown id:a1c50278 tags:
<hr style="height: 1px;">
<i>This notebook was authored by the TP1 Course Team, Copyright 2024 KIT ETP All Rights Reserved.</i>
<hr style="height: 1px;">
<br>
# Particle Physics 1
## Exercise 3: EMCAL in a Nutshell
**Institut für Experimentelle Teilchenphysik** <br>
Lecture: Prof. Dr. M. Klute, Dr. P. Goldenzweig <br>
Exercise: Dr. G. De Pietro <br>
Assistance: L. Reuter, J. Eppelt, S. Giappichini, dwong <br>
Hand-In: 16.11.2023
<h1>(Draft)Exercise 3: EMCAL in a nutshell</h1>
Some helpful links:<br>
* Google Colab (https://colab.research.google.com/): for Python development in your web-browser<br>
* Miniconda (https://docs.conda.io/en/latest/miniconda.html): a free minimal installer for conda<br>
* Numpy (https://numpy.org/doc/stable/user/quickstart.html): a widely used library for mathematical operations in Python<br>
<h3>Navigation</h3>
<table style="width:100%">
<tr>
<td style="text-align: left; vertical-align: top; font-size: 10pt;"><a href="#section_4_1">P4.1 Double Pendulum</a></td>
<td style="text-align: left; vertical-align: top; font-size: 10pt;"><a href="#problems_4_1">P4.1 Problems</a></td>
</tr>
<tr>
<td style="text-align: left; vertical-align: top; font-size: 10pt;"><a href="#section_4_3">P4.3 Maxwell-Boltzmann Distribution from Molecular Simulation</a></td>
<td style="text-align: left; vertical-align: top; font-size: 10pt;"><a href="#problems_4_3">P4.3 Problems</a></td>
</tr>
<tr>
<td style="text-align: left; vertical-align: top; font-size: 10pt;"><a href="#section_4_4">P4.4 Ideal Gas Law from Molecular Simulation</a></td>
<td style="text-align: left; vertical-align: top; font-size: 10pt;"><a href="#problems_4_4">P4.4 Problems</a></td>
</tr>
</table>
%% Cell type:markdown id:b82039ad tags:
### Setup
We will give a brief introduction to EMCAL and clustering. In the process, numpy, sklearn, uproot will be used.
%% Cell type:code id:b3619d05 tags:
``` python
# !pip install sklearn
# !pip install uproot
import numpy as np
from sklearn.cluster import KMeans
import uproot
import matplotlib.pyplot as plt
import geant4_simulation as g4sim
```
%% Cell type:code id:329972a6 tags:
``` python
```
%% Cell type:code id:eea2907e tags:
``` python
```
%% Cell type:markdown id:ad70f3aa-e25b-4929-b97b-b33325e649d8 tags:
<a name='section_1_0'></a>
<hr style="height: 1px;">
## <h2 style="border:1px; border-style:solid; padding: 0.25em; color: #FFFFFF; background-color: #FFA500">Introduction to Geant4</h2>
%% Cell type:code id:78f00792-6cdd-4419-b204-cae3a4dd9a1f tags:
``` python
# Create an instance of the ApplicationManager class.
g4 = g4sim.ApplicationManager()
```
%% Cell type:markdown id:47058a39 tags:
%% Cell type:markdown id:cce470a2 tags:
<a name='section_1_0'></a>
<hr style="height: 1px;">
## <h2 style="border:1px; border-style:solid; padding: 0.25em; color: #FFFFFF; background-color: #FFA500">Introduction to EMCAL</h2>
%% Cell type:code id:bb598536 tags:
``` python
```
%% Cell type:code id:e4377339 tags:
``` python
```
%% Cell type:code id:5fc30d71 tags:
``` python
```
%% Cell type:code id:7b666775 tags:
``` python
```
%% Cell type:markdown id:123fc926 tags:
<a name='section_2_0'></a>
<hr style="height: 1px;">
## <h2 style="border:1px; border-style:solid; padding: 0.25em; color: #FFFFFF; background-color: #FFA500">Particle hit shapes</h2>
%% Cell type:code id:edcf44c5 tags:
``` python
```
%% Cell type:markdown id:47da65a9 tags:
### Moments in statistics
The moments of a distribution provide useful information about its shape and spread. Below are the formulas for different moments:
- **1st order(raw)**$$\text{mean: }\mu := \mathbb{E}[X] = \frac{\mu_1}{1}
$$
- **2nd order(central)**: $$\text{variance: }\sigma^2 = \mathbb{E}[(X - \mu)^2] = \frac{\mu_2}{1^2} = \mu_2
$$
- **3rd order(standardized)**:$$\text{Skewness} = \mathbb{E} \left[ \left( \frac{X - \mu}{\sigma} \right)^3 \right] = \frac{\mathbb{E}[(X - \mu)^3]}{(\mathbb{E}[(X - \mu)^2])^{3/2}}
$$
- **4th order(standardized)**:$$\text{Kurtosis}g = \mathbb{E} \left[ \left( \frac{X - \mu}{\sigma} \right)^4 \right] = \frac{\mathbb{E}[(X - \mu)^4]}{(\mathbb{E}[(X - \mu)^2])^2}
$$
<span style="color:red">Bonus: What does Skewness/Kurtosis represent, why two expressions are equivalent?</span>
ans: hits on EMCAL plane also form a discrete probability distribution
%% Cell type:code id:627b99e7 tags:
``` python
```
%% Cell type:code id:00f7acae tags:
``` python
```
%% Cell type:code id:7fe9430c tags:
``` python
```
%% Cell type:markdown id:f7312bba tags:
<a name='section_3_0'></a>
<hr style="height: 1px;">
## <h2 style="border:1px; border-style:solid; padding: 0.25em; color: #FFFFFF; background-color: #FFA500">Clustering</h2>
%% Cell type:code id:8a84f2d5 tags:
``` python
```
%% Cell type:code id:47a42966 tags:
``` python
```
%% Cell type:markdown id:7807528d tags:
<a name='section_4_0'></a>
<hr style="height: 1px;">
## <h2 style="border:1px; border-style:solid; padding: 0.25em; color: #FFFFFF; background-color: #FFA500">Linkage methods</h2>
%% Cell type:code id:22c9d725 tags:
``` python
```
%% Cell type:code id:32c1dfac tags:
``` python
```
%% Cell type:code id:92f7c3b2 tags:
``` python
```
%% Cell type:code id:9cff34cf tags:
``` python
```
%% Cell type:code id:899dd92a tags:
``` python
```
%% Cell type:code id:1d5618ae tags:
``` python
```
%% Cell type:markdown id:139e1880 tags:
<a name='section_5_0'></a>
<hr style="height: 1px;">
## <h2 style="border:1px; border-style:solid; padding: 0.25em; color: #FFFFFF; background-color: #FFA500">Reading: ECAL at CMS</h2>
%% Cell type:markdown id:ebbcd7a3 tags:
<h3>CM-Solenoid: deal with cylindrical coordinates</h3>
%% Cell type:code id:454fe7c6 tags:
``` python
```
%% Cell type:code id:d1832fb7 tags:
``` python
```
%% Cell type:code id:822889bf tags:
``` python
```
%% Cell type:code id:af985ef4 tags:
``` python
```
%% Cell type:code id:fdc6e26b tags:
``` python
```
%% Cell type:code id:c881c954 tags:
``` python
```
%% Cell type:code id:61dad576 tags:
``` python
```
......
File added
%% Cell type:code id:de76542a tags:
``` python
# !pip install scikit-learn
# !pip install uproot
import numpy as np
from sklearn.cluster import KMeans
import uproot
import matplotlib.pyplot as plt
import geant4_simulation as g4sim
```
%% Output
Requirement already satisfied: scikit-learn in /opt/conda/lib/python3.9/site-packages (1.5.2)
Requirement already satisfied: joblib>=1.2.0 in /opt/conda/lib/python3.9/site-packages (from scikit-learn) (1.4.2)
Requirement already satisfied: scipy>=1.6.0 in /opt/conda/lib/python3.9/site-packages (from scikit-learn) (1.7.2)
Requirement already satisfied: numpy>=1.19.5 in /opt/conda/lib/python3.9/site-packages (from scikit-learn) (1.21.4)
Requirement already satisfied: threadpoolctl>=3.1.0 in /opt/conda/lib/python3.9/site-packages (from scikit-learn) (3.5.0)
Requirement already satisfied: uproot in /opt/conda/lib/python3.9/site-packages (5.4.1)
Requirement already satisfied: xxhash in /opt/conda/lib/python3.9/site-packages (from uproot) (3.5.0)
Requirement already satisfied: numpy in /opt/conda/lib/python3.9/site-packages (from uproot) (1.21.4)
Requirement already satisfied: fsspec in /opt/conda/lib/python3.9/site-packages (from uproot) (2024.10.0)
Requirement already satisfied: cramjam>=2.5.0 in /opt/conda/lib/python3.9/site-packages (from uproot) (2.9.0)
Requirement already satisfied: typing-extensions>=4.1.0 in /opt/conda/lib/python3.9/site-packages (from uproot) (4.12.2)
Requirement already satisfied: packaging in /opt/conda/lib/python3.9/site-packages (from uproot) (21.0)
Requirement already satisfied: awkward>=2.4.6 in /opt/conda/lib/python3.9/site-packages (from uproot) (2.6.9)
Requirement already satisfied: importlib-metadata>=4.13.0 in /opt/conda/lib/python3.9/site-packages (from awkward>=2.4.6->uproot) (8.5.0)
Requirement already satisfied: awkward-cpp==39 in /opt/conda/lib/python3.9/site-packages (from awkward>=2.4.6->uproot) (39)
Requirement already satisfied: zipp>=3.20 in /opt/conda/lib/python3.9/site-packages (from importlib-metadata>=4.13.0->awkward>=2.4.6->uproot) (3.20.2)
Requirement already satisfied: pyparsing>=2.0.2 in /opt/conda/lib/python3.9/site-packages (from packaging->uproot) (2.4.7)
%% Cell type:code id:d090ee8f tags:
``` python
g4 = g4sim.ApplicationManager()
```
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment