1 #define MACRO_READ_LOUDEST "ReadLoudestList.C"
2 #define MACRO_READ_PERIOD "ReadPeriodList.C"
3 #define PERIOD_MAX_SIZE 10
4 #define LOUDEST_MAX_SIZE 1000
5 #define LOUDEST_LIST_SIZE 100
6 #define MAX_LIST_SIZE 100 // maximum number of input root files in the input file list
8 #define DAY (24.*3600.)
10 #define WWW_PUBLIC "https://www.atlas.aei.uni-hannover.de/~waveburst/LSC/reports/"
11 #define WWW_LAG_MANUAL "https://www.atlas.aei.uni-hannover.de/~waveburst/doc/cwb/man/What-are-lags-and-how-to-use-them.html#What-are-lags-and-how-to-use-them"
12 #define WWW_SLAG_MANUAL "https://www.atlas.aei.uni-hannover.de/~waveburst/doc/cwb/man/What-are-super-lags-and-how-to-use-them.html#What-are-super-lags-and-how-to-use-them"
16 void mkhtml_index(vector<TString> chunk_report, TString odir);
17 void GetPeriod(TString ifile, TString irun,
double& xstart,
double& xstop,
double& obsTime);
20 void cwb_mkhtml_all(TString fList, TString run, TString
search,
int lag,
int slag, TString wlabel, TString path) {
22 cout<<
"cwb_mkhtml_all.C starts..."<<endl;
26 bool AddFileEntriesToTabs=
true;
27 if(fList.Sizeof()>0 && fList[0]==
'#') {
28 AddFileEntriesToTabs=
false;
29 fList = fList(1,fList.Sizeof()-1);
33 TString odir = path(0,path.Last(
'/'));
34 if(odir==
"") odir =
".";
35 TString rep_dir = odir(odir.Last(
'/')+1,odir.Sizeof());
37 TString file = path(path.Last(
'/')+1,path.Sizeof());
39 TString
type = file(file.Last(
'.')+1,file.Sizeof());
41 cout <<
"cwb_mkhtml_all - Error: path must be: odir/tag.png" << endl;
45 TString
tag = file(0,file.Index(
".",0));
47 cout <<
"cwb_mkhtml_all - Error: empty tag -> path must be: odir/tag.png" << endl;
51 CWB::Toolbox::checkFile(odir);
55 sprintf(cmd,
"cp %s %s/InputChunkList.txt",fList.Data(),odir.Data());
60 if(gSystem->Getenv(
"CWB_USER_URL")!=NULL) {
61 strcpy(cwb_user_url,TString(gSystem->Getenv(
"CWB_USER_URL")).Data());
64 search.ReplaceAll(
":",
" ");
65 char search_title[512];
66 sprintf(search_title,
"%s Search : Multiple Chunks",search.Data());
68 char ifile_period[1024];
69 if(bbh)
sprintf(ifile_period,
"%s/%s_bbh_period.txt",odir.Data(),tag.Data());
70 else sprintf(ifile_period,
"%s/%s_nobbh_period.txt",odir.Data(),tag.Data());
71 cout << ifile_period << endl;
76 GetPeriod(ifile_period, run, xstart, xstop, obsTime);
78 cout << xstart <<
" " << xstop <<
" " << obsTime << endl;
80 double interval = (xstop-xstart)/
DAY;
82 wat::Time beg_date(xstart);
83 wat::Time end_date(xstop);
85 TString sbeg_date = beg_date.GetDateString();sbeg_date.Resize(19);
86 TString send_date = end_date.GetDateString();send_date.Resize(19);
89 sprintf(period,
"GPS Interval [%d,%d]. UTC Interval %s - %s. Interval duration = %.2f days.",
int(xstart),
int(xstop),sbeg_date.Data(),send_date.Data(),interval);
93 sprintf(box_title,
"Open Box Result");
95 sprintf(box_title,
"Fake Open Box Result - ( <td><a href=\"%s\" target=\"_blank\">LAG</a></td> = %d - <td><a href=\"%s\" target=\"_blank\">SLAG</a></td> = %d )",
WWW_LAG_MANUAL,lag,
WWW_SLAG_MANUAL,slag);
99 sprintf(livetime,
"Livetime - Foreground: %.2f days",obsTime/
DAY);
101 char ifile_loudest_bbh[1024];
102 sprintf(ifile_loudest_bbh,
"%s_bbh_loudest.txt",tag.Data());
103 char ifile_loudest_nobbh[1024];
104 sprintf(ifile_loudest_nobbh,
"%s_nobbh_loudest.txt",tag.Data());
110 sprintf(fileout,
"%s/body.html", odir.Data());
111 cout << fileout << endl;
112 out.open(fileout,ios::out);
113 if (!out.good()) {cout <<
"Error Opening File : " << fileout << endl;
exit(1);}
115 out <<
"<html>" << endl;
118 out <<
"<div align=\"center\"><font color=\"blue\"><h1>" << search_title <<
"</h1></font></div>" << endl;
119 out <<
"<div align=\"center\"><font color=\"red\"><h4>"<< box_title <<
"</h4></font></div>" << endl;
120 out <<
"<div align=\"center\">" << endl;
121 out <<
"<a target=\"_blank\" href=\"InputChunkList.txt\">(Input Chunk List) </a>" << endl;
122 out <<
"</div>" << endl;
123 out <<
"<div align=\"center\"><font color=\"black\"><h4>"<< period <<
"</h4></font></div>" << endl;
124 out <<
"<div align=\"center\"><font color=\"black\"><h4>"<< livetime <<
"</h4></font></div>" << endl;
127 out <<
"<hr>" << endl;
128 out <<
"<br>" << endl;
129 out <<
"<br>" << endl;
131 out <<
"<table>" << endl;
132 out <<
"<tr><td width=\"50%\"><div align=\"center\">" << endl;
133 out <<
"<font color=\"red\"><h2>Cumulative Number vs IFAR</h2></font>" << endl;
134 out <<
"<font color=\"red\"><h3>(Included Known BBH)</h3></font>" << endl;
135 out <<
"<a target=\"_blank\" href=\""<< ifile_loudest_bbh <<
"\">(Loudest Event List) </a>" << endl;
136 out <<
"</div><div align=\"center\"><ul><br/>" << endl;
137 out <<
"<a class=\"image\" title=\"" << tag <<
"\">" << endl;
138 out <<
"<img src=\"" << tag <<
"_bbh_plot.png\" width=\"470\"> </a>" << endl;
139 out <<
"</br></ul>" << endl;
140 out <<
"</div><br><br></td><td width=\"50%\"><div align=\"center\">" << endl;
141 out <<
"<font color=\"red\"><h2>Cumulative Number vs IFAR</h2></font>" << endl;
142 out <<
"<font color=\"red\"><h3>(Excluded Known BBH)</h3></font>" << endl;
143 out <<
"<a target=\"_blank\" href=\""<< ifile_loudest_nobbh <<
"\">(Loudest Event List) </a>" << endl;
144 out <<
"</div><div align=\"center\"><ul><br/>" << endl;
145 out <<
"<a class=\"image\" title=\"" << tag <<
"\">" << endl;
146 out <<
"<img src=\"" << tag <<
"_nobbh_plot.png\" width=\"470\"> </a>" << endl;
147 out <<
"</br></ul>" << endl;
148 out <<
"</div><br><br></td></tr>" << endl;
149 out <<
"</table>" << endl;
152 gSystem->Exec(
"date");
159 char cwb_config_env[1024] =
"";
160 if(gSystem->Getenv(
"CWB_CONFIG")!=NULL) {
161 strcpy(cwb_config_env,TString(gSystem->Getenv(
"CWB_CONFIG")).Data());
163 char macro_read_loudest_path[1024];
167 CWB::Toolbox::checkFile(macro_read_loudest_path);
168 gROOT->LoadMacro(gSystem->ExpandPathName(macro_read_loudest_path));
183 char ifile_bbh_loudest[1024];
184 sprintf(ifile_bbh_loudest,
"%s/%s_bbh_loudest.txt",odir.Data(),tag.Data());
185 char ifile_nobbh_loudest[1024];
186 sprintf(ifile_nobbh_loudest,
"%s/%s_nobbh_loudest.txt",odir.Data(),tag.Data());
187 cout << ifile_nobbh_loudest << endl;
189 int nLoudest =
ReadLoudestList(ifile_nobbh_loudest, run_loudest, chunk_loudest, gps_loudest, bbh_name_loudest, ifar_sec_loudest, ifar_year_loudest,
190 obs_time_sec_loudest, obs_time_day_loudest, expected_loudest, observed_loudest, cumul_FAP_loudest, sigma_loudest);
191 cout <<
"nLoudest = " << nLoudest << endl;
195 out <<
"<head>" << endl;
196 out <<
"<style type=\"text/css\">" << endl;
197 out <<
".datagrid tr:hover td" << endl;
199 out <<
" background-color:#F1F1F2;" << endl;
201 out <<
"</style>" << endl;
202 out <<
"</head>" << endl;
203 out <<
"<b>" << endl;
204 out <<
"<hr>" << endl;
205 out <<
"<br>" << endl;
206 out <<
"<font color=\"red\" style=\"font-weight:bold;\"><center><p><h2>Foreground Loudest Event List (Excluded known BBH)</h2><p><center></font>" << endl;
207 out <<
"<font color=\"black\" style=\"font-weight:bold;\"><center><p><h3>(Ranked with IFAR)</h3><p><center></font>" << endl;
208 out <<
"<br>" << endl;
209 out <<
"</html>" << endl;
211 out <<
"<table border=0 cellpadding=2 class=\"datagrid\">" << endl;
212 out <<
"<tr align=\"center\">"<< endl;
213 out <<
"<td>ID</td>"<< endl;
214 out <<
"<td>IFAR(yrs)</td>"<< endl;
215 out <<
"<td> GPS </td>"<< endl;
216 out <<
"<td>chunk</td>"<< endl;
217 out <<
"<td>Expected-Events</td>"<< endl;
218 out <<
"<td>Observed-Events</td>"<< endl;
219 out <<
"<td>Cumulative-FAP</td>"<< endl;
220 out <<
"<td>Sigma</td>"<< endl;
221 out <<
"</tr>"<< endl;
224 for(
int i=0; i<nLoudest; i++) {
228 out <<
"<tr align=\"center\">"<< endl;
230 sprintf(os,
"<td>%.i</td>",i+1);
232 sprintf(os,
"<td>%.2f</td>",ifar_year_loudest[i]);
234 sprintf(os,
"<td>%3.3f</td>",gps_loudest[i]);
236 sprintf(os,
"<td>%i</td>",chunk_loudest[i]);
238 sprintf(os,
"<td>%3.3f</td>",expected_loudest[i]);
240 sprintf(os,
"<td>%i</td>",observed_loudest[i]);
242 sprintf(os,
"<td>%.3f</td>",cumul_FAP_loudest[i]);
244 sprintf(os,
"<td>%.2f</td>",sigma_loudest[i]);
247 out <<
"</tr>" << endl;
253 out <<
"</table>" << endl;
254 out <<
"<p>" << endl;
259 vector<TString> chunk_report;
263 sprintf(link,
"%s/%s/dump/%s/",cwb_user_url,wlabel.Data(),rep_dir.Data());
264 int high = 1100+26*nList;
265 sprintf(options,
"--link %s --label ALL --name body.html --high %d",link,high);
266 chunk_report.push_back(options);
268 if(fList!=
"" && AddFileEntriesToTabs) {
269 vector<TString> chunk_dir;
272 for(
int i=0;i<chunk_dir.size();i++) {
273 sprintf(link,
"%s/%s/dump/%s/",cwb_user_url,chunk_dir[i].Data(),rep_dir.Data());
274 sprintf(options,
"--link %s --label K%d --name body.html",link,chunk_id[i]);
275 chunk_report.push_back(options);
276 cout << i <<
"\t" << options << endl;
285 void GetPeriod(TString ifile, TString irun,
double& xstart,
double& xstop,
double& obsTime) {
288 char cwb_config_env[1024] =
"";
289 if(gSystem->Getenv(
"CWB_CONFIG")!=NULL) {
290 strcpy(cwb_config_env,TString(gSystem->Getenv(
"CWB_CONFIG")).Data());
293 char macro_read_period_path[1024];
296 CWB::Toolbox::checkFile(macro_read_period_path);
299 gROOT->LoadMacro(gSystem->ExpandPathName(macro_read_period_path));
310 int nPeriod =
ReadPeriodList(ifile, run, gps_start, date_start, gps_stop, date_stop,
311 interval_day, obs_time_sec, obs_time_day);
313 for(
int i=0;i<nPeriod;i++) {
315 xstart = gps_start[i];
317 obsTime = obs_time_sec[i];
331 sprintf(ofile,
"%s/index.html", odir.Data());
333 cout <<
"make index html file : " << ofile << endl;
334 out.open(ofile,ios::out);
335 if (!out.good()) {cout <<
"mkhtml_index : Error Opening File : " << ofile << endl;
exit(1);}
338 char html_index_template[1024]=
"";
340 if(gSystem->Getenv(
"CWB_HTML_INDEX")==NULL) {
341 cout <<
"Error : environment CWB_HTML_INDEX is not defined!!!" << endl;
exit(1);
343 strcpy(html_index_template,gSystem->Getenv(
"CWB_HTML_INDEX"));
345 TB.checkFile(html_index_template);
348 in.open(html_index_template,ios::in);
350 cout <<
"mkhtml_index : Error Opening File : " << html_index_template << endl;
356 in.getline(istring,1024);
357 if (!in.good())
break;
358 TString ostring(istring);
359 out << ostring.Data() << endl;
362 out <<
"<html>" << endl;
363 out <<
"<br>" << endl;
366 char sbody_height[256];
367 sprintf(sbody_height,
"%d",1800);
368 out <<
"<div class=\"tabber\">" << endl;
369 for(
int i=0;i<chunk_report.size();i++)
if(chunk_report[i]!=
"") {
371 TString chunk_report_link = CWB::Toolbox::getParameter(chunk_report[i],
"--link");
372 if(chunk_report_link==
"" && i!=0) {
373 cout<<
"mkhtml_index : Error : chunk_report --link not defined"<<endl;
exit(1);}
375 TString chunk_report_label = CWB::Toolbox::getParameter(chunk_report[i],
"--label");
376 if((chunk_report_link!=
"</tab>/")&&(chunk_report_label==
"")) {
377 cout<<
"mkhtml_index : Error : chunk_report --label not defined"<<endl;
exit(1);}
379 TString chunk_report_high = CWB::Toolbox::getParameter(chunk_report[i],
"--high");
380 if(chunk_report_high==
"") chunk_report_high=sbody_height;
381 int ichunk_report_high = chunk_report_high.Atoi();
383 TString chunk_report_name = CWB::Toolbox::getParameter(chunk_report[i],
"--name");
385 if(chunk_report_link==
"<tab>/") {
386 out <<
"<div class=\"tabbertab\">" << endl;
387 out <<
" <h2>" << chunk_report_label <<
"</h2>" << endl;
388 out <<
"<div class=\"tabber\">" << endl;
389 }
else if(chunk_report_link==
"</tab>/") {
390 out <<
"</div>" << endl;
391 out <<
"</div>" << endl;
393 out <<
"<div class=\"tabbertab\">" << endl;
394 out <<
" <h2>" << chunk_report_label <<
"</h2>" << endl;
396 if(chunk_report_name==
"") {
397 out <<
" <iframe src=\"" << chunk_report_link <<
"header.html\" width=\"100%\" height=\"900px\" "
398 <<
"marginwidth=\"15\" marginheight=\"15\" frameborder=\"0\"></iframe>" << endl;
400 out <<
" <iframe src=\"" << chunk_report_link <<
"body.html\" width=\"100%\" "
401 <<
" height=\"" << ichunk_report_high <<
"px\" frameborder=\"0\"></iframe>" << endl;
403 out <<
" <iframe src=\"" << chunk_report_link << chunk_report_name <<
"\" width=\"100%\" "
404 <<
" height=\"" << ichunk_report_high <<
"px\" frameborder=\"0\"></iframe>" << endl;
407 out <<
"</div>" << endl;
410 out <<
"</div>" << endl;
412 out <<
"</html>" << endl;
419 sprintf(cmd,
"cp %s/html/etc/html/ROOT.css %s/",gSystem->ExpandPathName(
"$HOME_WAT"),odir.Data());
421 sprintf(cmd,
"cp %s/html/etc/html/ROOT.js %s/",gSystem->ExpandPathName(
"$HOME_WAT"),odir.Data());
423 sprintf(cmd,
"cp %s/html/etc/html/tabber.css %s/",gSystem->ExpandPathName(
"$HOME_WAT"),odir.Data());
425 sprintf(cmd,
"cp %s/html/etc/html/tabber.js %s/",gSystem->ExpandPathName(
"$HOME_WAT"),odir.Data());
436 in.open(fList.Data(),ios::in);
437 if (!in.good()) {cout <<
"Error Opening File : " << fList.Data() << endl;
exit(1);}
443 in.getline(str,1024);
444 if (!in.good())
break;
445 if(str[0] !=
'#') size++;
447 in.clear(ios::goodbit);
448 in.seekg(0, ios::beg);
449 if (size==0) {cout <<
"Error : File " << fList.Data() <<
" is empty" << endl;
exit(1);}
453 int xlag,xslag,ichunk,ibin;
458 in >> sfile >> xlag >> xslag >> ichunk >> ibin >> srun;
459 if(!in.good())
break;
460 if(sfile[0]==
'#')
continue;
464 TString file = path(path.Last(
'/')+1,path.Sizeof());
465 file.ReplaceAll(
"wave_",
"");
466 TString dir = file(0,file.First(
'.'));
469 chunk_dir.push_back(dir);
470 chunk_id.push_back(ichunk);
482 in.open(tabber.Data(),ios::in);
483 if (!in.good()) {cout <<
"Error Opening File : " << fList.Data() << endl;
exit(1);}
486 TString tabber_tmp = tabber+
".tmp";
487 out.open(tabber_tmp,ios::out);
488 if (!out.good()) {cout <<
"Error Opening File : " << tabber_tmp << endl;
exit(1);}
492 in.getline(str,1024);
493 if (!in.good())
break;
495 ostr.ReplaceAll(
"0.8em",
"0.75em");
496 out << ostr.Data() << endl;
502 sprintf(cmd,
"mv %s %s",tabber_tmp.Data(),tabber.Data());
#define MACRO_READ_PERIOD
int ReadChunkDirs(TString fList, vector< TString > &chunk_dir, vector< int > &chunk_id)
int chunk_id[MAX_RUNS][CHUNK_MAX_SIZE]
sprintf(tag,"wave_%s", data_label)
int ReadLoudestList(TString ifile, TString *run, int *chunk, double *gps, TString *bbh_name, double *ifar_sec, double *ifar_year, int *obs_time_sec, double *obs_time_day, double *expected, int *observed, double *cumul_FAP, double *sigma)
int ReadPeriodList(TString ifile, TString *run, double *gps_start, TString *date_start, double *gps_stop, TString *date_stop, double *interval_day, int *obs_time_sec, double *obs_time_day)
void GetPeriod(TString ifile, TString irun, double &xstart, double &xstop, double &obsTime)
#define MACRO_READ_LOUDEST
#define LOUDEST_LIST_SIZE
void mkhtml_index(vector< TString > chunk_report, TString odir)
void cwb_mkhtml_all(TString fList, TString run, TString search, int lag, int slag, TString wlabel, TString path)
void ModifyFontSizeCSS(TString tabber)