Logo ROOT  
Reference Guide
Loading...
Searching...
No Matches
ExampleMacro_GUI.C
Go to the documentation of this file.
1/*
2 This piece of code demonstrates how a root macro is used as a standalone
3 application with full acces the grapical user interface (GUI) of ROOT */
4
5// include ALL header files needed
6#include "TROOT.h"
7#include "TApplication.h"
8#include "TBrowser.h"
9#include "TFile.h"
10#include "TH1F.h"
11#include "TCanvas.h"
12#include "TMath.h"
13
14// eventually, include some additoinal C or C++ libraries
15#include <cmath>
16
17// ==>> put the code of your macro here
19 // Create a histogram, fill it with random gaussian numbers
20 TH1F *h = new TH1F ("h", "example histogram", 100, -5.,5.);
21 h->FillRandom("gaus",1000);
22
23 // draw the histogram
24 h->DrawClone();
25
26/* - Create a new ROOT file for output
27 - Note that this file may contain any kind of ROOT objects, histograms,
28 pictures, graphics objects etc.
29 - the new file is now becoming the current directory */
30 TFile *f1 = new TFile("ExampleMacro.root","RECREATE","ExampleMacro");
31
32 // write Histogram to current directory (i.e. the file just opened)
33 h->Write();
34
35 // Close the file.
36 // (You may inspect your histogram in the file using the TBrowser class)
37 f1->Close();
38}
39
40// the "dressing" code for a stand-alone ROOT application starts here
41void StandaloneApplication(int argc, char** argv) {
42 // ==>> here the ROOT macro is called
44}
45
46// This is the standard main of C++ starting a ROOT application
47int main(int argc, char** argv) {
48 TApplication app("Root Application", &argc, argv);
49 StandaloneApplication(app.Argc(), app.Argv());
50 app.Run();
51 return 0;
52}
void ExampleMacro_GUI()
void StandaloneApplication(int argc, char **argv)
#define h(i)
Definition RSha256.hxx:106
This class creates the ROOT Application Environment that interfaces to the windowing system eventloop...
virtual void Run(Bool_t retrn=kFALSE)
Main application eventloop. Calls system dependent eventloop via gSystem.
char ** Argv() const
Int_t Argc() const
A file, usually with extension .root, that stores data and code in the form of serialized objects in ...
Definition TFile.h:130
1-D histogram with a float per channel (see TH1 documentation)
Definition TH1.h:878
int main()
TF1 * f1
Definition legend1.C:11