source: trunk/Mars/macros/rootlogon.C@ 14200

Last change on this file since 14200 was 14200, checked in by tbretz, 12 years ago
Added mextralgo
File size: 6.3 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@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
50Bool_t isloaded()
51{
52 TString str = gSystem->GetLibraries("libmars.so");
53
54 return !str.IsNull();
55}
56
57void unload()
58{
59 if (!isloaded())
60 return;
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
69bool load(TString &dir)
70{
71 if (isloaded())
72 return;
73
74 cout << "\033[33m\033[1m" << "Loading '" << dir << "libmars.so'... " << "\033[0m" << flush;
75
76 if (dir.IsNull())
77 dir = "./";
78
79 if (gSystem->Load(dir+"libmars.so")!=0)
80 {
81 cout << "\033[33m\033[1m" << "error." << endl;
82 cout << "\033[0m" << endl;
83 return false;
84 }
85 else
86 {
87 MParContainer::Class()->IgnoreTObjectStreamer();
88 MArray::Class()->IgnoreTObjectStreamer();
89 cout << "\033[33m\033[1m" << "done." << endl;
90 cout << "\033[0m" << endl;
91 return true;
92 }
93}
94/*
95void make()
96{
97 unload();
98
99 if (gSystem->Exec("make"))
100 {
101 cout << "Error calling make..." << endl;
102 return;
103 }
104
105 load();
106}
107*/
108void rootlogon()
109{
110 cout << endl;
111
112 const Bool_t fileexist = !gSystem->AccessPathName("libmars.so", kFileExists);
113
114 TString dir = fileexist ? "" : gSystem->Getenv("MARSSYS");
115 if (!dir.IsNull())
116 {
117 cout << "\033[34m\033[1m" << "Searching Mars in " << dir << " (MARSSYS)" << "\033[0m" << endl << endl;
118
119 if (!dir.EndsWith("/"))
120 dir += "/";
121 }
122
123 if (!load(dir))
124 return;
125
126 MLog::RedirectErrorHandler(MLog::kColor);
127
128 // This initialized the thread factory. This is needed to supress
129 // an error which is displayed if the thread factory is initialized
130 // from another than the main thread (e.g. in the constructor
131 // of MStatusDisplay)
132 TThread::Self();
133
134 gInterpreter->AddIncludePath(dir+"macros");
135 gInterpreter->AddIncludePath(dir+"manalysis");
136 gInterpreter->AddIncludePath(dir+"mastro");
137 gInterpreter->AddIncludePath(dir+"mbase");
138 gInterpreter->AddIncludePath(dir+"mbadpixels");
139 gInterpreter->AddIncludePath(dir+"mcamera");
140 gInterpreter->AddIncludePath(dir+"mcalib");
141 gInterpreter->AddIncludePath(dir+"mcore");
142 gInterpreter->AddIncludePath(dir+"mhcalib");
143 gInterpreter->AddIncludePath(dir+"mdata");
144 gInterpreter->AddIncludePath(dir+"mfbase");
145 gInterpreter->AddIncludePath(dir+"mfileio");
146 gInterpreter->AddIncludePath(dir+"mfilter");
147 gInterpreter->AddIncludePath(dir+"mgeom");
148 gInterpreter->AddIncludePath(dir+"mgui");
149 gInterpreter->AddIncludePath(dir+"mhbase");
150 gInterpreter->AddIncludePath(dir+"mhflux");
151 gInterpreter->AddIncludePath(dir+"mhft");
152 gInterpreter->AddIncludePath(dir+"mhist");
153 gInterpreter->AddIncludePath(dir+"mhistmc");
154 gInterpreter->AddIncludePath(dir+"mhvstime");
155 gInterpreter->AddIncludePath(dir+"mimage");
156 gInterpreter->AddIncludePath(dir+"mjobs");
157 gInterpreter->AddIncludePath(dir+"mjoptim");
158 gInterpreter->AddIncludePath(dir+"mjtrain");
159 gInterpreter->AddIncludePath(dir+"mmain");
160 gInterpreter->AddIncludePath(dir+"mmc");
161 gInterpreter->AddIncludePath(dir+"mmontecarlo");
162 gInterpreter->AddIncludePath(dir+"mmuon");
163 gInterpreter->AddIncludePath(dir+"mpedestal");
164 gInterpreter->AddIncludePath(dir+"mpointing");
165 gInterpreter->AddIncludePath(dir+"mranforest");
166 gInterpreter->AddIncludePath(dir+"mraw");
167 gInterpreter->AddIncludePath(dir+"mreflector");
168 gInterpreter->AddIncludePath(dir+"mreport");
169 gInterpreter->AddIncludePath(dir+"msignal");
170 gInterpreter->AddIncludePath(dir+"msql");
171 gInterpreter->AddIncludePath(dir+"mstarcam");
172 gInterpreter->AddIncludePath(dir+"mtools");
173 gInterpreter->AddIncludePath(dir+"mtrigger");
174 gInterpreter->AddIncludePath(dir+"melectronics");
175 gInterpreter->AddIncludePath(dir+"msim");
176 gInterpreter->AddIncludePath(dir+"msimreflector");
177 gInterpreter->AddIncludePath(dir+"msimcamera");
178 gInterpreter->AddIncludePath(dir+"mcorsika");
179 gInterpreter->AddIncludePath(dir+"mextralgo");
180
181 TString options = " -O3 -DHAVE_ZLIB -D__MARS__ -pipe -Wall -Woverloaded-virtual -fno-exceptions -fPIC ";
182
183 TString s = "cd $BuildDir ; ";
184 s += "g++ -std=c++0x -c" + options + "-Iinclude -D_REENTRANT $IncludePath $SourceFiles ; ";
185 s += "g++ -std=c++0x $ObjectFiles -shared -Wl,-soname,$LibName.so -O -o $SharedLib";
186 gSystem->SetMakeSharedLib(s);
187
188 cout << "\033[32m" << "Welcome to the Mars Root environment." << "\033[0m" << endl;
189 cout << endl;
190}
Note: See TracBrowser for help on using the repository browser.