forked from root-project/root
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ExampleMacro_GUI.C
55 lines (47 loc) · 1.59 KB
/
ExampleMacro_GUI.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
52
53
54
55
/*
This piece of code demonstrates how a root macro is used as a standalone
application with full acces the grapical user interface (GUI) of ROOT */
// include ALL header files needed
#ifndef __CINT__
#include "TROOT.h"
#include "TApplication.h"
#include "TBrowser.h"
#include "TFile.h"
#include "TH1F.h"
#include "TCanvas.h"
#include "TMath.h"
#endif
// eventually, include some additoinal C or C++ libraries
#include <math.h>
// ==>> put the code of your macro here
void ExampleMacro_GUI() {
// Create a histogram, fill it with random gaussian numbers
TH1F *h = new TH1F ("h", "example histogram", 100, -5.,5.);
h->FillRandom("gaus",1000);
// draw the histogram
h->DrawClone();
/* - Create a new ROOT file for output
- Note that this file may contain any kind of ROOT objects, histograms,
pictures, graphics objects etc.
- the new file is now becoming the current directory */
TFile *f1 = new TFile("ExampleMacro.root","RECREATE","ExampleMacro");
// write Histogram to current directory (i.e. the file just opened)
h->Write();
// Close the file.
// (You may inspect your histogram in the file using the TBrowser class)
f1->Close();
}
// the "dressing" code for a stand-alone ROOT application starts here
#ifndef __CINT__
void StandaloneApplication(int argc, char** argv) {
// ==>> here the ROOT macro is called
ExampleMacro_GUI();
}
// This is the standard main of C++ starting a ROOT application
int main(int argc, char** argv) {
TApplication app("Root Application", &argc, argv);
StandaloneApplication(app.Argc(), app.Argv());
app.Run();
return 0;
}
#endif