Opening TMVA GUI when the executable is compiled using `make` command


I can successfully compile and run the TMVAClassification.C file given in the directory /root/tutorials/tmva using the command $ make TMVAClassification; ./TMVAClassification. But despite having this line in the code:

//Launch the GUI for the root macros
   if (!gROOT->IsBatch()) TMVA::TMVAGui( outfileName );

no GUI appears after the completion. However, if I run: $ root TMVAClassification.C, The GUI opens at programme completion. I need to be able to do that because I will eventually use other libraries in the same code. Someone help please?


A TApplication is needed when creating a standalone application. Try to change TMVAClassification.C this way:

int main( int argc, char** argv )
   TApplication theApp("TMVAClassification", &argc, argv);
   // Select methods (don't look at this code - not of interest)
   TString methodList;
   for (int i=1; i<argc; i++) {
      TString regMethod(argv[i]);
      if(regMethod=="-b" || regMethod=="--batch") continue;
      if (!methodList.IsNull()) methodList += TString(",");
      methodList += regMethod;
   int ret = TMVAClassification(methodList);
   return ret;

Cheers, Bertrand.

1 Like

Thanks for clarifying that. And I needed to add

#include "TApplication.h"

at the beginning of the code.

Indeed… And you’re welcome :slight_smile: