root which even monkey can use

28
ROOT Which Even Monkeys Can Use Y.Shirasaki, O.Tajima 11 11 4

Upload: vl

Post on 21-Feb-2018

218 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Root which even monkey can use

7/24/2019 Root which even monkey can use

http://slidepdf.com/reader/full/root-which-even-monkey-can-use 1/28

ROOTWhich Even Monkeys Can Use

Y.Shirasaki, O.Tajima

11 11 4

Page 2: Root which even monkey can use

7/24/2019 Root which even monkey can use

http://slidepdf.com/reader/full/root-which-even-monkey-can-use 2/28

1

1 Welcome to ROOT 1

1.1   . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .   1

1.2   . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .   1

2 Histogram 3

2.1   . . . . . . . . . . . . . . . . . . . . . . . . . . . . .   3

2.1.1 1   . . . . . . . . . . . . . . . . . . . . . . . . .   3

2.1.2 fitting   . . . . . . . . . . . . . . . . . . . . . . . . .   5

2.1.3   . . . . . . . . . . . . . . . . . . . . . . . . . . . .   6

3 Graph 7

3.1   . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .   7

3.1.1   . . . . . . . . . . . . . . . . . . . . . . . . .   7

3.1.2   . . . . . . . . . . . . . . . . . . . . . . .   8

4 Function 10

4.1 TF1, TF2   . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .   10

4.2   . . . . . . . . . . . . . . . . . . . . . . . . . . . . .   10

4.3   . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .   12

5 Ntuple 13

5.1 Ntuple   . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .   13

5.2   . . . . . . . . . . . . . . . . . . . . . . . .   14

5.3 TCut   . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .   15

6 Graphics 16

6.1 Terminal Scirpt   . . . . . . . . . . . . . . . . . . . . . . .   16

6.2 Graphics Editor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .   17

6.3   . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .   17

7 18

7.1   . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .   18

7.2   . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .   18

7.3   . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .   20

Page 3: Root which even monkey can use

7/24/2019 Root which even monkey can use

http://slidepdf.com/reader/full/root-which-even-monkey-can-use 3/28

7.4   . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .   20

7.5 Graph   . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .   21

7.6 Global Style   . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .   21

7.7   . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .   21

8 Sourcefile 22

8.1   . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .   228.2 sourcefile   . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .   22

8.3 ˜/.root hist   . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .   23

9 ROOT 24

9.1 Makefile   . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .   24

9.2   . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .   25

2

Page 4: Root which even monkey can use

7/24/2019 Root which even monkey can use

http://slidepdf.com/reader/full/root-which-even-monkey-can-use 4/28

1

1 Welcome to ROOT

ROOT ROOT

1.1

ROOT

yasuhiro@s3(100)> setenv   ROOTSYS   /home/yasuhiro/Root

yasuhiro@s3(101)> set path=( $path ${ROOTSYS}/bin )

yasuhiro@s3(102)> setenv   LD LIBRARY PATH   ${ROOTSYS}/lib

1.2

ROOT

yasuhiro@s3(103)>   root

ROOT

*******************************************

* *

* W E L C O M E to R O O T *

* *

* Version 2.22/09 19 July 1999 *

* *

* You are welcome to visit our Web site *

* http://root.cern.ch *

* *

*******************************************

FreeType Engine v1.1 used to render TrueType fonts.

CINT/ROOT C/C++ Interpreter version 5.14.9, Jul 17 1999

Type ? for help. Commands must be C++ statements.

Page 5: Root which even monkey can use

7/24/2019 Root which even monkey can use

http://slidepdf.com/reader/full/root-which-even-monkey-can-use 5/28

1 Welcome to ROOT   2

Enclose multiple statements between { }.

CINT prompt

root [0]

ROOT ROOT ROOT

root [?]

root [?]   .q

ROOT ROOT

yasuhiro@s3(104)>   root

Page 6: Root which even monkey can use

7/24/2019 Root which even monkey can use

http://slidepdf.com/reader/full/root-which-even-monkey-can-use 6/28

3

2 Histogram

1

2.1

2.1.1 1

TH1

1.6

2.0

0.23

...

root [0]   TH1S  h1(”name”, ”title”, 150, -10, 20);

new TH1S() 1 short int”name”

”title”

150, -10, 20 150

-10, 20

( h1) (filename.dat)

root [1]   #include  <fstream.h>

root [2]   ifstream data(” filename.dat ”);

root [3]  double x;

root [4]  while (data  >>  x) h1.Fill(x);

root [5]   data.close();

root [6]   h1.Draw();

( 2.1)

Page 7: Root which even monkey can use

7/24/2019 Root which even monkey can use

http://slidepdf.com/reader/full/root-which-even-monkey-can-use 7/28

2 Histogram   4

-10 -5 0 5 10 15 200

500

1000

1500

2000

2500

3000

3500

name

Nent = 77101

Mean = 1.80011

RMS = 1.88289

title name

Nent = 77101

Mean = 1.80011

RMS = 1.88289

2.1: TH1

root [7]   h1.Draw(”E”);

"E"   ( 2.2(a))

root [8]   h1.Draw(”L”);

"L"   ( 2.2(b))

root [9]   h1.Draw(”P”);

"P"   ( 2.2(c))

-10 -5 0 5 10 15 200

500

1000

1500

2000

2500

3000

3500

name

Nent = 77101

Mean = 1.80011

RMS = 1.88289

title name

Nent = 77101

Mean = 1.80011

RMS = 1.88289

(a)

-10 -5 0 5 10 15 200

500

1000

1500

2000

2500

3000

3500

name

Nent = 77101

Mean = 1.80011

RMS = 1.88289

title name

Nent = 77101

Mean = 1.80011

RMS = 1.88289

(b)

-10 -5 0 5 10 15 200

500

1000

1500

2000

2500

3000

3500

name

Nent = 77101

Mean = 1.80011

RMS = 1.88289

title name

Nent = 77101

Mean = 1.80011

RMS = 1.88289

(c)

2.2: TH1

Page 8: Root which even monkey can use

7/24/2019 Root which even monkey can use

http://slidepdf.com/reader/full/root-which-even-monkey-can-use 8/28

2 Histogram   5

-10 -5 0 5 10 15 200

500

1000

1500

2000

2500

3000

3500

name

Nent = 77101

Mean = 1.80017

RMS = 1.88291

title name

Nent = 77101

Mean = 1.80017

RMS = 1.88291

(a)

-10 -5 0 5 10 15 200

500

1000

1500

2000

2500

3000

3500

name

Nent = 77101

Mean = 1.80011

RMS = 1.88289

Chi2 / ndf = 735.2 / 79

Constant= 3289.52 +- 12.2546

Mean = 1.89589 +- 0.00772947

Sigma = 1.85237 +- 0.00164245

title name

Nent = 77101

Mean = 1.80011

RMS = 1.88289

Chi2 / ndf = 735.2 / 79

Constant= 3289.52 +- 12.2546

Mean = 1.89589 +- 0.00772947

Sigma = 1.85237 +- 0.00164245

(b)

2.3: fitting

2.1.2 fitting

h1root [10]   h1.Fit(”gaus ”);

Gaussian fitting ”gaus” fitting

( 2.3(a))

root [11]   h1.Fit(”expo”);

root [12]   h1.Fit(”pol1”);

root [13]   h1.Fit(”pol2 ”);

”expo” exponential fitting “pol1” “pol2” 1 2

poln(n ) n fitting

fitting

root [14]   gStyle->SetOptFit();

( 2.3(b))

fitting

fitting

 p1 cos( p2x) + p3   (2.1)

1 TF1

root [15]   TF1  f1(”f1”, ”[0]*cos([1]*x)+[2]”);

h1 TH1 fitting

root [16]   f1.SetParameters(10, 1, 10);

Page 9: Root which even monkey can use

7/24/2019 Root which even monkey can use

http://slidepdf.com/reader/full/root-which-even-monkey-can-use 9/28

2 Histogram   6

-1 -0.8 -0.6 -0.4 -0.2 -0 0.2 0.4 0.6 0.8 10

10

20

30

40

50

h1

Nent = 81

Mean = -1.18061e-16

RMS = 0.533035

Chi2 / ndf = 148.161 / 37

p0 = 19.2534 +- 1.01825

p1 = 3.6241 +- 0.0798794

p2 = 20.6145 +- 0.860159

h1 h1

Nent = 81

Mean = -1.18061e-16

RMS = 0.533035

Chi2 / ndf = 148.161 / 37

p0 = 19.2534 +- 1.01825

p1 = 3.6241 +- 0.0798794

p2 = 20.6145 +- 0.860159

(a)

-1 -0.8 -0.6 -0.4 -0.2 -0 0.2 0.4 0.6 0.8 10

10

20

30

40

50

h1

Nent = 81

Mean = -1.18061e-16

RMS = 0.533035

Chi2 / ndf = 511.072 / 37

p0 = 6.58279 +- 0.61629

p1 = 10.1434 +- 0.112695

p2 = 9.50536 +- 0.502806

h1 h1

Nent = 81

Mean = -1.18061e-16

RMS = 0.533035

Chi2 / ndf = 511.072 / 37

p0 = 6.58279 +- 0.61629

p1 = 10.1434 +- 0.112695

p2 = 9.50536 +- 0.502806

(b)

2.4: cos fitting

TF1 Function fitting

10, 1, 10

root [17]   h1.Fit(”f1”);

fitting 2.4(a)2.4(b)

root [18]   f1.SetParameters(10, 10, 10);

2.1.3

TAxis SetRange

SetRange bin X FindBin bin

[-10, 20] TH1S h1[-5, 5]

root [0] h1 = new TH1S("name", "title", 150, -10, 20);

:

:

root [5] h1->GetXaxis()->SetRange(h1->GetXaxis()->FindBin(-5),

h1->GetXaxis()->FindBin(5));

root [6] h1->Draw();

Page 10: Root which even monkey can use

7/24/2019 Root which even monkey can use

http://slidepdf.com/reader/full/root-which-even-monkey-can-use 10/28

7

3 Graph

2

3.1

3.1.1

386.0 7.5384

406.0 10.7109

421.0 14.525...

  ...

(filename.dat)

float

x[10], y[10] 10

root [0] #include <fstream.h>

root [1] float x[10], y[10];

root [2] ifstream data(" filename.dat ");

root [3] int index=0;

root [4] while(!data.eof()) {data >> x[index] >> y[index]; index++;}

root [5] data.close();

root [6] graph = new   TGraph(index, x, y);

root [7] graph->Draw("AP");

”AP”

A:

P: ( )

Page 11: Root which even monkey can use

7/24/2019 Root which even monkey can use

http://slidepdf.com/reader/full/root-which-even-monkey-can-use 11/28

3 Graph   8

380 400 420 440 460

8

10

12

14

16

18

20

22

Graph

3.1: TGraph

( 3.1)

root [6]   graph->Draw(”APL”);

"L"   ( 3.2(a))

root [8]   graph->Draw(”APC”);

"C"   ◦ ◦   ( 3.2(b))

3.1.2

x, y

x, y x error, y error

root [9] graph = new   TGraphErrors(index, x, y, x_error, y_error);

root [10]   graph->Draw(”AP”);

( 3.3(a))

fitting

root [11]   graph->Fit(”pol1”);

1 fitting ( 3.3(b))

Page 12: Root which even monkey can use

7/24/2019 Root which even monkey can use

http://slidepdf.com/reader/full/root-which-even-monkey-can-use 12/28

3 Graph   9

380 400 420 440 460

8

10

12

14

16

18

20

22

Graph

(a)

380 400 420 440 460

8

10

12

14

16

18

20

22

Graph

(b)

3.2: TGraph

380 400 420 440 460 480

6

8

10

12

14

16

18

20

22

24

26

Graph

(a)

380 400 420 440 460 480

6

8

10

12

14

16

18

20

22

24

26

Chi2 / ndf = 0.539918 / 3

p0 = -62.3724 +- 10.6153

p1 = 0.18101 +- 0.0268242

Graph Chi2 / ndf = 0.539918 / 3

p0 = -62.3724 +- 10.6153

p1 = 0.18101 +- 0.0268242

(b) 1 fitting

3.3: fitting

Page 13: Root which even monkey can use

7/24/2019 Root which even monkey can use

http://slidepdf.com/reader/full/root-which-even-monkey-can-use 13/28

10

4 Function

ROOT (1 2 ) plot

4.1 TF1, TF2

C Fortran   x  ∗ ∗n xn

1root [0]   TF1 f1(”f1”, ”x*sin(x)*exp(-0.1*x)”, -10, 10); f1.Draw();

f (x) =  x sin xe−0.1x (4.1)

plot -10 10 ( 4.1)

2root [1]   TF2 f2(”f2”, ”abs(sin(x)/x)*(cos(y)*y)”, -6, 6, -6, 6);

f (x, y) =

sin x

x

y cos y   (4.2)

plot x -6 6 y -6 6 ( 4.2)

(abs() C )

root [2]   f2.Draw(”surf”);

root [3]   f2.Draw(”cont1”);

root [4]   f2.Draw(”lego”);

TH2

4.2

fitting

TF1 TF2

[0] [1] [2]root [5] TF1 f3("f3", "[0]+[1]*exp(x)", -5, 5);

Page 14: Root which even monkey can use

7/24/2019 Root which even monkey can use

http://slidepdf.com/reader/full/root-which-even-monkey-can-use 14/28

4 Function   11

-10 -8 -6 -4 -2 0 2 4 6 8 10

-10

-5

0

5

10

15

x*sin(x)*exp(-0.1*x)

4.1: 1   f (x) =  x sin xe−0.1x

-6-4 -2 0

24

6

-6-4

-20

24

6

-4

-2

0

2

4

abs(sin(x)/x)*(cos(y)*y)

4.2: 2   f (x, y) =

sin x

x

y cos y

Page 15: Root which even monkey can use

7/24/2019 Root which even monkey can use

http://slidepdf.com/reader/full/root-which-even-monkey-can-use 15/28

4 Function   12

0

root [6] f3.SetParamters(1, 2);

0 1 1 2

fitting

4.3

gaussian landau gaus landau

double gaussian

f (x) = 100e−x2

2 + 20e−

  x2

2×32

root [7] TF1 f4(”f4”, ”gaus(0)+gaus(3)”, -10, 10);

root [8] f4.SetParameters(100, 0, 1, 20, 0, 3);

Page 16: Root which even monkey can use

7/24/2019 Root which even monkey can use

http://slidepdf.com/reader/full/root-which-even-monkey-can-use 16/28

13

5 Ntuple

Ntuple ntuple

double tirple quadruple   · · ·   n

Ntuple

5.1 Ntuple

Ntuple Ntupleroot [0] ntuple

= new TNtuple("name", "title", " " [, ]);

Ntuple ”:”

“x:y:z:energy”

“px:py”

Ntuple

root [1] ifstream data(" ");

root [2] float x, y, z, energy;

root [3] while( data >> x >> y >> z >> energy)

ntuple->Fill(x, y, z, energy);

root [4] data.close();

Ntuplentuple->Print();

Ntuple

Ntuple Draw

Page 17: Root which even monkey can use

7/24/2019 Root which even monkey can use

http://slidepdf.com/reader/full/root-which-even-monkey-can-use 17/28

5 Ntuple   14

root [5] ntuple->Draw(" " [," "]" [," "]);

”x” x 1D

”sqrt(x)“

“x+y/z”

“:”

2D 3D

“x:y” x y 2D

“x:y:z” x y z 3D

“x*2:sqrt(y)”

“x<0” x 0

“sqrt(x + y)>4”

“x>0 && z<0”

root [5] ntuple->Draw(‘‘sqrt(x):y*2’’, ‘‘z<0’’);

Ntuple z 0 sqrt(x)

y*2 2D

5.2

”htemp”

”¿¿”root [6] ntuple->Draw(‘‘sqrt(x):y*2 >> hist’’, ‘‘z<0’’);

”hist”

“+”root [7] ntuple->Draw(‘‘sqrt(x):y*4 >>+ hist’’, ‘‘z<0’’);

Gaussian fittingroot [8] hist->Fit(‘‘gaus’’);

Page 18: Root which even monkey can use

7/24/2019 Root which even monkey can use

http://slidepdf.com/reader/full/root-which-even-monkey-can-use 18/28

5 Ntuple   15

5.3 TCut

TCut

root [9] TCut positiveCut = "x>0 && y>0 && z>0";

root [10] ntuple->Draw(‘‘sqrt(x):y*2’’, positiveCut);

root [11] ntuple->Draw(‘‘sqrt(x):z’’, positiveCut);

:

:

”positiveCut” ”energyCut”root [12] ntuple->Draw(‘‘sqrt(x):y*2’’, positiveCut && energyCut);

Page 19: Root which even monkey can use

7/24/2019 Root which even monkey can use

http://slidepdf.com/reader/full/root-which-even-monkey-can-use 19/28

16

6 Graphics

6.1 Terminal Scirpt

2 (1,2) (3,4)root [1]   TLine   l1(1, 2, 3, 4); l1.Draw();

root [2]   TBox   b1(1, 2, 3, 4); b1.Draw();

(1,2) (3,4)root [3]   TArrow   a1(1, 2, 3, 4); a1.Draw();

(1,2) (3,4)   → ↔

root [4] a1.SetOption("<>"); a1.Draw();

TArrow

root [5] TArrow a1(1, 2, 3, 4, 0.05, "<>"); a1.Draw();0.05 (

0.05 )

( (4,5) 2)root [6]   TArc   ar1(4, 5, 2); ar1.Draw();

TEllipse x y

TEllipse

( (2,3) )root [7]   TMarker   m1(2, 3, 20); m1.Draw();

20

root [8]   TText   t1(2, 3, "Text foo bar baz"); t1.Draw();

Page 20: Root which even monkey can use

7/24/2019 Root which even monkey can use

http://slidepdf.com/reader/full/root-which-even-monkey-can-use 20/28

6 Graphics   17

6.2 Graphics Editor

ROOT

Edit  ->  Editor

( )

6.3

Set ... Attributes (... )

Apply

Page 21: Root which even monkey can use

7/24/2019 Root which even monkey can use

http://slidepdf.com/reader/full/root-which-even-monkey-can-use 21/28

18

7

7.1

Canvas Pad

Canvasroot [0]   TCanvas   c1("Name", "Title");

root [1] c1.Divide(2, 2);

x 2 ( 2) y 2 (2 2)

( 4 ) Pad

root [2] c1.cd(1);

root [3] TF1 f1("f1", "sin(x)", -2, 2); f1.Draw();

root [4] c1.cd(4);

root [5] TF1 f2("f2", "cos(x)", -2, 2); f2.Draw();

Pad ( 7.1)root [6] c1.cd(3);

root [7]   gPad->Divide(3, 2);

7.2

ROOT () TH1F

root [8] TH1F waku("waku", "Title", 2, 350, 550);

root [9] waku.SetMinimum(20.0);

root [10] waku.SetMaximum(110.0);

root [11] waku.Draw();

Page 22: Root which even monkey can use

7/24/2019 Root which even monkey can use

http://slidepdf.com/reader/full/root-which-even-monkey-can-use 22/28

7   19

-2 -1.5 -1 -0.5 0 0.5 1 1.5 2

-1

-0.5

0

0.5

1

sin(x)

-2 -1.5 -1 -0.5 0 0.5 1 1.5 2

-0.4

-0.2

0

0.2

0.4

0.6

0.8

1

cos(x)

7.1:

TGraph graphroot [12] graph.Draw("LP");

root [13] c2.Update();

TPad c2root [14] c2.SetLogx();

root [15] c2.SetLogy();

Pad x y log

root [16] c2.SetLogx(0);

root [17] c2.SetLogy(0);

root [18] c2.SetGridx();

root [19] c2.SetGridy();grid Pad

Page 23: Root which even monkey can use

7/24/2019 Root which even monkey can use

http://slidepdf.com/reader/full/root-which-even-monkey-can-use 23/28

7   20

7.3

ROOT

root [0] TCanvas c1("c1", "Title", 50, 50, 700, 500);

root [1] TPaveLabel l1(0.3, 0.91, 0.7, 0.99, "Global Title");

root [2] l1.Draw();

root [3] TPad p1("p1", "title", 0, 0, 1, 0.9); p1.Draw(); p1.cd();

root [4] TF1 f1("f1", "sin(x)", -3, 3); f1.Draw();

root [5] TPaveText* t1 = gROOT.FindObject("title");

root [6] t1.SetTextFont(131);

root [7] t1.SetX1NDC(0.4); t1.SetX2NDC(0.6);

root [8] t1.Draw();

x y (axis title) TH1F h1root [9] h1.SetXTitle("Wavelength");

root [10] h1.SetYTitle("Transparency");

root [11] h1.GetXaxis()->SetLabelFont(112);

root [12] h1.GetXaxis()->SetTitleOffset(.5);

root [13] h1.GetXaxis()->SetTitleSize(.07);

TitleOffset

root [14]   TText   t1(1.8, 0.44, "text"); t1.Draw();

(1.8, 0.44) text

t1 SetTextFont() SetTextSize()

7.4

root [15] h1.SetFillColor(2);

root [16] h1.SetFillStyle(3002); h1.Draw();

root [17] h1.SetFillColor(2);

root [18] h1.SetFillStyle(3002); h1.Draw();

root [19] h2.SetFillColor(4);

root [20] h2.SetFillStyle(3002); h2.Draw();

Page 24: Root which even monkey can use

7/24/2019 Root which even monkey can use

http://slidepdf.com/reader/full/root-which-even-monkey-can-use 24/28

7   21

TH1 TAttLineroot [21] h1.SetLineWidth(5); h1.Draw();

7.5 GraphTGraph TAttLine TAttFill TAttMaker

root [22] graph.SetFillColor(5);

root [23] graph.SetLineColor(3);

root [24] graph.SetLineWidth(4);

root [25] graph.SetMarkerColor(6); graph.Draw("ALP");

7.6 Global Style

TH1 TGraph attribute

TStyle* gStyleroot [26] gROOT->SetStyle("Plain");

7.7

ROOT tcsh TABROOT (   ${ROOTSYS}/tutorials  )

root [27] .x gr

TAB graph.C

TAB

Page 25: Root which even monkey can use

7/24/2019 Root which even monkey can use

http://slidepdf.com/reader/full/root-which-even-monkey-can-use 25/28

22

8 Sourcefile

PostScript EPS, GIF

8.1

ROOT TCanvas c1

root [10] c1.Print("filename.ps");

filename.ps

EPS GIF

Print filename.eps EPS file-

name.gif GIF

8.2 sourcefileROOT source file ( )

graph.cc

#include <fstream.h>

void graph()

{

c1 = new TCanvas("c1", "Title", 0, 0, 700, 500);

c1->SetGridx();

c1->SetGridy();c1->SetFillColor(0);

c1->Draw();

waku = new TH1F("waku", "Title", 2, 350, 550);

waku->SetMinimum(20.0);

Page 26: Root which even monkey can use

7/24/2019 Root which even monkey can use

http://slidepdf.com/reader/full/root-which-even-monkey-can-use 26/28

8 Sourcefile   23

waku->SetMaximum(110.0);

waku->SetDirectory(0);

waku->SetTitleOffset(1.2);

waku->SetXTitle("Wavelength");

waku->SetYTitle("Transparency");

waku->Draw("A");

ifstream data("2dhist.dat");

float x[500], y[500];

int event = 0;

while (data >> x[event] >> y[event])

event++;

g1 = new TGraph(event, x, y);

g1->Draw("LP");

c1->Update();

c1->Print();

}

source file ROOTroot [0] .x graph.cc

source file   2dhist.dat

8.3 ˜/.root histROOT .root hist

ROOT source

file

Page 27: Root which even monkey can use

7/24/2019 Root which even monkey can use

http://slidepdf.com/reader/full/root-which-even-monkey-can-use 27/28

24

9 ROOT

cxx g++ ROOT class library

9.1 Makefile

${ROOTSYS}/test/Makefile}   compile

compiler option   CXXFLAGS   link library   ROOTLIBS

ROOTGLIBS   Makefile

:

ROOTLIBS = -L$(ROOTSYS)/lib -lNew -lBase -lCint -lClib -lCont \

-lFunc -lGraf -lGraf3d -lHist -lHtml -lMatrix -lMeta \

-lMinuit -lNet -lPostscript -lProof -lTree -lUnix -lZip

ROOTGLIBS = -lGpad -lGui -lGX11 -lX3d

GLIBS = $(ROOTLIBS) $(ROOTGLIBS) -lXpm -lX11 -lm -lPW

CXX = cxx

CXXFLAGS = -O -nostdnew -D__osf__ -D__alpha -I$(ROOTSYS)/includeLD = cxx

LDFLAGS = -g

TARGET = test

OBJS = main.o

all: ${TARGET}

${TARGET}: ${OBJS}

${CXX} ${CXXFLAGS} -o $@ ${OBJS} ${GLIBS}

.cc.o:

${CXX} ${CXXFLAGS} -c $<

clean:

rm -f *.o core ${TARGET}

Page 28: Root which even monkey can use

7/24/2019 Root which even monkey can use

http://slidepdf.com/reader/full/root-which-even-monkey-can-use 28/28

9 ROOT   25

9.2

TROOT object

#include "TROOT.h"

class TTestBench {

( )

};

int main(int argc, char** argv)

{

TROOT Root("Root", "TEST Program");

return TTestBench(argc, argv).Run();

}

${ROOTSYS}/test