21 #define CHUNK_FILE_LIST "Chunk_List.txt"
22 #define CHUNK_MAX_SIZE 100
24 #define MAX_CED_ENTRIES 10
25 #define MIN_CED_RHO 4.5
28 #define WWW_PUBLIC "https://ldas-jobs.ligo.caltech.edu/~waveburst/reports/"
29 #define WWW_LAG_MANUAL "https://gwburst.gitlab.io/documentation/latest/html/faq.html?highlight=lag#what-are-lags-and-how-to-use-them"
30 #define WWW_SLAG_MANUAL "https://gwburst.gitlab.io/documentation/latest/html/faq.html?highlight=lag#what-are-super-lags-and-how-to-use-them"
34 void ComputeSigmaFAP(
double OBSERVATIONAL_TIME,
double BACKGROUND_TIME,
int TRIALS_FACTOR=1);
35 void ComputeSigmaFAP(
double& fap,
double& sigma,
double ifar,
double obs_time);
37 void cwb_mkhtml_chunk(TString
run, TString
search, TString ibin,
int ichunk,
bool bbh, TString dir_bkg, TString dir_frg, TString odir, TString wlabel, TString net_file_name,
int lag,
int slag,
int nIFO) {
39 cout<<
"cwb_mkhtml_chunk.C starts..."<<endl;
42 netevent W(net_file_name,
nIFO);
44 gSystem->Exec(
"date");
49 TList* ifoList = W.fChain->GetUserInfo();
50 detectorParams dParams[NIFO_MAX];
51 for (
int n=0;
n<ifoList->GetSize();
n++) {
52 detector* pDetector = (detector*)ifoList->At(
n);
53 dParams[
n] = pDetector->getDetectorParams();
54 ifo.push_back(dParams[
n].
name);
55 net+=TString(dParams[
n].
name);
59 cout <<
"ifo names are not contained in the input wave root file: " << net_file_name << endl;
69 if(gSystem->Getenv(
"CWB_USER_URL")!=NULL) {
70 strcpy(cwb_user_url,TString(gSystem->Getenv(
"CWB_USER_URL")).Data());
73 char schunk[512];
sprintf(schunk,
"%02d",ichunk);
74 char search_title[512];
77 TString
tag = dir_bkg.Contains(
".J_") ?
"Combined " :
"";
78 sprintf(search_title,
"%s %s %s Bin%s %sSearch",
run.Data(),net.Data(),
search.Data(),ibin.Data(),
tag.Data());
80 sprintf(search_title,
"%s %s %s Bin%s Search",
run.Data(),net.Data(),
search.Data(),ibin.Data());
86 cout << xstart <<
" " << xstop << endl;
88 double interval = (xstop-xstart)/(24.*3600.);
90 wat::Time beg_date(xstart);
91 wat::Time end_date(xstop);
93 TString sbeg_date = beg_date.GetDateString();sbeg_date.Resize(19);
94 TString send_date = end_date.GetDateString();send_date.Resize(19);
97 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);
100 if(lag==0 && slag==0)
101 sprintf(box_title,
"Open Box Result");
103 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);
107 sprintf(bkg_rep,
"<td><a href=\"%s/%s/%s/index.html\" target=\"_blank\">Background Report</a></td>",cwb_user_url,wlabel.Data(),dir_bkg.Data());
112 sprintf(fileliv,
"../../%s/data/live.txt",dir_bkg.Data());
113 cout << fileliv << endl;
115 double OLIVETIME =
GetLiveTime(fileliv,slag,lag,countlag);
116 double LIVETIME =
GetLiveTime(fileliv,-1,-1,countlag);
120 cout << OLIVETIME <<
" " << LIVETIME << endl;
124 sprintf(livetime,
"Livetime - Background: %.2f years, Foreground: %.2f days",LIVETIME/(24.*3600.*365.),OLIVETIME/(24.*3600.));
130 sprintf(fileout,
"%s/body.html", odir.Data());
131 cout << fileout << endl;
132 out.open(fileout,ios::out);
133 if (!out.good()) {cout <<
"Error Opening File : " << fileout << endl;
exit(1);}
135 out <<
"<html>" << endl;
138 out <<
"<div align=\"center\"><font color=\"blue\"><h1>" << search_title <<
" : Chunk " << schunk <<
"</h1></font></div>" << endl;
139 out <<
"<div align=\"center\"><font color=\"red\"><h4>"<< box_title <<
"</h4></font></div>" << endl;
140 out <<
"<div align=\"center\"><font color=\"black\"><h4>"<< period <<
"</h4></font></div>" << endl;
141 out <<
"<div align=\"center\"><font color=\"black\"><h4>"<< livetime <<
"</h4></font></div>" << endl;
142 out <<
"<div align=\"center\"><font color=\"black\"><h4>"<< bkg_rep <<
"</h4></font></div>" << endl;
145 out <<
"<hr>" << endl;
146 out <<
"<br>" << endl;
147 out <<
"<br>" << endl;
149 out <<
"<table>" << endl;
150 out <<
"<tr><td width=\"50%\"><div align=\"center\">" << endl;
151 out <<
"<font color=\"red\"><h2>FAR vs Rank</h2></font>" << endl;
152 out <<
"</div><div align=\"center\"><ul><br/>" << endl;
153 out <<
"<a class=\"image\" title=\"FARvsRank\">" << endl;
154 out <<
"<img src=\"FARvsRank.png\" width=\"470\"> </a>" << endl;
155 out <<
"</br></ul>" << endl;
156 out <<
"</div><br><br></td><td width=\"50%\"><div align=\"center\">" << endl;
157 out <<
"<font color=\"red\"><h2>Cumulative Number vs IFAR</h2></font>" << endl;
158 out <<
"</div><div align=\"center\"><ul><br/>" << endl;
159 out <<
"<a class=\"image\" title=\"CumulativeNumberVsIFAR_bbh_plot\">" << endl;
160 if(bbh) out <<
"<img src=\"CumulativeNumberVsIFAR_bbh_plot.png\" width=\"470\"> </a>" << endl;
161 else out <<
"<img src=\"CumulativeNumberVsIFAR_nobbh_plot.png\" width=\"470\"> </a>" << endl;
162 out <<
"</br></ul>" << endl;
163 out <<
"</div><br><br></td></tr>" << endl;
164 out <<
"</table>" << endl;
166 out <<
"<table>" << endl;
167 out <<
"<tr><td width=\"50%\"><div align=\"center\">" << endl;
168 out <<
"<font color=\"red\"><h2>Background: Rank vs Time</h2></font>" << endl;
169 out <<
"</div><div align=\"center\"><ul><br/>" << endl;
170 out <<
"<a class=\"image\" title=\"rho_time\">" << endl;
171 out <<
"<img src=\"rho_time.gif\" width=\"470\"> </a>" << endl;
172 out <<
"</br></ul>" << endl;
173 out <<
"</div><br><br></td><td width=\"50%\"><div align=\"center\">" << endl;
174 out <<
"<font color=\"red\"><h2>Background: Rank vs Frequency</h2></font>" << endl;
175 out <<
"</div><div align=\"center\"><ul><br/>" << endl;
176 out <<
"<a class=\"image\" title=\"rho_frequency\">" << endl;
177 out <<
"<img src=\"rho_frequency.gif\" width=\"470\"> </a>" << endl;
178 out <<
"</br></ul>" << endl;
179 out <<
"</div><br><br></td></tr>" << endl;
180 out <<
"</table>" << endl;
187 sprintf(sel,
"rho[%d]:Entry$",rho_id);
189 W.fChain->SetEstimate(W.fChain->GetEntries());
190 W.fChain->Draw(sel,cut,
"goff");
191 Int_t nentries = (Int_t)W.fChain->GetSelectedRows();
192 Int_t *index =
new Int_t[nentries];
193 double* entry = W.fChain->GetV2();
194 TMath::Sort(nentries,W.fChain->GetV1(),index,
true);
200 out <<
"<head>" << endl;
201 out <<
"<style type=\"text/css\">" << endl;
202 out <<
".datagrid tr:hover td" << endl;
204 out <<
" background-color:#F1F1F2;" << endl;
206 out <<
"</style>" << endl;
207 out <<
"</head>" << endl;
208 out <<
"<b>" << endl;
209 out <<
"<hr>" << endl;
210 out <<
"<br>" << endl;
211 out <<
"<font color=\"red\" style=\"font-weight:bold;\"><center><p><h2>Foreground Loudest Event List</h2><p><center></font>" << endl;
212 if(bbh) out <<
"<a target=\"_blank\" href=\"CumulativeNumberVsIFAR_bbh_loudest.txt\">(Events sorted by IFAR: Cumulative FAP) </a>" << endl;
213 else out <<
"<a target=\"_blank\" href=\"CumulativeNumberVsIFAR_nobbh_loudest.txt\">(Events sorted by IFAR: Cumulative FAP) </a>" << endl;
214 out <<
"<br>" << 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>CED</td>"<< endl;
221 out <<
"<td>rho</td>"<< endl;
222 out <<
"<td>IFAR(yr)</td>"<< endl;
226 out <<
"<td>SNRnet</td>"<< endl;
228 out <<
"<td>Correlation</td>"<< endl;
229 out <<
"<td>Frequency(Hz)</td>"<< endl;
230 out <<
"<td>Bandwidth(Hz)</td>"<< endl;
231 out <<
"<td>Duration(sec)</td>"<< endl;
233 for (
int nn=0;nn<
nIFO;nn++) out <<
"<td>GPS " << ifo[nn] <<
"</td>"<< endl;
234 for (
int nn=0;nn<
nIFO;nn++) out <<
"<td>SNR " << ifo[nn] <<
"</td>"<< endl;
235 out <<
"<td>Combined</td>"<< endl;
236 out <<
"</tr>"<< endl;
238 out <<
"<td></td>" << endl;
243 W.fChain->SetBranchAddress(
"ifar",&ifar);
245 if(dir_bkg.Contains(
".J_")) W.fChain->SetBranchAddress(
"combine",&combine);
248 for(
int i=0; i<nentries; i++) {
252 W.fChain->GetEntry(entry[index[i]]);
261 cout <<
"EVENT " << i <<
"\trho = " << W.rho[rho_id] <<
"\tnetcc = " << W.netcc[0] <<
"\tifar (years) = " << ifar/(24.*3600.*365.)
262 <<
"\tobs (days) = " << OLIVETIME/(24.*3600.) <<
"\tfap = " << fap <<
"\tsigma = " << sigma <<
"\tcombine = " << combine << endl;
265 out <<
"<tr align=\"center\">"<< endl;
270 int start = TMath::Nint(W.start[0]-W.left[0])+
segEdge;
271 int stop = TMath::Nint(W.stop[0]+W.right[0])-TMath::Nint(W.start[0]-W.left[0])-2*
segEdge;
272 sprintf(
label,
"%i_%i_%s_slag%i_lag%i_%i_job%i", start, stop, wlabel.Data(), (
int)W.slag[
nIFO], (
int)W.lag[
nIFO], 1, W.run);
277 for (
int nn=0; nn<
nIFO; nn++)
sprintf(namedir,
"%s%s",namedir,ifo[nn].Data());
278 for (
int nn=0; nn<
nIFO; nn++) {
279 sprintf(namedir,
"%s_%.3f",namedir,W.start[nn]);
281 sprintf(os,
"<td><a href=\"%s/%s/%s/ced/ced_%s/%s\" target=\"_blank\">%i</a></td>",cwb_user_url,wlabel.Data(),dir_frg.Data(),s_ced.Data(),namedir,ecount);
285 sprintf(os,
"<td>%.2f</td>",W.rho[rho_id]);
287 sprintf(os,
"<td>%.2g</td>",ifar/(24.*3600.*365.));
295 sprintf(os,
"<td>%3.1f</td>",sqrt(W.likelihood));
299 sprintf(os,
"<td>%i</td>",(
int)W.frequency[0]);
301 sprintf(os,
"<td>%i</td>",(
int)W.bandwidth[1]);
303 sprintf(os,
"<td>%.3f</td>",W.duration[1]);
305 for (
int nn=0; nn<
nIFO; nn++) {
306 sprintf(os,
"<td>%.2f</td>",W.time[nn]);
309 for (
int nn=0; nn<
nIFO; nn++) {
310 sprintf(os,
"<td>%3.1f</td>",sqrt(W.sSNR[nn]));
313 sprintf(os,
"<td>%d</td>",combine);
316 out <<
"</tr>" << endl;
320 out <<
"</table>" << endl;
321 out <<
"<p>" << endl;
330 char cwb_config_env[1024] =
"";
331 if(gSystem->Getenv(
"CWB_CONFIG")!=NULL) {
332 strcpy(cwb_config_env,TString(gSystem->Getenv(
"CWB_CONFIG")).Data());
335 char chunk_file_list[1024];
337 cout << chunk_file_list << endl;
343 int nChunks =
ReadChunkList(chunk_file_list,chunk,start,stop);
345 for(
int i=0;i<nChunks;i++) {
346 if(chunk[i]==ichunk) {
353 void ComputeSigmaFAP(
double OBSERVATIONAL_TIME,
double BACKGROUND_TIME,
int TRIALS_FACTOR) {
355 double N = OBSERVATIONAL_TIME*(1./BACKGROUND_TIME);
356 double FAP = 1-exp(-N*TRIALS_FACTOR);
357 double Gsigma = sqrt(2)*TMath::ErfcInverse(FAP);
359 double FAP_from_Gsigma = TMath::Erfc(Gsigma*1./sqrt(2));
362 cout <<
"-----------------------------------------------" << endl;
363 cout <<
"OBSERVATIONAL_TIME : " << OBSERVATIONAL_TIME/(24.*3600.) <<
" days" << endl;
364 cout <<
"BACKGROUND_TIME : " << BACKGROUND_TIME/(24.*3600.*365.) <<
" years" << endl;
365 cout <<
"-----------------------------------------------" << endl;
366 cout <<
"FAP : " << FAP << endl;
367 cout <<
"Gaussian sigma : " << Gsigma << endl;
368 cout <<
"-----------------------------------------------" << endl;
375 double N = obs_time/ifar;
376 double FAP = 1-exp(-N);
377 double Gsigma = sqrt(2)*TMath::ErfcInverse(FAP);
379 double FAP_from_Gsigma = TMath::Erfc(Gsigma*1./sqrt(2))/2;
void GetLiveTime(int nwave, TChain **live, int *lag, int *slag, int *bin, TString *run, double *liveZero, double *liveTot)
int ReadChunkList(TString ifile, int *chunk=NULL, double *start=NULL, double *stop=NULL)
void GetChunkRange(TString run, TString search, int ichunk, double &xstart, double &xstop)
void ComputeSigmaFAP(double OBSERVATIONAL_TIME, double BACKGROUND_TIME, int TRIALS_FACTOR=1)
void cwb_mkhtml_chunk(TString run, TString search, TString ibin, int ichunk, bool bbh, TString dir_bkg, TString dir_frg, TString odir, TString wlabel, TString net_file_name, int lag, int slag, int nIFO)
sprintf(tag,"wave_%s", data_label)