Logo coherent WaveBurst  
Library Reference Guide
Logo
cwb_mkhtml_index.C
Go to the documentation of this file.
1 /*
2 # Copyright (C) 2019 Gabriele Vedovato, Francesco Salemi
3 #
4 # This program is free software: you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation, either version 3 of the License, or
7 # (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <https://www.gnu.org/licenses/>.
16 */
17 
18 
19 {
20 
21  CWB::Toolbox::checkFile(gSystem->Getenv("CWB_ROOTLOGON_FILE"));
22  CWB::Toolbox::checkFile(gSystem->Getenv("CWB_PARAMETERS_FILE"));
23  CWB::Toolbox::checkFile(gSystem->Getenv("CWB_UPARAMETERS_FILE"));
24  CWB::Toolbox::checkFile(gSystem->Getenv("CWB_PPARAMETERS_FILE"));
25  CWB::Toolbox::checkFile(gSystem->Getenv("CWB_UPPARAMETERS_FILE"));
26  CWB::Toolbox::checkFile(gSystem->Getenv("CWB_EPPARAMETERS_FILE"));
27 
28  // get user defined html index file name (used by cwb_mkrep command)
31  if(gSystem->Getenv("CWB_MKREP_INDEX_FILE")!=NULL) {
32  cwb_mkrep_index_file=TString(gSystem->Getenv("CWB_MKREP_INDEX_FILE"));
33  if(!cwb_mkrep_index_file.EndsWith(".html")) {
34  cout<<"cwb_mkhtml_index.C : Error : the index html must have the .html extension"<<endl;
35  exit(1);
36  }
37  // get and create dir name contained in cwb_mkrep_index_file path
38  cwb_mkrep_index_dir = cwb_mkrep_index_file;
39  cwb_mkrep_index_dir = cwb_mkrep_index_dir.ReplaceAll(gSystem->BaseName(cwb_mkrep_index_dir),"");
40  char cmd[1024];
41  sprintf(cmd,"mkdir -p %s",cwb_mkrep_index_dir.Data());
42  cout << cmd << endl;
43  gSystem->Exec(cmd);
44  } else {
45  cwb_mkrep_index_file="";
46  }
47 
48  // If fad is enable & simulation==4 then execute cwb_mkfad.C macro
49  if(pp_fad!="" && simulation==4) {
50  gROOT->LoadMacro("$HOME_WAT/tools/cwb/macros/cwb_mkfad.C");
51  // get loud parameter from pp_fad
53  if(pp_fad_nzbins=="") pp_fad_nzbins="0";
54  int ipp_fad_nzbins = pp_fad_nzbins.Atoi();
55  // execute cwb_mkfad.C macro
56  cwb_mkfad("fad",ipp_fad_nzbins,0,false);
57  // add FAD report to the main report
58  for(int i=0;i<pp_sreport.size();i++) {
59  if(pp_sreport[i]=="") {pp_sreport[i]="--link fad --label FAD --name fad.html --high 4800";break;}
60  }
61  }
62 
63  // check if there are auxiliary reports to be added to the main report
65  for(int i=0;i<pp_sreport.size();i++) if(pp_sreport[i]!="") pp_sreport_size++;
66  if((pp_sreport_size>0)&&(simulation>=0)) {
67  vector<TString> pp_sreport_tmp = pp_sreport;
68  for(int i=0;i<pp_sreport.size();i++) pp_sreport[i]="";
69  pp_sreport[0]=TString("--label ")+data_label;
70  pp_sreport_size=1;
71  for(int i=0;i<pp_sreport_tmp.size();i++) if(pp_sreport_tmp[i]!="") {
72  pp_sreport[pp_sreport_size]=pp_sreport_tmp[i];
73  pp_sreport_size++;
74  }
75  }
76 
77  // open output index file
78  ofstream out;
79  char ofile[256];
80  if(cwb_mkrep_index_file!="") {
81  sprintf(ofile,"%s", cwb_mkrep_index_file.Data());
82  } else {
83  sprintf(ofile,"%s/index.html", pp_dir);
84  }
85  cout << "make index html file : " << ofile << endl;
86  out.open(ofile,ios::out);
87  if (!out.good()) {cout << "cwb_mkhtml_index.C : Error Opening File : " << ofile << endl;exit(1);}
88 
89  // open input index template file
90  ifstream in;
92  if (!in.good()) {
93  cout << "cwb_mkhtml_index.C : Error Opening File : " << html_index_template << endl;
94  exit(1);
95  }
96 
97  char sbody_height[256];
98  if(simulation==0) {
99  sprintf(sbody_height,"%d",2350+26*pp_max_nloudest_list);
100  } else {
101  if(TString(gSystem->Getenv("CWB_REPORT_PE"))!="") {
102  sprintf(sbody_height,"%d",5000);
103  } else {
104  sprintf(sbody_height,"%d",5800);
105  }
106  }
107 
108  char istring[1024];
109  while (1) {
110  in.getline(istring,1024);
111  if (!in.good()) break;
112  TString ostring(istring);
113  out << ostring.Data() << endl;
114  }
115 
116  out << "<html>" << endl;
117  out << "<br>" << endl;
118 
119  if(pp_sreport_size==0) {
120 
121  out << " <iframe src=\"header.html\" width=\"100%\" height=\"970px\" "
122  << "marginwidth=\"15\" marginheight=\"15\" frameborder=\"0\"></iframe>" << endl;
123 
124  if(TString(gSystem->Getenv("CWB_REPORT_PE"))!="") {
125 
126  out << "<div class=\"tabber\">" << endl;
127 
128  out << "<div class=\"tabbertab\">" << endl;
129  out << " <h2>Sky Localization</h2>" << endl;
130  out << " <iframe src=\"prc_body.html\" width=\"100%\" "
131  << " height=\"" << sbody_height << "px\" frameborder=\"0\"></iframe>" << endl;
132  out << "</div>" << endl;
133 
134  out << "<div class=\"tabbertab\">" << endl;
135  out << " <h2>Waveform</h2>" << endl;
136  out << " <iframe src=\"wrc_body.html\" width=\"100%\" "
137  << " height=\"" << sbody_height << "px\" frameborder=\"0\"></iframe>" << endl;
138  out << "</div>" << endl;
139 
140  out << "<div class=\"tabbertab\">" << endl;
141  out << " <h2>Chirp Mass</h2>" << endl;
142  out << " <iframe src=\"mchirp_body.html\" width=\"100%\" "
143  << " height=\"" << sbody_height << "px\" frameborder=\"0\"></iframe>" << endl;
144  out << "</div>" << endl;
145 
146  out << "</div>" << endl;
147  } else if(TString(gSystem->Getenv("CWB_REPORT_CBC"))!="") {
148 
149  // if CWB_DOC_URL is define then man infos are added to web pages
150  TString cwb_doc_url="";
151  if(gSystem->Getenv("CWB_DOC_URL")!=NULL) {
152  cwb_doc_url=TString(gSystem->Getenv("CWB_DOC_URL"));
153  }
154 
155  char plot_list[1024];
156  sprintf(plot_list,"<a target=\"_parent\" name=\"Full Plot List\" href=\"%s\">Full Plot List</a>",pp_data_dir);
157  if(cwb_doc_url!="") out<<"<table align=\"center\" width=97%> <tr> <td align=\"left\">"<<endl;
158  out << plot_list << endl;
159  if(cwb_doc_url!="") {
160  out<<"</td>"<<endl;
161  out<<"<td align=\"right\">"<<endl;
162  out<<"<a target=\"_parent\" href=\""<<cwb_doc_url.Data()
163  <<"/cwb/man/Simulation-part.html#Simulation-part\">infos</a>"<<endl;
164  out<<"</td> </tr> </table>"<<endl;
165  }
166 
167  out << "<div class=\"tabber\">" << endl;
168 
169  out << "<div class=\"tabbertab\">" << endl;
170  out << " <h2>Main plots</h2>" << endl;
171  out << " <iframe src=\"main_body.html\" width=\"100%\" "
172  << " height=\"" << 1900 << "px\" frameborder=\"0\"></iframe>" << endl;
173  out << "</div>" << endl;
174 
175  out << "<div class=\"tabbertab\">" << endl;
176  out << " <h2>ROC curves</h2>" << endl;
177  out << " <iframe src=\"ROC_body.html\" width=\"100%\" "
178  << " height=\"" << 3500 << "px\" frameborder=\"0\"></iframe>" << endl;
179  out << "</div>" << endl;
180 
181  out << "<div class=\"tabbertab\">" << endl;
182  out << " <h2>Sampled parameter space</h2>" << endl;
183  out << " <iframe src=\"parspace_body.html\" width=\"100%\" "
184  << " height=\"" << 1800 << "px\" frameborder=\"0\"></iframe>" << endl;
185  out << "</div>" << endl;
186 
187  out << "<div class=\"tabbertab\">" << endl;
188  out << " <h2>Distance plots</h2>" << endl;
189  out << " <iframe src=\"distance_body.html\" width=\"100%\" "
190  << " height=\"" << 2180 << "px\" frameborder=\"0\"></iframe>" << endl;
191  out << "</div>" << endl;
192 
193  out << "<div class=\"tabbertab\">" << endl;
194  out << " <h2>SNR plots</h2>" << endl;
195  out << " <iframe src=\"snr_body.html\" width=\"100%\" "
196  << " height=\"" << 1300 << "px\" frameborder=\"0\"></iframe>" << endl;
197  out << "</div>" << endl;
198 
199  out << "</div>" << endl;
200 
201 
202  } else {
203  out << " <iframe src=\"body.html\" width=\"100%\" "
204  << " height=\"" << sbody_height << "px\" frameborder=\"0\"></iframe>" << endl;
205  }
206  } else {
207 
208  sprintf(sbody_height,"%d",5800);
209  out << "<div class=\"tabber\">" << endl;
210  for(int i=0;i<pp_sreport.size();i++) if(pp_sreport[i]!="") {
211 
212  TString pp_sreport_link = CWB::Toolbox::getParameter(pp_sreport[i],"--link");
213  if(pp_sreport_link=="" && i!=0) {
214  cout<<"cwb_mkhtml_index.C : Error : pp_sreport --link not defined"<<endl;exit(1);}
215  if((i!=0)||(simulation<0)) {
216  if(!pp_sreport_link.EndsWith("/")) pp_sreport_link=pp_sreport_link+"/";
217  }
218 
219  TString pp_sreport_label = CWB::Toolbox::getParameter(pp_sreport[i],"--label");
220  if((pp_sreport_link!="</tab>/")&&(pp_sreport_label=="")) {
221  cout<<"cwb_mkhtml_index.C : Error : pp_sreport --label not defined"<<endl;exit(1);}
222 
223  TString pp_sreport_high = CWB::Toolbox::getParameter(pp_sreport[i],"--high");
224  if(pp_sreport_high=="") pp_sreport_high=sbody_height;
225  int ipp_sreport_high = pp_sreport_high.Atoi();
226 
227  TString pp_sreport_name = CWB::Toolbox::getParameter(pp_sreport[i],"--name");
228 
229  if(pp_sreport_link=="<tab>/") { // open a sub tab
230  out << "<div class=\"tabbertab\">" << endl;
231  out << " <h2>" << pp_sreport_label << "</h2>" << endl;
232  out << "<div class=\"tabber\">" << endl;
233  } else if(pp_sreport_link=="</tab>/") { // close sub tab
234  out << "</div>" << endl;
235  out << "</div>" << endl;
236  } else { // add a tab
237  out << "<div class=\"tabbertab\">" << endl;
238  out << " <h2>" << pp_sreport_label << "</h2>" << endl;
239 
240  if(pp_sreport_name=="") {
241  out << " <iframe src=\"" << pp_sreport_link << "header.html\" width=\"100%\" height=\"900px\" "
242  << "marginwidth=\"15\" marginheight=\"15\" frameborder=\"0\"></iframe>" << endl;
243 
244  out << " <iframe src=\"" << pp_sreport_link << "body.html\" width=\"100%\" "
245  << " height=\"" << ipp_sreport_high << "px\" frameborder=\"0\"></iframe>" << endl;
246  } else {
247  out << " <iframe src=\"" << pp_sreport_link << pp_sreport_name << "\" width=\"100%\" "
248  << " height=\"" << ipp_sreport_high << "px\" frameborder=\"0\"></iframe>" << endl;
249  }
250 
251  out << "</div>" << endl;
252  }
253  }
254  out << "</div>" << endl;
255  }
256 
257  out << "</html>" << endl;
258 
259  in.close();
260  out.close();
261 
262  // copy javascripts & Cascading Style Sheets to report the directory
263  TString odir = (cwb_mkrep_index_file!="") ? cwb_mkrep_index_dir : pp_dir;
264  char cmd[1024];
265  sprintf(cmd,"cp %s/html/etc/html/ROOT.css %s/",gSystem->ExpandPathName("$HOME_WAT"),odir.Data());
266  gSystem->Exec(cmd);
267  sprintf(cmd,"cp %s/html/etc/html/ROOT.js %s/",gSystem->ExpandPathName("$HOME_WAT"),odir.Data());
268  gSystem->Exec(cmd);
269  sprintf(cmd,"cp %s/html/etc/html/tabber.css %s/",gSystem->ExpandPathName("$HOME_WAT"),odir.Data());
270  gSystem->Exec(cmd);
271  sprintf(cmd,"cp %s/html/etc/html/tabber.js %s/",gSystem->ExpandPathName("$HOME_WAT"),odir.Data());
272  gSystem->Exec(cmd);
273 
274  exit(0);
275 }
TString cwb_doc_url
TString("c")
char odir[1024]
cout<< "baudline_FFL : "<< baudline_FFL<< endl;ofstream out;out.open(baudline_FFL, ios::out);if(!out.good()) {cout<< "Error Opening File : "<< baudline_FFL<< endl;exit(1);} ifstream in;in.open(frFiles[ifoID], ios::in);if(!in.good()) {cout<< "Error Opening File : "<< frFiles[ifoID]<< endl;exit(1);} TString pfile_path="";char istring[1024];while(1) { in > istring
ofstream out
i drho i
static bool checkFile(TString fName, bool question=false, TString message="")
Definition: Toolbox.cc:4670
char data_label[512]
Definition: test_config1.C:160
char html_index_template[1024]
vector< TString > pp_sreport
int pp_sreport_size
static TString getParameter(TString options, TString param="")
Definition: Toolbox.cc:6727
ifstream in
TString cwb_mkrep_index_file
TString cwb_mkrep_index_dir
char pp_dir[512]
Definition: test_config1.C:155
char pp_data_dir[1024]
char ofile[256]
char cmd[1024]
sprintf(tfres,"(1/%g)x(%g) (sec)x(Hz)", 2 *df, df)
int pp_max_nloudest_list
TString pp_fad_nzbins
Definition: cwb_mkfad.C:106
void cwb_mkfad(TString odir="fad", int nzbins=-1, double obstime=0, bool bexit=true)
Definition: cwb_mkfad.C:126
simulation
Definition: cwb_eced.C:26
exit(0)