Is there a way to run ROOT in a “headless” mode? For example, could I run an instance of a ROOT script or application from a command line, have it generate graphical features (like a histogram) and print/save it to a file all without requiring or displaying a UI?
I’ve searched for “headless” in the ROOT documentation and here on the forum, but I haven’t found anything yet.
Google for “ROOT batch mode”.
See also [url]Compile and run from command prompt and [url]Compile a macro without running?
Wile E. Coyote – Thanks for the suggestion.
I tried using SetBatch(true), and while it didn’t paint the UI it also didn’t do any UI operations at all. So when I instructed ROOT to draw a histogram to a batch mode canvas and then save it, presumably the histogram was never drawn as the file was never saved.
What I’m looking for is something in between – a headless mode where the UI operations happen, but aren’t painted to a screen. That way I can draw and save a histogram to an image without ever displaying the canvas.
Does that make sense and is it possible in ROOT?
Try to execute:
root -b -l -q trial.cxx
root -b -l -q trial.cxx++ using the following “trial.cxx”: [code]#include “TH1.h”
TH1F *h1 = new TH1F(“h1”, “histo from a gaussian”, 100, -3, 3);
TCanvas *c1 = new TCanvas(“c1”, “c1”);
gPad->Modified(); gPad->Update(); // just a precaution
Ah, I found where I went wrong – at least it appears to be working now.
I had created a new canvas and then called SetBatch(true) on it, which didn’t work well. If I call gROOT->SetBatch(true) before creating the canvas and gROOT->SetBatch(false) after drawing & saving, the file is created without a window appearing. Hopefully there aren’t ramifications to turning on & off batch mode like this.
Thanks for the help!