source: trunk/Mars/cmake/rootlogon.C.in@ 19259

Last change on this file since 19259 was 19242, checked in by tbretz, 7 years ago
New files for cmake.
File size: 7.1 KB
Line 
1/* ======================================================================== *\
2!
3! *
4! * This file is part of MARS, the MAGIC Analysis and Reconstruction
5! * Software. It is distributed to you in the hope that it can be a useful
6! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
7! * It is distributed WITHOUT ANY WARRANTY.
8! *
9! * Permission to use, copy, modify and distribute this software and its
10! * documentation for any purpose is hereby granted without fee,
11! * provided that the above copyright notice appear in all copies and
12! * that both that copyright notice and this permission notice appear
13! * in supporting documentation. It is provided "as is" without express
14! * or implied warranty.
15! *
16!
17!
18! Author(s): Thomas Bretz, 12/2000 <mailto:tbretz@physik.rwth-aachen.de>
19!
20! Copyright: MAGIC Software Development, 2000-2018
21!
22!
23\* ======================================================================== */
24
25///////////////////////////////////////////////////////////////////////////
26//
27// rootlogon.C
28// ===========
29//
30// This file is the startup script ("autoexec.bat") executed when root is
31// started. The definition which file to start is done in ".rootrc".
32// There are three files which are automatically processed by root at
33// startup: A systemwide .rootrc, one in your home directory and one
34// in the current directory.
35// So rootlogon.C is correctly executed if your start root from your
36// Mars directory.
37//
38// The script setupts some small environmental things and makes
39// sure that the Mars shared object (libmars.so) is loaded. This shared
40// object gives you access to all Mars features from within the root
41// interpreter.
42//
43///////////////////////////////////////////////////////////////////////////
44#include <iomanip>
45
46
47Bool_t isloaded()
48{
49 TString str = gSystem->GetLibraries("libmars.so");
50
51 return !str.IsNull();
52}
53
54void unload()
55{
56 if (!isloaded())
57 return;
58
59 cout << "Unloading 'libmars.so'... " << flush;
60 if (gSystem->Unload("libmars.so"))
61 cout << "error!" << endl;
62 else
63 cout << "done." << endl << endl;
64}
65
66bool load(TString &dir)
67{
68 if (isloaded())
69 return;
70
71 cout << "\033[33m\033[1m" << "Loading '" << dir << "/libmars.so'... " << "\033[0m" << flush;
72
73 if (dir.IsNull())
74 dir = "./";
75
76 if (gSystem->Load(dir+"/libmars.so")!=0)
77 {
78 cout << "\033[31m\033[1m" << "error!" << endl;
79 cout << "\033[0m" << endl;
80 return false;
81 }
82 else
83 {
84 MParContainer::Class()->IgnoreTObjectStreamer();
85 MArray::Class()->IgnoreTObjectStreamer();
86 cout << "\033[33m\033[1m" << "done." << endl;
87 cout << "\033[0m" << endl;
88 return true;
89 }
90}
91
92void rootlogon()
93{
94 // This is a workaround to make axis behave as they
95 // are UTC and not local time
96 // gSystem->Setenv("TZ", "UTC");
97
98 cout << endl;
99
100 if (!load("${PROJECT_BINARY_DIR}"))
101 return;
102
103 MLog::RedirectErrorHandler(MLog::kColor);
104
105 // This initialized the thread factory. This is needed to supress
106 // an error which is displayed if the thread factory is initialized
107 // from another than the main thread (e.g. in the constructor
108 // of MStatusDisplay)
109 TThread::Self();
110
111 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/macros");
112 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/include");
113 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/manalysis");
114 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/mastro");
115 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/mbase");
116 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/mbadpixels");
117 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/mcamera");
118 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/mcalib");
119 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/mcore");
120 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/mdrs");
121 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/mhcalib");
122 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/mdata");
123 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/mfbase");
124 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/mfileio");
125 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/mfilter");
126 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/mgeom");
127 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/mgui");
128 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/mhbase");
129 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/mhflux");
130 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/mhft");
131 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/mhist");
132 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/mhistmc");
133 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/mhvstime");
134 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/mimage");
135 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/mjobs");
136 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/mjoptim");
137 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/mjtrain");
138 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/mmain");
139 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/mmc");
140 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/mmontecarlo");
141 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/mmuon");
142 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/mpedestal");
143 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/mpointing");
144 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/mranforest");
145 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/mraw");
146 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/mreflector");
147 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/mreport");
148 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/msignal");
149 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/msql");
150 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/mstarcam");
151 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/mtools");
152 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/mtrigger");
153 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/melectronics");
154 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/msim");
155 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/msimreflector");
156 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/msimcamera");
157 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/mcorsika");
158 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/mextralgo");
159
160 TString opt(gSystem->GetFlagsOpt());
161 TString dbg(gSystem->GetFlagsDebug());
162 TString lib(gSystem->GetLinkedLibs());
163
164 TString add = " -O5 -std=c++0x -Wall -Winit-self -fPIC -Wpointer-arith -Wcast-align -Woverloaded-virtual";
165 add += " -D__MARS__";
166 add += " -DHAVE_ZLIB";
167 add += " -DPACKAGE_NAME='\""+MARS::GetPackageName()+"\"'";
168 add += " -DPACKAGE_VERSION='\""+MARS::GetPackageName()+"\"'";
169 add += " -DREVISION='\""+MARS::GetRevision()+"\"'";
170 add += " -I\"${PROJECT_SOURCE_DIR}\"";
171
172 opt += add;
173 dbg += add;
174
175 lib += " -lnova -lz";
176
177 gSystem->SetLinkedLibs(lib);
178 gSystem->SetFlagsOpt(opt);
179 gSystem->SetFlagsDebug(dbg);
180
181
182 cout << "\033[32m" << "Welcome to the Mars Root environment." << "\033[0m" << endl;
183 cout << endl;
184}
Note: See TracBrowser for help on using the repository browser.