Run ROOT in batch mode from C++/Python code

 

Run ROOT in batch mode from C++/Python code

 

When running ROOT code from C++ or Python code it’s possible that doing a Draw call, e.g. to draw a histogram to a canvas then saved to a eps file, you get the canvas display runtime for a second. This happens because ROOT thinks it is running in interactive mode.

To get it running in batch mode this call has to be included in your code for C++:

gROOT->SetBatch(true);

and for Python code

prompt> python

python> import ROOT

python> ROOT.gROOT.SetBatch(True)

or also telling on command line the ROOT batch option (-b):

prompt> python - -b

the '-' tells python that the python options are finished, and that the

following '-b' is meant for the user program. ROOT will pick it up and

subsequently run in batch. Of course, if you run a script, no '-' is

needed anymore:

prompt> python mycode.py -b

(Thanks to S.Binet and  W.Lavrijsen)

Thursday, April 3, 2008

 
 
Made on a Mac

next >

< previous