ROOT
git-r3/HEAD
Reference Guide
Loading...
Searching...
No Matches
ExampleMacro.C
Go to the documentation of this file.
1
/***************************************************************************
2
* --------------------------------------------------------------------------
3
* Template to exercise ROOT code
4
* -> Plot a normalized Gaussian with mean = 5.0 and sigma = 1.5
5
* and its derivative and integral in the range of 0 to 10
6
* --------------------------------------------------------------------------
7
* initial version: 21-Aug-2008 G. Quast
8
*
9
* modification log:
10
***************************************************************************/
11
12
/*
13
* Note that this file can be either used as a compiled program
14
or as a ROOT macro.
15
* If it is used as a compiled program, additional include statements
16
and the definition of the main program have to be made. This is
17
not needed if the code is executed at the ROOT prompt.
18
*/
19
20
#include "
TFile.h
"
// run as a "stand-alone application", i.e. if it is not
21
#include "
TH1F.h
"
// called from an interactive ROOT session.
22
#include "
TCanvas.h
"
23
#include "
TMath.h
"
24
// eventually, load some C libraries
25
#include <cmath>
26
27
void
ExampleMacro
();
28
29
//______________________________________________________________________________
30
int
main
()
31
{
32
ExampleMacro
();
33
return
0;
34
}
35
36
//______________________________________________________________________________
37
38
/*
39
* From here on, the code can also be used as a macro
40
41
==>> put your code here
42
(remember to update the name of you Macro in the
43
lines above if you intend to comile the code)
44
*/
45
void
ExampleMacro
() {
46
// Create a histogram, fill it with random gaussian numbers
47
TH1F
*
h
=
new
TH1F
(
"h"
,
"example histogram"
, 100, -5.,5.);
48
h
->FillRandom(
"gaus"
,1000);
49
50
// draw the histogram
51
h
->DrawClone();
52
53
/* - Create a new ROOT file for output
54
- Note that this file may contain any kind of ROOT objects, histograms,
55
pictures, graphics objects etc.
56
- the new file is now becoming the current directory */
57
TFile
*
f1
=
new
TFile
(
"ExampleMacro.root"
,
"RECREATE"
,
"ExampleMacro"
);
58
59
// write Histogram to current directory (i.e. the file just opened)
60
h
->Write();
61
62
// Close the file.
63
// (You may inspect your histogram in the file using the TBrowser class)
64
f1
->Close();
65
}
ExampleMacro
void ExampleMacro()
Definition
ExampleMacro.C:45
main
int main()
Definition
ExampleMacro.C:30
h
#define h(i)
Definition
RSha256.hxx:106
TCanvas.h
TFile.h
TH1F.h
TMath.h
TFile
A file, usually with extension .root, that stores data and code in the form of serialized objects in ...
Definition
TFile.h:130
TH1F
1-D histogram with a float per channel (see TH1 documentation)
Definition
TH1.h:878
f1
TF1 * f1
Definition
legend1.C:11
documentation
primer
macros
ExampleMacro.C
ROOTgit-r3/HEAD - Reference Guide Generated on
(GVA Time) using Doxygen 1.16.1