Issue for visualization of TH1 with a compiled program


I would like to know how to see at the end of a compiled program TH1F I filled.
I created a TCanvas, my TH1F…
When I draw it at the end of my program nothing appears, but my TH1F exists (it was written in a file).

It must be simple but I have no idea!

Thank you

Can you send the piece of code you wrote to draw the histogram ?



have you done :


Here are the main part of the code where I draw my TH1F.
I attached the complete code if you need it…

sprintf(canvasname,“Energy spectrum of the Detector %d”,detectnbr);
c1 = new TCanvas(“c1”,canvasname,200,10,900,700);

spectrum = new TH1F(spectrumname,title,maxch,0,maxch);


// Drawing of the spectrum
spectrum -> Draw();

[i] I just tried it… but it changed nothing

TAnalyse.cxx (18.9 KB)

I forgot to tell you I close the file where I save the TH1F at the very end of my program

You will find an example in:


enter $ROOTSYS/test/ and type “make”

[quote]You will find an example in:


enter $ROOTSYS/test/ and type “make”

This is quite a solution except that while the TCanvas is used the application is blocked… What I want to have is like in the root interpreter: as long as you don’t leave root your TCanvas live but your macro can reach its end and stop: your TCanvas will remain…

But in my case I do not use the root interpreter…

Maybe there is no solution… (for the moment)


either you go into theApp.Run() to show your canvas for as long as you like, or you exit the application. You cannot exit the application and keep the canvas on the screen.

Cheers, Fons.

Thank you that’s what I feared…

I’ll find another way…

Thank you