You are here: Foswiki>Computing_HEP Web>RootIntro (31 Oct 2016, JacobFerguson)EditAttach

Contents:

`/cern/root/vX.XX.XX/`

. For example, to setup ROOT version 5.24/00:
source /cern/root/v5.24.00/rootsetup.shPlease refrain from setting up your own local ROOT version on the desktop cluster. If there is a particular version you would like to use, please contact

`sudo apt-get update `

sudo apt-get install ubuntu-desktop

2. I recommend this step for normal Linux distrobutions as well, but it is nessacary here, install all required packages for ROOT with the following comand
`sudo apt-get install git dpkg-dev cmake g++ gcc binutils libx11-dev libxpm-dev \ libxft-dev libxext-dev`

From here, just follow the instructions below
- create a TCanvas, draw objects on it, and save it as a pdf.
- use TRandom3 to:
- generate uniform random numbers between 0 and 10.
- generate Gaussian random numbers with (Mean = 5 and RMS = 1).

- create and fill a 1D histogram (TH1, TH1D, TH1F).
- create a TF1 and fit it to a 1D histogram.

- You need two separate macros.
- In the first macro, generate 10000 Uniform random numbers and fill a histogram with these numbers.
- In the second macro, generate 10000 Gaussian random numbers and fill a histogram with these numbers.
- For both cases, check if the distributions are as expected. To check, you will need to fit the distributions with analytical functions.

- Make a new macro.
- Generate 10000 random numbers in total (Uniform and Gaussian). The generation of Uniform and Gaussian random numbers should be done randomly (without any order).
- The ratio between the Gaussian generated numbers to the Uniform generated numbers should be around 1/10.
- Create a new histogram and fill these 10000 random numbers.

- Repeat step 2, but do it using two macros. Don't overwrite your old macros, just make new files.
- In the first macro, generate the random numbers and put them in a text file.
- In the second macro, read the numbers from the text file and fill a histogram with them. Save the histogram in a root file.

- Read the histogram from the root file created in Step 3. Then, with an analytical function, fit this histogram:
- using the Fit method in ROOT.
- without using the Fit method in ROOT.

- Calculate analytically the integral of f(x) for x between -2 and +2.
- Calculate numerically the integral of f(x) for x between -2 and +2 using the Monte Carlo method. The integral of f(x) between x=a and x=b is the area S between f(x) and the lines x=a, x=b, and y=0.
- Define a rectangle containing the area S.
- Generate ("Uniform") random points in the rectangle and check the fraction of points in the area S.
- Make a plot with the function f(x) and the generated points.

- Calculate the same integral numerically by filling the area S with rectangles.
- Use a histogram with a given binning (each bin is a rectangle).
- Repeat this step with 3 different binnings.
- Make 3 different plots: one for each histogram. On each plot, draw f(x).

- Explain/Interpret/Analyze the differences between the different results. (Where are the differences coming from? When will they be equal? Why?)

- On the same canvas, draw 2 plots of g(x), one on the left and one on the right. On the left keep g(x) in linear scale (default), on the right set the x and y axis to logarithmic scale.
- Calculate the integral of g(x) for x between 0.1 and 10.1 with the Monte Carlo method generating only 1000 points (as you did in Part 1). Draw the points on the plots.
- Compare the numerical integral with the analytical integral. Can you find a method that generates a more precise numerical result using only 1000 points?

Edit | Attach | Print version | History: r8 < r7 < r6 < r5 | Backlinks | View wiki text | Edit wiki text | More topic actions

Topic revision: r8 - 31 Oct 2016, JacobFerguson

Copyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.

Ideas, requests, problems regarding Foswiki? Send feedback

Ideas, requests, problems regarding Foswiki? Send feedback