You are on page 1of 6

Indian Institute of Science

Education and Research

PHY 411: Nuclear Physics Lab

Simulation Tools

Adarsh Krishnan, MS 14 177


Adarsh Prabhakaran, MS 14 110
Avinash Kumar, MS 14 047

supervised by
Dr. Satyajit Jena
0.1 Aim:
To briefly study the Monte-Carlo Technique and to create a Gaussian and
Poissonian random number distribution using ROOT.

0.2 Brief:
ROOT is a data processing framework, used worldwide by scientists working
on high energy physics to analyze their data and to do simulations. Originally
written as an object-oriented program in FORTRAN, ROOT was created by
the team at CERN but was later re-written in C++ and now has applications
in other fields such as astronomy and big data analysis.A feature unique to
ROOT is the data container named Tree, with its subdivisions branches
and leaves.

Monte Carlo method uses randomness to solve analytical problems which


are harder or impossible to solve otherwise. Here, we use Monte Carlo method
to randomly select a point from a Gaussian curve and plot it in another
histogram of the same axes.

When the iteration was small, we got a very crude form of the Gaussian.

When the iteration value was high, the Gaussian curve was observed
finely. It might be because eventually, we must have covered all the
points in the initial plot.

0.3 Observation:
A plot of tan x and tan x/x was made as a practice step. A Gaussian function
was defined using TF1 as g2. Using the random points taken from the
TH1 function, we made a histogram. We then repeated the same for a
Poisson Distribution.

1
Listing 1: tan x tan (x/x) Gaussian & Poisson Distribution
{

TF1 p1= new TF1( p1 , tan ( x ) , 5 , 5 ) ;


TF1 p2= new TF1( p2 , tan ( x ) / x , 5 , 5 ) ;

TCanvas t 1= new TCanvas ( t 1 ) ;

t1>D i v i d e ( 2 , 3 ) ;
t1>cd ( 1 ) ;
p1>Draw ( ) ;
t1>cd ( 2 ) ;
p2>Draw ( ) ;
t1>cd ( 3 ) ;

TF1 g2 = new TF1( g2 , TMath : : Gaus ( x , [ 0 ] , [ 1 ] , 0 ) , 5 , 1 0 ) ;

TF1 k= new TF1( k , TMath : : Gaus ( x , [ 0 ] , [ 1 ] , 0 ) , 5 , 5 ) ;


k>S e t P a r a m e t e r s ( 0 . 2 , 1 . 3 ) ;

k>Draw ( ) ;

t1>cd ( 4 ) ;

TH1F s=new TH1F( s , Gaussian , 1 0 0 0 , 5 , 5 ) ;


f or ( int i =0; i <100000; i ++)
{
s>F i l l ( k>GetRandom ( ) ) ;
}

s>Draw ( ) ;

t1>cd ( 5 ) ;

TF1 a = new TF1( a , TMath : : P o i s s o n ( x , 3 ) , 1 0 , 1 0 ) ;


TH1F a1 = new TH1F( a1 , P o i s s o n , 1 0 0 0 0 , 1 0 , 1 0 ) ;
f or ( int j = 0 ; j <1000000; j ++){

2
a1>F i l l ( a>GetRandom ( ) ) ;
}
a>Draw ( ) ;

t1>cd ( 6 ) ;
a1>Draw ( ) ;
}

3
Two Gaussian histograms were plotted with dierent mean and variance.
The two histograms were added using ROOT. The blue colored plot is the
corresponding final result.

Listing 2: Adding two Gaussian Distributions


{

TF1 p1= new TF1( p1 , tan ( x ) , 5 , 5 ) ;


TF1 p2= new TF1( p2 , tan ( x ) / x , 5 , 5 ) ;

TCanvas t 1= new TCanvas ( t 1 ) ;

t1>D i v i d e ( 2 , 3 ) ;
t1>cd ( 1 ) ;
p1>Draw ( ) ;
t1>cd ( 2 ) ;
p2>Draw ( ) ;
t1>cd ( 3 ) ;

TF1 g2 = new TF1( g2 , TMath : : Gaus ( x , [ 0 ] , [ 1 ] , 0 ) , 5 , 1 0 ) ;

TF1 k= new TF1( k , TMath : : Gaus ( x , [ 0 ] , [ 1 ] , 0 ) , 5 , 5 ) ;


k>S e t P a r a m e t e r s ( 0 . 2 , 1 . 3 ) ;

k>Draw ( ) ;

t1>cd ( 4 ) ;

TH1F s=new TH1F( s , Gaussian , 1 0 0 0 , 5 , 5 ) ;


f or ( int i =0; i <100000; i ++)
{
s>F i l l ( k>GetRandom ( ) ) ;
}

s>Draw ( ) ;

t1>cd ( 5 ) ;

4
TF1 a = new TF1( a , TMath : : P o i s s o n ( x , 3 ) , 1 0 , 1 0 ) ;
TH1F a1 = new TH1F( a1 , P o i s s o n , 1 0 0 0 0 , 1 0 , 1 0 ) ;
f or ( int j = 0 ; j <1000000; j ++){
a1>F i l l ( a>GetRandom ( ) ) ;
}
a>Draw ( ) ;

t1>cd ( 6 ) ;
a1>Draw ( ) ;
}

0.4 Conclusion:
We successfully carried out examples of Monte Carlo Method using ROOT.

***

You might also like