Unfolding for stack detector data
Project description
CMA-ES Spectrum Unfolding
Welcome to the CMA-ES Spectrum Unfolding project! This project provides a robust framework for unfolding particle spectra using the Covariance Matrix Adaptation Evolution Strategy (CMA-ES) created by Hansen et al. By leveraging data from Monte-Carlo simulations and experimental measurements, this script can effectively reconstruct the underlying particle energy distribution.
Table of Contents
- Overview
- Requirements
- Installation and Usage
- Expert Usage
- Results of Calibrated Spectrometer
- How to Cite
- Contact Information
- Acknowledgments
- License
Overview
This project utilizes CMA-ES to unfold a particle spectrum from an array of deposited energy values obtained through Monte-Carlo simulations. The method is tailored for scenarios where experimental data is captured using instruments like scintillators, providing a way to reconstruct the original energy distribution of particles.
Requirements
To run this project, ensure you have the following Python packages installed:
pip3 install numpy pandas cma glob re matplotlib.pyplot scipy.interpolate scipy.stats
These libraries provide essential functionalities for numerical computations, data handling, optimization, and visualization.
Installation and Usage
Follow these steps to set up and use the project:
-
Clone or Download the Repository:
Clone the repository using Git:
git clone https://github.com/ggfauvel/CMA-unfold.git
Alternatively, you can download the repository as a ZIP file and extract it.
- Prepare Your Data:
-
Response Matrix: Provide a response matrix calculated from a Monte-Carlo code. This matrix should be shaped as
((N_bin, N_dep)), where:N_binis the number of different mono-energetic particle energies used in the simulation.N_depis the number of experimental data points (e.g., number of imaging plates or scintillators).
-
Experimental Data: Supply the experimental data named
Exp_FLUKAin the shape((N_dep,)), representing the deposited energy data points.
- Run the Script:
Execute the main script to perform the spectrum unfolding. The script will process the data, perform optimization using CMA-ES, and visualize the results. Key variable to observe is sim, which represents the unfolded spectrum.
python spectrum_analysis.py
This will generate plots comparing experimental and simulated data and display the unfolded spectrum with error bounds.
Expert Usage
For more advanced users, you can calculate the errors associated with the unfolding method using the provided script:
- Response Matrix (RM) calculation: This script uses FLUKA. You have to fill the RM_variables.py script. It uses the Test.inp. You must launch the script while being in the folder of the .inp, here for example
cd RM
python3 Python_script/RM.py
Using flair, you must compile a custom executable using the source_final.f in the RM folder.
- Error Calculation Script: Use
Calc_errors.pyto evaluate the accuracy and reliability of the unfolding results. This script analyzes the uncertainty in the unfolded spectrum, providing a detailed error profile.
Results of Calibrated Spectrometer
This section presents the calibration results of a stacking scintillator calorimeter using a Co-60 radioactive source. Calibration with Co-60, a commonly used radioactive source, provides two distinct gamma-ray peaks at energies of 1.17 MeV and 1.33 MeV. These calibration points are critical for accurately interpreting the energy response of the spectrometer.
Calibration Lines
The calibration of the spectrometer is visualized by plotting the detected signal against the known gamma-ray energies from the Co-60 source:
- Co-60 Energy Lines: Two prominent lines at 1.17 MeV and 1.33 MeV are used to calibrate the spectrometer's energy scale. These lines are indicative of the spectrometer's ability to resolve distinct energy peaks accurately.
Below are some images showing the calibration process and the results:
- Raw Data Visualization: A plot showing the raw output from the scintillator array when exposed to the Co-60 source.
- Calibrated Spectrum: A comparison of the theoretical data and the unfolding.
- Calibrated Spectrum: More precise spectrum
It is possible to achieve a better precision on 'mono-energetic' spectrum but cannot be extrapolated to continuous distribution. It is up to the user to define the needs of the detector.
These images provide a clear view of the spectrometer's calibration, demonstrating its capability to accurately detect and resolve gamma-ray peaks from radioactive sources like Co-60.
Tips to make the dream work
- The more detectors you have, the more precise you need to be with your .inp input as a small deviation from reality accumulates quickly. EVERY element close to the detector must be included.
- When using the algorithm for peaks solution, you can use a smoothing factor close to zero it finds peaks very accurately but then struggles for continuous distributions.
- The experimental setup must be included inside the FLUKA simulation if no/low shielding used or a long detector is used without pinhole.
How to Cite
If you use this code in your research or publication, please cite it as follows:
G. Fauvel, K. Tangtartharakul, A. Arefiev, J. De Chant, S. Hakimi, O. Klimo, M. Manuel, A. McIlvenny, K. Nakamura, L. Obst-Huebl, P. Rubovic, S. Weber, F. P. Condamine; Compact in-vacuum gamma-ray spectrometer for high-repetition rate PW-class laser–matter interaction. Rev. Sci. Instrum. 1 February 2025; 96 (2): 023102. https://doi.org/10.1063/5.0206348
Alternatively, you can use the following BibTeX entry for LaTeX users:
@article{10.1063/5.0206348,
author = {Fauvel, G. and Tangtartharakul, K. and Arefiev, A. and De Chant, J. and Hakimi, S. and Klimo, O. and Manuel, M. and McIlvenny, A. and Nakamura, K. and Obst-Huebl, L. and Rubovic, P. and Weber, S. and Condamine, F. P.},
title = {Compact in-vacuum gamma-ray spectrometer for high-repetition rate PW-class laser–matter interaction},
journal = {Review of Scientific Instruments},
volume = {96},
number = {2},
pages = {023102},
year = {2025},
month = {02},
issn = {0034-6748},
doi = {10.1063/5.0206348},
url = {https://doi.org/10.1063/5.0206348},
eprint = {https://pubs.aip.org/aip/rsi/article-pdf/doi/10.1063/5.0206348/20383725/023102\_1\_5.0206348.pdf},
}
Contact Information
For further information, questions, or collaboration, please contact:
Fauvel Gaëtan
Email: fauvel.gaetan@outlook.com
Acknowledgments
We wish to acknowledge the support of the National Sci- ence Foundation (NSF Grant No. PHY-2206777) and the Czech Science Foundation (GA ČR) for funding on project number No. 22-42890L in the frame of the National Science Foundation–Czech Science Foundation partnership.
Third-Party Licenses
This project uses the py-cma library, which is licensed under the BSD 3-Clause License.
The BSD 3-Clause License Copyright (c) 2014 Inria Author: Nikolaus Hansen, 2008- Author: Petr Baudis, 2014 Author: Youhei Akimoto, 2016-
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
-
Redistributions of source code must retain the above copyright and authors notice, this list of conditions and the following disclaimer.
-
Redistributions in binary form must reproduce the above copyright and authors notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
-
Neither the name of the copyright holder nor the names of its contributors nor the authors names may be used to endorse or promote products derived from this software without specific prior written permission.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Thank you for using the CMA-ES Spectrum Unfolding project! We hope it serves your research and analytical needs.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cma_unfold-1.0.0.tar.gz.
File metadata
- Download URL: cma_unfold-1.0.0.tar.gz
- Upload date:
- Size: 5.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
232d2bdd1c6b1a2cb454474a9337a2b5ecbb11489e7d0d932844898f9620b165
|
|
| MD5 |
4f04e5a14c952061f2c4b35383b5d3cb
|
|
| BLAKE2b-256 |
5128a6fae4d13ed78f4f627a053cfdb45ffc56fa8dea60c02789c828819157bb
|
Provenance
The following attestation bundles were made for cma_unfold-1.0.0.tar.gz:
Publisher:
python-publish.yml on ggfauvel/CMA-unfold
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
cma_unfold-1.0.0.tar.gz -
Subject digest:
232d2bdd1c6b1a2cb454474a9337a2b5ecbb11489e7d0d932844898f9620b165 - Sigstore transparency entry: 246481680
- Sigstore integration time:
-
Permalink:
ggfauvel/CMA-unfold@d4f017267a904caf00ddf9259dd5c805692e75a0 -
Branch / Tag:
refs/tags/v1.0.1 - Owner: https://github.com/ggfauvel
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@d4f017267a904caf00ddf9259dd5c805692e75a0 -
Trigger Event:
release
-
Statement type:
File details
Details for the file cma_unfold-1.0.0-py3-none-any.whl.
File metadata
- Download URL: cma_unfold-1.0.0-py3-none-any.whl
- Upload date:
- Size: 5.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dbce54b95d0c66d1f7a9dc71d933a145d9a5d5263c6c2339ca7793b3003ee257
|
|
| MD5 |
794b9be4f4554a501a5f1b634b23eeee
|
|
| BLAKE2b-256 |
f64cc060deb1a9a23c7a1ee7e6245d00729879f1977f2df026e514698e98b9f0
|
Provenance
The following attestation bundles were made for cma_unfold-1.0.0-py3-none-any.whl:
Publisher:
python-publish.yml on ggfauvel/CMA-unfold
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
cma_unfold-1.0.0-py3-none-any.whl -
Subject digest:
dbce54b95d0c66d1f7a9dc71d933a145d9a5d5263c6c2339ca7793b3003ee257 - Sigstore transparency entry: 246481684
- Sigstore integration time:
-
Permalink:
ggfauvel/CMA-unfold@d4f017267a904caf00ddf9259dd5c805692e75a0 -
Branch / Tag:
refs/tags/v1.0.1 - Owner: https://github.com/ggfauvel
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@d4f017267a904caf00ddf9259dd5c805692e75a0 -
Trigger Event:
release
-
Statement type: