I was wondering wether there was a way to have a TH1F histogram outside of the ROOT environment.
Sorry for not including a sample code of what I wanted to do:
compile.cpp:
// This program is to get the basics of working with C++ and ROOT
#include<iostream>
#include"TH1F.h"
#include"TCanvas.h"
using namespace std;
int main()
{
TH1F *h1 = new TH1F("h1", "Test Histogram", 100, -4, 4);
h1->FillRandom("gaus", 10000);
TCanvas *c1 = new TCanvas("c1", "Test Canvas");
h1->Draw();
}
and then at the command line:
$ g++ -Wall -IApplications/root/include root-config --libs compile.cpp
compile.cpp: In function ‘int main()’:
compile.cpp:13: warning: unused variable ‘c1’
I was told I needed to include a statement:
in order to “see” the histogram.
To try and answer my own question: I think I need to be in ROOT and then either call the macro or use ACLiC.
you need to call TApplication::Run, or use Aclic. See the Users Guide on how to get your own program working with TApplication::Run. Note, though, that the recommended way of running compiled code is Aclic, not your own program.