Problem loading customized style while launching ROOT

Dear experts,

I have a problem loading automatically a customized style while launching ROOT.
The ROOT version is the latest git ROOT, which is 6.03/01

What I did was to create a .rootrc under home as follows:

Unix.*.Root.DynamicPath:    .:$(ROOTSYS)/lib:$(HOME)/RootUtils/lib:
Unix.*.Root.MacroPath:	    .:$(HOME)/RootUtils:

Root.ShowPath: false

and the env are:

[shuli@pb-d-128-141-151-98]~/root/root.git% echo $ROOTSYS
/usr/local
[shuli@pb-d-128-141-151-98]~/root/root.git% echo $HOME
/Users/shuli

and under $HOME/RootUtils I put the macros contained in the attached tarball “atlasstyle-00-03-05.tar.gz”.

But when launching ROOT, I got an error:

In file included from input_line_25:1:
/Users/shuli/RootUtils/rootlogon.C:5:3: error: use of undeclared identifier 'SetAtlasStyle'
  SetAtlasStyle();
  ^
root [0] 

while if I do the style loading by hand, I have no problem at all:

root [0]    gROOT->LoadMacro("AtlasStyle.C");
root [1]    SetAtlasStyle();

Applying ATLAS style settings...

root [2] 

Do you have any solution to set the customized style setting while automatical launching ROOT?
Many thanks.
atlasstyle-00-03-05.tar.gz (1.36 MB)

Is it a new problem with ROOT 6 ? did it work with ROOT 5 ?

Dear experts,

I am having the same problem.
I define SetAtlasStyle in my rootlogon.C for customized loading. It worked fine with ROOT5 but sourcing ROOT6, I obtain the same error:

In file included from input_line_29:1:
/afs/cern.ch/user/c/cinca/.rootlogon.C:20:5: error: use of undeclared identifier 'SetAtlasStyle'
    SetAtlasStyle();
    ^
root [0]

For information, I am using ROOT 6.02/02 on afs at CERN.

Hi,

Could you please try this: replace

gROOT->LoadMacro("AtlasStyle.C");

with

#include "AtlasStyle.C"

right at the top of the macro?

Cheers, Axel.

Yes, it worked perfectly out-of-box for any ROOT 5 versions.

[quote=“Axel”]Hi,

Could you please try this: replace

gROOT->LoadMacro("AtlasStyle.C");

with

#include "AtlasStyle.C"

right at the top of the macro?

Cheers, Axel.[/quote]

Hi Axel,

Thanks for the suggestion but unfortunately it doesn’t work but have new error messages like this:

[shuli@pb-d-128-141-151-51]~% root -l
In file included from input_line_25:1:
In file included from /Users/shuli/RootUtils/rootlogon.C:4:
In file included from /Users/shuli/RootUtils/AtlasStyle.C:14:
/Users/shuli/RootUtils/AtlasStyle.h:20:19: warning: empty parentheses interpreted as a function declaration [-Wvexing-parse]
TStyle* AtlasStyle();
                  ^~
/Users/shuli/RootUtils/AtlasStyle.h:20:19: note: replace parentheses with an initializer to declare a variable
TStyle* AtlasStyle();
                  ^~
                   = nullptr
In file included from input_line_25:1:
In file included from /Users/shuli/RootUtils/rootlogon.C:4:
/Users/shuli/RootUtils/AtlasStyle.C:19:1: error: function definition is not allowed here
{
^
/Users/shuli/RootUtils/AtlasStyle.C:28:1: error: function definition is not allowed here
{
^

Any solution? Many thanks.

Hi,

I assume rootlogon.C starts with ‘{’. That makes #includes in the middle of it difficult. Can you change it to

#include "AtlasStyle.C"
void rootlogon() {
...

If that doesn’t do: could you attach rootlogon.C and AtlasStyle.C, please?

Cheers, Axel.

I just tried the last recipe (was hang the same problem since I move to root 6 and stumbled on this page). If works fine if I change rootlogon.C in:

#include "AtlasStyle.C"
void rootlogon()
{
  // Load ATLAS style
  //gROOT->LoadMacro("AtlasStyle.C");
  SetAtlasStyle();
}

Thanks for the confirmation, mdelma!

Axel.

Hello,
I have a related problem since I updated to ROOT 6.
In my rootlogon.C I have the following:

[code]void rootlogon()
{
cout << “\n pPlasma ROOT login script\n” << endl;

gSystem->Load(“libplasma.so”);

// Add folder to the include path
TString IncPath = Form("%s%s",gSystem->Getenv(“PPLASMA”),"/inc");
gROOT->ProcessLine(Form(".include %s",IncPath.Data()));
//gSystem->AddIncludePath(Form(" -I%s",IncPath.Data()));

#include “PlasmaGlob.hh” // <-- This line fails in ROOT 6
PlasmaGlob::Initialize();

// Palettes!
gROOT->Macro(“PlasmaPalettes.C”);
}
[/code]

Because PlasmaGlob.hh it is not in ROOT’s include path by default, I need to add first the header location in the ROOT’s path.
Once I do this the include line should work, but ROOT can’t find it still:

In file included from input_line_24:1: /Users/delaossa/plasma/simulations/rootlogon.C:12:12: fatal error: 'PlasmaGlob.hh' file not found #include "PlasmaGlob.hh" // This line fails in ROOT 6

Curiously, once the ROOT prompt appears I can normally include that file and there is no errors anymore.
Somehow, the include path is not updated after the corresponding sentence during the rootlogon.C script, and it does only when the script ends.
This was not like this in ROOT 5 and everything worked as it is.
I cannot put the include line at the begining of the script because then, it is not possible to add the folder to the include path, and ROOT cannot find the header file.

By the way, if I try to set the include path using

instead of

The include path is not updated, not even when the ROOT session starts and the interpreter prompt appears.
Any help with this please?

Hi,

Finally! I have an answer.

In the master you have new macros called

R__ADD_INCLUDE_PATH($PPLASMA/inc)
R__LOAD_LIBRARY(libplasma.so)

(There is also a R__ADD_LIBRARY_PATH.)

In v6.04, only R__LOAD_LIBRARY exists.

This allows us to load the library while parsing. So here’s your ROOT 6 master version:

R__LOAD_LIBRARY(libplasma.so)
R__ADD_INCLUDE_PATH($PPLASMA/inc)
#include "PlasmaGlob.hh"

void rootlogon()
{
  cout << "\n pPlasma ROOT login script\n" << endl;
  PlasmaGlob::Initialize();
  
  // Palettes!
  gROOT->Macro("PlasmaPalettes.C");
}

In ROOT 6.04 you can at least do

R__LOAD_LIBRARY(libplasma.so)

void rootlogon()
{
  cout << "\n pPlasma ROOT login script\n" << endl;

  // You could set the environment variable ROOT_INCLUDE_PATH to
  // contain $PPLASMA/inc, or:
  // Add folder to the include path
  TString IncPath = Form("%s%s",gSystem->Getenv("PPLASMA"),"/inc");
  gROOT->ProcessLine(Form(".include %s",IncPath.Data()));

  // if you don't have a dictionary for PlasmaGlob in libplasma
  gInterpreter->Declare("#include \"PlasmaGlob.hh\"");
  gInterpreter->Process("PlasmaGlob::Initialize();");
  
  // or if you do have a dictionary for PlasmaGlob in libplasma:
  // #include happened by loading the library, so just do:
  PlasmaGlob::Initialize();

  // Palettes!
  gROOT->Macro("PlasmaPalettes.C");
}

Cheers, Axel.

please see also

viewtopic.php?f=3&t=21049

Hi Axel,

This works nicely ROOT6. Thanks.