TROOT instance, is it necesary?

Dear rooters,

When I started, I was told to compile my C++ code, which uses ROOT libs, as a binary (outside ROOT). I have used gROOT few times, without worrying about the TROOT class.

  1. Is there any advantage in declaring a custom instance of TROOT in the beginning of the code, rather than doing nothing (and using the global gROOT)?

  2. Does it have any impact when running several binaries at the same time? (for instance, I do not use global variables, but I am aware ROOT does, and I do not know if this may be a problem if these globals are shared between processes that use ROOT)

Thank you in advance.

Regards,
atd
Ref: https://root.cern.ch/doc/master/classTROOT.html


ROOT Version: 6.18
Platform: CC7
Compiler: gcc 4.8


I don’t think you should instantiate TROOT directly, but rather using TApplication or TRint, which will internally create a static & global TROOT object (gROOT).

Hi,
as far as I know,

  1. no, there is no advantage, but you probably want to build a TApplication object at the beginning of your main if the program is meant to display canvases: without TApplication, the program quits instead of hanging on opened canvases

  2. no, different binaries are completely independent and know nothing about each other. Global variables are global within a process.

Hope this helps,
Enrico

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.