1.2.4. Uranie namespace

As for the vast majority of ROOT’s classes, Uranie’s classes started with a capital T (for instance “TFoo.h”, if a class would be called “Foo”). Most of them inherit from TNamed, a generic class of ROOT which offers method for name and title bookkeeping. This is an important feature of the way ROOT-files are written (the name being the tag used to write or read any object and to handle them in memory). These classes belong to a specific namespace, in order to prevent any mixing between ROOT and Uranie (even though in practice, the name of the new classes implemented in Uranie is checked not to exist in ROOT for obvious safety and clarity reasons). Uranie defines many namespaces dedicated to the different module already introduced in Uranie modules organisation.

  • URANIE::DataServer ; the namespace associated with the DataServer library

  • URANIE::Launcher ; the namespace associated with the Launcher library

  • URANIE::Sampler ; the namespace associated with the Sampler library

  • URANIE::Optimizer ; the namespace associated with the Optimizer library

  • URANIE::Modeler ; the namespace associated with the Modeler library

  • URANIE::Sensitivity ; the namespace associated with the Sensitivity library

  • URANIE::Relauncher ; the namespace associated with the Relauncher library

  • URANIE::MpiRelauncher ; the namespace associated with the Relauncher library once used with MPI

  • URANIE::Calibration ; the namespace associated with the Calibration library

  • URANIE::MetaModelOptim ; the namespace associated with the MetaModelOptim library

  • URANIE::Reoptimizer ; the namespace associated with the Reoptimizer library

  • URANIE::UncertModeler ; the namespace associated with the UncertModeler library

  • URANIE::Reliability ; the namespace associated with the Reliability library

You can use the full qualified name to access to Uranie classes or use the using namespace directives to use the short name.

Another way to use the short name is to use again the rootlogon.C macro. If done so, all macros could access Uranie classes via the short name implicitly. Here is an example of rootlogon.C file:

using namespace URANIE::DataServer;
using namespace URANIE::Launcher;
using namespace URANIE::Sampler;
using namespace URANIE::Optimizer;
using namespace URANIE::Modeler;
using namespace URANIE::UncertModeler;
using namespace URANIE::Sensitivity;
using namespace URANIE::Relauncher;
using namespace URANIE::Reoptimizer;
using namespace URANIE::Calibration;
using namespace URANIE::Reliability;
// using namespace URANIE::XMLProblem;
// using namespace URANIE::MpiRelauncher;

void rootlogon()
{

    gStyle->SetPalette(1);
    gStyle->SetOptDate(21);

    //General graphical style
    // Default colors
    int white = 0;
    int color = 30;

    //Legend
    gStyle->SetLegendBorderSize(0);
    gStyle->SetFillStyle(0);

    // Pads
    gStyle->SetPadColor(white);
    gStyle->SetTitleFillColor(white);
    gStyle->SetStatColor(white);

}

/* ==================== Hint ====================
   
   Might be practical to store this in a convenient place (for instance
   your home directory) and to create an alias to make sure that you use
   only one rootlogon file independently of where you are.
  
   example : alias root="root -l ${HOME}/rootlogon.C"
   
   Many style issue can be set once and for all here.

   Warnings : 
    => The name of the main function (in between the void and the () part) 
    has to be the same as the name of the file (without extension).
    => If you intend to change this file name and make it a hidden file (let's 
    say  ${HOME}/.toto.C, the name of the main function would have to start with 
    an underscore, so here it would be "void _toto()".
*/

The most generic solution to simply don’t have to bother with namespaces while possibly tuning root graphical options to ones taste is to centralise this file and make it our own. By putting it somewhere central (for instance as a hidden file in your home folder, something like ~/.rootlogon.C) it is possible to make an alias that could have two purposes:

C Shell Family (csh, tcsh, etc.)

alias root root -l ~/.rootlogon.C

Bourne Shell Family (sh, bash, etc.)

alias root="root -l ~/.rootlogon.C"

With this kind of alias, one can have two interesting by-products: on the one hand, there will be no splash screen anymore (resulting from the “-l” option) while on the other hand, all the Uranie namespaces will be loaded along with your own graphical preferences, if you have any.