First of all thank Wile_E_Coyote for helping me and prodding me in the right direction !
Wading through the lines of code, I (re)learned the following:
MacroPath :
It is currently not set in $(root-config --etcdir) , therefore the following piece of
code is triggered in core/base/src/TROOT.cxx :
////////////////////////////////////////////////////////////////////////////////
/// Get the macro directory in the installation. Static utility function.
const TString& TROOT::GetMacroDir() {
#ifdef ROOTMACRODIR
if (IgnorePrefix()) {
#endif
static TString rootmacrodir;
if (rootmacrodir.IsNull()) {
rootmacrodir = "macros";
gSystem->PrependPathName(GetRootSys(), rootmacrodir);
}
return rootmacrodir;
#ifdef ROOTMACRODIR
} else {
const static TString rootmacrodir = ROOTMACRODIR;
return rootmacrodir;
}
#endif
}
resulting in rootmacrodir=(ROOTSYS)/macros
startup macro (i.e. rootlogon.C) :
- search along the macrodir for a macro whose name is “.rootlogon.C” and/or
what has been set in $(root-config --etcdir)/system.rootrc, let’s call it your-rootlogon.C .
(This information is retrieved in TEnv.cxx):
# Rint (interactive ROOT executable) specific alias, logon and logoff macros.
Rint.Load: rootalias.C
Rint.Logon: rootlogon.C
Rint.Logoff: rootlogoff.C
- now the following piece of code is executed from the file
core/rint/src/TRint.cxx:
////////////////////////////////////////////////////////////////////////////////
/// Execute logon macro's. There are three levels of logon macros that
/// will be executed: the system logon etc/system.rootlogon.C, the global
/// user logon ~/.rootlogon.C and the local ./.rootlogon.C. For backward
/// compatibility also the logon macro as specified by the Rint.Logon
/// environment setting, by default ./rootlogon.C, will be executed.
/// No logon macros will be executed when the system is started with
/// the -n option.
void TRint::ExecLogon()
{
if (NoLogOpt()) return;
TString name = ".rootlogon.C";
TString sname = "system";
sname += name;
char *s = gSystem->ConcatFileName(TROOT::GetEtcDir(), sname);
if (!gSystem->AccessPathName(s, kReadPermission)) {
ProcessFile(s);
}
delete [] s;
s = gSystem->ConcatFileName(gSystem->HomeDirectory(), name);
if (!gSystem->AccessPathName(s, kReadPermission)) {
ProcessFile(s);
}
delete [] s;
// avoid executing ~/.rootlogon.C twice
if (strcmp(gSystem->HomeDirectory(), gSystem->WorkingDirectory())) {
if (!gSystem->AccessPathName(name, kReadPermission))
ProcessFile(name);
}
// execute also the logon macro specified by "Rint.Logon"
const char *logon = gEnv->GetValue("Rint.Logon", (char*)0);
if (logon) {
char *mac = gSystem->Which(TROOT::GetMacroPath(), logon, kReadPermission);
if (mac)
ProcessFile(logon);
delete [] mac;
}
}
In summary, execute ( if available) in the following order
- $(root-config --etcdir)/system.rootlogon.C
- ${HOME}/.rootlogon.C
- MacroPath/your-rootlogon.C
This information is either available in the documentation or should be added.
Now most users wonder why I care about these installation details, things work just
fine. But you are probably working in a collaboration (CMS/ATLAS etc)
which sets up your environment , taking care of all these details.
A complain by many (academic) users of ROOT is that knowledge of this wonderful
tool does not bring them very far in a job interview. Clearly it is not installed and
used as widely outside the physics community as we wish.
One reason is that installing these tools seamlessly in an existing production environment is not an easy task. Luckily, many knobs are available to accomplish this,
but sometimes the information is lacking.