Difference between revisions of "TF ErrAna InClassLab"

From New IAC Wiki
Jump to navigation Jump to search
Line 43: Line 43:
 
We are going to repeat Lab 1 but this time we will make a script to do the typing for us.
 
We are going to repeat Lab 1 but this time we will make a script to do the typing for us.
  
 +
Step 1.
  
 +
Use an edit to create a text file.
 +
 +
In windows this chould be
  
 
[http://wiki.iac.isu.edu/index.php/Forest_Error_Analysis_for_the_Physical_Sciences] [[Forest_Error_Analysis_for_the_Physical_Sciences]]
 
[http://wiki.iac.isu.edu/index.php/Forest_Error_Analysis_for_the_Physical_Sciences] [[Forest_Error_Analysis_for_the_Physical_Sciences]]

Revision as of 20:50, 18 January 2010

Start ROOT and Draw Histogram

Step 1

In this first lab your goal will be to start root and draw a histogram.

If you are on a Windows machine start the ROOT interpreter by double clicking on the Desctop icon which looks like a tree and says ROOT underneath it If you are on a Unix machine set the environmental variable ROOTSYS to point to the base subdirectory containing the ROOT files and start root with the command $ROOTSYS/bin/root. You can set the ROOTSYS environmental variable under the bash chell with the command

export ROOTSYS=path

where path identifies the location of the root base subdirectory. My ROOT base subdirectory is located at ~/src/ROOT/root so I would execture the following shell command

export ROOTSYS=~/src/ROOT/root

Step 2

Define a variable to contain the desired histogram

TH1F *Hist1=new TH1F("Hist1","Hist1",50,-0.5,49.5);


The above function "TH1F" has 5 parameters and is a member of the class TH1.

The first parameter "Hist1" create a name for the histogram. The second parameter gives the histogram a title. I usually set the name and title to the same variable name I use to store the histogram. This allows me to look up the variable name of the histogram when I double click on the histogram from the browser listing. The third parameter (50) is an integer which identifies the number of "bins" the histogram will use to store information. The Fourth parameter (-0.5) is a real number identifying the numerical value to be used for the lowest bin and the fifth parameter is the value for the highest bin.

Step 3

The class TH1 contains a function "Fill" which you can you to insert data into the histogram. In the above example the variable "Hist1" was defined in terms of the class TH1. To use the Fill function which is defined within the class TH1 and associated with the histogram named Hist1 you use the command

 Hist1->Fill(10);

The above Fill function will increment the counter for the bin in Hist1 which is associated with the numerical value "10"

Step 4

The TH1 class also has a function to graphically display the created histogram. The function is executed with the command

 Hist1->Draw();


You should now see a histogram on your computer screen if ROOT is able to create a graphics window.

Lab 2

We are going to repeat Lab 1 but this time we will make a script to do the typing for us.

Step 1.

Use an edit to create a text file.

In windows this chould be

[1] Forest_Error_Analysis_for_the_Physical_Sciences