Logo Coherent WaveBurst  
Reference Guide
Logo
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
cwb_mkhtml_prod.C
Go to the documentation of this file.
1 // make the html production report : used by the cwb_report command
2 {
3 
4  #define NEPS 28
5  #define NEPS2 19
6 
7  #include "wat.hh"
8 
9  CWB::Toolbox::checkFile(gSystem->Getenv("CWB_ROOTLOGON_FILE"));
10  CWB::Toolbox::checkFile(gSystem->Getenv("CWB_PARAMETERS_FILE"));
11  CWB::Toolbox::checkFile(gSystem->Getenv("CWB_UPARAMETERS_FILE"));
12  CWB::Toolbox::checkFile(gSystem->Getenv("CWB_PPARAMETERS_FILE"));
13  CWB::Toolbox::checkFile(gSystem->Getenv("CWB_UPPARAMETERS_FILE"));
14  CWB::Toolbox::checkFile(gSystem->Getenv("CWB_EPPARAMETERS_FILE"));
15 
16  bool singleDetector=false;
17  if(nIFO==1) { // Single Detector Mode
19  config.Import();
20  config.SetSingleDetectorMode();
21  config.Export();
22  singleDetector=true;
23  }
24  if(nIFO==2) { // 2 detectors with the same name "same detector -> nIFO=1"
25  if(TString(ifo[0])==TString(ifo[1])) nIFO=1;
26  }
27 
28  // if CWB_DOC_URL is define then man infos are added to web pages
30  if(gSystem->Getenv("CWB_DOC_URL")!=NULL) {
31  cwb_doc_url=TString(gSystem->Getenv("CWB_DOC_URL"));
32  }
33 
34  // check vetoes
35  bool bcat2 = false;
36  bool bhveto = false;
37  bool bcat3 = false;
38 
39  for(int i=0;i<nVDQF;i++) if(VDQF[i].cat==CWB_CAT2) bcat2=true;
40  for(int i=0;i<nVDQF;i++) if(VDQF[i].cat==CWB_HVETO) bhveto=true;
41  for(int i=0;i<nVDQF;i++) if(VDQF[i].cat==CWB_CAT3) bcat3=true;
42 
43  TString NetCC,Rho,RhOut,RhAcor,svED,sPEN,sHRSS,sfLow,sfHigh,sfResample,spp_rho_min,spp_rho_max;
44 
45  char s[16];
46  sprintf(s,"%.2f",T_cor); NetCC=s;
47  sprintf(s,"%.2f",T_cut); Rho=s;
48  sprintf(s,"%.2f",T_out); RhOut=s;
49  sprintf(s,"%.2f",T_acor); RhAcor=s;
50  sprintf(s,"%.2f",T_vED); svED=s;
51  sprintf(s,"%.2f",T_pen); sPEN=s;
52  sprintf(s,"%.2f",fLow); sfLow=s;
53  sprintf(s,"%.2f",fHigh); sfHigh=s;
54  sprintf(s,"%.2f",pp_rho_min); spp_rho_min=s;
55  sprintf(s,"%.2f",pp_rho_max); spp_rho_max=s;
56 
57  TString psfix(data_label);
58  TFile* psp = TFile::Open(net_file_name);
59  cout<<"Opening "<<net_file_name<<endl;
60  TTree* wave_tree = (TTree*)psp->Get("waveburst");
61 
62  // create body.html file
63 
64  ofstream out;
65  char fileout[1024];
66  sprintf(fileout,"%s/body.html", pp_dir);
67  cout << fileout << endl;
68  out.open(fileout,ios::out);
69  if (!out.good()) {cout << "Error Opening File : " << fileout << endl;exit(1);}
70 
73  PP_DATA_PATH=netdir;
75  PP_DATA_DIR=netdir;
76 
78 
79  // convert eps plots to gif plots
80  vector<TString> epsList = CWB::Toolbox::getFileListFromDir(PP_DATA_PATH, ".eps");
81  for(int i=0;i<epsList.size();i++) {
82  TString ofile=epsList[i];
83  ofile.ReplaceAll(".eps",".gif");
84  char cmd[2048];
85  sprintf(cmd,"convert %s %s",epsList[i].Data(),ofile.Data());
86  cout << cmd << endl;
87  gSystem->Exec(cmd);
88  sprintf(cmd,"rm %s",epsList[i].Data());
89  cout << cmd << endl;
90  gSystem->Exec(cmd);
91  }
92 
93  // get livetime
94  char fileliv[1024];
95  sprintf(fileliv,"%s/live.txt",PP_DATA_PATH.Data());
96  cout << fileliv << endl;
97  int countlag=0;
98  double OLIVETIME = GetLiveTime(fileliv,0,0,countlag); // get zero livetime
99  double LIVETIME = GetLiveTime(fileliv,-1,-1,countlag); // get total livetime
100  LIVETIME-=OLIVETIME; // non zero live time
101  countlag-=1; // subtract the zero lag
102  cout.precision(14);
103  cout << OLIVETIME << " " << LIVETIME << endl;
104 
105  ifstream bkgin;
106  bkgin.open(html_body_prod_template,ios::in);
107  if (!bkgin.good()) {cout << "Error Opening File : " << html_body_prod_template << endl;exit(1);}
108 
109  char exec[1024];
110  char istring[1024];
111 
112  while (1) {
113  bkgin.getline(istring,256);
114  if (!bkgin.good()) break;
115  TString ostringa(istring);
116  if(bcat3||bhveto) {
117  ostringa.ReplaceAll("<!--VETO","");
118  ostringa.ReplaceAll("VETO-->","");
119  } else {
120  ostringa.ReplaceAll("<!--NOVETO","");
121  ostringa.ReplaceAll("VETONO-->","");
122  }
123  if(TString(analysis)=="1G") {
124  ostringa.ReplaceAll("<!--RHO_PF","");
125  ostringa.ReplaceAll("RHO_PF-->","");
126  } else {
127  ostringa.ReplaceAll("<!--RHO_SUBNET","");
128  ostringa.ReplaceAll("RHO_SUBNET-->","");
129  }
130  if(pp_rho_vs_rate_no_multiplicity) {
131  ostringa.ReplaceAll("<!--MULTI","");
132  ostringa.ReplaceAll("MULTI-->","");
133  }
134  ostringa.ReplaceAll("FLOW",sfLow);
135  ostringa.ReplaceAll("FHIGH",sfHigh);
136  ostringa.ReplaceAll("PP_RHO_MIN",spp_rho_min);
137  ostringa.ReplaceAll("PP_RHO_MAX",spp_rho_max);
138  ostringa.ReplaceAll("PP_DATA_DIR",PP_DATA_DIR);
139  ostringa.ReplaceAll("NETCC",NetCC);
140  ostringa.ReplaceAll("RHO",Rho);
141  ostringa.ReplaceAll("RH_OUT",RhOut);
142  ostringa.ReplaceAll("RH_ACOR",RhAcor);
143  ostringa.ReplaceAll("svED",svED);
144  TString Rate= "rate = " + RATEBACKGROUND;
145  ostringa.ReplaceAll("RATEBACKGROUND",Rate);
146  ostringa.ReplaceAll("SUBTITLE",subtitle);
147  ostringa.ReplaceAll("TITLE",title);
148  char ltime[1024];
149  sprintf(ltime, "zero lag : <font color=\"red\"> %.2f sec = %.2f days</font>",
150  OLIVETIME,OLIVETIME/86400.);
151  ostringa.ReplaceAll("LIVETIME",ltime);
152  sprintf(ltime, "non-zero lags : <font color=\"red\"> %i lags - %.2f sec = %.2f days = %.1f years </fonts>",
153  countlag,LIVETIME,LIVETIME/(float)86400.,LIVETIME/86400./365.);
154  ostringa.ReplaceAll("LIVETIM2",ltime);
155  ostringa.ReplaceAll("PLOT_LIST",pp_data_dir);
156  if(cwb_doc_url!="") {
157  ostringa.ReplaceAll("<!--CWB_DOC_URL","");
158  ostringa.ReplaceAll("CWB_DOC_URL-->","");
159  ostringa.ReplaceAll("XCWB_DOC_URL",cwb_doc_url.Data());
160  }
161 
162  ostringa.ReplaceAll("</html>","");
163  out << ostringa.Data() << endl;
164  }
165  bkgin.close();
166 
167  char _ifo[NIFO_MAX][8];
168  for(int n=0;n<nIFO;n++) {
169  if(strlen(ifo[n])>0) strcpy(_ifo[n],ifo[n]); // built in detector
170  else strcpy(_ifo[n],detParms[n].name); // user define detector
171  }
172 
173  char file_ev[1024];
174  sprintf(file_ev,"%s/events.txt",PP_DATA_PATH.Data());
175  ifstream for_ev(file_ev);
176  char file_header[1024];
177  sprintf(file_header,"%s/events_header.txt",PP_DATA_PATH.Data());
178  ofstream for_header(file_header);
179  char file_notsorted[1024];
180  sprintf(file_notsorted,"%s/events_notsorted.txt",PP_DATA_PATH.Data());
181  ofstream for_notsorted(file_notsorted);
182  char in_ev[100000];
183  while(1) {
184  for_ev.getline(in_ev,100000);
185  if (!for_ev.good()) break;
186  TString sin_ev(in_ev);
187  if (sin_ev.Contains("#")) for_header << sin_ev.Data() << endl;
188  else for_notsorted << sin_ev.Data() << endl;
189  }
190  for_header.close();
191  for_notsorted.close();
192  char file_sorted[1024];
193  sprintf(file_sorted,"%s/events_sorted.txt",PP_DATA_PATH.Data());
194  sprintf(exec,"sort -g -r --key=3 %s > %s",file_notsorted, file_sorted);
195  gSystem->Exec(exec);
196  sprintf(exec,"cat %s %s > %s/EVENTS.txt",file_header, file_sorted, PP_DATA_PATH.Data());
197  gSystem->Exec(exec);
198 
199  sprintf(file_notsorted,"%s/events_notsorted.txt",PP_DATA_PATH.Data());
200  ifstream f_ev(file_sorted);
201  char pm[2];
202  char c3[2];
203  float icc, irho, iacor, ilag, islag, ilik, ipen, icHH, ivHH, ivED, icc2, icc3; //SLAG
204  int ifreq, iband;
205  float idur;
206  int isize, irate, irun;
208  double time0, time1, time2, time3;
209  float phi, theta, psi;
210  int ecount=0;
211 
212  char os[1024];
213 
214  out << "<table border=0 cellpadding=2 class=\"datagrid\">" << endl;
215  out << "<tr align=\"center\">"<< endl;
216  out << "<td>ID</td>"<< endl;
217  if(bhveto) out << "<td>KW</td>"<< endl;
218  if(bcat3) out << "<td>cat3 </td>"<< endl;
219  out << "<td>rho["<<pp_irho<<"]</td>"<< endl;
220  out << "<td>cc["<<pp_inetcc<<"]</td>"<< endl;
221  if(TString(analysis)=="2G") out << "<td>subnet</td>"<< endl;
222 // out << "<td>ecor</td>"<< endl;
223  out << "<td>lag</td>"<< endl;
224  out << "<td>slag</td>"<< endl;
225  out << "<td>SNRnet</td>"<< endl;
226  if(TString(analysis)=="1G") out << "<td>pf</td>"<< endl;
227  if(TString(analysis)=="1G") out << "<td>vED</td>"<< endl;
228  out << "<td>freq</td>"<< endl;
229  out << "<td>bw</td>"<< endl;
230  out << "<td>dur</td>"<< endl;
231  out << "<td>size</td>"<< endl;
232  if(optim==true) out << "<td>res</td>"<< endl;
233  out << "<td>run</td>"<< endl;
234  for (int nn=0;nn<nIFO;nn++) out << "<td>GPS " << _ifo[nn] << "</td>"<< endl;
235  for (int nn=0;nn<nIFO;nn++) out << "<td>SNR " << _ifo[nn] << "</td>"<< endl;
236 /*
237  for (int nn=0;nn<nIFO;nn++) out << "<td>hrss " << _ifo[nn] << "</td>"<< endl;
238  out << "<td>phi</td>"<< endl;
239  out << "<td>theta</td>"<< endl;
240  out << "<td>psi</td>"<< endl;
241 */
242  out << "</tr>"<< endl;
243 
244  double start[5];
245  while(ecount<pp_max_nloudest_list) {
246  if (nIFO>3) {
247  f_ev>>pm>>c3>>irho>>icc>>icc2>>icc3>>iacor>>ilag>>islag>>ilik>>ipen>>icHH>>ifreq>>iband>>idur>>isize>>irate>>irun>>time0>>time1>>time2>>time3>>SNR0>>SNR1>>SNR2>>SNR3>>hrss0>>hrss1>>hrss2>>hrss3>>phi>>theta>>psi;
248  } else if (nIFO>2) {
249  f_ev>>pm>>c3>>irho>>icc>>icc2>>icc3>>iacor>>ilag>>islag>>ilik>>ipen>>icHH>>ifreq>>iband>>idur>>isize>>irate>>irun>>time0>>time1>>time2>>SNR0>>SNR1>>SNR2>>hrss0>>hrss1>>hrss2>>phi>>theta>>psi;
250  } else {
251  f_ev>>pm>>c3>>irho>>icc>>icc2>>icc3>>iacor>>ilag>>islag>>ilik>>ipen>>icHH>>ifreq>>iband>>idur>>isize>>irate>>irun>>time0>>time1>>SNR0>>SNR1>>hrss0>>hrss1>>phi>>theta>>psi;
252  }
253  if (!f_ev.good()) break;
254  TString ppm(pm);
255  TString cc3(c3);
256  if (ppm.Contains("+")) {
257  ecount++;
258  cout << ecount << " ";cout.flush();
259  out << "<tr align=\"center\">"<< endl;
260  sprintf(os,"run==%i",irun);
261  TString s_ced=GetFileLabel(wave_tree,irun,ilag,islag,segEdge,psfix);
262  char namedir[1024];
263  sprintf(namedir,"");
264  if(singleDetector&&strlen(channelNamesRaw[0])>1) {
265  start[0]=GetStart(wave_tree, 0, irun, irho, time0, time1, analysis, pp_irho);
266  sprintf(namedir, "%s_%s_%.3f", _ifo[0],channelNamesRaw[0],start[0]);
267  } else {
268  for (int nn=0; nn<nIFO; nn++) sprintf(namedir,"%s%s",namedir,_ifo[nn]);
269  for (int nn=0; nn<nIFO; nn++) {
270  start[nn]=GetStart(wave_tree, nn, irun, irho, time0, time1, analysis, pp_irho);
271  sprintf(namedir,"%s_%.3f",namedir,start[nn]);
272  }
273  }
274  sprintf(os,"<td><a href=\"ced/ced_%s/%s\" target=\"_blank\">%i</a></td>",s_ced.Data(),namedir,ecount);
275  out << os << endl;
276  if(bhveto) {
277  sprintf(os,"<td>%s</td>",ppm.Remove(0,1).Data());
278  out << os << endl;
279  }
280  if(bcat3) {
281  sprintf(os,"<td>%s</td>",cc3.Remove(0,1).Data());
282  out << os << endl;
283  }
284  sprintf(os,"<td>%.2f</td>",irho);
285  out << os << endl;
286  sprintf(os,"<td>%.2f</td>",icc);
287  out << os << endl;
288  if(TString(analysis)=="2G") {
289  sprintf(os,"<td>%.2f</td>",icc2);
290  out << os << endl;
291  }
292 /*
293  sprintf(os,"<td>%.2f</td>",iacor);
294  out << os << endl;
295 */
296  sprintf(os,"<td>%i</td>",(int)ilag);
297  out << os << endl;
298  sprintf(os,"<td>%i</td>",(int)islag);
299  out << os << endl;
300  sprintf(os,"<td>%3.1f</td>",sqrt(ilik));
301  out << os << endl;
302  sprintf(os,"<td>%.3f</td>",ipen);
303  if(TString(analysis)=="1G") out << os << endl;
304  sprintf(os,"<td>%.3f</td>",icHH);
305  if(TString(analysis)=="1G") out << os << endl;
306  sprintf(os,"<td><font color=\"black\">%i</font></td>",ifreq);
307  out << os << endl;
308  sprintf(os,"<td>%i</td>",iband);
309  out << os << endl;
310  sprintf(os,"<td>%.3f</td>",idur);
311  out << os << endl;
312  sprintf(os,"<td>%i</td>",isize);
313  out << os << endl;
314  sprintf(os,"<td>%i</td>",irate);
315  if(optim==true) out << os << endl;
316  sprintf(os,"<td>%i</td>",irun);
317  out << os << endl;
318  sprintf(os,"<td>%.2f</td>",time0);
319  out << os << endl;
320  if (nIFO>1){
321  sprintf(os,"<td>%.2f</td>",time1);
322  out << os << endl;
323  }
324  if (nIFO>2){
325  sprintf(os,"<td>%.2f</td>",time2);
326  out << os << endl;
327  }
328  if (nIFO>3){
329  sprintf(os,"<td>%.2f</td>",time3);
330  out << os << endl;
331  }
332  sprintf(os,"<td>%3.1f</td>",sqrt(SNR0));
333  out << os << endl;
334  if (nIFO>1){
335  sprintf(os,"<td>%3.1f</td>",sqrt(SNR1));
336  out << os << endl;
337  }
338  if (nIFO>2){
339  sprintf(os,"<td>%3.1f</td>",sqrt(SNR2));
340  out << os << endl;
341  }
342  if (nIFO>3){
343  sprintf(os,"<td>%3.1f</td>",sqrt(SNR3));
344  out << os << endl;
345  }
346 /*
347  sprintf(os,"<td>%.1e</td>",hrss0);
348  out << os << endl;
349  sprintf(os,"<td>%.1e</td>",hrss1);
350  out << os << endl;
351  if (nIFO>2){
352  sprintf(os,"<td>%.1e</td>",hrss2);
353  out << os << endl;
354  }
355  if (nIFO>3){
356  sprintf(os,"<td>%.1e</td>",hrss3);
357  out << os << endl;
358  }
359  sprintf(os,"<td>%.2f</td>",phi);
360  out << os << endl;
361  sprintf(os,"<td>%.2f</td>",theta);
362  out << os << endl;
363  sprintf(os,"<td>%.2f</td>",psi);
364  out << os << endl;
365 */
366  out << "</tr>" << endl;
367  }
368 
369  }
370  cout << endl;
371  f_ev.close();
372  out << "</table>" << endl;
373  out << "<p>" << endl;
374  out << endl;
375 
376  cout << exec << endl;
377  gSystem->Exec(exec);
378 
379  sprintf(file_notsorted,"%s/events_notsorted.txt",PP_DATA_PATH.Data());
380  sprintf(exec,"rm %s",file_notsorted);
381  cout << exec << endl;
382  gSystem->Exec(exec);
383  sprintf(exec,"rm %s",file_header);
384  cout << exec << endl;
385  gSystem->Exec(exec);
386 
387  out << "</table>" << endl;
388  out << "<p>" << endl;
389  out << endl;
390  out.close();
391  exit(0);
392 }
393 
float SNR1
float hrss3
float SNR0
TString PP_DATA_PATH
static vector< TString > getFileListFromDir(TString dir_name, TString endString="", TString beginString="", TString containString="", bool fast=false)
Definition: Toolbox.cc:4333
double T_pen
void Export(TString fname="")
Definition: config.cc:388
double time1
char cmd[1024]
float idur
double fHigh
sprintf(netdir,"%s/%s", pp_dir, pp_data_dir)
char html_body_prod_template[1024]
float irho
float hrss2
char channelNamesRaw[NIFO_MAX][50]
par[0] name
int ecount
float ilik
int n
Definition: cwb_net.C:10
void GetLiveTime()
Definition: GetLiveTime.C:31
dqfile VDQF[100]
TString("c")
float icc2
double T_cor
bool optim
int ifreq
double GetStart(TTree *tree, int nifo, int run, float rho, double time0, double time1, TString analysis, int irho)
Definition: Toolfun.hh:238
vector< TString > epsList
TString cwb_doc_url
bool bcat2
i pp_inetcc
float SNR2
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
Definition: cwb_frdisplay.C:94
char ofile[512]
double segEdge
Definition: test_config1.C:49
int nVDQF
TString PP_DATA_DIR
i drho i
void Import(TString umacro="")
Definition: config.cc:334
static bool checkFile(TString fName, bool question=false, TString message="")
Definition: Toolbox.cc:3956
int iband
bool singleDetector
char c3[2]
char ifo[NIFO_MAX][8]
float psi
TString GetFileLabel(TTree *tree, int run, int lag, int slag, double segEdge, TString psfix)
Definition: Toolfun.hh:196
float ivED
float ilag
#define nIFO
ofstream out
Definition: cwb_merge.C:196
char data_label[512]
Definition: test_config1.C:160
double T_acor
float theta
double time2
bool bhveto
bool bcat3
float hrss1
TString _ifo[NIFO_MAX]
Definition: cwb_eced.C:14
TString RATEBACKGROUND
float iacor
double pp_rho_min
float ivHH
float icHH
char netdir[1024]
const int NIFO_MAX
Definition: wat.hh:4
double time0
float ipen
int Rate
ifstream f_ev(file_sorted)
double pp_rho_max
char net_file_name[256]
float hrss0
float icc
s s
Definition: cwb_net.C:137
int isize
char title[256]
Definition: SSeriesExample.C:1
char subtitle[1024]
float icc3
int irate
ifstream in
double fLow
float SNR3
char fileliv[1024]
char fileout[256]
Definition: cwb_mkhtml_pe.C:25
char pp_dir[512]
Definition: test_config1.C:155
char pp_data_dir[1024]
float islag
strcpy(RunLabel, RUN_LABEL)
TString cc3(c3)
float phi
double T_cut
int pp_max_nloudest_list
int irun
int cat
double T_out
double T_vED
TString config
detectorParams detParms[4]
TString ppm(pm)
double time3
i drho pp_irho
void SetSingleDetectorMode()
Definition: config.cc:1334
char pm[2]
exit(0)
char os[1024]