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@astro.uni-wuerzburg.de>
|
---|
19 | !
|
---|
20 | ! Copyright: MAGIC Software Development, 2000-2004
|
---|
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 | // If libmars.so is not found in the current directory we search in the
|
---|
44 | // directory given in "MARSSYS" environment variable.
|
---|
45 | //
|
---|
46 | ///////////////////////////////////////////////////////////////////////////
|
---|
47 | #include <iomanip>
|
---|
48 |
|
---|
49 | Bool_t isloaded()
|
---|
50 | {
|
---|
51 | TString str = gSystem->GetLibraries("libmars.so");
|
---|
52 |
|
---|
53 | return !str.IsNull();
|
---|
54 | }
|
---|
55 |
|
---|
56 | /*
|
---|
57 | void unload()
|
---|
58 | {
|
---|
59 | if (!isloaded())
|
---|
60 | return true;
|
---|
61 |
|
---|
62 | cout << "Unloading 'libmars.so'... " << flush;
|
---|
63 | if (gSystem->Unload("libmars.so"))
|
---|
64 | cout << "error!" << endl;
|
---|
65 | else
|
---|
66 | cout << "done." << endl << endl;
|
---|
67 | }
|
---|
68 | */
|
---|
69 |
|
---|
70 | bool load(TString &dir)
|
---|
71 | {
|
---|
72 | if (isloaded())
|
---|
73 | return true;
|
---|
74 |
|
---|
75 | cout << "\033[33m\033[1m" << "Loading '" << dir << "libmars.so'... " << "\033[0m" << flush;
|
---|
76 |
|
---|
77 | if (dir.IsNull())
|
---|
78 | dir = "./";
|
---|
79 |
|
---|
80 | if (gSystem->Load(dir+"libmars.so")!=0)
|
---|
81 | {
|
---|
82 | cout << "\033[31m\033[1m" << "error!" << endl;
|
---|
83 | cout << "\033[0m" << endl;
|
---|
84 | return false;
|
---|
85 | }
|
---|
86 | else
|
---|
87 | {
|
---|
88 | MParContainer::Class()->IgnoreTObjectStreamer();
|
---|
89 | MArray::Class()->IgnoreTObjectStreamer();
|
---|
90 | cout << "\033[33m\033[1m" << "done." << endl;
|
---|
91 | cout << "\033[0m" << endl;
|
---|
92 | return true;
|
---|
93 | }
|
---|
94 | }
|
---|
95 | /*
|
---|
96 | void make()
|
---|
97 | {
|
---|
98 | unload();
|
---|
99 |
|
---|
100 | if (gSystem->Exec("make"))
|
---|
101 | {
|
---|
102 | cout << "Error calling make..." << endl;
|
---|
103 | return;
|
---|
104 | }
|
---|
105 |
|
---|
106 | load();
|
---|
107 | }
|
---|
108 | */
|
---|
109 | void rootlogon()
|
---|
110 | {
|
---|
111 | // This is a workaround to make axis behave as they
|
---|
112 | // are UTC and not local time
|
---|
113 | // gSystem->Setenv("TZ", "UTC");
|
---|
114 |
|
---|
115 | cout << endl;
|
---|
116 |
|
---|
117 | const Bool_t fileexist = !gSystem->AccessPathName("libmars.so", kFileExists);
|
---|
118 |
|
---|
119 | TString dir = fileexist ? "" : gSystem->Getenv("MARSSYS");
|
---|
120 | if (!dir.IsNull())
|
---|
121 | {
|
---|
122 | cout << "\033[34m\033[1m" << "Searching Mars in " << dir << " (MARSSYS)" << "\033[0m" << endl << endl;
|
---|
123 |
|
---|
124 | if (!dir.EndsWith("/"))
|
---|
125 | dir += "/";
|
---|
126 | }
|
---|
127 |
|
---|
128 | if (!load(dir))
|
---|
129 | return;
|
---|
130 |
|
---|
131 | MLog::RedirectErrorHandler(MLog::kColor);
|
---|
132 |
|
---|
133 | // This initialized the thread factory. This is needed to supress
|
---|
134 | // an error which is displayed if the thread factory is initialized
|
---|
135 | // from another than the main thread (e.g. in the constructor
|
---|
136 | // of MStatusDisplay)
|
---|
137 | TThread::Self();
|
---|
138 |
|
---|
139 | gInterpreter->AddIncludePath(dir+"macros");
|
---|
140 | gInterpreter->AddIncludePath(dir+"include");
|
---|
141 | gInterpreter->AddIncludePath(dir+"manalysis");
|
---|
142 | gInterpreter->AddIncludePath(dir+"mastro");
|
---|
143 | gInterpreter->AddIncludePath(dir+"mbase");
|
---|
144 | gInterpreter->AddIncludePath(dir+"mbadpixels");
|
---|
145 | gInterpreter->AddIncludePath(dir+"mcamera");
|
---|
146 | gInterpreter->AddIncludePath(dir+"mcalib");
|
---|
147 | gInterpreter->AddIncludePath(dir+"mcore");
|
---|
148 | gInterpreter->AddIncludePath(dir+"mdrs");
|
---|
149 | gInterpreter->AddIncludePath(dir+"mhcalib");
|
---|
150 | gInterpreter->AddIncludePath(dir+"mdata");
|
---|
151 | gInterpreter->AddIncludePath(dir+"mfbase");
|
---|
152 | gInterpreter->AddIncludePath(dir+"mfileio");
|
---|
153 | gInterpreter->AddIncludePath(dir+"mfilter");
|
---|
154 | gInterpreter->AddIncludePath(dir+"mgeom");
|
---|
155 | gInterpreter->AddIncludePath(dir+"mgui");
|
---|
156 | gInterpreter->AddIncludePath(dir+"mhbase");
|
---|
157 | gInterpreter->AddIncludePath(dir+"mhflux");
|
---|
158 | gInterpreter->AddIncludePath(dir+"mhft");
|
---|
159 | gInterpreter->AddIncludePath(dir+"mhist");
|
---|
160 | gInterpreter->AddIncludePath(dir+"mhistmc");
|
---|
161 | gInterpreter->AddIncludePath(dir+"mhvstime");
|
---|
162 | gInterpreter->AddIncludePath(dir+"mimage");
|
---|
163 | gInterpreter->AddIncludePath(dir+"mjobs");
|
---|
164 | gInterpreter->AddIncludePath(dir+"mjoptim");
|
---|
165 | gInterpreter->AddIncludePath(dir+"mjtrain");
|
---|
166 | gInterpreter->AddIncludePath(dir+"mmain");
|
---|
167 | gInterpreter->AddIncludePath(dir+"mmc");
|
---|
168 | gInterpreter->AddIncludePath(dir+"mmontecarlo");
|
---|
169 | gInterpreter->AddIncludePath(dir+"mmuon");
|
---|
170 | gInterpreter->AddIncludePath(dir+"mpedestal");
|
---|
171 | gInterpreter->AddIncludePath(dir+"mpointing");
|
---|
172 | gInterpreter->AddIncludePath(dir+"mranforest");
|
---|
173 | gInterpreter->AddIncludePath(dir+"mraw");
|
---|
174 | gInterpreter->AddIncludePath(dir+"mreflector");
|
---|
175 | gInterpreter->AddIncludePath(dir+"mreport");
|
---|
176 | gInterpreter->AddIncludePath(dir+"msignal");
|
---|
177 | gInterpreter->AddIncludePath(dir+"msql");
|
---|
178 | gInterpreter->AddIncludePath(dir+"mstarcam");
|
---|
179 | gInterpreter->AddIncludePath(dir+"mtools");
|
---|
180 | gInterpreter->AddIncludePath(dir+"mtrigger");
|
---|
181 | gInterpreter->AddIncludePath(dir+"melectronics");
|
---|
182 | gInterpreter->AddIncludePath(dir+"msim");
|
---|
183 | gInterpreter->AddIncludePath(dir+"msimreflector");
|
---|
184 | gInterpreter->AddIncludePath(dir+"msimcamera");
|
---|
185 | gInterpreter->AddIncludePath(dir+"mcorsika");
|
---|
186 | gInterpreter->AddIncludePath(dir+"mextralgo");
|
---|
187 |
|
---|
188 | TString opt(gSystem->GetFlagsOpt());
|
---|
189 | TString dbg(gSystem->GetFlagsDebug());
|
---|
190 | TString lib(gSystem->GetLinkedLibs());
|
---|
191 |
|
---|
192 | TString add = " -O5 -std=c++0x -Wall -Winit-self -fPIC -Wpointer-arith -Wcast-align -Woverloaded-virtual";
|
---|
193 | add += " -D__MARS__";
|
---|
194 | add += " -DHAVE_ZLIB";
|
---|
195 | add += " -DPACKAGE_NAME='\""+MARS::GetPackageName()+"\"'";
|
---|
196 | add += " -DPACKAGE_VERSION='\""+MARS::GetPackageName()+"\"'";
|
---|
197 | add += " -DREVISION='\""+MARS::GetRevision()+"\"'";
|
---|
198 |
|
---|
199 | opt += add;
|
---|
200 | dbg += add;
|
---|
201 |
|
---|
202 | lib += " -lnova -lz";
|
---|
203 |
|
---|
204 | gSystem->SetLinkedLibs(lib);
|
---|
205 | gSystem->SetFlagsOpt(opt);
|
---|
206 | gSystem->SetFlagsDebug(dbg);
|
---|
207 |
|
---|
208 |
|
---|
209 | cout << "\033[32m" << "Welcome to the Mars Root environment." << "\033[0m" << endl;
|
---|
210 | cout << endl;
|
---|
211 | }
|
---|