Logo coherent WaveBurst  
Library Reference Guide
Logo
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 Aux 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  if(OS=="Darwin") {
108  if(gSystem->Load("libFITSIO.so")<0) libSTAT=false;
109  } else {
110  if(gSystem->Load("libpng.so")<0) libSTAT=false;
111  }
112 
113  // lal suite library
114  if(gSystem->Getenv("_USE_LAL")) {
115  TString lal_dir=TString(gSystem->Getenv("HOME_LAL"));
116  if(lal_dir!="") {
117  printf("Loading LAL Suite : %s ...\n",lal_dir.Data());
118  if(gSystem->Load(lal_dir+"/lib/liblal.so")<0) libSTAT=false;
119  if(gSystem->Load(lal_dir+"/lib/liblalsupport.so")<0) libSTAT=false;
120  if(gSystem->Load(lal_dir+"/lib/liblalframe.so")<0) libSTAT=false;
121  if(gSystem->Load(lal_dir+"/lib/liblalmetaio.so")<0) libSTAT=false;
122  if(gSystem->Load(lal_dir+"/lib/liblalsimulation.so")<0) libSTAT=false;
123  if(gSystem->Load(lal_dir+"/lib/liblalinspiral.so")<0) libSTAT=false;
124  if(gSystem->Load(lal_dir+"/lib/liblalburst.so")<0) libSTAT=false;
125  } else {
126  printf("Loading LAL Suite ...\n");
127  if(gSystem->Load("liblal.so")<0) libSTAT=false;
128  if(gSystem->Load("liblalsupport.so")<0) libSTAT=false;
129  if(gSystem->Load("liblalframe.so")<0) libSTAT=false;
130  if(gSystem->Load("liblalmetaio.so")<0) libSTAT=false;
131  if(gSystem->Load("liblalsimulation.so")<0) libSTAT=false;
132  if(gSystem->Load("liblalinspiral.so")<0) libSTAT=false;
133  if(gSystem->Load("liblalburst.so")<0) libSTAT=false;
134  }
135  if(gSystem->Load("libmetaio.so")<0) libSTAT=false;
136  }
137 
138  // cvode library
139  if(gSystem->Getenv("_USE_EBBH")) {
140  TString cvode_dir=TString(gSystem->Getenv("HOME_CVODE"));
141  printf("Loading cvode : %s ...\n",cvode_dir.Data());
142  if(OS=="Linux") {
143  if(gSystem->Load(cvode_dir+"/lib/libsundials_cvode.so")<0) libSTAT=false;
144  if(gSystem->Load(cvode_dir+"/lib/libsundials_nvecserial.so")<0) libSTAT=false;
145  }
146  if(OS=="Darwin") {
147  if(gSystem->Load(cvode_dir+"/lib/libsundials_cvode.dylib")<0) libSTAT=false;
148  if(gSystem->Load(cvode_dir+"/lib/libsundials_nvecserial.dylib")<0) libSTAT=false;
149  }
150  }
151 
153  // healpix & cfitsio libraries
154  if(gSystem->Getenv("_USE_HEALPIX")) {
155  // cfitsio library need to be standard
156  if(OS=="Linux") {
157  TString cfitsio_dir=TString(gSystem->Getenv("HOME_CFITSIO"));
158  printf("Loading cfitsio : %s ...\n",cfitsio_dir.Data());
159  if(gSystem->Load(cfitsio_dir+"/libcfitsio.so")<0) libSTAT=false;
160  }
161 
162  // healpix library
163  TString healpix_dir=TString(gSystem->Getenv("HOME_HEALPIX"));
164  printf("Loading HEALPix : %s ...\n",healpix_dir.Data());
165  if(OS=="Darwin") {
166  if(gSystem->Load(healpix_dir+"/src/cxx/osx/lib/libcxxsupport.dylib")<0) libSTAT=false;
167  if(gSystem->Load(healpix_dir+"/src/cxx/osx/lib/libfftpack.dylib")<0) libSTAT=false;
168  if(gSystem->Load(healpix_dir+"/src/cxx/osx/lib/libc_utils.dylib")<0) libSTAT=false;
169  if(gSystem->Load(healpix_dir+"/src/cxx/osx/lib/libhealpix_cxx.dylib")<0) libSTAT=false;
170  }
171  if(OS=="Linux") {
172  if(healpix_dir.Contains("2.20a")) {
173  printf("\nHEALPix %s error : obsolete version (must be >= 3.00) !!!\n\n",healpix_dir.Data());
174  gSystem->Exit(1);
175  }
176 
177  if(gSystem->Load(healpix_dir+"/src/cxx/shared/lib/libcxxsupport.so")<0) libSTAT=false;
178  if(gSystem->Load(healpix_dir+"/src/cxx/shared/lib/libfftpack.so")<0) libSTAT=false;
179  if(gSystem->Load(healpix_dir+"/src/cxx/shared/lib/libc_utils.so")<0) libSTAT=false;
180 
181  Long_t id,size,flags,mt; int estat; TString libname; bool blib=false;
182  libname = healpix_dir+"/src/cxx/shared/lib/libpsht.so";
183  estat = gSystem->GetPathInfo(libname,&id,&size,&flags,&mt);
184  if(estat==0) {blib=true;if(gSystem->Load(libname)<0) libSTAT=false;} // for HEALPix < 3.30
185  libname = healpix_dir+"/src/cxx/shared/lib/libsharp.so";
186  estat = gSystem->GetPathInfo(libname,&id,&size,&flags,&mt);
187  if(estat==0) {blib=true;if(gSystem->Load(libname)<0) libSTAT=false;} // for HEALPix >= 3.30
188  if(blib==false) {
189  printf("\nLoading HEALPix %s error !!!\n\n",healpix_dir.Data());
190  cout << "check : " << healpix_dir+"/src/cxx/shared/lib/libpsht.so" << endl;
191  cout << "check : " << healpix_dir+"/src/cxx/shared/lib/libsharp.so" << endl << endl;
192  gSystem->Exit(1);
193  }
194 
195  if(gSystem->Load(healpix_dir+"/src/cxx/shared/lib/libhealpix_cxx.so")<0) libSTAT=false;
196 
197  // gomp library (used in healpix : libpsht.so - SphericalHarmonic)
198  if(gSystem->AccessPathName("/usr/lib/gcc/x86_64-redhat-linux/8/libgomp.so")==0)
199  libgomp="/usr/lib/gcc/x86_64-redhat-linux/8/libgomp.so";
200  if(gSystem->AccessPathName("/usr/lib/gcc/x86_64-redhat-linux/4.8.2/libgomp.so")==0)
201  libgomp="/usr/lib/gcc/x86_64-redhat-linux/4.8.2/libgomp.so";
202  if(gSystem->AccessPathName("/usr/lib/gcc/x86_64-linux-gnu/8/libgomp.so")==0)
203  libgomp="/usr/lib/gcc/x86_64-linux-gnu/8/libgomp.so";
204  if(gSystem->AccessPathName("/usr/lib/gcc/x86_64-linux-gnu/4.6/libgomp.so")==0)
205  libgomp="/usr/lib/gcc/x86_64-linux-gnu/4.6/libgomp.so";
206  if(gSystem->AccessPathName("/usr/lib/gcc/x86_64-linux-gnu/4.7/libgomp.so")==0)
207  libgomp="/usr/lib/gcc/x86_64-linux-gnu/4.7/libgomp.so";
208  if(gSystem->AccessPathName("/usr/lib/gcc/x86_64-linux-gnu/4.8/libgomp.so")==0)
209  libgomp="/usr/lib/gcc/x86_64-linux-gnu/4.8/libgomp.so";
210  if(gSystem->AccessPathName("/usr/lib/gcc/x86_64-linux-gnu/4.9/libgomp.so")==0)
211  libgomp="/usr/lib/gcc/x86_64-linux-gnu/4.9/libgomp.so";
212  if(libgomp!="") {
213  if(gSystem->Load(libgomp)<0) libSTAT=false;
214  } else {
215  printf("Loading gomp : library not found !!! (used by SphericalHarmonic in HEALPix)\n");
216  }
217  }
218  }
219 
220  printf("Load cWB Libraries...\n");
221 
222  // wavelet library & macros
223  lib_path = wat_install+"/lib/wavelet.so";
224  printf("Loading WAT : %s ...\n",lib_path.Data());
225  if(gSystem->Load(lib_path)<0) libSTAT=false;
226 
227  printf("Loading Macros : %s ...\n",wat_dir.Data());
228  // these macros do not work with ROOT6, must be fixed !!!
229  // if(OS=="Darwin") gROOT->LoadMacro(wat_dir+"/wat/macro/Plot.C"); // note: this macro produce an issue with treeviewer
230  // gROOT->LoadMacro(wat_dir+"/wat/macro/Spectrum.C"); // note: this macro could crash root (not safe)
231  // gROOT->LoadMacro(wat_dir+"/wat/macro/WTSpectrum.C"); // note: this macro could crash root (not safe)
232  gROOT->LoadMacro(wat_dir+"/wat/macro/Histogram.C");
233  gROOT->LoadMacro(wat_dir+"/wat/macro/AddPulse.C");
234  //gROOT->LoadMacro(wat_dir+"/wat/macro/AddSignals.C");
235  gROOT->LoadMacro(wat_dir+"/wat/macro/readAscii.C");
236  gROOT->LoadMacro(wat_dir+"/wat/macro/readtxt.C");
237 
238  // frame library
239  TString fr_dir=TString(gSystem->Getenv("HOME_FRLIB"));
240  printf("Loading Frame : %s ...\n",fr_dir.Data());
241  if(OS=="Linux") {
242  if(gSystem->Load(fr_dir+"/"+OS+"/libFrame.so")<0) libSTAT=false;
243  if(gSystem->Load(fr_dir+"/"+OS+"/libFrameROOT.so")<0) libSTAT=false;
244  }
245  if(OS=="Darwin") {
246  if(gSystem->Load(fr_dir+"/"+OS+"/libFrame.dylib")<0) libSTAT=false;
247  if(gSystem->Load(fr_dir+"/"+OS+"/libFrameROOT.dylib")<0) libSTAT=false;
248  }
249 
250  // eBBH library
251  if(gSystem->Getenv("_USE_EBBH")) {
252  lib_path = wat_install+"/lib/eBBH.so";
253  printf("Loading eBBH : %s ...\n",lib_path.Data());
254  if(gSystem->Load(lib_path)<0) libSTAT=false;
255  }
256 
257  // stft library
258  lib_path = wat_install+"/lib/STFT.so";
259  printf("Loading STFT : %s ...\n",lib_path.Data());
260  if(gSystem->Load(lib_path)<0) libSTAT=false;
261 
262  // gwat library
263  lib_path = wat_install+"/lib/gwat.so";
264  printf("Loading gwat : %s ...\n",lib_path.Data());
265  if(gSystem->Load(lib_path)<0) libSTAT=false;
266 
267  // toolbox library
268  lib_path = wat_install+"/lib/Toolbox.so";
269  printf("Loading Toolbox : %s ...\n",lib_path.Data());
270  if(gSystem->Load(lib_path)<0) libSTAT=false;
271 
272  // history library
273  lib_path = wat_install+"/lib/History.so";
274  printf("Loading History : %s ...\n",lib_path.Data());
275  if(gSystem->Load(lib_path)<0) libSTAT=false;
276 
277  // bicoherence library
278  lib_path = wat_install+"/lib/Bicoherence.so";
279  printf("Loading Bicoherence : %s ...\n",lib_path.Data());
280  if(gSystem->Load(lib_path)<0) libSTAT=false;
281 
282  // filter library
283  lib_path = wat_install+"/lib/Filter.so";
284  printf("Loading Filter : %s ...\n",lib_path.Data());
285  if(gSystem->Load(lib_path)<0) libSTAT=false;
286 
287  // cwb frame library
288  lib_path = wat_install+"/lib/frame.so";
289  printf("Loading CWB FRAME : %s ...\n",lib_path.Data());
290  if(gSystem->Load(lib_path)<0) libSTAT=false;
291 
292  // cwb library
293  lib_path = wat_install+"/lib/cwb.so";
294  printf("Loading cwb : %s ...\n",lib_path.Data());
295  if(gSystem->Load(lib_path)<0) libSTAT=false;
296 
297  // wavegraph library
298  lib_path = wat_install+"/lib/wavegraph.so";
299  printf("Loading wavegraph : %s ...\n",lib_path.Data());
300  if(gSystem->Load(lib_path)<0) libSTAT=false;
301 
302  // declare ACLiC includes environment
303  gSystem->AddIncludePath("-I$HOME_WAT_INSTALL/inc");
304  gSystem->AddIncludePath("-I$ROOTSYS/include");
305  gSystem->AddIncludePath("-I"+wat_install+"/inc");
306  gSystem->AddIncludePath("-I"+fr_dir+"/src");
307  if(gSystem->Getenv("_USE_HEALPIX")) {
308  gSystem->AddIncludePath("-I$HOME_HEALPIX/src/cxx/Healpix_cxx");
309  gSystem->AddIncludePath("-I$HOME_HEALPIX/src/cxx/cxxsupport");
310  }
311  if(gSystem->Getenv("_USE_LAL")) {
312  TString lal_dir=TString(gSystem->Getenv("HOME_LAL"));
313  if(lal_dir!="") {
314  gSystem->AddIncludePath("-I"+lal_dir+"/include");
315  }
316  }
317  if(gSystem->Getenv("_USE_EBBH")) {
318  TString cvode_dir=TString(gSystem->Getenv("HOME_CVODE"));
319  if(cvode_dir!="") {
320  gSystem->AddIncludePath("-I"+cvode_dir+"/include");
321  }
322  }
323 
324  // declare ACLiCFlag options
325  TString fopts = gSystem->GetFlagsOpt();
326  fopts.Append(" -D_USE_ROOT -fPIC -Wno-deprecated -mavx -Wall -Wno-unknown-pragmas");
327  fopts.Append(" -fexceptions -O2 -D__STDC_CONSTANT_MACROS");
328  if(gSystem->Getenv("_USE_HEALPIX")) fopts.Append(" -D_USE_HEALPIX");
329  if(gSystem->Getenv("_USE_EBBH")) fopts.Append(" -D_USE_EBBH");
330  if(gSystem->Getenv("_USE_LAL")) fopts.Append(" -D_USE_LAL");
331 #ifdef _USE_ROOT6
332  fopts.Append(" -D_USE_ROOT6");
333 #endif
334  if(OS=="Darwin") fopts.Append(" -fno-common -dynamiclib -undefined dynamic_lookup");
335  else fopts.Append(" -fopenmp");
336  gSystem->SetFlagsOpt(fopts.Data());
337 
338  // set the offset for TimeDisplay, the seconds declared in xaxis
339  // are refered to "1980-01-06 00:00:00 UTC Sun" -> GPS = 0
340  gStyle->SetTimeOffset(315964790);
341 
342  gStyle->SetPalette(1,0);
343  gStyle->SetNumberContours(256);
344 
345  gROOT->ForceStyle(0);
346 
347  if(gSystem->Getenv("HOME_WAT")) {
348  printf("\ncWB library path : %s\n",gSystem->Getenv("HOME_WAT"));
349  }
350 
351  if(gSystem->Getenv("CWB_CONFIG")) {
352  printf("\ncWB config path : %s\n",gSystem->Getenv("CWB_CONFIG"));
353  }
354 
355  // Print CWB logo
357 
358  // set prompt
359  // Warning : prompt do not works in ROOT 6.00.02 (to be be fixed in the next version)
360  ((TRint*)gROOT->GetApplication())->SetPrompt("cwb [%d] ");
361 
362  // check library
363  if(!libSTAT) {
364  cout << "Error Loading Libraries ..." << endl << endl;
365  gSystem->Exit(1);
366  }
367 }
368 
TString fopts
TString GetLALVersion(TString options="")
Definition: Toolfun.hh:1004
TString("c")
Long_t flags
printf("Load Aux Libraries...\)
Long_t size
TString libgomp
TString wat_install
Definition: cwb_rootlogon.C:88
TString lib_path
Definition: cwb_rootlogon.C:89
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)