Skip to content
Snippets Groups Projects
Commit aea85f45 authored by Giacomo De Pietro's avatar Giacomo De Pietro :goat:
Browse files

Few corrections

parent 6236293e
Branches
No related tags found
No related merge requests found
%% Cell type:markdown id:a1c50278 tags:
# Übungen zu Teilchenphysik I
## Exercise 03 - EMCal in a nutshell
D. Wong, November 2024
%% Cell type:markdown id:b82039ad tags:
## Setup
It is very likely that you will need the following packages, so don't forget to import them!
%% Cell type:code id:f4145d8d tags:
``` python
import numpy as np
import uproot
import matplotlib.pyplot as plt
# This is a local module that will be necessary for the sections 2 and 3: it's already provided in this repository
import exercise3_utils as ex3
```
%% Cell type:markdown id:ad70f3aa-e25b-4929-b97b-b33325e649d8 tags:
<a name='section_1_0'></a>
<hr style="height: 1px;">
## <h1 style="border:1px; border-style:solid; padding: 0.25em; color: #FFFFFF; background-color: #FFA500">Section 1: Electromagnetic cascades in a calorimeter</h1>
%% Cell type:markdown id:b58b527c tags:
<div style="text-align: center; font-family: 'Arial', sans-serif; font-size: 24px; line-height: 1.5; color: yellow; background-color: black; padding: 20px;">
<img src="https://static1.cbrimages.com/wordpress/wp-content/uploads/2022/05/Darth-Varder-Lightning.jpg?q=50&fit=crop&w=1140&h=&dpr=1.5" alt="Darth Vader" width="300" style="float: left; margin-right: 10px;">
<p style="font-size: 34px; font-weight: bold;">Anakin Skywalker was weak. He didn't know the power EM showers.</p>
<p style="text-align: right; font-size: 24px; font-style: italic; margin-top: 40px;">– Anakin himself</p>
</div>
%% Cell type:markdown id:ccb08dab tags:
An **electromagnetic (EM) shower** is a cascade of particles, including photons, electrons, and positrons, produced when a high-energy electron, positron, or photon enters a material.
![EMShower](https://www.aanda.org/articles/aa/full/2003/43/aaINTEGRAL41/img17.gif)
%% Cell type:markdown id:deebb60f tags:
<a name='section_1_1'></a>
<hr style="height: 1px;">
## <h3 style="border:1px; border-style:solid; padding: 0.25em; color: #FFFFFF; background-color: #FFA500">Problem 1.1: EMCal dimension estimation</h3>
%% Cell type:markdown id:14c1176f tags:
**Electromagnetic calorimeters (EMCal)** designed to measure EM showers use high-Z materials to trap the shower. The electrons in the shower produce scintillation light, and the amount of light collected is proportional to the total energy of the incident particles. This makes EMCal ideal for precisely measuring the energy of electrons, positrons and photons.
The CMS detector at the LHC uses lead tungstate (PbWO$_4$) as the EMCal material.
%% Cell type:markdown id:8d20c0c4 tags:
<div class="alert alert-info">
<strong>Exercise:</strong>
Calculate the radiation length and critical energy of PbWO$_4$ (its effective atomic number is Z = 68.35)</span>
</div>
%% Cell type:code id:0f96d0b8 tags:
``` python
```
%% Cell type:markdown id:4d1e95a6 tags:
The effective atomic number and Thomsons approximation cannot produce a good estimation for the radiation length and the critical energy.
Consuld the PDG website (https://pdg.lbl.gov/2024/AtomicNuclearProperties/) to get more precise values for both radiation length and critical energy for PbWO$_4$ (note that lead tungstate is an inorganic scintillator).
%% Cell type:markdown id:809505cb tags:
<div class="alert alert-info">
<strong>Exercise:</strong>
Calculate the approximate dimension of PbWO$_4$ crystal (longitudinal depth and transverse width) for a 100 GeV electron </span>
</div>
%% Cell type:code id:eb9667bd tags:
``` python
```
%% Cell type:markdown id:9941f5ee tags:
<div class="alert alert-info">
<strong>Exercise:</strong>
Is this a good estimation for EMCal size? CMS EMCal crystals are actually 25 $X_0$ long—why?</span>
</div>
%% Cell type:code id:26522e6b tags:
``` python
```
%% Cell type:markdown id:1cab1d98 tags:
<a name='section_1_2'></a>
<hr style="height: 1px;">
## <h3 style="border:1px; border-style:solid; padding: 0.25em; color: #FFFFFF; background-color: #FFA500">Problem 1.2: Shape of muon clusters on EMCal</h3>
%% Cell type:markdown id:ce5dd64c tags:
For bremsstrahlung process, the energy loss through distance is given by $-\frac{dE}{dx} \propto \frac{Z^2 E}{m_{particle}^2}$.
%% Cell type:markdown id:d68a4fdf tags:
<div class="alert alert-info">
<strong>Exercise:</strong>
Consider a muon with a momentum of 50 GeV. What is the shape of the shower on an EMCal? How do you expect the energy deposit to be distributed on an EMCal?</span>
</div>
%% Cell type:code id:1733b03a tags:
``` python
```
%% Cell type:markdown id:fcc1c2ae tags:
<div class="alert alert-info">
<strong>Exercise:</strong>
Knowing at what energy electrons and positrons start emitting significant bremsstrahlung (what energy?), determine the threshold energy for a muon to emit significant bremsstrahlung in a PbWO$_4$ EMCal.</span>
</div>
%% Cell type:code id:c4ad124f tags:
``` python
```
%% Cell type:markdown id:d9a0066a tags:
<a name='section_1_3'></a>
<hr style="height: 1px;">
## <h3 style="border:1px; border-style:solid; padding: 0.25em; color: #FFFFFF; background-color: #FFA500">Problem 1.3: Detector proposal</h3>
%% Cell type:markdown id:acb46def tags:
<div class="alert alert-info">
<strong>Exercise:</strong>
Imagine that a few years from now you are a principal investigator. How would you implement the identification of electrons from photons and muons?</span>
</div>
%% Cell type:code id:da11b943 tags:
``` python
```
%% Cell type:markdown id:cce470a2 tags:
<a name='section_2_0'></a>
<hr style="height: 1px;">
## <h1 style="border:1px; border-style:solid; padding: 0.25em; color: #FFFFFF; background-color: #FFA500">Section 2: Calorimetry and reconstruction</h1>
%% Cell type:markdown id:f67b8b7a tags:
The EMCal at the PHENIX experiment has in total, 2592 towers or channels to read out the energy deposits. The channels are arranged in a (72 x 36) matrix. For more details, please refer to the documentation.
Use the following code snippet to read one event from the EMCal simulation:
```
# Example to obtain EMCal hits
elmID, edep = ex3.get_hit_data()
edep = edep/ex3.sfc # This converts the energy depositions into GeV
```
In the rest of the exercise, whenever you are asked to work with the simulated events from the PHENIX EMCal, please remember to always conver the energy depositions as above using `ex3.sfc`!
%% Cell type:markdown id:21115aab tags:
<a name='section_2_1'></a>
<hr style="height: 1px;">
## <h3 style="border:1px; border-style:solid; padding: 0.25em; color: #FFFFFF; background-color: #FFA500">Problem 2.1: Events visualization and distribution</h3>
%% Cell type:markdown id:74bbc650 tags:
The `elmID` is the index of the channel that received an hit and `edep` is the energy deposition measured for a hit in the given channel. To reconstruct the energy of the particle, you need to convert `elmID` into 2D spatial coordinates. Also, the energy deposited in the EMCal should be divided by a sampling fraction constant (`ex3.sfc`).
%% Cell type:markdown id:7420fb15 tags:
<div class="alert alert-info">
<strong>Exercise:</strong>
Write an algorithm that converts the channel ID into a pair of X and Y coordinates (in cm) according to the geometry of the PHENIX EMCal.</span>
</div>
%% Cell type:code id:45c2aab2 tags:
``` python
```
%% Cell type:markdown id:b9237c27 tags:
<div class="alert alert-info">
<strong>Exercise:</strong>
Plot the 2D distribution of all hits in an event according to their X and Y coordinates and their energy deposition. For example, show event 5 from the electron sample.</span>
</div>
%% Cell type:code id:db52bcdc tags:
``` python
```
%% Cell type:markdown id:f26be2f4 tags:
<div class="alert alert-info">
<strong>Exercise:</strong>
What is the measured energy of the particle in event 5 of the electron sample? And what is the distribution of all measured energies in all events of the electron sample?</span>
</div>
%% Cell type:code id:48e772f2 tags:
``` python
```
%% Cell type:markdown id:11e5a490 tags:
<a name='section_2_2'></a>
<hr style="height: 1px;">
## <h3 style="border:1px; border-style:solid; padding: 0.25em; color: #FFFFFF; background-color: #FFA500">Problem 2.2: Cluster properties and moments</h3>
%% Cell type:markdown id:a1da7d49 tags:
After having measured the energy deposited by all the hits in a cluster, it is important to characterize the cluster and determine its properties. We will use the moments of a distribution to do this. Remember that the clusters we are analyzing are basically 2D distributions!
%% Cell type:markdown id:681e68a9 tags:
<div class="alert alert-info">
<strong>Exercise:</strong>
Using *numpy*, implement functions to calculate the mean (geometric center), width ($\sigma$), standardized skewness and standardized kurtosis for the PHENIX EMCal clusters.</span>
</div>
%% Cell type:code id:ddfd0b00 tags:
``` python
```
%% Cell type:markdown id:a2ced72d tags:
<div class="alert alert-info">
<strong>Exercise:</strong>
Visualize again some events from the electron sample and calculate the moments. Which moments look useful for identifying electrons, and why?</span>
</div>
%% Cell type:code id:a8496c16 tags:
``` python
```
%% Cell type:markdown id:7ea3f9dd tags:
<div class="alert alert-info">
<strong>Exercise:</strong>
(Optional) Implement functions to calculate skewness and kurtosis without "standardization" and compute them for few events. Why do we usually use the standardized versions?</span>
</div>
%% Cell type:code id:863a37a1 tags:
``` python
```
%% Cell type:markdown id:123fc926 tags:
<a name='section_3_0'></a>
<hr style="height: 1px;">
## <h1 style="border:1px; border-style:solid; padding: 0.25em; color: #FFFFFF; background-color: #FFA500">Section 3: Calorimetry and clustering</h1>
%% Cell type:markdown id:9e6d80be tags:
<a name='section_3_1'></a>
<hr style="height: 1px;">
## <h3 style="border:1px; border-style:solid; padding: 0.25em; color: #FFFFFF; background-color: #FFA500">Problem 3.1: An homemade K-means clustering algorithm</h3>
%% Cell type:markdown id:1e4614b2 tags:
<div class="alert alert-info">
<strong>Exercise:</strong>
Visualize the event 0 from the electron sample and the event 6 from the dielectron sample and then compute the relevant moments. Do they still provide a good description for multi-particle cases? Why?</span>
</div>
%% Cell type:code id:576b35cb tags:
``` python
```
%% Cell type:markdown id:e03da784 tags:
For cases with particle gun decays, we can perform clustering to group the hits associated with different secondary particles produced in the decay.
To test the clustering algorithms and evaluate if they are implemented correctly, you can use the following method to randomly generate a number of clusters with a given number of hits.
```
import ex3
points = ex3.generate_2d_points()
# ex3.generate_2d_points(num_clusters=X, points_per_cluster=Y, spread=Z, random_seed=42)
```
%% Cell type:markdown id:7721df28 tags:
<div class="alert alert-info">
<strong>Exercise:</strong>
Generate some points with the default settings (without passing arguments) and also with some custom settings and visualize the generated datasets.</span>
</div>
%% Cell type:code id:00f7acae tags:
``` python
```
%% Cell type:markdown id:e2b267cd tags:
<div class="alert alert-info">
<strong>Exercise:</strong>
Implement by yourself, using only standard Python and eventually numpy functions, the K-means clustering algorithm and test it on few generated datasets. Visualize the identified clusters, their centroids and the associated hits.</span>
</div>
%% Cell type:code id:5f7bb083 tags:
``` python
```
%% Cell type:markdown id:b37abc2d tags:
<a name='section_3_2'></a>
<hr style="height: 1px;">
## <h3 style="border:1px; border-style:solid; padding: 0.25em; color: #FFFFFF; background-color: #FFA500">Problem 3.2: Finding optimal number of centroids</h3>
%% Cell type:markdown id:8a9947f4 tags:
<div class="alert alert-info">
<strong>Exercise:</strong>
Implement by yourself an elbow method for your K-means algorithm and test it on few events to evaluate its performance.</span>
</div>
%% Cell type:code id:4a268a7e tags:
``` python
```
%% Cell type:markdown id:e4d95e60 tags:
<div class="alert alert-info">
<strong>Exercise:</strong>
Implement by yourself a silhouette method for your K-means algorithm and test it on few events to evaluate its performance.</span>
%% Cell type:code id:b1e2645c tags:
``` python
```
%% Cell type:markdown id:d3f62e35 tags:
<div class="alert alert-info">
<strong>Exercise:</strong>
Implement by yourself a seed-searching algorithm for your K-means algorithm and test it on few events to evaluate its performance. Note that, for this case, you need to use the events from the dielectron sample.</span>
%% Cell type:code id:9900bdfe tags:
``` python
```
%% Cell type:markdown id:f9ab48d5 tags:
<a name='section_3_2'></a>
<hr style="height: 1px;">
## <h3 style="border:1px; border-style:solid; padding: 0.25em; color: #FFFFFF; background-color: #FFA500">Problem 3.3: Putting everything together</h3>
%% Cell type:markdown id:a0d51e4e tags:
%% Cell type:markdown id:cf6cf62e tags:
Now that you have mastered the fine art of identifying clusters from a collection of hits, you can use your clustering algorithm over a special dataset of simulated PHENIX EMCal events, where each event has multiple clusters and a lot of noise hits. To get these events (100 in total), execute the following snippet:
```
import exercise3_utils as ex3
elmID, edep = ex3.get_testing_clustering()
```
Note that, in this case, `elmID` and `edep` are arrays of arrays. To get `elmID` and `edep` arrays for the event X (with 0 <= X <= 99), you can simply use `elmID[X]` and `edep[X]`.
%% Cell type:markdown id:104f05af tags:
<div class="alert alert-info">
<strong>Exercise:</strong>
Run your clustering algorithm (using your preferred method to find the optimal number of clusters) over few events from the multi-cluster/noisy sample above. For each event, plot the clusters found and which hits belong to the cluster. For each cluster found, calculate its position, width and energy.</span>
Run your clustering algorithm (using your preferred method to find the optimal number of clusters) over few events from the multi-cluster/noisy sample presented above. For each event, plot the clusters found and which hits belong to the cluster. For each cluster found, calculate its position, width and energy.</span>
%% Cell type:code id:0fff5f02 tags:
``` python
```
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment