Baixe Tutorial Root Básico e outras Manuais, Projetos, Pesquisas em PDF para Programação em C, somente na Docsity!
ROOT Basics
Deb Mohapatra
This lecture is based on Fermilab ROOT tutorial and ROOT lecture in CERN summer school
Introduction WHAT IS ROOT?
- ROOT is an object oriented framework
- It has a C/C++ interpreter (CINT) and C/C++ compiler (ACLIC)
- ROOT is used extensively in High Energy Physics for “data analysis”
- Reading and writing data files
- Calculations to produce plots, numbers and fits. WHY ROOT?
- It can handle large files (in GB) containing N-tuples and Histograms
- Multiplatform software
- Its based on widely known programming language C++
- Its free
Learning ROOT
- http://root.cern.ch/root/Tutorials.html
- http://root.cern.ch/root/HowTo.html
- http://www-root.fnal.gov/root/
- http://www.slac.stanford.edu/BFROOT/www/doc/w orkbook/root{1,2,3}/root{1,2,3}.html
ROOT Mailing Lists
Root Interactive Session
BASH export export ROOTSYS=/LD_LIBRARY_PATH=$ROOTSYS/cern/root lib:$LD_LIBRARY_PATH
export PATH=$ROOTSYS/bin:$PATH
TCSH setenv setenv ROOTSYSLD_LIBRARY_PATH /cern/root $ROOTSYS/lib:$LD_LIBRARY_PATH
setenv PATH $ROOTSYS/bin:$PATH
- Set ROOTSYS to the directory where ROOT is installed
- Add ROOT libraries to the LD_LIBRARY_PATH
- Include the ROOT executable binary files to the binary path
- You may add the above lines to your ~/.cshrc or ~/.bashrc
- You may define your root settings in ~/.rootlogon.C
- History of all commands are stored in ~/.root_hist
The Framework Organization
cintmakecintnew *.h... proofdproofservrmkdepend rootroot.exerootcint root-configrootd
bin
$ROOTSYS
libCint.solibCore.solibEG.so libEGPythia.solibEGPythia6.solibEGVenus.so libGpad.solibGraf.solibGraf3d.so libGui.solibGX11.so*libGX11TTF.so libHist.solibHistPainter.solibHtml.so libMatrix.solibMinuit.solibNew.so libPhysics.solibPostscript.solibProof.so libRFIO.solibRGL.solibRint.so libThread.solibTree.solibTreePlayer.so libTreeViewer.solibttf.solibX3d.so libXpm.a
Aclock.cxxAclock.hEvent.cxx Event.hEventLinkDef.hHello.cxx Hello.hMainEvent.cxxMakefile Makefile.inMakefile.win32README TestVectors.cxxTetris.cxxTetris.h eventa.cxxeventb.cxxeventload.cxx guitest.cxxhsimple.cxxhworld.cxx minexam.cxxstress.cxxtcollbm.cxx tcollex.cxxtest2html.cxxtstring.cxx vlazy.cxxvmatrix.cxxvvector.cxx
lib tutorials test include
EditorBar.CIfit.Canalyze.C archi.Carrow.Cbasic.C basic.datbasic3d.Cbenchmarks.C canvas.Cclasscat.Ccleanup.C compile.Ccopytree.Ccopytree2.C demos.Cdemoshelp.Cdialogs.C dirs.Cellipse.Ceval.C event.Cexec1.Cexec2.C feynman.Cfildir.Cfile.C fillrandom.Cfirst.Cfit1.C fit1_C.C
fitslicesy.Cformula1.Cframework.C games.Cgaxis.Cgeometry.C gerrors.Cgerrors2.Cgraph.C h1draw.Chadd.Chclient.C hcons.Chprod.Chserv.C hserv2.Chsimple.Chsum.C hsumTimer.Chtmlex.Cio.C latex.Clatex2.Clatex3.C manyaxis.Cmultifit.Cmyfit.C na49.Cna49geomfile.Cna49view.C na49visible.C
ntuple1.Coldbenchmarks.Cpdg.dat psexam.Cpstable.Crootalias.C rootenv.Crootlogoff.Crootlogon.C rootmarks.Cruncatalog.sqlrunzdemo.C second.Cshapes.Cshared.C splines.Csqlcreatedb.Csqlfilldb.C sqlselect.Cstaff.Cstaff.dat surfaces.Ctcl.Ctestrandom.C tornado.Ctree.Ctwo.C xyslider.CxysliderAction.Czdemo.C
User Interfaces
.q Quit .L macro.C Load a macro file .x macro.C Load and execute a macro file .x macro.C++ Compile and execute
Displaying a Histogram
Display a histogram The Canvas
Open the root file Browse the file
Basic Navigation by Clicking
- Left Click
- select the object
- drag the object
- resize the object
- Right Click
- context menu
- class::name
- methods
- Middle Click
- activate canvas
- freezes event status bar
Fitting, Coloring, and Zooming
- Adding a gaussian fit
- Coloring the histogram
- Zooming/unzooming
Adding Objects to the Canvas
- The Editor
- Adding an Arrow
- Adding Text
Modifying the Statistics
- The Canvas in the Browser
- Setting the (7) statistics options - default = 0001111
Reading & Storing Data in Root
- Data can be read from files/database/network
- Data is generally stored as a TTree/TNtuple ( similar to a table with rows and columns )
- Each row represents an event
- Each column represents a quantity
- Trees can be created from ASCII files.
Read the Root file and the Tree
TBrowser t;
ntuple->Scain();
nTuple->Print();
What do we learn from this Macro
How to Commands
Create a Root file? TFile //option:^ *f^ = new NEW, CREATE, RECREATE,^ TFile("basic.root","RECREATE UPDATE, or READ");
//Book //------ and fill histograms and trees
f f-->Write(); //write>Close(); //close the the file file
Book and fill a histogram? TH1F *h1 = new TH1F("h1","x distribution",100,-4,4);
/do fill/ some calculation and get the parameter that you want to
h1->Fill(x);
Book and fill a tree? TNtuple file","x:y:z^ *ntuple");^ = new^ TNtuple("ntuple","data^ from^ ascii
/do fill/ some calculation and get the parameter that you want to
ntuple->Fill(x,y,z);
CINT Data types Int_t^ and^ Float_t
(see http://root.cern.ch/root/html/ListOfTypes.html )