Dynamic updating of histogram outside of ROOT

Dear Root Talk,

I was wondering if it were possible to use the classes of ROOT in a C++ program to display a histogram which dynamically fills when data is received.

I did a quick test program which just creates a histogram filled with random data points. But once I execute the code no canvas window pops up.

Would I have to run the program in ROOT itself using the interpreter?

Thanks,
rootmonkey a.k.a. ROOT novice

You can do this from compiled or interpreted code. See tutorials or test programs, eg $ROOTSYS/tutorials/hsimple.C, hsum.C

Rene

Thanks for the reply.

Just to clarify:

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.

Hope this clarifies my question.

Hi,

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.

Cheers, Axel.

Thanks :smiley: