Logo Coherent WaveBurst  
Reference Guide
Logo
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
cwb_rootlogon.C
Go to the documentation of this file.
1 // cwb rootlogon macro : define the cwb environment - must defined in .rootrc
2 
3 {
4  #include "Riostream.h"
5  // Warning : This is used only for rootlogon.C
6  // Must be uncommented only for ROOT6
7  // For the others macros this definition is provides by CLing dictionary
8 
9 #if ROOT_VERSION_CODE >= ROOT_VERSION(6,0,0)
10  #define _USE_ROOT6
11 #else
12  if(gSystem->Getenv("_USE_ROOT6")!=NULL) {
13  cout << endl;
14  cout << "Error : environment _USE_ROOT6 is defined but ROOT version is < 6.00.00 !!!" << endl;
15  cout << endl;
16  exit(1);
17  }
18 #endif
19 
20  bool libSTAT=true; // lib status
21 
22  // ------------------------------------------------------------------------------------
23  // check operative system
24  // ------------------------------------------------------------------------------------
25  TString OS = "";
26  if(TString(gSystem->GetBuildArch()).Contains("linux")) OS="Linux";
27  if(TString(gSystem->GetBuildArch()).Contains("macos")) OS="Darwin";
28  if(OS=="") {
29  cout << "Error : Operative System not supported !!! " << endl;exit(1);}
30  else
31  cout << endl << "OS : " << OS.Data() << endl << endl;
32 
33  // ------------------------------------------------------------------------------------
34  // check if environmental variables are defined
35  // ------------------------------------------------------------------------------------
36  if(gSystem->Getenv("_USE_HEALPIX")!=NULL) {
37  if(gSystem->Getenv("HOME_CFITSIO")==NULL) {
38  cout << "Error : environment HOME_CFITSIO is not defined !!!" << endl;
39  exit(1);
40  }
41  if(gSystem->Getenv("HOME_HEALPIX")==NULL) {
42  cout << "Error : environment HOME_HEALPIX is not defined !!!" << endl;
43  exit(1);
44  }
45  }
46  if(gSystem->Getenv("_USE_LAL")!=NULL) {
47  if(gSystem->Getenv("HOME_LAL")==NULL) {
48  cout << "Error : environment HOME_LAL is not defined !!! " << endl;
49  exit(1);
50  }
51  }
52  if(gSystem->Getenv("_USE_EBBH")!=NULL) {
53  if(gSystem->Getenv("HOME_CVODE")==NULL) {
54  cout << "Error : environment HOME_CVODE is not defined !!!" << endl;
55  exit(1);
56  }
57  }
58  if(gSystem->Getenv("HOME_WAT_INSTALL")==NULL) {
59  cout << "Error : environment HOME_WAT_INSTALL is not defined !!!" << endl;exit(1);}
60  if(gSystem->Getenv("HOME_WAT")==NULL) {
61  cout << "Error : environment HOME_WAT is not defined !!! " << endl;exit(1);}
62  if(gSystem->Getenv("HOME_FRLIB")==NULL) {
63  cout << "Error : environment HOME_FRLIB is not defined !!! " << endl;exit(1);}
64  if(gSystem->Getenv("CWB_STFT")==NULL) {
65  cout << "Error : environment CWB_STFT is not defined !!! " << endl;exit(1);}
66  if(gSystem->Getenv("CWB_GWAT")==NULL) {
67  cout << "Error : environment CWB_GWAT is not defined !!! " << endl;exit(1);}
68  if(gSystem->Getenv("CWB_TOOLBOX")==NULL) {
69  cout << "Error : environment CWB_TOOLBOX is not defined !!! " << endl;exit(1);}
70  if(gSystem->Getenv("CWB_HISTORY")==NULL) {
71  cout << "Error : environment CWB_HISTORY is not defined !!! " << endl;exit(1);}
72  if(gSystem->Getenv("CWB_BICO")==NULL) {
73  cout << "Error : environment CWB_BICO is not defined !!! " << endl;exit(1);}
74  if(gSystem->Getenv("CWB_FRAME")==NULL) {
75  cout << "Error : environment CWB_FRAME is not defined !!! " << endl;exit(1);}
76  if(gSystem->Getenv("CWB_FILTER")==NULL) {
77  cout << "Error : environment CWB_FILTER is not defined !!! " << endl;exit(1);}
78  if(gSystem->Getenv("HOME_CWB")==NULL) {
79  cout << "Error : environment HOME_CWB is not defined !!! " << endl;exit(1);}
80  if(gSystem->Getenv("CWB_MACROS")==NULL) {
81  cout << "Error : environment CWB_MACROS is not defined !!!" << endl;exit(1);}
82 
83  cout << endl;
84  printf("ROOT/WAT/CWB initialization starting...\n");
85  cout << endl;
86 
87  TString wat_dir = gSystem->Getenv("HOME_WAT");
88  TString wat_install = gSystem->Getenv("HOME_WAT_INSTALL");
90 
91  // include paths
92  printf("Set Include Paths...\n");
93  char sys_cmd[256];
94  sprintf(sys_cmd,".include %s/inc",wat_install.Data());
95  gROOT->ProcessLine(sys_cmd);
96  sprintf(sys_cmd,".include %s/src",gSystem->Getenv("HOME_FRLIB"));
97  gROOT->ProcessLine(sys_cmd);
98 
99  // load libraries
100  printf("Load Libraries...\n");
101 
102  // auxiliaries root libraries
103  if(gSystem->Load("libPhysics.so")<0) libSTAT=false;
104  if(gSystem->Load("libFFTW.so")<0) libSTAT=false;
105  if(gSystem->Load("libHtml.so")<0) libSTAT=false;
106  if(gSystem->Load("libTreeViewer.so")<0) libSTAT=false;
107 
108  // lal suite library
109  if(gSystem->Getenv("_USE_LAL")) {
110  TString lal_dir=TString(gSystem->Getenv("HOME_LAL"));
111  if(lal_dir!="") {
112  printf("Loading LAL Suite : %s ...\n",lal_dir.Data());
113  if(gSystem->Load(lal_dir+"/lib/liblal.so")<0) libSTAT=false;
114  if(gSystem->Load(lal_dir+"/lib/liblalsupport.so")<0) libSTAT=false;
115  if(gSystem->Load(lal_dir+"/lib/liblalframe.so")<0) libSTAT=false;
116  if(gSystem->Load(lal_dir+"/lib/liblalmetaio.so")<0) libSTAT=false;
117  if(gSystem->Load(lal_dir+"/lib/liblalsimulation.so")<0) libSTAT=false;
118  if(gSystem->Load(lal_dir+"/lib/liblalinspiral.so")<0) libSTAT=false;
119  if(gSystem->Load(lal_dir+"/lib/liblalburst.so")<0) libSTAT=false;
120  } else {
121  printf("Loading LAL Suite ...\n");
122  if(gSystem->Load("liblal.so")<0) libSTAT=false;
123  if(gSystem->Load("liblalsupport.so")<0) libSTAT=false;
124  if(gSystem->Load("liblalframe.so")<0) libSTAT=false;
125  if(gSystem->Load("liblalmetaio.so")<0) libSTAT=false;
126  if(gSystem->Load("liblalsimulation.so")<0) libSTAT=false;
127  if(gSystem->Load("liblalinspiral.so")<0) libSTAT=false;
128  if(gSystem->Load("liblalburst.so")<0) libSTAT=false;
129  }
130  if(gSystem->Load("libmetaio.so")<0) libSTAT=false;
131  }
132 
133  // cvode library
134  if(gSystem->Getenv("_USE_EBBH")) {
135  TString cvode_dir=TString(gSystem->Getenv("HOME_CVODE"));
136  printf("Loading cvode : %s ...\n",cvode_dir.Data());
137  if(OS=="Linux") {
138  if(gSystem->Load(cvode_dir+"/lib/libsundials_cvode.so")<0) libSTAT=false;
139  if(gSystem->Load(cvode_dir+"/lib/libsundials_nvecserial.so")<0) libSTAT=false;
140  }
141  if(OS=="Darwin") {
142  if(gSystem->Load(cvode_dir+"/lib/libsundials_cvode.dylib")<0) libSTAT=false;
143  if(gSystem->Load(cvode_dir+"/lib/libsundials_nvecserial.dylib")<0) libSTAT=false;
144  }
145  }
146 
148  // healpix & cfitsio libraries
149  if(gSystem->Getenv("_USE_HEALPIX")) {
150  // cfitsio library
151  TString cfitsio_dir=TString(gSystem->Getenv("HOME_CFITSIO"));
152  printf("Loading cfitsio : %s ...\n",cfitsio_dir.Data());
153  if(gSystem->Load(cfitsio_dir+"/libcfitsio.so")<0) libSTAT=false;
154 
155  // healpix library
156  TString healpix_dir=TString(gSystem->Getenv("HOME_HEALPIX"));
157  printf("Loading HEALPix : %s ...\n",healpix_dir.Data());
158  if(OS=="Darwin") {
159  if(gSystem->Load(healpix_dir+"/src/cxx/osx/lib/libcxxsupport.dylib")<0) libSTAT=false;
160  if(gSystem->Load(healpix_dir+"/src/cxx/osx/lib/libfftpack.dylib")<0) libSTAT=false;
161  if(gSystem->Load(healpix_dir+"/src/cxx/osx/lib/libc_utils.dylib")<0) libSTAT=false;
162  if(gSystem->Load(healpix_dir+"/src/cxx/osx/lib/libhealpix_cxx.dylib")<0) libSTAT=false;
163  }
164  if(OS=="Linux") {
165  if(healpix_dir.Contains("2.20a")) {
166  printf("\nHEALPix %s error : obsolete version (must be >= 3.00) !!!\n\n",healpix_dir.Data());
167  gSystem->Exit(1);
168  }
169 
170  if(gSystem->Load(healpix_dir+"/src/cxx/shared/lib/libcxxsupport.so")<0) libSTAT=false;
171  if(gSystem->Load(healpix_dir+"/src/cxx/shared/lib/libfftpack.so")<0) libSTAT=false;
172  if(gSystem->Load(healpix_dir+"/src/cxx/shared/lib/libc_utils.so")<0) libSTAT=false;
173 
174  Long_t id,size,flags,mt; int estat; TString libname; bool blib=false;
175  libname = healpix_dir+"/src/cxx/shared/lib/libpsht.so";
176  estat = gSystem->GetPathInfo(libname,&id,&size,&flags,&mt);
177  if(estat==0) {blib=true;if(gSystem->Load(libname)<0) libSTAT=false;} // for HEALPix < 3.30
178  libname = healpix_dir+"/src/cxx/shared/lib/libsharp.so";
179  estat = gSystem->GetPathInfo(libname,&id,&size,&flags,&mt);
180  if(estat==0) {blib=true;if(gSystem->Load(libname)<0) libSTAT=false;} // for HEALPix >= 3.30
181  if(blib==false) {
182  printf("\nLoading HEALPix %s error !!!\n\n",healpix_dir.Data());
183  cout << "check : " << healpix_dir+"/src/cxx/shared/lib/libpsht.so" << endl;
184  cout << "check : " << healpix_dir+"/src/cxx/shared/lib/libsharp.so" << endl << endl;
185  gSystem->Exit(1);
186  }
187 
188  if(gSystem->Load(healpix_dir+"/src/cxx/shared/lib/libhealpix_cxx.so")<0) libSTAT=false;
189 
190  // gomp library (used in healpix : libpsht.so - SphericalHarmonic)
191  if(gSystem->AccessPathName("/usr/lib/gcc/x86_64-redhat-linux/4.4.4/libgomp.so")==0)
192  libgomp="/usr/lib/gcc/x86_64-redhat-linux/4.4.4/libgomp.so";
193  if(gSystem->AccessPathName("/usr/lib/gcc/x86_64-redhat-linux/4.8.2/libgomp.so")==0)
194  libgomp="/usr/lib/gcc/x86_64-redhat-linux/4.8.2/libgomp.so";
195  if(gSystem->AccessPathName("/usr/lib/gcc/x86_64-linux-gnu/4.4.4/libgomp.so")==0)
196  libgomp="/usr/lib/gcc/x86_64-linux-gnu/4.4.4/libgomp.so";
197  if(gSystem->AccessPathName("/usr/lib/gcc/x86_64-linux-gnu/4.6/libgomp.so")==0)
198  libgomp="/usr/lib/gcc/x86_64-linux-gnu/4.6/libgomp.so";
199  if(gSystem->AccessPathName("/usr/lib/gcc/x86_64-linux-gnu/4.7/libgomp.so")==0)
200  libgomp="/usr/lib/gcc/x86_64-linux-gnu/4.7/libgomp.so";
201  if(gSystem->AccessPathName("/usr/lib/gcc/x86_64-linux-gnu/4.8/libgomp.so")==0)
202  libgomp="/usr/lib/gcc/x86_64-linux-gnu/4.8/libgomp.so";
203  if(gSystem->AccessPathName("/usr/lib/gcc/x86_64-linux-gnu/4.9/libgomp.so")==0)
204  libgomp="/usr/lib/gcc/x86_64-linux-gnu/4.9/libgomp.so";
205  if(libgomp!="") {
206  if(gSystem->Load(libgomp)<0) libSTAT=false;
207  } else {
208  printf("Loading gomp : library not found !!! (used by SphericalHarmonic in HEALPix)\n");
209  }
210  }
211  }
212 
213  // wavelet library & macros
214  lib_path = wat_install+"/lib/wavelet.so";
215  printf("Loading WAT : %s ...\n",lib_path.Data());
216  if(gSystem->Load(lib_path)<0) libSTAT=false;
217 
218 #ifndef _USE_ROOT6
219  // these macros do not work with ROOT6, must be fixed !!!
220  // if(OS=="Darwin") gROOT->LoadMacro(wat_dir+"/wat/macro/Plot.C"); // note: this macro produce an issue with treeviewer
221  // gROOT->LoadMacro(wat_dir+"/wat/macro/Spectrum.C"); // note: this macro could crash root (not safe)
222  // gROOT->LoadMacro(wat_dir+"/wat/macro/WTSpectrum.C"); // note: this macro could crash root (not safe)
223  gROOT->LoadMacro(wat_dir+"/wat/macro/Histogram.C");
224  gROOT->LoadMacro(wat_dir+"/wat/macro/AddPulse.C");
225  gROOT->LoadMacro(wat_dir+"/wat/macro/AddSignals.C");
226  gROOT->LoadMacro(wat_dir+"/wat/macro/readAscii.C");
227  gROOT->LoadMacro(wat_dir+"/wat/macro/readtxt.C");
228 #endif
229 
230  // frame library
231  TString fr_dir=TString(gSystem->Getenv("HOME_FRLIB"));
232  printf("Loading Frame : %s ...\n",fr_dir.Data());
233  if(gSystem->Load(fr_dir+"/"+OS+"/libFrame.so")<0) libSTAT=false;
234  if(gSystem->Load(fr_dir+"/"+OS+"/libFrameROOT.so")<0) libSTAT=false;
235 
236  // eBBH library
237  if(gSystem->Getenv("_USE_EBBH")) {
238  lib_path = wat_install+"/lib/eBBH.so";
239  printf("Loading eBBH : %s ...\n",lib_path.Data());
240  if(gSystem->Load(lib_path)<0) libSTAT=false;
241  }
242 
243  // stft library
244  lib_path = wat_install+"/lib/STFT.so";
245  printf("Loading STFT : %s ...\n",lib_path.Data());
246  if(gSystem->Load(lib_path)<0) libSTAT=false;
247 
248  // gwat library
249  lib_path = wat_install+"/lib/gwat.so";
250  printf("Loading gwat : %s ...\n",lib_path.Data());
251  if(gSystem->Load(lib_path)<0) libSTAT=false;
252 
253  // toolbox library
254  lib_path = wat_install+"/lib/Toolbox.so";
255  printf("Loading Toolbox : %s ...\n",lib_path.Data());
256  if(gSystem->Load(lib_path)<0) libSTAT=false;
257 
258  // history library
259  lib_path = wat_install+"/lib/History.so";
260  printf("Loading History : %s ...\n",lib_path.Data());
261  if(gSystem->Load(lib_path)<0) libSTAT=false;
262 
263  // bicoherence library
264  lib_path = wat_install+"/lib/Bicoherence.so";
265  printf("Loading Bicoherence : %s ...\n",lib_path.Data());
266  if(gSystem->Load(lib_path)<0) libSTAT=false;
267 
268  // filter library
269  lib_path = wat_install+"/lib/Filter.so";
270  printf("Loading Filter : %s ...\n",lib_path.Data());
271  if(gSystem->Load(lib_path)<0) libSTAT=false;
272 
273  // cwb frame library
274  lib_path = wat_install+"/lib/frame.so";
275  printf("Loading CWB FRAME : %s ...\n",lib_path.Data());
276  if(gSystem->Load(lib_path)<0) libSTAT=false;
277 
278  // cwb library
279  lib_path = wat_install+"/lib/cwb.so";
280  printf("Loading cwb : %s ...\n",lib_path.Data());
281  if(gSystem->Load(lib_path)<0) libSTAT=false;
282 
283  // wavegraph library
284  lib_path = wat_install+"/lib/wavegraph.so";
285  printf("Loading wavegraph : %s ...\n",lib_path.Data());
286  if(gSystem->Load(lib_path)<0) libSTAT=false;
287 
288  // declare ACLiC includes environment
289  gSystem->AddIncludePath("-I$HOME_WAT_INSTALL/inc");
290  gSystem->AddIncludePath("-I$ROOTSYS/include");
291  gSystem->AddIncludePath("-I"+wat_install+"/inc");
292  gSystem->AddIncludePath("-I"+fr_dir+"/src");
293  if(gSystem->Getenv("_USE_HEALPIX")) {
294  gSystem->AddIncludePath("-I$HOME_HEALPIX/src/cxx/Healpix_cxx");
295  gSystem->AddIncludePath("-I$HOME_HEALPIX/src/cxx/cxxsupport");
296  }
297  if(gSystem->Getenv("_USE_LAL")) {
298  TString lal_dir=TString(gSystem->Getenv("HOME_LAL"));
299  if(lal_dir!="") {
300  gSystem->AddIncludePath("-I"+lal_dir+"/include");
301  }
302  }
303  if(gSystem->Getenv("_USE_EBBH")) {
304  TString cvode_dir=TString(gSystem->Getenv("HOME_CVODE"));
305  if(cvode_dir!="") {
306  gSystem->AddIncludePath("-I"+cvode_dir+"/include");
307  }
308  }
309 
310  // declare ACLiC library environment
311 /* are not necessary
312  TString libs = gSystem->GetLinkedLibs();
313  libs.Append(" -L$HOME_WAT_INSTALL/lib");
314  if(gSystem->Getenv("_USE_HEALPIX")) {
315  libs.Append(" -L$HOME_HEALPIX/src/cxx/Healpix_cxx/lib");
316  libs.Append(" -L$HOME_HEALPIX/src/cxx/cxxsupport/lib");
317  }
318  libs.Append(" -L$HOME_FRLIB/"+OS);
319  libs.Append(" -L/usr/local/lib -fexceptions -L$ROOTSYS/lib");
320  libs.Append(" -lFrame -lBicoherence -lToolbox -lSkyPlot -lHistory -lSTFT -lcwb -lWFilter -lframe");
321  if(gSystem->Getenv("_USE_HEALPIX")) {
322  libs.Append(" -lHEALPix");
323  }
324  libs.Append(" -lwavelet");
325  if(libgomp!="") {
326  libs.Append(" -L /tmp/"+uinfo->fUser);
327  libs.Append(" -lgomp");
328  }
329  gSystem->SetLinkedLibs(libs.Data());
330 */
331 
332  // declare ACLiCFlag options
333  TString fopts = gSystem->GetFlagsOpt();
334  fopts.Append(" -D_USE_ROOT -fPIC -Wno-deprecated -fopenmp -mavx -Wall -Wno-unknown-pragmas");
335  fopts.Append(" -fexceptions -O2 -D__STDC_CONSTANT_MACROS");
336  if(gSystem->Getenv("_USE_HEALPIX")) fopts.Append(" -D_USE_HEALPIX");
337 #ifdef _USE_ROOT6
338  fopts.Append(" -D_USE_ROOT6");
339 #endif
340  if(OS=="Darwin") fopts.Append(" -fno-common -dynamiclib -undefined dynamic_lookup");
341  gSystem->SetFlagsOpt(fopts.Data());
342 
343  // set the offset for TimeDisplay, the seconds declared in xaxis
344  // are refered to "1980-01-06 00:00:00 UTC Sun" -> GPS = 0
345  gStyle->SetTimeOffset(315964790);
346 
347  gStyle->SetPalette(1,0);
348  gStyle->SetNumberContours(256);
349 
350  gROOT->ForceStyle(0);
351 
352  if(gSystem->Getenv("HOME_WAT")) {
353  printf("\ncWB library path : %s\n",gSystem->Getenv("HOME_WAT"));
354  }
355 
356  if(gSystem->Getenv("CWB_CONFIG")) {
357  printf("\ncWB config path : %s\n",gSystem->Getenv("CWB_CONFIG"));
358  }
359 
360  // Print CWB logo
362 
363  // set prompt
364  // Warning : prompt do not works in ROOT 6.00.02 (to be be fixed in the next version)
365  ((TRint*)gROOT->GetApplication())->SetPrompt("cwb [%d] ");
366 
367  // check library
368  if(!libSTAT) {
369  cout << "Error Loading Libraries ..." << endl << endl;
370  gSystem->Exit(1);
371  }
372 }
373 
TString fopts
TString GetLALVersion(TString options="")
Definition: Toolfun.hh:892
TString("c")
Long_t flags
Long_t size
TString libgomp
TString wat_install
Definition: cwb_rootlogon.C:88
TString lib_path
Definition: cwb_rootlogon.C:89
printf("Set Include Paths...\n")
sprintf(sys_cmd,".include %s/inc", wat_install.Data())
int estat
TString OS
Definition: cwb_rootlogon.C:25
PrintLogoCWB(GetLALVersion())
Long_t mt
Long_t id
char sys_cmd[256]
Definition: cwb_rootlogon.C:93
exit(0)