"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.\n",
"\n",
"Use the following code snippet to read one event from the EMCal simulation:\n",
"\n",
"```\n",
"# Example to obtain EMCal hits\n",
"elmID, edep = ex3.get_hit_data()\n",
"edep = edep/ex3.sfc # This converts the energy depositions into GeV\n",
"```"
"```\n",
"\n",
"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`!"
]
},
{
...
...
@@ -609,7 +612,7 @@
},
{
"cell_type": "markdown",
"id": "a0d51e4e",
"id": "cf6cf62e",
"metadata": {},
"source": [
"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:\n",
...
...
@@ -629,7 +632,7 @@
"source": [
"<div class=\"alert alert-info\">\n",
"<strong>Exercise:</strong> \n",
"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: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
importnumpyasnp
importuproot
importmatplotlib.pyplotasplt
# This is a local module that will be necessary for the sections 2 and 3: it's already provided in this repository
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.
**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:
<divclass="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>
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>
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>
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`!
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>
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>
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.
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>
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>