Logo coherent WaveBurst  
Library Reference Guide
Logo
cwb_mkhtml_cbc.C
Go to the documentation of this file.
1 /*
2 # Copyright (C) 2019 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 // This macro makes the html page for the cbc report :
20 // used by the cbc_plot_ifar command
21 // Author : Francesco Salemi
22 {
23 #ifdef REDSHIFT
24  bool Redshift = 1;
25 #endif
26 
27  CWB::Toolbox::checkFile(gSystem->Getenv("CWB_ROOTLOGON_FILE"));
28  CWB::Toolbox::checkFile(gSystem->Getenv("CWB_PARAMETERS_FILE"));
29  CWB::Toolbox::checkFile(gSystem->Getenv("CWB_UPARAMETERS_FILE"));
30  CWB::Toolbox::checkFile(gSystem->Getenv("CWB_PPARAMETERS_FILE"));
31  CWB::Toolbox::checkFile(gSystem->Getenv("CWB_UPPARAMETERS_FILE"));
32  CWB::Toolbox::checkFile(gSystem->Getenv("CWB_EPPARAMETERS_FILE"));
33 
34  // create body.html file
35 
36  // if CWB_DOC_URL is define then man infos are added to web pages
38  if (gSystem->Getenv("CWB_DOC_URL") != NULL) {
39  cwb_doc_url = TString(gSystem->Getenv("CWB_DOC_URL"));
40  }
41 
42  ofstream out;
43  char fileout[256];
44 
45  sprintf(netdir, "%s/%s", pp_dir, pp_data_dir);
47  sprintf(netdir, "%s", pp_data_dir);
49  TString HTML_DATA_DIR = "html"; // is it needed?
50  // char file[2048];
51 
52  // convert eps plots to gif plots
53  vector<TString> epsList =
54  CWB::Toolbox::getFileListFromDir(PP_DATA_PATH, ".eps");
55  for (int i = 0; i < epsList.size(); i++) {
56  TString oFile = epsList[i];
57  oFile.ReplaceAll(".eps", ".png");
58  char cmd[2048];
59  sprintf(cmd, "convert %s -resize 996x774 %s", epsList[i].Data(),
60  oFile.Data());
61  cout << cmd << endl;
62  gSystem->Exec(cmd);
63  cout << "Removing eps files...." << endl;
64  sprintf(cmd, "rm %s", epsList[i].Data());
65  cout << cmd << endl;
66  gSystem->Exec(cmd);
67  }
68 
69  // SORTING of ascii files
70 
71 #ifdef WRITE_ASCII
72  char file_notsorted[1024];
73  sprintf(file_notsorted, "%s/recovered_signals.txt", PP_DATA_PATH.Data());
74  char file_sorted[1024];
75  sprintf(file_sorted, "%s/recovered_signals_GPSsorted.txt",
76  PP_DATA_PATH.Data());
77  char exec[1024];
78  sprintf(exec, "sort -g --key=1 %s > %s", file_notsorted, file_sorted);
79  gSystem->Exec(exec);
80  sprintf(file_notsorted, "%s/injected_signals.txt", PP_DATA_PATH.Data());
81  sprintf(file_sorted, "%s/injected_signals_GPSsorted.txt",
82  PP_DATA_PATH.Data());
83  sprintf(exec, "sort -g --key=1 %s > %s", file_notsorted, file_sorted);
84  gSystem->Exec(exec);
85 
86  TString xml;
87 // cout << XML[0] << endl;
88 /* for (int i = 1; i < nfactor + 1; i++) {
89  // if (Redshift) {
90  xml = XML[i - 1];
91  xml.ReplaceAll(".xml", ".found.txt");
92  sprintf(file_notsorted, "%s/%s", PP_DATA_PATH.Data(),
93  xml.Data());
94  xml.ReplaceAll(".found.txt", "_sorted.found.txt");
95  sprintf(file_sorted, "%s/%s", PP_DATA_PATH.Data(),
96  xml.Data());
97 
98  //} else {
99  sprintf(file_notsorted, "%s/recovered_signals_%d.txt",
100  PP_DATA_PATH.Data(), i);
101  sprintf(file_sorted,
102  "%s/recovered_signals_%d_GPSsorted.txt",
103  PP_DATA_PATH.Data(), i);
104  //}
105  sprintf(exec, "sort -g --key=1 %s > %s", file_notsorted,
106  file_sorted);
107  gSystem->Exec(exec);
108  if (Redshift) {
109  xml = XML[i - 1];
110  xml.ReplaceAll(".xml", ".inj.txt");
111  sprintf(file_notsorted, "%s/%s", PP_DATA_PATH.Data(),
112  xml.Data());
113  xml.ReplaceAll(".inj.txt", "_sorted.inj.txt");
114  sprintf(file_sorted, "%s/%s", PP_DATA_PATH.Data(),
115  xml.Data());
116 
117  } else {
118  sprintf(file_notsorted, "%s/injected_signals_%d.txt",
119  PP_DATA_PATH.Data(), i);
120  sprintf(file_sorted,
121  "%s/injected_signals_%d_GPSsorted.txt",
122  PP_DATA_PATH.Data(), i);
123  //}
124  sprintf(exec, "sort -g --key=1 %s > %s", file_notsorted,
125  file_sorted);
126  gSystem->Exec(exec);
127 } */
128 #endif
129 
130  network *net = NULL;
132  strcpy(cfg->tmp_dir, "tmp");
133  CWB::mdc MDC(net);
134  // load MDC setup (define MDC set)
135  // nfactor=4;
137 
138  int gIFACTOR = -1;
139  IMPORT(int, gIFACTOR)
140  CWB_PLUGIN_EXPORT(net)
141  CWB_PLUGIN_EXPORT(cfg)
142  CWB_PLUGIN_EXPORT(gIFACTOR)
143 
144  // --------------------------------------------------------------------
145  // create main html body
146  // --------------------------------------------------------------------
147 
148  sprintf(fileout, "%s/main_body.html", pp_dir);
149  cout << fileout << endl;
150  out.open(fileout, ios::out);
151  if (!out.good()) {
152  cout << "cwb_mkhtml_cbc.C : Error Opening File : " << fileout << endl;
153  exit(1);
154  }
155 
156  out << "<br><br>" << endl;
158  &out, "Effective Radii", "data/Effective_radius.png",
159  "Effective radius: m1 vs m2", "data/Effective_radius_chi.png",
160  "Effective radius: M<sub>total</sub> vs &chi;<sub>eff</sub>");
161  MakePlotsHtmlCellTable(&out, "Sensitive Distance", "data/ROC_IFAR_Mtot.png",
162  "Receiver Operating Curves (ROCs)",
163  "data/Distance_vs_total_mass_ifar.png",
164  "Recovered events vs FAR");
165  MakePlotsHtmlCellTable(&out, "Injected distance distribution",
166  "data/distance_distribution.png", "","", "");
167 
168  out.close();
169 
170  // --------------------------------------------------------------------
171  // create ROC html body
172  // --------------------------------------------------------------------
173 
174  sprintf(fileout, "%s/ROC_body.html", pp_dir);
175  cout << fileout << endl;
176  out.open(fileout, ios::out);
177  if (!out.good()) {
178  cout << "cwb_mkhtml_cbc.C : Error Opening File : " << fileout << endl;
179  exit(1);
180  }
181 
182  out << "<br><br>" << endl;
183  MakePlotsHtmlCellTable(&out, "Sensitive distance for M<sub>total</sub> bins ",
184  "data/ROC_IFAR_Mtot.png", "Inverse False Alarm Rate",
185  "data/ROC_rho1_Mtot.png", "Magnitude Test Statistic");
186  MakePlotsHtmlCellTable(&out, "Sensitive distance for M<sub>chirp</sub> bins ",
187  "data/ROC_IFAR_chirp.png", "Inverse False Alarm Rate",
188  "data/ROC_rho1_chirp.png", "Magnitude Test Statistic");
189  MakePlotsHtmlCellTable(&out, "Sensitive distance for &eta; bins ",
190  "data/ROC_IFAR_eta.png", "Inverse False Alarm Rate",
191  "data/ROC_rho1_eta.png", "Magnitude Test Statistic");
192  MakePlotsHtmlCellTable(&out, "Sensitive distance for Cos(&iota;) bins ",
193  "data/ROC_IFAR_iota.png", "Inverse False Alarm Rate",
194  "data/ROC_rho1_iota.png", "Magnitude Test Statistic");
196  &out, "Sensitive distance for &chi;<sub>eff</sub> bins ",
197  "data/ROC_IFAR_chieff.png", "Inverse False Alarm Rate",
198  "data/ROC_rho1_chieff.png", "Magnitude Test Statistic");
199  MakePlotsHtmlCellTable(&out, "Sensitive distance for &chi;<sub>p</sub> bins ",
200  "data/ROC_IFAR_chip.png", "Inverse False Alarm Rate",
201  "data/ROC_rho1_chip.png", "Magnitude Test Statistic");
202  // MakePlotsHtmlTable(&out,"Injected distance
203  // distribution","data/Injected_distances_distribution.png","580");
204 
205  out.close();
206 
207  // --------------------------------------------------------------------
208  // create parspace html body
209  // --------------------------------------------------------------------
210 
211  sprintf(fileout, "%s/parspace_body.html", pp_dir);
212  cout << fileout << endl;
213  out.open(fileout, ios::out);
214  if (!out.good()) {
215  cout << "cwb_mkhtml_cbc.C : Error Opening File : " << fileout << endl;
216  exit(1);
217  }
218 
219  out << "<br><br>" << endl;
221  &out, "Injected distributions for various signal parameters",
222  "data/mtot_distribution.png", "Total mass distribution",
223  "data/mchirp_distribution.png", "Chirp mass distribution");
224  MakePlotsHtmlCellTable(&out, "", "data/iota_distribution.png",
225  "Inclination distribution", "data/eta_distribution.png",
226  "Symmetric Mass ratio distribution");
227 
228  MakePlotsHtmlCellTable(&out, "", "data/chieff_distribution.png",
229  "&chi;<sub>eff</sub> distribution",
230  "data/chip_distribution.png",
231  "&chi;<sub>p</sub> distribution");
232  // MakePlotsHtmlCellTable(&out,"SNR
233  // plots","data/Injected_snr_distributions.png","","data/Estimated_snr_vs_Injected_snr.png","");
234  // MakePlotsHtmlTable(&out,"Relative snr
235  // loss","data/Relative_snr_Loss.png","580");
236 
237  out.close();
238 
239  // --------------------------------------------------------------------
240  // create distance html body
241  // --------------------------------------------------------------------
242 
243  sprintf(fileout, "%s/distance_body.html", pp_dir);
244  cout << fileout << endl;
245  out.open(fileout, ios::out);
246  if (!out.good()) {
247  cout << "cwb_mkhtml_cbc.C : Error Opening File : " << fileout << endl;
248  exit(1);
249  }
250 
251  out << "<br><br>" << endl;
252  MakePlotsHtmlCellTable(&out, "Distance plots", "data/Distance_vs_mtot.png",
253  "Distance vs Total mass",
254  "data/Distance_vs_mchirp.png",
255  "Distance vs Chirp mass");
256  MakePlotsHtmlCellTable(&out, "", "data/Distance_vs_eta.png",
257  "Distance vs Mass Ratio",
258  "data/Distance_vs_iota.png",
259  "Distance vs Cos(&iota;) Inclination");
260  MakePlotsHtmlCellTable(&out, "", "data/Distance_vs_chieff.png",
261  "Distance vs &chi;<sub>eff</sub>",
262  "data/Distance_vs_chip.png",
263  "Distance vs &chi;<sub>p</sub>");
264 
265  MakePlotsHtmlTable(&out, "Range vs rho", "data/Range.png", "580");
266 
267  out.close();
268  // --------------------------------------------------------------------
269  // create SNR html body
270  // --------------------------------------------------------------------
271 
272  sprintf(fileout, "%s/snr_body.html", pp_dir);
273  cout << fileout << endl;
274  out.open(fileout, ios::out);
275  if (!out.good()) {
276  cout << "cwb_mkhtml_cbc.C : Error Opening File : " << fileout << endl;
277  exit(1);
278  }
279 
280  out << "<br><br>" << endl;
281  MakePlotsHtmlCellTable(&out, "SNR plots",
282  "data/Injected_snr_distributions.png", "",
283  "data/Estimated_snr_vs_Injected_snr.png", "");
284  MakePlotsHtmlTable(&out, "Relative snr loss", "data/Relative_snr_Loss.png",
285  "580");
286 
287  out.close();
288 
289  exit(0);
290 }
void MakePlotsHtmlTable(ofstream *out, TString title, TString png1, TString png2="")
Definition: Toolfun.hh:875
static vector< TString > getFileListFromDir(TString dir_name, TString endString="", TString beginString="", TString containString="", bool fast=false)
Definition: Toolbox.cc:5108
TString PP_DATA_PATH
strcpy(cfg->tmp_dir, "tmp")
TString cwb_doc_url
TString("c")
i drho i
static bool checkFile(TString fName, bool question=false, TString message="")
Definition: Toolbox.cc:4670
CWB::config * cfg
CWB::mdc MDC(net)
#define CWB_PLUGIN_EXPORT(VAR)
Definition: CWB_Plugin.h:18
Definition: mdc.hh:248
#define IMPORT(TYPE, VAR)
Definition: cwb.hh:69
i() int(T_cor *100))
char netdir[1024]
char tmp_dir[1024]
Definition: config.hh:325
ofstream out
void MakePlotsHtmlCellTable(ofstream *out, TString title, TString png1, TString subtitle1="", TString png2="", TString subtitle2="")
Definition: Toolfun.hh:916
if(gSystem->Getenv("CWB_DOC_URL") !=NULL)
network * net
char fileout[256]
s s
Definition: cwb_net.C:155
TString HTML_DATA_DIR
char pp_dir[512]
Definition: test_config1.C:155
int gIFACTOR
char pp_data_dir[1024]
TString PP_DATA_DIR
char cmd[1024]
in open(HEN_LIST, ios::in)
vector< TString > epsList
sprintf(netdir, "%s/%s", pp_dir, pp_data_dir)
TString config
bool Redshift
exit(0)