A project to simulate and analyse interactions with particles using the ROOT framework. Project for the exam "Laboratorio di Elettromagnetismo e Ottica [Modulo 3]" at Bachelor in Physics.
- Introduction
- Description of the repository
- Prerequisites
- Run the code
- Classes and functions
- List of features
- Authors
This project simulates particle events generation and analysis by using only simulated data. Its purpose is of teaching bachelor's degree students in physics at University of Bologna, how a particle analysis works.
Repository diagram structure:
particle-analysis/
├── img/
│ ├── CanvasA.pdf
│ ├── CanvasB.pdf
│ ├── CanvasA.png
│ ├── CanvasB.png
├── include/
│ ├── Particle.h
│ ├── ParticleType.h
│ ├── ResonanceType.h
├── src/
│ ├── Particle.cpp
│ ├── ParticleType.cpp
│ ├── ResonanceType.cpp
│ ├── Main.cpp
│ ├── Analysis.cpp
│── README.md
│── CONTRIBUTING.md
│── License
│── .gitignore
│── .all-contributorsrc
│── Analysis.sh
│── Main.sh
- ROOT framework: see this for installation.
To download the project you can proceed in two independent ways.
Go to the main page of the repository and click on the upper right green button called Code
. Than click on Download ZIP
and wait the download to be completed.
Then open a fresh shell and move the downloaded zipped file to your home directory (or to any other place you prefer):
mv Downloads/particle-analysis-master.zip $HOME
Where Downloads
have to be replaced with the right name (and maybe the right path) of your downloads directory.
Now you have to enter your home folder (unless you were already in it, in this case skip this passage), extract the folder from the zipped file and renaming itself with its right repository name. Therefore lets type this commands one after the other:
cd $HOME
unzip particle-analysis-master.zip
mv particle-analysis-master particle-analysis
And that's all. You can enter the folder by simply typing:
cd particle-analysis
Alternatively you can download the latest version of the repository from the Releases
button on the right of the repository main page by clicking on the source code link. In this case the procedure is similar:
Open a fresh shell and move the downloaded zipped file to your home directory (or to any other place you prefer):
mv Downloads/particle-analysis-x.y.z.zip $HOME
Where x.y.z
is the release tag and Downloads
have to be replaced with the right name (and maybe the right path) of your downloads directory.
Now you have to enter your home folder (unless you were already in it, in this case skip this passage), extract the folder from the zipped file and renaming itself with its right repository name. Therefore lets type this commands one after the other:
cd $HOME
unzip particle-analysis-x.y.z.zip
mv particle-analysis-x.y.z particle-analysis
If you prefer to download the tar.gz format of the release you have to run the
gunzip
command followed by thetar -xvf
command on the zipped release folder and than proceed withmv
.
And that's all. You can enter the folder by simply typing:
cd particle-analysis
Now, let's suppose to continue from the previous step. For the compilation part I prepared two scripts Main.sh and Analysis.sh in order to simplify this procedure. So you have to simply run this two commands one after the other:
./Main.sh
./Analysis.sh
The first two commands make the .sh files executables and ./ commands run them. The first script runs the data generation macro, while the second one runs the data analysis macro.
The first command needs a bit of time to end since the program is doing billions of particles generations.
An extra obj folder with object files and a .root file (containing the histograms to be analyzed) are now created. The new obj folder files with cpp.so termination are used in the Main.cpp macro to run the command:
R__LOAD_LIBRARY(ClassName_cpp.so)
in order to load the libraries in the macro itself. Once the ./Analysis.sh
is finished a new img folder is produced and contains the final analysis plots.
Thanks to this scripts you wouldn't need to enter the ROOT command prompt, since this process is automatically inserted in .sh files.
The following classes are defined:
-
ParticleType.h
: this header contains the definition of theParticleType
class and of its methods and members. This class has the purpose of createing instances that bring with them the three fundamental characteristics of a particle: name, charge and mass.- Constructor:
ParticleType (const char *Name, const double Mass, const int Charge)
.
- Public methods:
const char *GetName() const
: to get the name of the particle.double GetMass() const
: to get the mass of the particle.int GetCharge() const
: to get the charge of the particle.virtual double GetWidth() const
: which returns 0.virtual void Print()
: to print information of a particle.
- Private members:
const char *fName
: which is the name of the particle.const double fMass
: which is the mass of the particle.const int fCharge
: which is the charge of the particle.
- Constructor:
-
ParticleType.cpp
: this script contains the initialization of thevirtual void Print()
method and of theParticleType
constructor. -
ResonanceType.h
: this header contains the definition of theResonanceType
class and of its methods and members.ResonanceType
class is heir of theParticleType
one and creates particles with characteristics of the mother class plus the resonance width attribute.- Constructor:
ResonanceType (const char *Name, const double Mass, const int Charge, const double Width)
.
- Public methods:
double GetWidth() const
: to get the width of the resonance.void Print()
: to print updated informations of a particle.
- Public members:
const double fWidth
: that is the width of the particle resonance.
- Constructor:
-
ResonanceType.cpp
: this script contains the initialization of thevoid Print()
method and of theResonanceType
constructor. -
Particle.h
: this header contains the definition of theParticle
class and of its methods and members. This class contains all the previous ones and has the purpose of being used for the events generation.- Constructors:
Particle()
.Particle (const char *Name, double Px = 0., double Py = 0., double Pz = 0.)
.Particle (int IParticle, double Px = 0., double Py = 0., double Pz = 0.)
.
- Methods:
int GetIParticle() const
: to get the particle ID.double GetPx() const
,double GetPy() const
anddouble GetPz() const
: to get momentum components along axis.double GetMass() const
: to get mass of the particle.double GetCharge() const
: to get charge of the particle.double GetEnergy() const
: to get energy of the particle.double GetInvMass(Particle &) const
: to get invariant mass of the particle.void SetParticle (int IParticle)
: to set ID of the particle.void SetParticle (const char *Name)
: to set name of the particle.void SetP (double, double, double)
: to set momentum values of the particle along axis.void Boost(double Bx, double By, double Bz)
: Lorentz boost along axis.static int AddParticleType (const char *Name, const double Mass, const int Charge, const double Width)
: to create a particle with characteristics.int Decay2body(Particle &dau1,Particle &dau2) const
: to set the decay products of a particle.static void Printer()
: to print information of a particle.void Printex(int IParticle, const char *Name)
: to print particle ID and name.static int FindParticle (const char *Name)
: to find the particle name in the class.
- Members:
static const int fMaxNumParticleType
: set equal to 10. It is the maximum number of particle types that can be produced.static ParticleType *fParticleType[fMaxNumParticleType]
: ParticleType pointer which stores particles informations.static int fNParticleType
: number of the pointer positions that are stored by existing particles.int fIParticle
: ID of the particle.double fPx, fPy, fPz
: momentum along axis.
- Constructors:
-
Particle.cpp
: this script contains the initialization of the three constructors and of all the methods of theParticle
class.
The three implemented classes have different purposes:
ParticleType
creates istances that bring with them the three fundamental characteristics of a particle: mass, name and charge.ResonanceType
, inherit from previous one and creates particles that has characteristics of the mother class and the resonance width (for particles that have one).Particle
: this class is used for the event generation.
To generate particles, a Main.cpp
macro has been written and simulates the event generation. This generated events are analyzed by a Analysis.cpp
program.
Interested histograms are:
- Particle types.
- Azimuthal impulse angle distribution.
- Polar impulse angle distribution.
- Impulse distribution.
- Combination of invariant mass distributions.
10^5 events have been generated, each of them of about 100 particles. 80% of generated particles are Pions, 10% are Kaons, 9% protons and the remaining 1% are resonances.
For the cinematic properties, the following distributions are used: a uniform distribution for the azimuthal coordinate (0, 2PI), a uniform distribution for the polar coordinate (0, PI) and an exponential distribution for the impulse. To analyze the resonant signal, the result of the subtraction between only Pions histograms and Kaons with opposite sign and the one of the histogram for only Pions and Kaons with same sign with the resonance histogram have been compared.
Significative resulting histograms are shown below:
Gianluca Bianco |
Marco Collesei |