22 #define PERIOD_MAX_SIZE 10
23 #define LOUDEST_MAX_SIZE 1000
24 #define LOUDEST_LIST_SIZE 100
25 #define MAX_LIST_SIZE 100
27 #define DAY (24.*3600.)
29 #define WWW_PUBLIC "https://ldas-jobs.ligo.caltech.edu/~waveburst/reports/"
30 #define WWW_LAG_MANUAL "https://gwburst.gitlab.io/documentation/latest/html/faq.html?highlight=lag#what-are-lags-and-how-to-use-them"
31 #define WWW_SLAG_MANUAL "https://gwburst.gitlab.io/documentation/latest/html/faq.html?highlight=lag#what-are-super-lags-and-how-to-use-them"
35 void mkhtml_index(vector<TString> chunk_report, TString odir);
36 void GetPeriod(TString ifile, TString irun,
double& xstart,
double& xstop,
double& obsTime);
41 cout<<
"cwb_mkhtml_all.C starts..."<<endl;
45 bool AddFileEntriesToTabs=
true;
46 if(fList.Sizeof()>0 && fList[0]==
'#') {
47 AddFileEntriesToTabs=
false;
48 fList = fList(1,fList.Sizeof()-1);
52 TString odir = path(0,path.Last(
'/'));
53 if(odir==
"") odir =
".";
54 TString rep_dir = odir(odir.Last(
'/')+1,odir.Sizeof());
56 TString file = path(path.Last(
'/')+1,path.Sizeof());
58 TString type = file(file.Last(
'.')+1,file.Sizeof());
60 cout <<
"cwb_mkhtml_all - Error: path must be: odir/tag.png" << endl;
64 TString
tag = file(0,file.Index(
".",0));
66 cout <<
"cwb_mkhtml_all - Error: empty tag -> path must be: odir/tag.png" << endl;
70 CWB::Toolbox::checkFile(odir);
74 sprintf(
cmd,
"cp %s %s/InputChunkList.txt",fList.Data(),odir.Data());
79 if(gSystem->Getenv(
"CWB_USER_URL")!=NULL) {
80 strcpy(cwb_user_url,TString(gSystem->Getenv(
"CWB_USER_URL")).Data());
83 search.ReplaceAll(
":",
" ");
84 char search_title[512];
85 sprintf(search_title,
"%s Search : Multiple Chunks",
search.Data());
87 char ifile_period[1024];
88 if(bbh)
sprintf(ifile_period,
"%s/%s_bbh_period.txt",odir.Data(),
tag.Data());
89 else sprintf(ifile_period,
"%s/%s_nobbh_period.txt",odir.Data(),
tag.Data());
90 cout << ifile_period << endl;
97 cout << xstart <<
" " << xstop <<
" " << obsTime << endl;
99 double interval = (xstop-xstart)/
DAY;
101 wat::Time beg_date(xstart);
102 wat::Time end_date(xstop);
104 TString sbeg_date = beg_date.GetDateString();sbeg_date.Resize(19);
105 TString send_date = end_date.GetDateString();send_date.Resize(19);
108 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);
110 char box_title[1024];
111 if(lag==0 && slag==0)
112 sprintf(box_title,
"Open Box Result");
114 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);
118 sprintf(livetime,
"Livetime - Foreground: %.2f days",obsTime/
DAY);
120 char ifile_loudest_bbh[1024];
121 sprintf(ifile_loudest_bbh,
"%s_bbh_loudest.txt",
tag.Data());
122 char ifile_loudest_nobbh[1024];
123 sprintf(ifile_loudest_nobbh,
"%s_nobbh_loudest.txt",
tag.Data());
129 sprintf(fileout,
"%s/body.html", odir.Data());
130 cout << fileout << endl;
131 out.open(fileout,ios::out);
132 if (!out.good()) {cout <<
"Error Opening File : " << fileout << endl;
exit(1);}
134 out <<
"<html>" << endl;
137 out <<
"<div align=\"center\"><font color=\"blue\"><h1>" << search_title <<
"</h1></font></div>" << endl;
138 out <<
"<div align=\"center\"><font color=\"red\"><h4>"<< box_title <<
"</h4></font></div>" << endl;
139 out <<
"<div align=\"center\">" << endl;
140 out <<
"<a target=\"_blank\" href=\"InputChunkList.txt\">(Input Chunk List) </a>" << endl;
141 out <<
"</div>" << endl;
142 out <<
"<div align=\"center\"><font color=\"black\"><h4>"<< period <<
"</h4></font></div>" << endl;
143 out <<
"<div align=\"center\"><font color=\"black\"><h4>"<< livetime <<
"</h4></font></div>" << endl;
146 out <<
"<hr>" << endl;
147 out <<
"<br>" << endl;
148 out <<
"<br>" << endl;
150 out <<
"<table>" << endl;
151 out <<
"<tr><td width=\"50%\"><div align=\"center\">" << endl;
152 out <<
"<font color=\"red\"><h2>Cumulative Number vs IFAR</h2></font>" << endl;
153 out <<
"<font color=\"red\"><h3>(Included Known BBH)</h3></font>" << endl;
154 out <<
"<a target=\"_blank\" href=\""<< ifile_loudest_bbh <<
"\">(Loudest Event List) </a>" << endl;
155 out <<
"</div><div align=\"center\"><ul><br/>" << endl;
156 out <<
"<a class=\"image\" title=\"" <<
tag <<
"\">" << endl;
157 out <<
"<img src=\"" <<
tag <<
"_bbh_plot.png\" width=\"470\"> </a>" << endl;
158 out <<
"</br></ul>" << endl;
159 out <<
"</div><br><br></td><td width=\"50%\"><div align=\"center\">" << endl;
160 out <<
"<font color=\"red\"><h2>Cumulative Number vs IFAR</h2></font>" << endl;
161 out <<
"<font color=\"red\"><h3>(Excluded Known BBH)</h3></font>" << endl;
162 out <<
"<a target=\"_blank\" href=\""<< ifile_loudest_nobbh <<
"\">(Loudest Event List) </a>" << endl;
163 out <<
"</div><div align=\"center\"><ul><br/>" << endl;
164 out <<
"<a class=\"image\" title=\"" <<
tag <<
"\">" << endl;
165 out <<
"<img src=\"" <<
tag <<
"_nobbh_plot.png\" width=\"470\"> </a>" << endl;
166 out <<
"</br></ul>" << endl;
167 out <<
"</div><br><br></td></tr>" << endl;
168 out <<
"</table>" << endl;
171 gSystem->Exec(
"date");
190 char ifile_bbh_loudest[1024];
191 sprintf(ifile_bbh_loudest,
"%s/%s_bbh_loudest.txt",odir.Data(),
tag.Data());
192 char ifile_nobbh_loudest[1024];
193 sprintf(ifile_nobbh_loudest,
"%s/%s_nobbh_loudest.txt",odir.Data(),
tag.Data());
194 cout << ifile_nobbh_loudest << endl;
196 int nLoudest =
ReadLoudestList(ifile_nobbh_loudest, run_loudest, chunk_loudest, gps_loudest, bbh_name_loudest, ifar_sec_loudest, ifar_year_loudest,
197 obs_time_sec_loudest, obs_time_day_loudest, expected_loudest, observed_loudest, cumul_FAP_loudest, sigma_loudest);
198 cout <<
"nLoudest = " << nLoudest << endl;
202 out <<
"<head>" << endl;
203 out <<
"<style type=\"text/css\">" << endl;
204 out <<
".datagrid tr:hover td" << endl;
206 out <<
" background-color:#F1F1F2;" << endl;
208 out <<
"</style>" << endl;
209 out <<
"</head>" << endl;
210 out <<
"<b>" << endl;
211 out <<
"<hr>" << endl;
212 out <<
"<br>" << endl;
213 out <<
"<font color=\"red\" style=\"font-weight:bold;\"><center><p><h2>Foreground Loudest Event List (Excluded known BBH)</h2><p><center></font>" << endl;
214 out <<
"<font color=\"black\" style=\"font-weight:bold;\"><center><p><h3>(Ranked with IFAR)</h3><p><center></font>" << endl;
215 out <<
"<br>" << endl;
216 out <<
"</html>" << endl;
218 out <<
"<table border=0 cellpadding=2 class=\"datagrid\">" << endl;
219 out <<
"<tr align=\"center\">"<< endl;
220 out <<
"<td>ID</td>"<< endl;
221 out <<
"<td>IFAR(yrs)</td>"<< endl;
222 out <<
"<td> GPS </td>"<< endl;
223 out <<
"<td>chunk</td>"<< endl;
224 out <<
"<td>Expected-Events</td>"<< endl;
225 out <<
"<td>Observed-Events</td>"<< endl;
226 out <<
"<td>Cumulative-FAP</td>"<< endl;
227 out <<
"<td>Sigma</td>"<< endl;
228 out <<
"</tr>"<< endl;
231 for(
int i=0; i<nLoudest; i++) {
235 out <<
"<tr align=\"center\">"<< endl;
237 sprintf(os,
"<td>%.i</td>",i+1);
239 sprintf(os,
"<td>%.2f</td>",ifar_year_loudest[i]);
241 sprintf(os,
"<td>%3.3f</td>",gps_loudest[i]);
243 sprintf(os,
"<td>%i</td>",chunk_loudest[i]);
245 sprintf(os,
"<td>%3.3f</td>",expected_loudest[i]);
247 sprintf(os,
"<td>%i</td>",observed_loudest[i]);
249 sprintf(os,
"<td>%.3f</td>",cumul_FAP_loudest[i]);
251 sprintf(os,
"<td>%.2f</td>",sigma_loudest[i]);
254 out <<
"</tr>" << endl;
260 out <<
"</table>" << endl;
261 out <<
"<p>" << endl;
266 vector<TString> chunk_report;
270 sprintf(link,
"%s/%s/dump/%s/",cwb_user_url,wlabel.Data(),rep_dir.Data());
271 int high = 1100+26*nList;
272 sprintf(
options,
"--link %s --label ALL --name body.html --high %d",link,high);
273 chunk_report.push_back(
options);
275 if(fList!=
"" && AddFileEntriesToTabs) {
276 vector<TString> chunk_dir;
279 for(
int i=0;i<chunk_dir.size();i++) {
280 sprintf(link,
"%s/%s/dump/%s/",cwb_user_url,chunk_dir[i].Data(),rep_dir.Data());
282 chunk_report.push_back(
options);
283 cout << i <<
"\t" <<
options << endl;
292 void GetPeriod(TString ifile, TString irun,
double& xstart,
double& xstop,
double& obsTime) {
303 int nPeriod =
ReadPeriodList(ifile,
run, gps_start, date_start, gps_stop, date_stop,
304 interval_day, obs_time_sec, obs_time_day);
306 for(
int i=0;i<nPeriod;i++) {
308 xstart = gps_start[i];
310 obsTime = obs_time_sec[i];
324 sprintf(ofile,
"%s/index.html", odir.Data());
326 cout <<
"make index html file : " << ofile << endl;
327 out.open(ofile,ios::out);
328 if (!out.good()) {cout <<
"mkhtml_index : Error Opening File : " << ofile << endl;
exit(1);}
331 char html_index_template[1024]=
"";
333 if(gSystem->Getenv(
"CWB_HTML_INDEX")==NULL) {
334 cout <<
"Error : environment CWB_HTML_INDEX is not defined!!!" << endl;
exit(1);
336 strcpy(html_index_template,gSystem->Getenv(
"CWB_HTML_INDEX"));
338 TB.checkFile(html_index_template);
341 in.open(html_index_template,ios::in);
343 cout <<
"mkhtml_index : Error Opening File : " << html_index_template << endl;
349 in.getline(istring,1024);
350 if (!in.good())
break;
351 TString ostring(istring);
352 out << ostring.Data() << endl;
355 out <<
"<html>" << endl;
356 out <<
"<br>" << endl;
359 char sbody_height[256];
360 sprintf(sbody_height,
"%d",1800);
361 out <<
"<div class=\"tabber\">" << endl;
362 for(
int i=0;i<chunk_report.size();i++)
if(chunk_report[i]!=
"") {
364 TString chunk_report_link = CWB::Toolbox::getParameter(chunk_report[i],
"--link");
365 if(chunk_report_link==
"" && i!=0) {
366 cout<<
"mkhtml_index : Error : chunk_report --link not defined"<<endl;
exit(1);}
368 TString chunk_report_label = CWB::Toolbox::getParameter(chunk_report[i],
"--label");
369 if((chunk_report_link!=
"</tab>/")&&(chunk_report_label==
"")) {
370 cout<<
"mkhtml_index : Error : chunk_report --label not defined"<<endl;
exit(1);}
372 TString chunk_report_high = CWB::Toolbox::getParameter(chunk_report[i],
"--high");
373 if(chunk_report_high==
"") chunk_report_high=sbody_height;
374 int ichunk_report_high = chunk_report_high.Atoi();
376 TString chunk_report_name = CWB::Toolbox::getParameter(chunk_report[i],
"--name");
378 if(chunk_report_link==
"<tab>/") {
379 out <<
"<div class=\"tabbertab\">" << endl;
380 out <<
" <h2>" << chunk_report_label <<
"</h2>" << endl;
381 out <<
"<div class=\"tabber\">" << endl;
382 }
else if(chunk_report_link==
"</tab>/") {
383 out <<
"</div>" << endl;
384 out <<
"</div>" << endl;
386 out <<
"<div class=\"tabbertab\">" << endl;
387 out <<
" <h2>" << chunk_report_label <<
"</h2>" << endl;
389 if(chunk_report_name==
"") {
390 out <<
" <iframe src=\"" << chunk_report_link <<
"header.html\" width=\"100%\" height=\"900px\" "
391 <<
"marginwidth=\"15\" marginheight=\"15\" frameborder=\"0\"></iframe>" << endl;
393 out <<
" <iframe src=\"" << chunk_report_link <<
"body.html\" width=\"100%\" "
394 <<
" height=\"" << ichunk_report_high <<
"px\" frameborder=\"0\"></iframe>" << endl;
396 out <<
" <iframe src=\"" << chunk_report_link << chunk_report_name <<
"\" width=\"100%\" "
397 <<
" height=\"" << ichunk_report_high <<
"px\" frameborder=\"0\"></iframe>" << endl;
400 out <<
"</div>" << endl;
403 out <<
"</div>" << endl;
405 out <<
"</html>" << endl;
412 sprintf(
cmd,
"cp %s/html/etc/html/ROOT.css %s/",gSystem->ExpandPathName(
"$HOME_WAT"),odir.Data());
414 sprintf(
cmd,
"cp %s/html/etc/html/ROOT.js %s/",gSystem->ExpandPathName(
"$HOME_WAT"),odir.Data());
416 sprintf(
cmd,
"cp %s/html/etc/html/tabber.css %s/",gSystem->ExpandPathName(
"$HOME_WAT"),odir.Data());
418 sprintf(
cmd,
"cp %s/html/etc/html/tabber.js %s/",gSystem->ExpandPathName(
"$HOME_WAT"),odir.Data());
429 in.open(fList.Data(),ios::in);
430 if (!in.good()) {cout <<
"Error Opening File : " << fList.Data() << endl;
exit(1);}
436 in.getline(str,1024);
437 if (!in.good())
break;
438 if(str[0] !=
'#')
size++;
440 in.clear(ios::goodbit);
441 in.seekg(0, ios::beg);
442 if (
size==0) {cout <<
"Error : File " << fList.Data() <<
" is empty" << endl;
exit(1);}
446 int xlag,xslag,ichunk,ibin;
451 in >> sfile >> xlag >> xslag >> ichunk >> ibin >> srun;
452 if(!in.good())
break;
453 if(sfile[0]==
'#')
continue;
457 TString file = path(path.Last(
'/')+1,path.Sizeof());
458 file.ReplaceAll(
"wave_",
"");
459 TString dir = file(0,file.First(
'.'));
462 chunk_dir.push_back(dir);
475 in.open(tabber.Data(),ios::in);
476 if (!in.good()) {cout <<
"Error Opening File : " << tabber.Data() << endl;
exit(1);}
479 TString tabber_tmp = tabber+
".tmp";
480 out.open(tabber_tmp,ios::out);
481 if (!out.good()) {cout <<
"Error Opening File : " << tabber_tmp << endl;
exit(1);}
485 in.getline(str,1024);
486 if (!in.good())
break;
488 ostr.ReplaceAll(
"0.8em",
"0.75em");
489 out << ostr.Data() << endl;
495 sprintf(
cmd,
"mv %s %s",tabber_tmp.Data(),tabber.Data());
int chunk_id[MAX_RUNS][CHUNK_MAX_SIZE]
int ReadLoudestList(TString ifile, TString *run, int *chunk, double *gps, TString *bbh_name, double *ifar_sec, double *ifar_year, double *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)
int ReadChunkDirs(TString fList, vector< TString > &chunk_dir, vector< int > &chunk_id)
void GetPeriod(TString ifile, TString irun, double &xstart, double &xstop, double &obsTime)
#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)
sprintf(tag,"wave_%s", data_label)