Perform an histogram plot using in an external program

Dear Expert,
I developed a Geant4 application and I’d like to visualise some of the results in ‘real-time’ during the simulation run. In particular I’d like to plot a ROOT histogram that is created during the simulation.

I included the ROOT libraries and I wrote something of this:
#include “TROOT.h”
#include “TCanvas.h”
#include “TFile.h”
#include “TH1F.h”
#include “TH2F.h”
#include “TGraph.h”
#include “TLegend.h”
#include “TLegendEntry.h”
#include “TStyle.h”

if (!theRootCanvas)
theRootCanvas = new TCanvas(“theRootCanvas”,“Interaction Parameters”,200, 10, 600,400);
theRootCanvas -> SetFillColor(20);
theRootCanvas -> SetBorderMode(1);
theRootCanvas -> SetBorderSize(1);
theRootCanvas -> SetFrameBorderMode(0);
theRootCanvas -> SetGrid();

The program compiles correctly but no canvas is created and nothing happens during the simulation run.

Someone can suggest me some example where this is done?

Thank you very much,
Pablo Cirrone

Hi Pablo,

never, ever call gROOT->Reset(); unless in a funny CINT code called “unnamed macro”.

You need a TApplication object, and you need to allow ROOT to process events (like “draw histogram”) by calling gSystem->ProcessEvents() regularly.

Cheers, Axel.