Printing histogram to png, with and without TApplication

Hello,
I use ROOT 4.04/02.
When I draw an histogram and print it into a png file, the result is not the same if I have a TApplication or not…

I don’t want to have a TApplication because I don’t want the TCanvas to display on the screen, since this program will be run on a cluster. When I have this line in my program :
TApplication theApp(“App”,&argc,argv);

the histogram are drawn correctly.

However, if I comment this line, the bins for which the content is 0 aren’t correctly displayed. There are bars that are displayed going in the negative direction.

I join two images generated, with and without including the TApplication line.




Can you send a small example (and the way to run it) reproducing the problem ?

Ok, I generated my histogram and I exported it as a macro, which I edited to make a runing program.
I joined the code, compile it with :
g++ -O2 c.C -o test.out -I/usr/local/root/include/root/ -L/usr/local/root/lib/root/ -lCore -lCint -lGui -lGpad -lHist -lGraf -lMatrix -lGeom

Then, run ./test.out and look at the file test.png that is generated.

Now, uncomment the line
// TApplication theApp(“App”,&argc,argv);
in the c.C file, recompile, and look again at the test.png.
c.C (2.02 KB)

I also got other graphical bugs when there is no TApplication in the code, when there are more bins in the histogram.

I included an example of graphic.


I do not get this problem with my root version. I am using the latest CVS head on linux (SLC3) may be your root version is too old.

mmmm, ok, do you have the version 5, or the latest CVS version of 4.04/02 ?

Can anyone conrifm this problem occurs in version 4.04/02 ?, just to ensure it is not a configuration problem.

Thank you

5.02/00 is available on the root web site

I confirm it doesn’t work with 4.04/02 on SLC3. I get the same “negative bins” when TApplication is commented.

Can you try that with Qt layer “On” to see whether the effect is still persisiting ?
Check root.cern.ch/phpBB2/viewtopic.php?t=2231 on the Qt layer docs.

Hello fine,
It’s not that I don’t want to read the documentation, but I don’t really have time to do it. Can you just tell me what I need to change to my code to enable Qt layer (which, by the way, I have no clues of what it is)

[quote=“mboisso”]Hello fine,
It’s not that I don’t want to read the documentation, but I don’t really have time to do it. Can you just tell me what I need to change to my code to enable Qt layer (which, by the way, I have no clues of what it is)[/quote]

:frowning: I think if you have no time you should read docs or just forget my advice.

What about your code. You need change no line in your code.

The documentation in question is 2 pages. I really have no time to re-type these pages here :slight_smile:

If you have Qt but have no Qt layer installed you can add it alone.

To adjust the brand new ROOT version do:

        cvs -d :pserver:cvsuser@cvs.bnl.gov:/data01/CVS co -d qtRoot root
          cd qtRoot
          # define where you want to install the Qt components
          
          export QTROOTSYSDIR=`pwd`/qtrootsys
          
          # you may want to add Qt components into your ROOT installation
          # directly. In this case replace "qtrootsys" directory 
          # name with $ROOTSYS
          # -- For example:
          # -- export QTROOTSYSDIR=$ROOTSYS

          qmake          # Do not mess QMAKE with GMAKE. 
                         # At this point you need QMAKE
          
          # use > qmake "CONFIG+=debug" # if you want to install the Qt components
                                      # with the debug information attached
          make install 
          
          # Note:  Please disregard the warning messages:
          #       "WARNING: Failure to find: ${QMAKE_TARGET}Dict.cxx"

          ls  ${QTROOTSYSDIR}
          
          # clean the redundant files
          
           make distclean

Of course I can go further but then … then many people on this forum may have been forced wasting their time reading once again what they had already read from root.cern.ch/phpBB2/viewtopic.php?t=2231

Please send me a message if you want me reply you directly.