72 #define PP_ZL_STYLE "step"
73 #define PP_BELT_STYLE "continuos"
75 #define PP_IFAR_MAX -1
76 #define PP_RHO_MIN 4.5
83 #define PP_GW151226_IFAR 0
84 #define PP_ZL_MAX_IFAR 0
92 #define MAX_LIST_SIZE 100
93 #define IFAR_NBIN 2000
104 #define FAP0 (1.-0.682689)
105 #define FAP1 (1.-0.954499)
106 #define FAP2 (1.-0.997300)
108 #define DAY (24.*3600.)
109 #define YEAR (24.*3600.*365.)
111 #define CHUNK_FILE_LIST "Chunk_List.txt"
112 #define CHUNK_MAX_SIZE 100
118 #define PA_FILE_LIST "Public_Alerts.lst"
147 double gw151226_ifar;
249 int ReadFileList(TString ifName, TChain** live, TChain** wave, TChain** mdc,
int* lag,
int* slag,
int* chunk,
int* bin, TString*
run);
250 void GetLiveTime(
int nwave, TChain** live,
int* lag,
int* slag,
int* bin, TString*
run,
double* liveZero,
double* liveTot);
252 void MakePlot(TString
title,
double obsTime,
double ifar_cmax);
270 if((
gOPT.run!=
"O1")&&(
gOPT.run!=
"O2")&&(
gOPT.run!=
"O1O2")&&(
gOPT.run!=
"O3")) {
271 cout <<
"Make_PP_IFAR - Error : run option not allowed, must be O1/O2/O1O2/O3" << endl;
275 TString SEARCH =
gOPT.search;
276 if(
gOPT.search.Contains(
":")) SEARCH =
gOPT.search(0,
gOPT.search.Index(
":",0));
277 if((SEARCH!=
"BBH")&&(SEARCH!=
"IMBHB")&&(SEARCH!=
"BurstLF")&&(SEARCH!=
"BurstHF")&&(SEARCH!=
"BurstLD")) {
278 cout <<
"Make_PP_IFAR - Error : search option not allowed, must be BBH/IMBHB/BurstLF/BurstHF/BurstLD + ':bin1/bin2/...'" << endl;
283 cout <<
"Make_PP_IFAR - Error : trials value not allowed, must be >0" << endl;
287 if(
gOPT.sfactor<=0) {
288 cout <<
"Make_PP_SFACTOR - Error : sfactor value not allowed, must be >0" << endl;
293 cout <<
"Make_PP_IFAR - Error : nifo value not allowed, must 2/3" << endl;
297 if((
gOPT.zl_style!=
"step")&&(
gOPT.zl_style!=
"marker")) {
298 cout <<
"Make_PP_IFAR - Error : zl_style value not allowed, must be step/marker" << endl;
302 if((
gOPT.belt_style!=
"step")&&(
gOPT.belt_style!=
"continuos")) {
303 cout <<
"Make_PP_IFAR - Error : belt_style value not allowed, must be step/continuos" << endl;
308 TString fext = ifName(ifName.Last(
'.')+1,4);
311 cout <<
"Make_PP_IFAR - Error : when input file ext=root lag,slag,chunk must be >=0" << endl;
318 if(
gOPT.exit) gROOT->SetBatch(kTRUE);
348 char cwb_config_env[1024] =
"";
349 if(gSystem->Getenv(
"CWB_CONFIG")!=NULL) {
350 strcpy(cwb_config_env,TString(gSystem->Getenv(
"CWB_CONFIG")).Data());
357 if(
n==0 &&
gOPT.run.Contains(
"O1")) RUN=
"O1";
359 if(
n==1 &&
gOPT.run.Contains(
"O2")) RUN=
"O2";
361 if(
n==2 &&
gOPT.run.Contains(
"O3")) RUN=
"O3";
364 char chunk_file_list[1024];
366 cout << chunk_file_list << endl;
369 cout <<
"----------------------------------------------------------------------------------------------------" << endl;
370 cout <<
"chunk" <<
"\t\t" <<
"start" <<
"\t\t" <<
"stop" <<
"\t\t"
371 <<
" days\t\t" <<
"beg-date" <<
" - " <<
"end-date" <<
"\t" <<
"run" << endl;
372 cout <<
"----------------------------------------------------------------------------------------------------" << endl;
377 cout <<
"----------------------------------------------------------------------------------------------------" << endl;
386 if(SEARCH==
"BBH" || SEARCH==
"IMBHB") rho_id=1;
396 for(
int i=0;i<
MAX_LIST_SIZE;i++) live[i] =
new TChain(
"liveTime");
399 for(
int i=0;i<
MAX_LIST_SIZE;i++) wave[i] =
new TChain(
"waveburst");
406 chunk[0] =
gOPT.chunk;
411 TString fwave = ifName;
412 TString flive = ifName;
413 flive.ReplaceAll(
"wave_",
"live_");
416 wave[0]->SetTitle(fwave);
417 live[0]->SetTitle(flive);
420 nwave =
ReadFileList(ifName, live, wave, mdc, lag, slag, chunk, bin,
run);
423 gOPT.chunk = chunk[0];
427 cout <<
"Make_PP_IFAR - Error : no files read from input list, check input list format" << endl;
434 for(
int i=1;i<nwave;i++) {
435 if(bin[i]<0)
continue;
436 if(lag[i]!=xlag || slag[i]!=xslag) {
437 cout <<
"Make_PP_IFAR - Error : lag,slag defined in input list root files are not consistent" << endl;
443 for(
int i=0;i<nwave;i++) {
444 if(bin[i]<0)
continue;
445 for(
int j=0;j<nwave;j++) {
446 if(bin[j]<0)
continue;
447 if((i!=j) && (lag[i]==lag[j] && slag[i]==slag[j] && chunk[i]==chunk[j] && bin[i]==bin[j] && TString(wave[i]->GetTitle())==TString(wave[j]->GetTitle()))) {
448 cout <<
"Make_PP_IFAR - Error : input file list contains duplicated entries for lag,slag,chunk,bin = "
449 << lag[i] <<
"," << slag[i] <<
"," << chunk[i] <<
"," << bin[i] << endl;
451 << wave[i]->GetTitle() << endl;
459 for(
int i=0;i<nwave;i++) {
460 if(bin[i]<0)
continue;
462 for(
int j=0;j<vbin.size();j++)
if(bin[i]==vbin[j]) exist=
true;
463 if(!exist) vbin.push_back(bin[i]);
465 for(
int i=0;i<nwave;i++) {
466 if(bin[i]<0)
continue;
468 for(
int j=0;j<nwave;j++) {
469 if(bin[j]<0)
continue;
470 if((i!=j) && (lag[i]==lag[j] && slag[i]==slag[j] && chunk[i]==chunk[j])) {
471 for(
int k=0;k<vbin.size();k++)
if(bin[j]!=vbin[k]) nbins++;
474 if(nbins!=vbin.size()) {
475 cout <<
"Make_PP_IFAR - Error : input file list must contains all bins for each chunk: "
476 << wave[i]->GetTitle() << endl;
477 cout <<
" lag,slag,chunk,bin = "
478 << lag[i] <<
"," << slag[i] <<
"," << chunk[i] <<
"," << bin[i] << endl;
496 obsTime+=liveTot[
n]/
gOPT.trials;
502 printf(
"%s : total live time: non-zero lags = %10.1f sec, %10.2f days, %10.4f years \n\n",RUN.Data(),liveTot[
n],liveTot[
n]/
DAY,liveTot[
n]/
YEAR);
505 printf(
"%s : total observational time: non-zero lags = %10.1f sec, %10.2f days, %10.4f years \n\n",
gOPT.run.Data(),obsTime,obsTime/
DAY,obsTime/
YEAR);
522 double ifar_cmin = 0;
523 double ifar_cmax = 1e100;
526 for(
int m=0;
m<nwave;
m++) {
527 if(bin[
m]<0)
continue;
528 int isize = (int)wave[
m]->GetEntries();
529 wave[
m]->SetEstimate(isize);
530 char cut[64];
sprintf(cut,
"rho[%d]>%f",rho_id,
gOPT.rho_min);
531 wave[
m]->Draw(
"ifar",cut,
"goff",isize);
532 double* ifar = wave[
m]->GetV1();
533 int sel_entries = wave[
m]->GetSelectedRows();
534 value = log10(TMath::MinElement(sel_entries,ifar));
536 cout <<
"tMax events per year : " << (1./pow(10,
value))*
YEAR << endl;
538 cout <<
"chunk\t" << chunk[
m] <<
"\tbin\t" << bin[
m] <<
"\tMax events per year : " << (1./pow(10,
value))*
YEAR << endl;
540 value = log10(TMath::MaxElement(sel_entries,ifar));
546 cout <<
"ifar_cmin : " << pow(10,ifar_cmin)/
YEAR <<
" years" << endl;
547 cout <<
"ifar_cmax : " << pow(10,ifar_cmax)/
YEAR <<
" years" << endl;
548 cout <<
"ifar_max : " << pow(10,ifar_max)/
YEAR <<
" years" << endl;
550 double inf = ifar_cmin;
551 double sup = TMath::Nint(ifar_max+0.5);
562 vector<double> vIFAR;
565 for(
int m=0;
m<nwave;
m++) {
566 if(bin[
m]<0)
continue;
571 if(lag[
m]==-1 && slag[
m]==-1)
sprintf(
tmp,
"ifar>%f && lag[%d]!=0 && rho[%d]>%f",pow(10,ifar_cmin)*
gOPT.trials,
gOPT.nifo,rho_id,
gOPT.rho_min);
572 if(lag[
m]>= 0 && slag[
m]==-1)
sprintf(
tmp,
"ifar>%f && lag[%d]==%d && rho[%d]>%f",pow(10,ifar_cmin)*
gOPT.trials,
gOPT.nifo,lag[
m],rho_id,
gOPT.rho_min);
573 if(lag[
m]>= 0 && slag[
m]>= 0)
sprintf(
tmp,
"ifar>%f && lag[%d]==%d && slag[%d]==%d && rho[%d]>%f",pow(10,ifar_cmin)*
gOPT.trials,
gOPT.nifo,lag[
m],
gOPT.nifo,slag[
m],rho_id,
gOPT.rho_min);
575 Cuts = TString::Format(
"%s ",
tmp);
577 Cuts += TString::Format(
" && %s ",
tmp);
579 cout <<
"CutBBH : " << Cuts << endl;
580 wave[
m]->SetEstimate(wave[
m]->GetEntries());
581 wave[
m]->Draw(sel,Cuts.Data(),
"goff");
582 nsel+= wave[
m]->GetSelectedRows();
583 double* V1 = wave[
m]->GetV1();
584 double* V2 = wave[
m]->GetV2();
585 for(
int k=0;k<wave[
m]->GetSelectedRows();k++) {vIFAR.push_back(V1[k]);vGPS.push_back(V2[k]);}
590 if(
gOPT.bbh &&
gOPT.gw151226_ifar>0) {
599 int size = vIFAR.size();
600 int *index =
new int[
size];
602 for(
int k=0;k<
size;k++)
IFAR[k]=vIFAR[k];
604 if(
gOPT.zl_style==
"marker") {
608 for(
int k=0;k<
size;k++) {
618 for(
int k=
size-1;k>=0;k--) {
634 if(
gOPT.zl_max_ifar>0) {
641 if(log10(loudest_zl_ifar_sec)>sup) sup=log10(loudest_zl_ifar_sec);
642 if(inf>0 && sup/inf<2) sup=2*inf;
645 if(pow(10, inf)/
YEAR>0.01) inf=log10(0.01*
YEAR);
650 cout <<
"ifar inf : " << pow(10, inf)/
YEAR <<
" years" << endl;
651 cout <<
"ifar sup : " << pow(10, sup)/
YEAR <<
" years" << endl;
664 double ifar_sim_min = 0;
665 double ifar_sim_max = 1.e20;
667 while(!vIFAR.empty()) vIFAR.pop_back();
668 vIFAR.clear(); std::vector<double>().swap(vIFAR);
672 for(
int m=0;
m<nwave;
m++) {
673 if(bin[
m]>=0)
continue;
675 int ninj = mdc[
m]->GetEntries();
676 cout <<
run[
m] <<
"\t" << chunk[
m] <<
"\tmdc injected entries : " << ninj << endl;
678 wave[
m]->SetEstimate(wave[
m]->GetEntries());
682 sprintf(
tmp,
"ifar>%f && rho[%d]>%f",pow(10,ifar_cmin)*
gOPT.trials,rho_id,
gOPT.rho_min);
683 Cuts = TString::Format(
"%s ",
tmp);
684 wave[
m]->Draw(sel,Cuts.Data(),
"goff");
685 double* V1 = wave[
m]->GetV1();
686 for(
int k=0;k<wave[
m]->GetSelectedRows();k++) {vIFAR.push_back(V1[k]);vNINJ.push_back(ninj);}
687 double efficiency = ninj>0 ? (double)wave[
m]->GetSelectedRows()/(double)ninj : 0;
688 cout <<
run[
m] <<
"\t" << chunk[
m] <<
"\tselected wave sim detected entries : "
689 << wave[
m]->GetSelectedRows() <<
"\tefficiency(%): " << int(100*efficiency) <<
"\tcumulative: " << vIFAR.size() << endl;
690 if(vIFAR.size()==0)
continue;
691 int sel_entries = wave[
m]->GetSelectedRows();
692 value = TMath::MinElement(sel_entries,V1);
695 value = TMath::MaxElement(sel_entries,V1);
705 cout <<
"ifar_sim_min : " << ifar_sim_min <<
" years" << endl;
706 cout <<
"ifar_sim_max : " << ifar_sim_max <<
" years" << endl;
714 int size = vIFAR.size();
715 int *index =
new int[
size];
717 for(
int k=0;k<
size;k++)
IFAR[k]=vIFAR[k];
726 for(
int k=
size-1;k>=0;k--) {
728 #ifdef APPLY_MAX_SIM_IFAR
749 #ifdef APPLY_MAX_SIM_IFAR
766 int ifar_cmax_index=0;
767 for(
int i=0;i<
SIM_IFAR.size();i++)
if(
SIM_IFAR.data[i]<pow(10,ifar_cmax)/
YEAR) ifar_cmax_index=i;
781 double x = inf+
n*difar_bin;
782 if(x<(ifar_cmin-difar_bin) && x<inf)
continue;
783 if(x>ifar_cmax)
continue;
814 if(
gOPT.belt_style==
"step") {
831 cout <<
"Make_PP_IFAR.C - generate belts : be patient, it takes a while ..." << endl;
834 double x = inf+
n*difar_bin;
836 if(x<(ifar_cmin-difar_bin) && x<inf)
continue;
837 xIFAR[N] = pow(10,x);
840 double mu =
xFAR[N]*obsTime;
860 if(
gOPT.belt_style==
"step") {
913 sigma[0] = sqrt(2)*TMath::ErfcInverse(
FAP0);
914 sigma[1] = sqrt(2)*TMath::ErfcInverse(
FAP1);
915 sigma[2] = sqrt(2)*TMath::ErfcInverse(
FAP2);
917 cout << endl <<
"--------------------------------------------------------" << endl << endl;;
918 cout <<
"FAP = " <<
FAP0 <<
"\t -> SIGMA = " << sigma[0] << endl;
919 cout <<
"FAP = " <<
FAP1 <<
"\t -> SIGMA = " << sigma[1] << endl;
920 cout <<
"FAP = " <<
FAP2 <<
"\t -> SIGMA = " << sigma[2] << endl;
921 cout << endl <<
"--------------------------------------------------------" << endl << endl;;
958 canvas =
new TCanvas(
"FAR",
"FAR", 300,40, 800, 600);
970 gr0->SetLineWidth(2);
971 gr0->SetLineStyle(1);
972 gr0->SetLineColor(kGray+2);
973 gr0->GetHistogram()->GetXaxis()->CenterTitle();
974 gr0->GetHistogram()->GetYaxis()->CenterTitle();
975 gr0->GetHistogram()->GetXaxis()->SetLabelOffset(0.0001);
976 gr0->GetHistogram()->GetXaxis()->SetTickLength(0.02);
977 gr0->GetHistogram()->GetXaxis()->SetLabelSize(0.035);
978 gr0->GetHistogram()->GetYaxis()->SetLabelSize(0.035);
979 gr0->GetHistogram()->GetXaxis()->SetTitleSize(0.035);
980 gr0->GetHistogram()->GetYaxis()->SetTitleSize(0.035);
981 gr0->GetHistogram()->GetXaxis()->SetTitleOffset(1.7);
982 gr0->GetHistogram()->GetYaxis()->SetTitleOffset(1.5);
983 gr0->GetHistogram()->GetXaxis()->SetTitleOffset(1.4);
984 gr0->GetHistogram()->GetYaxis()->SetTitleOffset(1.2);
985 gr0->GetHistogram()->GetXaxis()->SetAxisColor(17);
986 gr0->GetHistogram()->GetYaxis()->SetAxisColor(17);
993 double ymax =
gr0->GetHistogram()->GetMaximum();
995 if(ymax/ymin<10) ymax=10*ymin;
998 gr0->GetHistogram()->GetYaxis()->SetRangeUser(ymin,ymax);
999 gr0->GetHistogram()->GetXaxis()->SetRangeUser(0.01,1e5);
1010 gr0->GetHistogram()->GetXaxis()->SetTitle(
"Inverse False Alarm Rate (yr)");
1011 gr0->GetHistogram()->GetYaxis()->SetTitle(
"Cumulative Number of Events");
1012 gr0->GetHistogram()->GetXaxis()->SetLabelFont(132);
1013 gr0->GetHistogram()->GetYaxis()->SetLabelFont(132);
1014 gr0->GetHistogram()->GetXaxis()->SetTitleFont(132);
1015 gr0->GetHistogram()->GetYaxis()->SetTitleFont(132);
1016 gr0->GetHistogram()->GetXaxis()->SetTickLength(0);
1020 egr2->SetMarkerStyle(20);
1021 egr2->SetMarkerSize(0);
1022 egr2->SetLineColor(15);
1023 egr2->SetFillStyle(1001);
1024 egr2->SetFillColor(18);
1025 egr2->Draw(
"3SAME");
1029 egr1->SetMarkerStyle(20);
1030 egr1->SetMarkerSize(0);
1031 egr1->SetLineColor(15);
1032 egr1->SetFillStyle(1001);
1033 egr1->SetFillColor(17);
1034 egr1->Draw(
"3SAME");
1038 egr0->SetMarkerStyle(20);
1039 egr0->SetMarkerSize(0);
1040 egr0->SetLineColor(15);
1041 egr0->SetFillStyle(1001);
1042 egr0->SetFillColor(16);
1043 egr0->Draw(
"3SAME");
1050 int ifar_cmax_index=0;
1060 grsim->SetLineColor(kGreen);
1061 grsim->SetLineWidth(1);
1062 grsim->SetMarkerSize(0);
1063 grsim->Draw(
"LSAME");
1077 gr->SetLineColor(kRed);
1078 gr->SetMarkerColor(kRed);
1079 gr->SetMarkerStyle(23);
1080 if(
gOPT.zl_style==
"marker") {
1081 gr->SetMarkerSize(0.4);
1084 gr->SetMarkerSize(0);
1092 #ifdef PLOT_FOREGROUND_NOBBH
1094 wavearray<double> ZL_IFAR_NOBBH(
ZL_NEVT.size());
1098 for(
int i=0;i<
ZL_NEVT.size();i++) {
1101 if(ZL_IFAR_NOBBH[nobbh_size-1]==ZL_IFAR_NOBBH[nobbh_size-2]) nobbh_size-=1;
1102 ZL_IFAR_NOBBH.resize(nobbh_size);
1103 wavearray<double> ZL_NEVT_NOBBH(nobbh_size);
1104 for(
int i=0;i<nobbh_size;i+=2) {
1105 ZL_NEVT_NOBBH[i]=(nobbh_size-i)/2+1;
1106 ZL_NEVT_NOBBH[i+1]=(nobbh_size-i)/2;
1108 ZL_NEVT_NOBBH[0]=(nobbh_size)/2+1;
1112 if(ZL_NEVT_NOBBH.size()>0) {
1113 gr_nobbh =
new TGraph(ZL_NEVT_NOBBH.size(),ZL_IFAR_NOBBH.data,ZL_NEVT_NOBBH.data);
1117 gr_nobbh->SetLineColor(kBlack);
1118 gr_nobbh->SetLineWidth(1);
1119 gr_nobbh->SetLineStyle(3);
1120 gr_nobbh->SetMarkerColor(kRed);
1121 gr_nobbh->SetMarkerStyle(23);
1122 if(
gOPT.zl_style==
"marker") {
1123 gr_nobbh->SetMarkerSize(0.4);
1124 gr_nobbh->Draw(
"PSAME");
1126 gr_nobbh->SetMarkerSize(0);
1127 gr_nobbh->Draw(
"SAME");
1137 for(
int i=0;i<
ZL_NEVT.size();i++) {
1140 bool selected=
false;
1147 arrow->SetAngle(60);
1148 arrow->SetLineWidth(2);
1149 arrow->SetLineColor(kBlue);
1150 arrow->SetFillColor(kBlue);
1151 arrow->SetArrowSize(0.012);
1154 marker->SetMarkerSize(1.2);
1155 marker->SetMarkerColor(kBlue);
1159 latex->SetTextFont(132);
1160 latex->SetTextSize(0.028);
1161 latex->SetTextColor(kBlack);
1170 marker->SetMarkerSize(1.2);
1171 marker->SetMarkerColor(kRed);
1176 #ifdef PLOT_FOREGROUND_NOBBH
1177 leg =
new TLegend(0.6,0.6,0.90,0.90,NULL,
"brNDC");
1180 leg =
new TLegend(0.6,0.630,0.90,0.90,NULL,
"brNDC");
1182 leg =
new TLegend(0.6,0.6,0.90,0.90,NULL,
"brNDC");
1186 leg->SetBorderSize(1);
1187 leg->SetTextAlign(22);
1188 leg->SetTextFont(132);
1189 leg->SetLineColor(1);
1190 leg->SetLineStyle(1);
1191 leg->SetLineWidth(1);
1192 leg->SetFillColor(0);
1193 leg->SetFillStyle(1001);
1194 if(
grsimbkg!=NULL)
leg->SetTextSize(0.035);
else leg->SetTextSize(0.035);
1195 leg->SetLineColor(kBlack);
1196 leg->SetFillColor(kWhite);
1199 sprintf(legLabel,
"Foreground");
if(
gr!=NULL)
leg->AddEntry(
gr,legLabel,
"lp");
1200 #ifdef PLOT_FOREGROUND_NOBBH
1201 sprintf(legLabel,
"Residual Foreground");
if(gr_nobbh!=NULL)
leg->AddEntry(gr_nobbh,legLabel,
"lp");
1203 sprintf(legLabel,
"Expected Background");
leg->AddEntry(
gr0,legLabel,
"lp");
1204 if(
gOPT.bbh && anyBBH)
leg->AddEntry(
marker,
"BBH Events",
"p");
1207 leg->AddEntry(
grsim,
"Signal Model",
"lp");;
1208 leg->AddEntry(
grsimbkg,
"Noise+Signal Model",
"lp");;
1211 leg->AddEntry(
egr2,
"< 3 #sigma",
"f");
1212 leg->AddEntry(
egr1,
"< 2 #sigma",
"f");
1213 leg->AddEntry(
egr0,
"< 1 #sigma",
"f");
1220 double xmax = pow(10,gPad->GetUxmax());
1221 double xmin = pow(10,gPad->GetUxmin());
1224 double ymax = pow(10,gPad->GetUymax());
1225 cout <<
"xmin=" << xmin <<
" xmax=" << xmax << endl;
1226 cout <<
"ymin=" << ymin <<
" ymax=" << ymax << endl;
1228 TLine* frameLine[4];
1229 frameLine[0] =
new TLine(xmin,ymin,xmax,ymin);
1230 frameLine[1] =
new TLine(xmin,ymin,xmin,ymax);
1231 frameLine[2] =
new TLine(xmax,ymin,xmax,ymax);
1232 frameLine[3] =
new TLine(0.,ymax,xmax,ymax);
1233 for(
int i=0;i<4;i++) frameLine[i]->Draw();
1239 TString PFNAME =
gOPT.pfname(0,
gOPT.pfname.Last(
'.'));
1240 if(
gOPT.bbh)
sprintf(ofname,
"%s_bbh_plot.png",PFNAME.Data());
1241 else sprintf(ofname,
"%s_nobbh_plot.png",PFNAME.Data());
1243 if(
gOPT.bbh)
sprintf(ofname,
"%s_bbh_plot.root",PFNAME.Data());
1244 else sprintf(ofname,
"%s_nobbh_plot.root",PFNAME.Data());
1246 if(
gOPT.bbh)
sprintf(ofname,
"%s_bbh_plot.pdf",PFNAME.Data());
1247 else sprintf(ofname,
"%s_nobbh_plot.pdf",PFNAME.Data());
1254 double max = mu>10 ? 10*mu : 100;
1256 TF1 f(
"poisson",
"TMath::Poisson(x,[1])",0,max);
1257 f.SetParameter(1,mu);
1261 return f.GetQuantiles(6,
q,probSum);
1267 for(
int j=0;j<1000000;j++) {
1269 FAP -= TMath::PoissonI(j,mu);
1271 if(FAP<fap)
return j==0 ? 0 : j+1;
1279 for(
int j=0;j<1000000;j++) {
1281 FAP += TMath::PoissonI(j,mu);
1283 if(FAP>fap)
return j==0 ? 0 : j-1;
1288 int ReadFileList(TString ifName, TChain** live, TChain** wave, TChain** mdc,
int* lag,
int* slag,
int* chunk,
int* bin, TString*
run) {
1293 in.open(ifName.Data(),ios::in);
1294 if (!in.good()) {cout <<
"ReadFileList Error Opening File : " << ifName.Data() << endl;
exit(1);}
1300 in.getline(str,1024);
1301 if (!in.good())
break;
1302 if(str[0] !=
'#')
size++;
1304 in.clear(ios::goodbit);
1305 in.seekg(0, ios::beg);
1306 if (
size==0) {cout <<
"ReadFileList Error : File " << ifName.Data() <<
" is empty" << endl;
exit(1);}
1310 int xlag,xslag,ichunk,ibin;
1315 in.getline(str,1024);
1316 if (!in.good())
break;
1317 if(str[0] ==
'#' || str[0]==
'\0')
continue;
1318 in.seekg(fpos, ios::beg);
1319 in >> sfile >> xlag >> xslag >> ichunk >> ibin >> srun;
1320 if(!in.good())
break;
1323 TString fwave = sfile;
1324 if(!CWB::Toolbox::isFileExisting(fwave)) {cout <<
"ReadFileList Error : File not exist : " << fwave << endl;
exit(1);}
1325 wave[nwave]->Add(fwave);
1326 wave[nwave]->SetTitle(fwave);
1328 TString flive = sfile;
1329 flive.ReplaceAll(
"wave_",
"live_");
1330 if(!CWB::Toolbox::isFileExisting(flive)) {cout <<
"ReadFileList Error : File not exist : " << flive << endl;
exit(1);}
1331 live[nwave]->Add(flive);
1332 live[nwave]->SetTitle(flive);
1334 TString fmdc = sfile;
1335 fmdc.ReplaceAll(
"wave_",
"mdc_");
1336 if(!CWB::Toolbox::isFileExisting(fmdc)) {cout <<
"ReadFileList Error : File not exist : " << fmdc << endl;
exit(1);}
1337 mdc[nwave]->Add(fmdc);
1338 mdc[nwave]->SetTitle(fmdc);
1340 chunk[nwave]=ichunk;
1343 cout << nwave+1 <<
"\t" << fwave <<
"\t" << xlag <<
"\t" << xslag <<
"\t" << ichunk <<
"\t" << ibin <<
"\t" << srun << endl;
1351 void GetLiveTime(
int nwave, TChain** live,
int* lag,
int* slag,
int* bin, TString*
run,
double* liveZero,
double* liveTot) {
1355 wavearray<double> Trun(500000); Trun = 0.;
1356 wavearray<double> Wlag[NIFO_MAX+1];
1357 wavearray<double> Wslag[NIFO_MAX+1];
1358 wavearray<double> Tdlag;
1359 wavearray<double> Tlag;
1360 wavearray<double> Rlag;
1361 wavearray<double> Elag;
1362 wavearray<double> Olag;
1364 cout <<
"Start CWB::Toolbox::getLiveTime : be patient, it takes a while ..." << endl;
1365 for(
int m=0;
m<nwave;
m++) {
1366 if(bin[
m]<0)
continue;
1367 cout <<
"Compute liveTot : Read : " << live[
m]->GetTitle() << endl;
1368 if(
run[
m]==
"O1") liveTot[0]+=TB.getLiveTime(
gOPT.nifo,*live[
m],Trun,Wlag,Wslag,Tlag,Tdlag,lag[
m],slag[
m]);
1369 if(
run[
m]==
"O2") liveTot[1]+=TB.getLiveTime(
gOPT.nifo,*live[
m],Trun,Wlag,Wslag,Tlag,Tdlag,lag[
m],slag[
m]);
1370 if(
run[
m]==
"O3") liveTot[2]+=TB.getLiveTime(
gOPT.nifo,*live[
m],Trun,Wlag,Wslag,Tlag,Tdlag,lag[
m],slag[
m]);
1374 for(
int m=0;
m<nwave;
m++) {
1375 if(bin[
m]<0)
continue;
1376 if((lag[
m]!=0)&&(slag[
m]!=0)) {
1377 cout <<
"Compute liveZero : Read : " << live[
m]->GetTitle() << endl;
1378 if(
run[
m]==
"O1") liveZero[0]+=TB.getLiveTime(
gOPT.nifo,*live[
m],Trun,Wlag,Wslag,Tlag,Tdlag,0,0);
1379 if(
run[
m]==
"O2") liveZero[1]+=TB.getLiveTime(
gOPT.nifo,*live[
m],Trun,Wlag,Wslag,Tlag,Tdlag,0,0);
1380 if(
run[
m]==
"O3") liveZero[2]+=TB.getLiveTime(
gOPT.nifo,*live[
m],Trun,Wlag,Wslag,Tlag,Tdlag,0,0);
1382 if(
run[
m]==
"O1") printf(
"live time: zero lags = %10.1f, %10.1f days \n",liveZero[0],liveZero[0]/
DAY);
1383 if(
run[
m]==
"O2") printf(
"live time: zero lags = %10.1f, %10.1f days \n",liveZero[1],liveZero[1]/
DAY);
1384 if(
run[
m]==
"O3") printf(
"live time: zero lags = %10.1f, %10.1f days \n",liveZero[2],liveZero[1]/
DAY);
1424 if(
gOPT.run.Contains(
"O1")) {
1425 CutBBH += TString::Format(
" !(abs(time[0]-%f)<0.2) ",
O1_BBH_GPS[0]);
1427 if(
gOPT.run.Contains(
"O1")) {
1428 for(
int i=1;i<
O1_BBH_GPS.size();i++) CutBBH += TString::Format(
"&& !(abs(time[0]-%f)<0.2) ",
O1_BBH_GPS[i]);
1431 if(
gOPT.run==
"O1O2") {
1432 CutBBH += TString::Format(
"&& !(abs(time[0]-%f)<0.2) ",
O2_BBH_GPS[0]);
1433 }
else if(
gOPT.run==
"O2") {
1434 CutBBH += TString::Format(
" !(abs(time[0]-%f)<0.2) ",
O2_BBH_GPS[0]);
1436 if(
gOPT.run.Contains(
"O2")) {
1437 for(
int i=1;i<
O2_BBH_GPS.size();i++) CutBBH += TString::Format(
"&& !(abs(time[0]-%f)<0.2) ",
O2_BBH_GPS[i]);
1440 if(
gOPT.run.Contains(
"O3")) {
1441 CutBBH += TString::Format(
" !(abs(time[0]-%f)<0.2) ",
O3_BBH_GPS[0]);
1443 if(
gOPT.run.Contains(
"O3")) {
1444 for(
int i=1;i<
O3_BBH_GPS.size();i++) CutBBH += TString::Format(
"&& !(abs(time[0]-%f)<0.5) ",
O3_BBH_GPS[i]);
1510 TString sexit =
gOPT.exit?
"true":
"false";
1511 TString bbh =
gOPT.bbh?
"true":
"false";
1515 cout <<
"-----------------------------------------" << endl;
1516 cout <<
"PP IFAR config options " << endl;
1517 cout <<
"-----------------------------------------" << endl << endl;
1519 cout <<
"PP_RUN " <<
gOPT.run << endl;
1520 cout <<
"PP_SEARCH " <<
gOPT.search << endl;
1522 cout <<
"PP_NIFO " <<
gOPT.nifo << endl;
1523 cout <<
"PP_LAG " <<
gOPT.lag << endl;
1524 cout <<
"PP_SLAG " <<
gOPT.slag << endl;
1525 cout <<
"PP_CHUNK " <<
gOPT.chunk << endl;
1527 cout <<
"PP_TRIALS " <<
gOPT.trials << endl;
1529 cout <<
"PP_PFNAME " <<
gOPT.pfname << endl;
1530 cout <<
"PP_ZL_STYLE " <<
gOPT.zl_style << endl;
1531 cout <<
"PP_BELT_STYLE " <<
gOPT.belt_style << endl;
1533 cout <<
"PP_IFAR_MAX " <<
gOPT.ifar_max <<
" yr"<< endl;
1534 cout <<
"PP_RHO_MIN " <<
gOPT.rho_min << endl;
1536 cout <<
"PP_SFACTOR " <<
gOPT.sfactor << endl;
1538 cout <<
"PP_BBH " << bbh << endl;
1539 cout <<
"PP_EXIT " << sexit << endl;
1541 cout <<
"PP_GW151226_IFAR " <<
gOPT.gw151226_ifar << endl;
1542 cout <<
"PP_ZL_MAX_IFAR " <<
gOPT.zl_max_ifar << endl;
1554 TObjArray*
token = TString(
options).Tokenize(TString(
' '));
1555 for(
int j=0;j<
token->GetEntries();j++) {
1557 TObjString* tok = (TObjString*)
token->At(j);
1558 TString stok = tok->GetString();
1560 if(stok.Contains(
"run=")) {
1561 TString pp_run=stok;
1562 pp_run.Remove(0,pp_run.Last(
'=')+1);
1566 if(stok.Contains(
"search=")) {
1567 TString pp_search=stok;
1568 pp_search.Remove(0,pp_search.Last(
'=')+1);
1569 gOPT.search=pp_search;
1572 if(stok.Contains(
"nifo=")) {
1573 TString pp_nifo=stok;
1574 pp_nifo.Remove(0,pp_nifo.Last(
'=')+1);
1575 if(pp_nifo.IsDigit())
gOPT.nifo=pp_nifo.Atoi();
1578 if(stok.Contains(
"lag=") && !stok.Contains(
"slag=")) {
1579 TString pp_lag=stok;
1580 pp_lag.Remove(0,pp_lag.Last(
'=')+1);
1581 if(pp_lag.IsDigit())
gOPT.lag=pp_lag.Atoi();
1584 if(stok.Contains(
"slag=")) {
1585 TString pp_slag=stok;
1586 pp_slag.Remove(0,pp_slag.Last(
'=')+1);
1587 if(pp_slag.IsDigit())
gOPT.slag=pp_slag.Atoi();
1590 if(stok.Contains(
"chunk=")) {
1591 TString pp_chunk=stok;
1592 pp_chunk.Remove(0,pp_chunk.Last(
'=')+1);
1593 if(pp_chunk.IsDigit())
gOPT.chunk=pp_chunk.Atoi();
1596 if(stok.Contains(
"trials=")) {
1597 TString pp_trials=stok;
1598 pp_trials.Remove(0,pp_trials.Last(
'=')+1);
1599 if(pp_trials.IsDigit())
gOPT.trials=pp_trials.Atoi();
1602 if(stok.Contains(
"pfname=")) {
1603 TString pp_pfname=stok;
1604 pp_pfname.Remove(0,pp_pfname.Last(
'=')+1);
1605 gOPT.pfname=pp_pfname;
1608 if(stok.Contains(
"zl_style=")) {
1609 TString pp_zl_style=stok;
1610 pp_zl_style.Remove(0,pp_zl_style.Last(
'=')+1);
1611 gOPT.zl_style=pp_zl_style;
1614 if(stok.Contains(
"belt_style=")) {
1615 TString pp_belt_style=stok;
1616 pp_belt_style.Remove(0,pp_belt_style.Last(
'=')+1);
1617 gOPT.belt_style=pp_belt_style;
1620 if(stok.Contains(
"ifar_max=")) {
1621 TString pp_ifar_max=stok;
1622 pp_ifar_max.Remove(0,pp_ifar_max.Last(
'=')+1);
1623 if(pp_ifar_max.IsFloat())
gOPT.ifar_max=pp_ifar_max.Atof();
1626 if(stok.Contains(
"rho_min=")) {
1632 if(stok.Contains(
"sfactor=")) {
1633 TString pp_sfactor=stok;
1634 pp_sfactor.Remove(0,pp_sfactor.Last(
'=')+1);
1635 if(pp_sfactor.IsFloat())
gOPT.sfactor=pp_sfactor.Atof();
1638 if(stok.Contains(
"bbh=")) {
1639 TString pp_bbh=stok;
1640 pp_bbh.Remove(0,pp_bbh.Last(
'=')+1);
1641 if(pp_bbh==
"true")
gOPT.bbh=
true;
1642 if(pp_bbh==
"false")
gOPT.bbh=
false;
1645 if(stok.Contains(
"exit=")) {
1646 TString pp_exit=stok;
1647 pp_exit.Remove(0,pp_exit.Last(
'=')+1);
1648 if(pp_exit==
"true")
gOPT.exit=
true;
1649 if(pp_exit==
"false")
gOPT.exit=
false;
1652 if(stok.Contains(
"gw151226_ifar=")) {
1653 TString pp_gw151226_ifar=stok;
1654 pp_gw151226_ifar.Remove(0,pp_gw151226_ifar.Last(
'=')+1);
1655 if(pp_gw151226_ifar.IsFloat())
gOPT.gw151226_ifar=pp_gw151226_ifar.Atof();
1658 if(stok.Contains(
"zl_max_ifar=")) {
1659 TString pp_zl_max_ifar=stok;
1660 pp_zl_max_ifar.Remove(0,pp_zl_max_ifar.Last(
'=')+1);
1661 if(pp_zl_max_ifar.IsFloat())
gOPT.zl_max_ifar=pp_zl_max_ifar.Atof();
1669 if(
gOPT.pfname==
"")
return;
1672 TString PFNAME =
gOPT.pfname(0,
gOPT.pfname.Last(
'.'));
1673 if(
gOPT.bbh)
sprintf(ofname,
"%s_bbh_loudest.txt",PFNAME.Data());
1674 else sprintf(ofname,
"%s_nobbh_loudest.txt",PFNAME.Data());
1679 out.open(ofname,ios::out);
1680 if (!out.good()) {cout <<
"Error Opening Output File : " << ofname << endl;
exit(1);}
1681 cout <<
"Create Output File : " << ofname << endl;
1685 sprintf(sout,
"%*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s",
1686 4,
"#run", 6,
"chunk", 18,
"gps_time", 10,
"known.BBH", 16,
"ifar(sec)", 16,
"ifar(year)", 16,
"obs_time(sec)",
1687 16,
"obs_time(days)", 16,
"expected", 10,
"observed", 11,
"cumul.FAP", 8,
"sigma");
1688 out << sout << endl;
1692 for (
int i=
ZL_IFAR.size()-1; i>=0; i--) {
1698 for(
int j=0;j<observed;j++) {
1699 FAP -= TMath::PoissonI(j,expected);
1704 double sigma = sqrt(2)*TMath::ErfcInverse(FAP);
1707 if(bbh_name==
"") bbh_name=
".";
1712 sprintf(sout,
"%*s %*d %*.6f %*s %*.1f %*.4f %*f %*.1f %*.9f %*d %*.3e %*.2f",
1713 4,
run.Data(), 6, chunkID, 18,
ZL_GPS[i], 10, bbh_name.Data(), 16,
1715 16, obsTime/
DAY, 16, expected, 10, observed, 11, FAP, 8, sigma);
1716 if(
gOPT.zl_style==
"marker") {
1717 out << sout << endl;
1720 if(i%2==0) {out << sout << endl; observed++;}
1745 if(
gOPT.pfname==
"")
return;
1748 TString PFNAME =
gOPT.pfname(0,
gOPT.pfname.Last(
'.'));
1749 if(
gOPT.bbh)
sprintf(ofname,
"%s_bbh_period.txt",PFNAME.Data());
1750 else sprintf(ofname,
"%s_nobbh_period.txt",PFNAME.Data());
1755 out.open(ofname,ios::out);
1756 if (!out.good()) {cout <<
"Error Opening Output File : " << ofname << endl;
exit(1);}
1757 cout <<
"Create Output File : " << ofname << endl;
1761 sprintf(sout,
"%*s %*s %*s %*s %*s %*s %*s %*s",
1762 4,
"#run", 20,
"gps_start", 20,
"date_start", 20,
"gps_stop", 20,
"date_stop", 20,
"interval(days)", 20,
"obs_time(sec)", 20,
"obs_time(days)");
1763 out << sout << endl;
1769 if(
n==0 &&
gOPT.run.Contains(
"O1")) RUN=
"O1";
1771 if(
n==1 &&
gOPT.run.Contains(
"O2")) RUN=
"O2";
1773 if(
n==2 &&
gOPT.run.Contains(
"O3")) RUN=
"O3";
1779 double interval = (end_date.GetGPS()-beg_date.GetGPS())/
DAY;
1781 TString sbeg_date = beg_date.GetDateString();sbeg_date.Resize(19);
1782 TString send_date = end_date.GetDateString();send_date.Resize(19);
1784 sbeg_date.ReplaceAll(
" ",
"-");
1785 send_date.ReplaceAll(
" ",
"-");
1787 sprintf(sout,
"%*s %*.0d %*s %*.0d %*s %*.2f %*f %*.1f", 4, RUN.Data(), 20, beg_date.GetGPS(), 20, sbeg_date.Data(),
1788 20, end_date.GetGPS(), 20, send_date.Data(), 20, interval, 20, obsTime[
n]/
gOPT.trials, 20, obsTime[
n]/
DAY/
gOPT.trials);
1789 out << sout << endl;
1797 if(
gOPT.pfname==
"")
return;
1800 TString PFNAME =
gOPT.pfname(0,
gOPT.pfname.Last(
'.'));
1801 if(
gOPT.bbh)
sprintf(ofname,
"%s_bbh_config.txt",PFNAME.Data());
1802 else sprintf(ofname,
"%s_nobbh_config.txt",PFNAME.Data());
1805 out.open(ofname,ios::out);
1806 if(!out.good()) {cout <<
"DumpUserOptions : Error Opening File : " << ofname << endl;
exit(1);}
1807 cout <<
"dump: " << ofname << endl;
1810 TString tabs=
"\t\t\t\t";
1814 sprintf(
version,
"WAT Version : %s - SVN Revision : %s - Tag/Branch : %s",watversion(
'f'),watversion(
'r'),watversion(
'b'));
1819 char cwb_config_env[1024] =
"";
1820 if(gSystem->Getenv(
"CWB_CONFIG")!=NULL) {
1821 strcpy(cwb_config_env,TString(gSystem->Getenv(
"CWB_CONFIG")).Data());
1823 char cfg_version[256];
1824 TString cfg_branch = GetGitInfos(
"branch",cwb_config_env);
1825 TString cfg_tag = GetGitInfos(
"tag",cwb_config_env);
1826 TString cfg_diff = GetGitInfos(
"diff",cwb_config_env);
1827 if(cfg_branch!=
"") {
1828 if(cfg_diff!=
"") cfg_branch=cfg_branch+
"/M";
1829 sprintf(cfg_version,
"cWB Config Branch\t%s",cfg_branch.Data());
1830 }
else if(cfg_tag!=
"") {
1831 if(cfg_diff!=
"") cfg_branch=cfg_branch+
"/M";
1832 sprintf(cfg_version,
"cWB Config Tag\t%s",cfg_tag.Data());
1834 sprintf(cfg_version,
"cWB Config\t%s",
"Undefined");
1838 out <<
"--------------------------------" << endl;
1839 out <<
"PP IFAR version " << endl;
1840 out <<
"--------------------------------" << endl;
1844 out<< cfg_version <<endl;
1845 out<<
"cWB Config Hash\t" << GetGitInfos(
"hash",cwb_config_env) <<endl;
1848 out <<
"--------------------------------" << endl;
1849 out <<
"PP IFAR config options " << endl;
1850 out <<
"--------------------------------" << endl;
1853 out <<
"pp_run " <<
gOPT.run << endl;
1854 info =
"// run type: allowed types are O1/O2/O1O2/O3 (Default: O3)";
1855 out << tabs << info << endl << endl;
1857 out <<
"pp_search " <<
gOPT.search << endl;
1858 info =
"// search type: allowed types are BBH,BurstLF,BurstHF,BurstLD,IMBHB + bin1/bin2/... (Default: none)";
1859 out << tabs << info << endl << endl;
1861 out <<
"pp_nifo " <<
gOPT.nifo << endl;
1862 info =
"// number of detectors (Default: 2)";
1863 out << tabs << info << endl << endl;
1865 out <<
"pp_lag " <<
gOPT.lag << endl;
1866 info =
"// lag -> used only when the input file name is a root file (Default: -1)";
1867 out << tabs << info << endl << endl;
1869 out <<
"pp_slag " <<
gOPT.slag << endl;
1870 info =
"// slag -> used only when the input file name is a root file (Default: -1)";
1871 out << tabs << info << endl << endl;
1873 out <<
"pp_chunk " <<
gOPT.chunk << endl;
1874 info =
"// chunk -> used only when the input file name is a root file (Default: -1)";
1875 out << tabs << info << endl << endl;
1877 out <<
"pp_trials " <<
gOPT.trials << endl;
1878 info =
"// trials factor (Default: 1)";
1879 out << tabs << info << endl << endl;
1881 out <<
"pp_pfname " <<
gOPT.pfname << endl;
1882 info =
"// output plot file name, included the directory (Default: none)";
1883 out << tabs << info << endl << endl;
1885 out <<
"pp_zl_style " <<
gOPT.zl_style << endl;
1886 info =
"// zero lag plot style: step/marker -> zero lag is displayed with step/marker (Default: step)";
1887 out << tabs << info << endl << endl;
1889 out <<
"pp_belt_style " <<
gOPT.belt_style << endl;
1890 info =
"// belt plot style: step/continous -> belts are displayed with step/continuos poisson distribution (Default: continuos)";
1891 out << tabs << info << endl << endl;
1893 out <<
"pp_ifar_max " <<
gOPT.ifar_max << endl;
1894 info =
"// max ifar (year) used for plot, if =-1 then it is the maximum ifar from root files (Default: -1)";
1895 out << tabs << info << endl << endl;
1897 out <<
"pp_rho_min " <<
gOPT.rho_min << endl;
1898 info =
"// min rho[0/1] read from output root files (Default: 4.5)";
1899 out << tabs << info << endl << endl;
1901 out <<
"pp_sfactor " <<
gOPT.sfactor << endl;
1902 info =
"// factor used to normalize the simulation events for the computation of astrophysical rates (Default: 1)";
1903 out << tabs << info << endl << endl;
1905 out <<
"bbh " <<
gOPT.bbh << endl;
1906 info =
"// false/true -> if false the known bbh events are excluded from analysis (Default: false)";
1907 out << tabs << info << endl << endl;
1909 out <<
"exit " <<
gOPT.exit << endl;
1910 info =
"// false/true -> if true program exit ayt the end of the execution (Default: true)";
1911 out << tabs << info << endl << endl;
1913 out <<
"pp_gw151226_ifar " <<
gOPT.gw151226_ifar << endl;
1914 info =
"// GW151226 IFAR(YEARS): if > 0 the GW151226 event is added to the foreground (Default: 0, not added)";
1915 out << tabs << info << endl << endl;
1917 out <<
"pp_zl_max_ifar " <<
gOPT.zl_max_ifar << endl;
1918 info =
"// ZL_MAX_IFAR(YEARS): if > 0 all foreground with IFAR>zl_max_ifar is set to zl_max_ifar (Default: 0, not used)";
1919 out << tabs << info << endl << endl;
1926 if(
gOPT.pfname==
"")
return;
1929 TString PFNAME =
gOPT.pfname(0,
gOPT.pfname.Last(
'.'));
1930 if(
gOPT.bbh)
sprintf(ofname,
"%s_bbh_background.txt",PFNAME.Data());
1931 else sprintf(ofname,
"%s_nobbh_background.txt",PFNAME.Data());
1934 out.open(ofname,ios::out);
1935 if (!out.good()) {cout <<
"Error Opening Output File : " << ofname << endl;
exit(1);}
1936 cout <<
"Create Output File : " << ofname << endl;
1940 out <<
"#background data : ifar(years), expected, lower_sigma1, lower_sigma2, lower_sigma3, upper_sigma1, upper_sigma2, upper_sigma3" << endl;
1942 for(
int i=0;i<
xIFAR.size();i++) {
1944 double med =
bRATE[i];
1955 out <<
xIFAR[i] <<
" " << med
1956 <<
" " << l900 <<
" " << l990 <<
" " << l999
1957 <<
" " << u900 <<
" " << u990 <<
" " << u999
1967 if(
gOPT.pfname==
"")
return;
1970 TString PFNAME =
gOPT.pfname(0,
gOPT.pfname.Last(
'.'));
1971 if(
gOPT.bbh)
sprintf(ofname,
"%s_bbh_foreground.txt",PFNAME.Data());
1972 else sprintf(ofname,
"%s_nobbh_foreground.txt",PFNAME.Data());
1975 out.open(ofname,ios::out);
1976 if (!out.good()) {cout <<
"Error Opening Output File : " << ofname << endl;
exit(1);}
1977 cout <<
"Create Output File : " << ofname << endl;
1981 out <<
"#foreground data : ifar(years), observed" << endl;
1983 for(
int i=0;i<
ZL_NEVT.size();i++) {
1995 if(
gOPT.pfname==
"")
return;
1999 TString PFNAME =
gOPT.pfname(0,
gOPT.pfname.Last(
'.'));
2000 if(
gOPT.bbh)
sprintf(ofname,
"%s_bbh_simulation.txt",PFNAME.Data());
2001 else sprintf(ofname,
"%s_nobbh_simulation.txt",PFNAME.Data());
2004 out.open(ofname,ios::out);
2005 if (!out.good()) {cout <<
"Error Opening Output File : " << ofname << endl;
exit(1);}
2006 cout <<
"Create Output File : " << ofname << endl;
2010 out <<
"#simulation data : ifar(years), estimated+background, lower_90.0, upper_90.0" << endl;
2013 int ifar_cmax_index=0;
2016 for(
int i=0;i<ifar_cmax_index;i++) {
2023 out <<
SIM_IFAR[i] <<
" " << med <<
" " << l90 <<
" " << u90 << endl;
2031 if(
gOPT.run!=
"O3")
return 0;
2038 char cwb_config_env[1024] =
"";
2039 if(gSystem->Getenv(
"CWB_CONFIG")!=NULL) {
2040 strcpy(cwb_config_env,TString(gSystem->Getenv(
"CWB_CONFIG")).Data());
2043 char pa_file_list[1024];
2045 cout << pa_file_list << endl;
2047 CWB::Toolbox::checkFile(pa_file_list);
2051 in.open(pa_file_list,ios::in);
2052 if (!in.good()) {cout <<
"Error Opening File : " << pa_file_list << endl;
exit(1);}
2058 in.getline(str,1024);
2059 if (!in.good())
break;
2060 if(str[0] !=
'#') isize++;
2062 in.clear(ios::goodbit);
2063 in.seekg(0, ios::beg);
2064 if(isize==0) {cout <<
"Error : File " << pa_file_list <<
" is empty" << endl;
exit(1);}
2067 if(
gOPT.run==
"O3") {
2078 if(!in.good())
break;
2079 if(
name[0]==
'#')
continue;
2080 wat::Time sdate(time);
2082 TString month[12] = {
"Jan",
"Feb",
"Mar",
"Apr",
"May",
"Jun",
"Jul",
"Aug",
"Sep",
"Oct",
"Nov",
"Dec"};
2085 char sout_txt[1024];
2087 month[sdate.GetMonth()-1].Data(),sdate.GetDay(),sdate.GetHour(),sdate.GetMinute());
2090 if(
gOPT.run==
"O3") {
int GetPercentiles(double mu, double *q)
int ReadFileList(TString ifName, TChain **live, TChain **wave, TChain **mdc, int *lag, int *slag, int *chunk, int *bin, TString *run)
wavearray< double > eyRATEsup1
int GetChunkID(double gps, TString &run)
double GetGPSBBH(TString name)
wavearray< double > eyRATEsup2
wavearray< double > eyRATEinf2
void MakePlot(TString title, double obsTime, double ifar_cmax)
wavearray< double > eyRATEsup0
double chunk_start[MAX_RUNS][CHUNK_MAX_SIZE]
vector< double > O2_BBH_GPS
TGraphAsymmErrors * egrsimbkg0
void GetLiveTime(int nwave, TChain **live, int *lag, int *slag, int *bin, TString *run, double *liveZero, double *liveTot)
void DumpSimulation(double ifar_cmax)
wavearray< double > xIFAR
vector< TString > O2_BBH_NAME
wavearray< double > ZL_GPS
wavearray< double > SIM_NEVT
int GetPoissonNsup(double mu, double fap)
wavearray< double > ZL_IFAR
wavearray< double > eySIM_BKG_sup0
void ReadUserOptions(TString options)
vector< TString > O3_BBH_NAME
wavearray< double > eyRATEinf0
void Make_PP_IFAR(TString ifName, TString options)
wavearray< double > ySIM_BKG
wavearray< double > exSIM_BKG_IFAR
void DumpLoudest(double obsTime)
wavearray< double > SIM_IFAR
wavearray< double > ZL_NEVT
wavearray< double > xSIM_BKG_IFAR
vector< TString > O1_BBH_NAME
int chunk_id[MAX_RUNS][CHUNK_MAX_SIZE]
wavearray< double > SIM_BKG_NEVT
vector< double > O3_BBH_GPS
void DumpPeriod(double *obsTime)
wavearray< double > exFAR
wavearray< double > eyRATEinf1
wavearray< double > bRATE
int GetPoissonNinf(double mu, double fap)
double chunk_stop[MAX_RUNS][CHUNK_MAX_SIZE]
wavearray< double > eySIM_BKG_inf0
TString GetNameBBH(double gps)
vector< double > O1_BBH_GPS
int ReadChunkList(TString ifile, int *chunk=NULL, double *start=NULL, double *stop=NULL)
sprintf(tag,"wave_%s", data_label)