-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSimpleFunction.C
51 lines (51 loc) · 4.53 KB
/
SimpleFunction.C
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
void SimpleFunction()
{
// To run this macro just run on root terminal
// .L SimpleFunction.C
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Author: Muhammad Farooq Email: [email protected]
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// https://root.cern.ch/root-user-guides-and-manuals //
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// https://root.cern.ch/doc/master/classTCanvas.html //
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// TCanvas(name,title,width,height) //
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Define a Canvas //
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
TCanvas* c=new TCanvas("c","Function",700,700);
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// https://root.cern.ch/doc/master/classTF1.html //
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// TF1(name,function,xmin,xmax) //
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Define fucntion for one varible //
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
TF1* f1 = new TF1("f1", "cos(x)", 0., 10.);
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Define another fucntion for one varible //
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
TF1* f2 = new TF1("f2", "sin(x)", 0., 10.);
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Cosmetics for Drawing functions //
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// https://root.cern/root/html606/classTAttLine.html //
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
f2->SetLineColor(kBlue);//line color for the 2nd function
f2->SetLineStyle(9);//line style for the 2nd function
f1->SetLineColor(kRed);
f1->SetLineStyle(8);
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Drawing a function //
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
f1->Draw();
f2->Draw("Same");//we use Same for the drawing the fucntion on the existing function
c->Draw();
c->SaveAs("Function.png");//To save your output in required your desires
}