52 #define PP_ZL_STYLE "step"
53 #define PP_BELT_STYLE "continuos"
55 #define PP_IFAR_MAX -1
56 #define PP_RHO_MIN 4.5
63 #define PP_GW151226_IFAR 0
64 #define PP_ZL_MAX_IFAR 0
70 #define MAX_RUNS 2 // O1,O2
72 #define MAX_LIST_SIZE 100 // maximum number of input root files in the input file list
73 #define IFAR_NBIN 2000 // number of bins used for the computation of belts and background
84 #define FAP0 1-0.682689 // FAP used to define the first belt : SIGMA = 1.
85 #define FAP1 1-0.954499 // FAP used to define the second belt : SIGMA = 2.
86 #define FAP2 1-0.997300 // FAP used to define the third belt : SIGMA = 3.
88 #define DAY (24.*3600.)
89 #define YEAR (24.*3600.*365.)
91 #define CHUNK_FILE_LIST "Chunk_List.txt"
92 #define MACRO_READ_CHUNK "ReadChunkList.C"
93 #define CHUNK_MAX_SIZE 100
126 double gw151226_ifar;
223 int ReadFileList(TString ifName, TChain** live, TChain** wave, TChain** mdc,
int* lag,
int* slag,
int*
chunk,
int* bin, TString* run);
224 void GetLiveTime(
int nwave, TChain** live,
int* lag,
int* slag,
int* bin, TString* run,
double* liveZero,
double* liveTot);
226 void MakePlot(TString title,
double obsTime,
double ifar_cmax);
244 if((gOPT.run!=
"O1")&&(gOPT.run!=
"O2")&&(gOPT.run!=
"O1O2")) {
245 cout <<
"Make_PP_IFAR - Error : run option not allowed, must be O1/O2/O1O2" << endl;
249 TString SEARCH = gOPT.search;
250 if(gOPT.search.Contains(
":")) SEARCH = gOPT.search(0,gOPT.search.Index(
":",0));
251 if((SEARCH!=
"BBH")&&(SEARCH!=
"IMBHB")&&(SEARCH!=
"BurstLF")&&(SEARCH!=
"BurstHF")&&(SEARCH!=
"BurstLD")) {
252 cout <<
"Make_PP_IFAR - Error : search option not allowed, must be BBH/IMBHB/BurstLF/BurstHF/BurstLD + ':bin1/bin2/...'" << endl;
257 cout <<
"Make_PP_IFAR - Error : trials value not allowed, must be >0" << endl;
261 if(gOPT.sfactor<=0) {
262 cout <<
"Make_PP_SFACTOR - Error : sfactor value not allowed, must be >0" << endl;
266 if(gOPT.nifo!=2 && gOPT.nifo!=3) {
267 cout <<
"Make_PP_IFAR - Error : nifo value not allowed, must 2/3" << endl;
271 if((gOPT.zl_style!=
"step")&&(gOPT.zl_style!=
"marker")) {
272 cout <<
"Make_PP_IFAR - Error : zl_style value not allowed, must be step/marker" << endl;
276 if((gOPT.belt_style!=
"step")&&(gOPT.belt_style!=
"continuos")) {
277 cout <<
"Make_PP_IFAR - Error : belt_style value not allowed, must be step/continuos" << endl;
282 TString fext = ifName(ifName.Last(
'.')+1,4);
284 if(gOPT.lag<0 || gOPT.slag<0 || gOPT.chunk<0) {
285 cout <<
"Make_PP_IFAR - Error : when input file ext=root lag,slag,chunk must be >=0" << endl;
292 if(gOPT.exit) gROOT->SetBatch(kTRUE);
322 char cwb_config_env[1024] =
"";
323 if(gSystem->Getenv(
"CWB_CONFIG")!=NULL) {
324 strcpy(cwb_config_env,TString(gSystem->Getenv(
"CWB_CONFIG")).Data());
331 if(
n==0 && gOPT.run.Contains(
"O1")) RUN=
"O1";
333 if(
n==1 && gOPT.run.Contains(
"O2")) RUN=
"O2";
336 char chunk_file_list[1024];
338 cout << chunk_file_list << endl;
340 char macro_read_chunk_path[1024];
343 CWB::Toolbox::checkFile(macro_read_chunk_path);
346 gROOT->LoadMacro(gSystem->ExpandPathName(macro_read_chunk_path));
349 cout <<
"----------------------------------------------------------------------------------------------------" << endl;
350 cout <<
"chunk" <<
"\t\t" <<
"start" <<
"\t\t" <<
"stop" <<
"\t\t"
351 <<
" days\t\t" <<
"beg-date" <<
" - " <<
"end-date" <<
"\t" <<
"run" << endl;
352 cout <<
"----------------------------------------------------------------------------------------------------" << endl;
357 cout <<
"----------------------------------------------------------------------------------------------------" << endl;
366 if(SEARCH==
"BBH" || SEARCH==
"IMBHB") rho_id=1;
376 for(
int i=0;i<
MAX_LIST_SIZE;i++) live[i] =
new TChain(
"liveTime");
379 for(
int i=0;i<
MAX_LIST_SIZE;i++) wave[i] =
new TChain(
"waveburst");
386 chunk[0] = gOPT.chunk;
391 TString fwave = ifName;
392 TString flive = ifName;
393 flive.ReplaceAll(
"wave_",
"live_");
396 wave[0]->SetTitle(fwave);
397 live[0]->SetTitle(flive);
400 nwave =
ReadFileList(ifName, live, wave, mdc, lag, slag, chunk, bin, run);
403 gOPT.chunk = chunk[0];
407 cout <<
"Make_PP_IFAR - Error : no files read from input list, check input list format" << endl;
414 for(
int i=1;i<nwave;i++) {
415 if(bin[i]<0)
continue;
416 if(lag[i]!=xlag || slag[i]!=xslag) {
417 cout <<
"Make_PP_IFAR - Error : lag,slag defined in input list root files are not consistent" << endl;
423 for(
int i=0;i<nwave;i++) {
424 if(bin[i]<0)
continue;
425 for(
int j=0;j<nwave;j++) {
426 if(bin[j]<0)
continue;
427 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()))) {
428 cout <<
"Make_PP_IFAR - Error : input file list contains duplicated entries for lag,slag,chunk,bin = "
429 << lag[i] <<
"," << slag[i] <<
"," << chunk[i] <<
"," << bin[i] << endl;
431 << wave[i]->GetTitle() << endl;
439 for(
int i=0;i<nwave;i++) {
440 if(bin[i]<0)
continue;
442 for(
int j=0;j<vbin.size();j++)
if(bin[i]==vbin[j]) exist=
true;
443 if(!exist) vbin.push_back(bin[i]);
445 for(
int i=0;i<nwave;i++) {
446 if(bin[i]<0)
continue;
448 for(
int j=0;j<nwave;j++) {
449 if(bin[j]<0)
continue;
450 if((i!=j) && (lag[i]==lag[j] && slag[i]==slag[j] && chunk[i]==chunk[j])) {
451 for(
int k=0;k<vbin.size();k++)
if(bin[j]!=vbin[k]) nbins++;
454 if(nbins!=vbin.size()) {
455 cout <<
"Make_PP_IFAR - Error : input file list must contains all bins for each chunk: "
456 << wave[i]->GetTitle() << endl;
457 cout <<
" lag,slag,chunk,bin = "
458 << lag[i] <<
"," << slag[i] <<
"," << chunk[i] <<
"," << bin[i] << endl;
471 GetLiveTime(nwave, live, lag, slag, bin, run, liveZero, liveTot);
476 obsTime+=liveTot[
n]/gOPT.trials;
481 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);
484 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);
501 double ifar_cmin = 0;
502 double ifar_cmax = 1e100;
505 for(
int m=0;
m<nwave;
m++) {
506 if(bin[
m]<0)
continue;
507 int isize = (int)wave[
m]->GetEntries();
508 wave[
m]->SetEstimate(isize);
509 char cut[64];
sprintf(cut,
"rho[%d]>%f",rho_id,gOPT.rho_min);
510 wave[
m]->Draw(
"ifar",cut,
"goff",isize);
511 double* ifar = wave[
m]->GetV1();
512 int sel_entries = wave[
m]->GetSelectedRows();
513 value = log10(TMath::MinElement(sel_entries,ifar));
515 cout <<
"tMax events per year : " << (1./pow(10,value))*
YEAR << endl;
517 cout <<
"chunk\t" << chunk[
m] <<
"\tbin\t" << bin[
m] <<
"\tMax events per year : " << (1./pow(10,value))*
YEAR << endl;
518 if(value>ifar_cmin) ifar_cmin=
value;
519 value = log10(TMath::MaxElement(sel_entries,ifar));
520 if(value>ifar_max) ifar_max=
value;
521 if(value<ifar_cmax) ifar_cmax=
value;
525 cout <<
"ifar_cmin : " << pow(10,ifar_cmin)/
YEAR <<
" years" << endl;
526 cout <<
"ifar_cmax : " << pow(10,ifar_cmax)/
YEAR <<
" years" << endl;
527 cout <<
"ifar_max : " << pow(10,ifar_max)/
YEAR <<
" years" << endl;
529 double inf = ifar_cmin;
530 double sup = TMath::Nint(ifar_max+0.5);
541 vector<double> vIFAR;
544 for(
int m=0;
m<nwave;
m++) {
545 if(bin[
m]<0)
continue;
548 sprintf(sel,
"ifar/%f:time[0]",gOPT.trials);
549 sprintf(tmp,
"ifar>%f",pow(10,ifar_cmin)*gOPT.trials);
550 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);
551 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);
552 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);
554 Cuts = TString::Format(
"%s ",tmp);
556 Cuts += TString::Format(
" && %s ",tmp);
558 cout <<
"CutBBH : " << Cuts << endl;
559 wave[
m]->SetEstimate(wave[m]->GetEntries());
560 wave[
m]->Draw(sel,Cuts.Data(),
"goff");
561 nsel+= wave[
m]->GetSelectedRows();
562 double* V1 = wave[
m]->GetV1();
563 double* V2 = wave[
m]->GetV2();
564 for(
int k=0;k<wave[
m]->GetSelectedRows();k++) {vIFAR.push_back(V1[k]);vGPS.push_back(V2[k]);}
569 if(gOPT.bbh && gOPT.gw151226_ifar>0) {
570 vIFAR.push_back(gOPT.gw151226_ifar*
YEAR);vGPS.push_back(
GetGPSBBH(
"GW151226"));
578 int size = vIFAR.size();
579 int *index =
new int[
size];
581 for(
int k=0;k<
size;k++) IFAR[k]=vIFAR[k];
582 TMath::Sort(size,IFAR,index,
true);
583 if(gOPT.zl_style==
"marker") {
587 for(
int k=0;k<
size;k++) {
588 ZL_GPS[size-k-1] = vGPS[index[k]];
597 for(
int k=size-1;k>=0;k--) {
613 if(gOPT.zl_max_ifar>0) {
620 if(log10(loudest_zl_ifar_sec)>sup) sup=log10(loudest_zl_ifar_sec);
621 if(inf>0 && sup/inf<2) sup=2*inf;
624 if(pow(10, inf)/
YEAR>0.01) inf=log10(0.01*
YEAR);
626 if(gOPT.ifar_max>0) sup = log10(gOPT.ifar_max*
YEAR);
629 cout <<
"ifar inf : " << pow(10, inf)/
YEAR <<
" years" << endl;
630 cout <<
"ifar sup : " << pow(10, sup)/
YEAR <<
" years" << endl;
643 double ifar_sim_min = 0;
644 double ifar_sim_max = 1.e20;
646 while(!vIFAR.empty()) vIFAR.pop_back();
647 vIFAR.clear(); std::vector<double>().swap(vIFAR);
651 for(
int m=0;
m<nwave;
m++) {
652 if(bin[
m]>=0)
continue;
654 int ninj = mdc[
m]->GetEntries();
655 cout << run[
m] <<
"\t" << chunk[
m] <<
"\tmdc injected entries : " << ninj << endl;
657 wave[
m]->SetEstimate(wave[
m]->GetEntries());
659 sprintf(sel,
"ifar/%f",gOPT.trials);
660 sprintf(tmp,
"ifar>%f",pow(10,ifar_cmin)*gOPT.trials);
661 sprintf(tmp,
"ifar>%f && rho[%d]>%f",pow(10,ifar_cmin)*gOPT.trials,rho_id,gOPT.rho_min);
662 Cuts = TString::Format(
"%s ",tmp);
663 wave[
m]->Draw(sel,Cuts.Data(),
"goff");
664 double* V1 = wave[
m]->GetV1();
665 for(
int k=0;k<wave[
m]->GetSelectedRows();k++) {vIFAR.push_back(V1[k]);vNINJ.push_back(ninj);}
666 double efficiency = ninj>0 ? (double)wave[
m]->GetSelectedRows()/(double)ninj : 0;
667 cout << run[
m] <<
"\t" << chunk[
m] <<
"\tselected wave sim detected entries : "
668 << wave[
m]->GetSelectedRows() <<
"\tefficiency(%): " << int(100*efficiency) <<
"\tcumulative: " << vIFAR.size() << endl;
669 if(vIFAR.size()==0)
continue;
670 int sel_entries = wave[
m]->GetSelectedRows();
671 value = TMath::MinElement(sel_entries,V1);
673 if(value>ifar_sim_min) ifar_sim_min=
value;
674 value = TMath::MaxElement(sel_entries,V1);
676 if(value<ifar_sim_max) ifar_sim_max=
value;
684 cout <<
"ifar_sim_min : " << ifar_sim_min <<
" years" << endl;
685 cout <<
"ifar_sim_max : " << ifar_sim_max <<
" years" << endl;
693 int size = vIFAR.size();
694 int *index =
new int[
size];
696 for(
int k=0;k<
size;k++) IFAR[k]=vIFAR[k];
697 TMath::Sort(size,IFAR,index,
true);
705 for(
int k=size-1;k>=0;k--) {
707 #ifdef APPLY_MAX_SIM_IFAR
728 #ifdef APPLY_MAX_SIM_IFAR
745 int ifar_cmax_index=0;
746 for(
int i=0;i<
SIM_IFAR.size();i++)
if(
SIM_IFAR.data[i]<pow(10,ifar_cmax)/
YEAR) ifar_cmax_index=i;
760 double x = inf+
n*difar_bin;
761 if(x<(ifar_cmin-difar_bin) && x<inf)
continue;
762 if(x>ifar_cmax)
continue;
793 if(gOPT.belt_style==
"step") {
812 double x = inf+
n*difar_bin;
814 if(x<(ifar_cmin-difar_bin) && x<inf)
continue;
815 xIFAR[N] = pow(10,x);
818 double mu =
xFAR[N]*obsTime;
837 if(gOPT.belt_style==
"step") {
890 sigma[0] = sqrt(2)*TMath::ErfcInverse(
FAP0);
891 sigma[1] = sqrt(2)*TMath::ErfcInverse(
FAP1);
892 sigma[2] = sqrt(2)*TMath::ErfcInverse(
FAP2);
894 cout << endl <<
"--------------------------------------------------------" << endl << endl;;
895 cout <<
"FAP = " <<
FAP0 <<
"\t -> SIGMA = " << sigma[0] << endl;
896 cout <<
"FAP = " <<
FAP1 <<
"\t -> SIGMA = " << sigma[1] << endl;
897 cout <<
"FAP = " <<
FAP2 <<
"\t -> SIGMA = " << sigma[2] << endl;
898 cout << endl <<
"--------------------------------------------------------" << endl << endl;;
911 sprintf(title,
"cWB %s (run=%s : lag=%d : slag=%d : included BBH)",gOPT.search.Data(),gOPT.run.Data(),gOPT.lag,gOPT.slag);
913 sprintf(title,
"cWB %s (run=%s : lag=%d : slag=%d : excluded BBH)",gOPT.search.Data(),gOPT.run.Data(),gOPT.lag,gOPT.slag);
918 MakePlot(title, obsTime, ifar_cmax);
930 if(gOPT.exit && gOPT.pfname!=
"")
exit(0);
933 void MakePlot(TString title,
double obsTime,
double ifar_cmax) {
935 canvas =
new TCanvas(
"FAR",
"FAR", 300,40, 800, 600);
945 gr0->SetTitle(title);
947 gr0->SetLineWidth(2);
948 gr0->SetLineStyle(1);
949 gr0->SetLineColor(kGray+2);
950 gr0->GetHistogram()->GetXaxis()->CenterTitle();
951 gr0->GetHistogram()->GetYaxis()->CenterTitle();
952 gr0->GetHistogram()->GetXaxis()->SetLabelOffset(0.0001);
953 gr0->GetHistogram()->GetXaxis()->SetTickLength(0.02);
954 gr0->GetHistogram()->GetXaxis()->SetLabelSize(0.035);
955 gr0->GetHistogram()->GetYaxis()->SetLabelSize(0.035);
956 gr0->GetHistogram()->GetXaxis()->SetTitleSize(0.035);
957 gr0->GetHistogram()->GetYaxis()->SetTitleSize(0.035);
958 gr0->GetHistogram()->GetXaxis()->SetTitleOffset(1.7);
959 gr0->GetHistogram()->GetYaxis()->SetTitleOffset(1.5);
960 gr0->GetHistogram()->GetXaxis()->SetTitleOffset(1.4);
961 gr0->GetHistogram()->GetYaxis()->SetTitleOffset(1.2);
962 gr0->GetHistogram()->GetXaxis()->SetAxisColor(17);
963 gr0->GetHistogram()->GetYaxis()->SetAxisColor(17);
970 double ymax =
gr0->GetHistogram()->GetMaximum();
972 if(ymax/ymin<10) ymax=10*ymin;
973 if(ymax>
gr0->GetHistogram()->GetMaximum()) ymax=
gr0->GetHistogram()->GetMaximum();
974 gr0->GetHistogram()->GetYaxis()->SetRangeUser(ymin,ymax);
975 gr0->GetHistogram()->GetXaxis()->SetRangeUser(0.01,1e5);
984 gr0->GetHistogram()->GetXaxis()->SetTitle(
"Inverse False Alarm Rate (yr)");
985 gr0->GetHistogram()->GetYaxis()->SetTitle(
"Cumulative Number of Events");
986 gr0->GetHistogram()->GetXaxis()->SetLabelFont(132);
987 gr0->GetHistogram()->GetYaxis()->SetLabelFont(132);
988 gr0->GetHistogram()->GetXaxis()->SetTitleFont(132);
989 gr0->GetHistogram()->GetYaxis()->SetTitleFont(132);
990 gr0->GetHistogram()->GetXaxis()->SetTickLength(0);
994 egr2->SetMarkerStyle(20);
995 egr2->SetMarkerSize(0);
996 egr2->SetLineColor(15);
997 egr2->SetFillStyle(1001);
998 egr2->SetFillColor(18);
1003 egr1->SetMarkerStyle(20);
1004 egr1->SetMarkerSize(0);
1005 egr1->SetLineColor(15);
1006 egr1->SetFillStyle(1001);
1007 egr1->SetFillColor(17);
1008 egr1->Draw(
"3SAME");
1012 egr0->SetMarkerStyle(20);
1013 egr0->SetMarkerSize(0);
1014 egr0->SetLineColor(15);
1015 egr0->SetFillStyle(1001);
1016 egr0->SetFillColor(16);
1017 egr0->Draw(
"3SAME");
1024 int ifar_cmax_index=0;
1034 grsim->SetLineColor(kGreen);
1035 grsim->SetLineWidth(1);
1036 grsim->SetMarkerSize(0);
1037 grsim->Draw(
"LSAME");
1051 gr->SetLineColor(kRed);
1052 gr->SetMarkerColor(kRed);
1053 gr->SetMarkerStyle(23);
1054 if(gOPT.zl_style==
"marker") {
1055 gr->SetMarkerSize(0.4);
1058 gr->SetMarkerSize(0);
1066 #ifdef PLOT_FOREGROUND_NOBBH
1068 wavearray<double> ZL_IFAR_NOBBH(
ZL_NEVT.size());
1072 for(
int i=0;i<
ZL_NEVT.size();i++) {
1075 if(ZL_IFAR_NOBBH[nobbh_size-1]==ZL_IFAR_NOBBH[nobbh_size-2]) nobbh_size-=1;
1076 ZL_IFAR_NOBBH.resize(nobbh_size);
1077 wavearray<double> ZL_NEVT_NOBBH(nobbh_size);
1078 for(
int i=0;i<nobbh_size;i+=2) {
1079 ZL_NEVT_NOBBH[i]=(nobbh_size-i)/2+1;
1080 ZL_NEVT_NOBBH[i+1]=(nobbh_size-i)/2;
1082 ZL_NEVT_NOBBH[0]=(nobbh_size)/2+1;
1086 if(ZL_NEVT_NOBBH.size()>0) {
1087 gr_nobbh =
new TGraph(ZL_NEVT_NOBBH.size(),ZL_IFAR_NOBBH.data,ZL_NEVT_NOBBH.data);
1091 gr_nobbh->SetLineColor(kBlack);
1092 gr_nobbh->SetLineWidth(1);
1093 gr_nobbh->SetLineStyle(3);
1094 gr_nobbh->SetMarkerColor(kRed);
1095 gr_nobbh->SetMarkerStyle(23);
1096 if(gOPT.zl_style==
"marker") {
1097 gr_nobbh->SetMarkerSize(0.4);
1098 gr_nobbh->Draw(
"PSAME");
1100 gr_nobbh->SetMarkerSize(0);
1101 gr_nobbh->Draw(
"SAME");
1111 for(
int i=0;i<
ZL_NEVT.size();i++) {
1114 bool selected=
false;
1121 arrow->SetAngle(60);
1122 arrow->SetLineWidth(2);
1123 arrow->SetLineColor(kBlue);
1124 arrow->SetFillColor(kBlue);
1125 arrow->SetArrowSize(0.012);
1128 marker->SetMarkerSize(1.2);
1129 marker->SetMarkerColor(kBlue);
1133 latex->SetTextFont(132);
1134 latex->SetTextSize(0.028);
1135 latex->SetTextColor(kBlack);
1144 marker->SetMarkerSize(1.2);
1145 marker->SetMarkerColor(kRed);
1150 #ifdef PLOT_FOREGROUND_NOBBH
1151 leg =
new TLegend(0.6,0.6,0.90,0.90,NULL,
"brNDC");
1154 leg =
new TLegend(0.6,0.630,0.90,0.90,NULL,
"brNDC");
1156 leg =
new TLegend(0.6,0.6,0.90,0.90,NULL,
"brNDC");
1160 leg->SetBorderSize(1);
1161 leg->SetTextAlign(22);
1162 leg->SetTextFont(132);
1163 leg->SetLineColor(1);
1164 leg->SetLineStyle(1);
1165 leg->SetLineWidth(1);
1166 leg->SetFillColor(0);
1167 leg->SetFillStyle(1001);
1168 if(
grsimbkg!=NULL)
leg->SetTextSize(0.035);
else leg->SetTextSize(0.035);
1169 leg->SetLineColor(kBlack);
1170 leg->SetFillColor(kWhite);
1173 sprintf(legLabel,
"Foreground");
if(
gr!=NULL)
leg->AddEntry(
gr,legLabel,
"lp");
1174 #ifdef PLOT_FOREGROUND_NOBBH
1175 sprintf(legLabel,
"Residual Foreground");
if(gr_nobbh!=NULL)
leg->AddEntry(gr_nobbh,legLabel,
"lp");
1177 sprintf(legLabel,
"Expected Background");
leg->AddEntry(
gr0,legLabel,
"lp");
1178 if(gOPT.bbh && anyBBH)
leg->AddEntry(
marker,
"BBH Events",
"p");
1181 leg->AddEntry(
grsim,
"Signal Model",
"lp");;
1182 leg->AddEntry(
grsimbkg,
"Noise+Signal Model",
"lp");;
1185 leg->AddEntry(
egr2,
"< 3 #sigma",
"f");
1186 leg->AddEntry(
egr1,
"< 2 #sigma",
"f");
1187 leg->AddEntry(
egr0,
"< 1 #sigma",
"f");
1192 double xmax =
gr0->GetHistogram()->GetXaxis()->GetXmax();
1193 double xmin =
gr0->GetHistogram()->GetXaxis()->GetXmin();
1196 double ymax = pow(10,gPad->GetUymax());
1197 cout <<
"xmin=" << xmin <<
" xmax=" << xmax << endl;
1198 cout <<
"ymin=" << ymin <<
" ymax=" << ymax << endl;
1200 TLine* frameLine[4];
1201 frameLine[0] =
new TLine(xmin,ymin,xmax,ymin);
1202 frameLine[1] =
new TLine(xmin,ymin,xmin,ymax);
1203 frameLine[2] =
new TLine(xmax,ymin,xmax,ymax);
1204 frameLine[3] =
new TLine(0.,ymax,xmax,ymax);
1205 for(
int i=0;i<4;i++) frameLine[i]->Draw();
1211 TString PFNAME = gOPT.pfname(0,gOPT.pfname.Last(
'.'));
1212 if(gOPT.bbh)
sprintf(ofname,
"%s_bbh_plot.png",PFNAME.Data());
1213 else sprintf(ofname,
"%s_nobbh_plot.png",PFNAME.Data());
1214 if(gOPT.bbh)
sprintf(ofname,
"%s_bbh_plot.root",PFNAME.Data());
1215 else sprintf(ofname,
"%s_nobbh_plot.root",PFNAME.Data());
1216 if(gOPT.bbh)
sprintf(ofname,
"%s_bbh_plot.pdf",PFNAME.Data());
1217 else sprintf(ofname,
"%s_nobbh_plot.pdf",PFNAME.Data());
1224 double max = mu>10 ? 10*mu : 100;
1226 TF1 f(
"poisson",
"TMath::Poisson(x,[1])",0,max);
1227 f.SetParameter(1,mu);
1231 return f.GetQuantiles(6,q,probSum);
1237 for(
int j=0;j<1000000;j++) {
1239 FAP -= TMath::PoissonI(j,mu);
1241 if(FAP<fap)
return j==0 ? 0 : j+1;
1249 for(
int j=0;j<1000000;j++) {
1251 FAP += TMath::PoissonI(j,mu);
1253 if(FAP>fap)
return j==0 ? 0 : j-1;
1258 int ReadFileList(TString ifName, TChain** live, TChain** wave, TChain** mdc,
int* lag,
int* slag,
int*
chunk,
int* bin, TString* run) {
1263 in.open(ifName.Data(),ios::in);
1264 if (!in.good()) {cout <<
"ReadFileList Error Opening File : " << ifName.Data() << endl;
exit(1);}
1270 in.getline(str,1024);
1271 if (!in.good())
break;
1272 if(str[0] !=
'#') size++;
1274 in.clear(ios::goodbit);
1275 in.seekg(0, ios::beg);
1276 if (size==0) {cout <<
"ReadFileList Error : File " << ifName.Data() <<
" is empty" << endl;
exit(1);}
1280 int xlag,xslag,ichunk,ibin;
1285 in.getline(str,1024);
1286 if (!in.good())
break;
1287 if(str[0] ==
'#' || str[0]==
'\0')
continue;
1288 in.seekg(fpos, ios::beg);
1289 in >> sfile >> xlag >> xslag >> ichunk >> ibin >> srun;
1290 if(!in.good())
break;
1293 TString fwave = sfile;
1294 if(!CWB::Toolbox::isFileExisting(fwave)) {cout <<
"ReadFileList Error : File not exist : " << fwave << endl;
exit(1);}
1295 wave[nwave]->Add(fwave);
1296 wave[nwave]->SetTitle(fwave);
1298 TString flive = sfile;
1299 flive.ReplaceAll(
"wave_",
"live_");
1300 if(!CWB::Toolbox::isFileExisting(flive)) {cout <<
"ReadFileList Error : File not exist : " << flive << endl;
exit(1);}
1301 live[nwave]->Add(flive);
1302 live[nwave]->SetTitle(flive);
1304 TString fmdc = sfile;
1305 fmdc.ReplaceAll(
"wave_",
"mdc_");
1306 if(!CWB::Toolbox::isFileExisting(fmdc)) {cout <<
"ReadFileList Error : File not exist : " << fmdc << endl;
exit(1);}
1307 mdc[nwave]->Add(fmdc);
1308 mdc[nwave]->SetTitle(fmdc);
1310 chunk[nwave]=ichunk;
1313 cout << nwave+1 <<
"\t" << fwave <<
"\t" << xlag <<
"\t" << xslag <<
"\t" << ichunk <<
"\t" << ibin <<
"\t" << srun << endl;
1321 void GetLiveTime(
int nwave, TChain** live,
int* lag,
int* slag,
int* bin, TString* run,
double* liveZero,
double* liveTot) {
1325 wavearray<double> Trun(500000); Trun = 0.;
1326 wavearray<double> Wlag[NIFO_MAX+1];
1327 wavearray<double> Wslag[NIFO_MAX+1];
1328 wavearray<double> Tdlag;
1329 wavearray<double> Tlag;
1330 wavearray<double> Rlag;
1331 wavearray<double> Elag;
1332 wavearray<double> Olag;
1334 cout <<
"Start CWB::Toolbox::getLiveTime : be patient, it takes a while ..." << endl;
1335 for(
int m=0;
m<nwave;
m++) {
1336 if(bin[
m]<0)
continue;
1337 cout <<
"Compute liveTot : Read : " << live[
m]->GetTitle() << endl;
1338 if(run[
m]==
"O1") liveTot[0]+=TB.getLiveTime(gOPT.nifo,*live[
m],Trun,Wlag,Wslag,Tlag,Tdlag,lag[m],slag[m]);
1339 if(run[m]==
"O2") liveTot[1]+=TB.getLiveTime(gOPT.nifo,*live[m],Trun,Wlag,Wslag,Tlag,Tdlag,lag[m],slag[m]);
1343 for(
int m=0;
m<nwave;
m++) {
1344 if(bin[
m]<0)
continue;
1345 if((lag[
m]!=0)&&(slag[
m]!=0)) {
1346 cout <<
"Compute liveZero : Read : " << live[
m]->GetTitle() << endl;
1347 if(run[
m]==
"O1") liveZero[0]+=TB.getLiveTime(gOPT.nifo,*live[
m],Trun,Wlag,Wslag,Tlag,Tdlag,0,0);
1348 if(run[m]==
"O2") liveZero[1]+=TB.getLiveTime(gOPT.nifo,*live[m],Trun,Wlag,Wslag,Tlag,Tdlag,0,0);
1350 if(run[m]==
"O1") printf(
"live time: zero lags = %10.1f, %10.1f days \n",liveZero[0],liveZero[0]/
DAY);
1351 if(run[m]==
"O2") printf(
"live time: zero lags = %10.1f, %10.1f days \n",liveZero[1],liveZero[1]/
DAY);
1388 if(gOPT.run.Contains(
"O1")) {
1389 CutBBH += TString::Format(
" !(abs(time[0]-%f)<0.2) ",
O1_BBH_GPS[0]);
1391 if(gOPT.run.Contains(
"O1")) {
1392 for(
int i=1;i<
O1_BBH_GPS.size();i++) CutBBH += TString::Format(
"&& !(abs(time[0]-%f)<0.2) ",
O1_BBH_GPS[i]);
1395 if(gOPT.run==
"O1O2") {
1396 CutBBH += TString::Format(
"&& !(abs(time[0]-%f)<0.2) ",
O2_BBH_GPS[0]);
1397 }
else if(gOPT.run==
"O2") {
1398 CutBBH += TString::Format(
" !(abs(time[0]-%f)<0.2) ",
O2_BBH_GPS[0]);
1400 if(gOPT.run.Contains(
"O2")) {
1401 for(
int i=1;i<
O2_BBH_GPS.size();i++) CutBBH += TString::Format(
"&& !(abs(time[0]-%f)<0.2) ",
O2_BBH_GPS[i]);
1461 TString sexit = gOPT.exit?
"true":
"false";
1462 TString bbh = gOPT.bbh?
"true":
"false";
1466 cout <<
"-----------------------------------------" << endl;
1467 cout <<
"PP IFAR config options " << endl;
1468 cout <<
"-----------------------------------------" << endl << endl;
1470 cout <<
"PP_RUN " << gOPT.run << endl;
1471 cout <<
"PP_SEARCH " << gOPT.search << endl;
1473 cout <<
"PP_NIFO " << gOPT.nifo << endl;
1474 cout <<
"PP_LAG " << gOPT.lag << endl;
1475 cout <<
"PP_SLAG " << gOPT.slag << endl;
1476 cout <<
"PP_CHUNK " << gOPT.chunk << endl;
1478 cout <<
"PP_TRIALS " << gOPT.trials << endl;
1480 cout <<
"PP_PFNAME " << gOPT.pfname << endl;
1481 cout <<
"PP_ZL_STYLE " << gOPT.zl_style << endl;
1482 cout <<
"PP_BELT_STYLE " << gOPT.belt_style << endl;
1484 cout <<
"PP_IFAR_MAX " << gOPT.ifar_max <<
" yr"<< endl;
1485 cout <<
"PP_RHO_MIN " << gOPT.rho_min << endl;
1487 cout <<
"PP_SFACTOR " << gOPT.sfactor << endl;
1489 cout <<
"PP_BBH " << bbh << endl;
1490 cout <<
"PP_EXIT " << sexit << endl;
1492 cout <<
"PP_GW151226_IFAR " << gOPT.gw151226_ifar << endl;
1493 cout <<
"PP_ZL_MAX_IFAR " << gOPT.zl_max_ifar << endl;
1502 if(TString(options)!=
"") {
1505 TObjArray*
token = TString(options).Tokenize(TString(
' '));
1506 for(
int j=0;j<token->GetEntries();j++) {
1508 TObjString* tok = (TObjString*)token->At(j);
1509 TString stok = tok->GetString();
1511 if(stok.Contains(
"run=")) {
1512 TString pp_run=stok;
1513 pp_run.Remove(0,pp_run.Last(
'=')+1);
1517 if(stok.Contains(
"search=")) {
1518 TString pp_search=stok;
1519 pp_search.Remove(0,pp_search.Last(
'=')+1);
1520 gOPT.search=pp_search;
1523 if(stok.Contains(
"nifo=")) {
1524 TString pp_nifo=stok;
1525 pp_nifo.Remove(0,pp_nifo.Last(
'=')+1);
1526 if(pp_nifo.IsDigit()) gOPT.nifo=pp_nifo.Atoi();
1529 if(stok.Contains(
"lag=") && !stok.Contains(
"slag=")) {
1530 TString pp_lag=stok;
1531 pp_lag.Remove(0,pp_lag.Last(
'=')+1);
1532 if(pp_lag.IsDigit()) gOPT.lag=pp_lag.Atoi();
1535 if(stok.Contains(
"slag=")) {
1536 TString pp_slag=stok;
1537 pp_slag.Remove(0,pp_slag.Last(
'=')+1);
1538 if(pp_slag.IsDigit()) gOPT.slag=pp_slag.Atoi();
1541 if(stok.Contains(
"chunk=")) {
1542 TString pp_chunk=stok;
1543 pp_chunk.Remove(0,pp_chunk.Last(
'=')+1);
1544 if(pp_chunk.IsDigit()) gOPT.chunk=pp_chunk.Atoi();
1547 if(stok.Contains(
"trials=")) {
1548 TString pp_trials=stok;
1549 pp_trials.Remove(0,pp_trials.Last(
'=')+1);
1550 if(pp_trials.IsDigit()) gOPT.trials=pp_trials.Atoi();
1553 if(stok.Contains(
"pfname=")) {
1554 TString pp_pfname=stok;
1555 pp_pfname.Remove(0,pp_pfname.Last(
'=')+1);
1556 gOPT.pfname=pp_pfname;
1559 if(stok.Contains(
"zl_style=")) {
1560 TString pp_zl_style=stok;
1561 pp_zl_style.Remove(0,pp_zl_style.Last(
'=')+1);
1562 gOPT.zl_style=pp_zl_style;
1565 if(stok.Contains(
"belt_style=")) {
1566 TString pp_belt_style=stok;
1567 pp_belt_style.Remove(0,pp_belt_style.Last(
'=')+1);
1568 gOPT.belt_style=pp_belt_style;
1571 if(stok.Contains(
"ifar_max=")) {
1572 TString pp_ifar_max=stok;
1573 pp_ifar_max.Remove(0,pp_ifar_max.Last(
'=')+1);
1574 if(pp_ifar_max.IsFloat()) gOPT.ifar_max=pp_ifar_max.Atof();
1577 if(stok.Contains(
"rho_min=")) {
1579 pp_rho_min.Remove(0,pp_rho_min.Last(
'=')+1);
1580 if(pp_rho_min.IsFloat()) gOPT.rho_min=pp_rho_min.Atof();
1583 if(stok.Contains(
"sfactor=")) {
1584 TString pp_sfactor=stok;
1585 pp_sfactor.Remove(0,pp_sfactor.Last(
'=')+1);
1586 if(pp_sfactor.IsFloat()) gOPT.sfactor=pp_sfactor.Atof();
1589 if(stok.Contains(
"bbh=")) {
1590 TString pp_bbh=stok;
1591 pp_bbh.Remove(0,pp_bbh.Last(
'=')+1);
1592 if(pp_bbh==
"true") gOPT.bbh=
true;
1593 if(pp_bbh==
"false") gOPT.bbh=
false;
1596 if(stok.Contains(
"exit=")) {
1597 TString pp_exit=stok;
1598 pp_exit.Remove(0,pp_exit.Last(
'=')+1);
1599 if(pp_exit==
"true") gOPT.exit=
true;
1600 if(pp_exit==
"false") gOPT.exit=
false;
1603 if(stok.Contains(
"gw151226_ifar=")) {
1604 TString pp_gw151226_ifar=stok;
1605 pp_gw151226_ifar.Remove(0,pp_gw151226_ifar.Last(
'=')+1);
1606 if(pp_gw151226_ifar.IsFloat()) gOPT.gw151226_ifar=pp_gw151226_ifar.Atof();
1609 if(stok.Contains(
"zl_max_ifar=")) {
1610 TString pp_zl_max_ifar=stok;
1611 pp_zl_max_ifar.Remove(0,pp_zl_max_ifar.Last(
'=')+1);
1612 if(pp_zl_max_ifar.IsFloat()) gOPT.zl_max_ifar=pp_zl_max_ifar.Atof();
1620 if(gOPT.pfname==
"")
return;
1623 TString PFNAME = gOPT.pfname(0,gOPT.pfname.Last(
'.'));
1624 if(gOPT.bbh)
sprintf(ofname,
"%s_bbh_loudest.txt",PFNAME.Data());
1625 else sprintf(ofname,
"%s_nobbh_loudest.txt",PFNAME.Data());
1630 out.open(ofname,ios::out);
1631 if (!out.good()) {cout <<
"Error Opening Output File : " << ofname << endl;
exit(1);}
1632 cout <<
"Create Output File : " << ofname << endl;
1636 sprintf(sout,
"%*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s",
1637 4,
"#run", 6,
"chunk", 18,
"gps_time", 10,
"known.BBH", 16,
"ifar(sec)", 16,
"ifar(year)", 16,
"obs_time(sec)",
1638 16,
"obs_time(days)", 16,
"expected", 10,
"observed", 11,
"cumul.FAP", 8,
"sigma");
1639 out << sout << endl;
1643 for (
int i=
ZL_IFAR.size()-1; i>=0; i--) {
1649 for(
int j=0;j<observed;j++) {
1650 FAP -= TMath::PoissonI(j,expected);
1655 double sigma = sqrt(2)*TMath::ErfcInverse(FAP);
1658 if(bbh_name==
"") bbh_name=
".";
1663 sprintf(sout,
"%*s %*d %*.6f %*s %*.1f %*.4f %*d %*.1f %*.9f %*d %*.3e %*.2f",
1664 4, run.Data(), 6, chunkID, 18,
ZL_GPS[i], 10, bbh_name.Data(), 16,
1666 16, obsTime/
DAY, 16, expected, 10, observed, 11, FAP, 8, sigma);
1667 if(gOPT.zl_style==
"marker") {
1668 out << sout << endl;
1671 if(i%2==0) {out << sout << endl; observed++;}
1695 if(gOPT.pfname==
"")
return;
1698 TString PFNAME = gOPT.pfname(0,gOPT.pfname.Last(
'.'));
1699 if(gOPT.bbh)
sprintf(ofname,
"%s_bbh_period.txt",PFNAME.Data());
1700 else sprintf(ofname,
"%s_nobbh_period.txt",PFNAME.Data());
1705 out.open(ofname,ios::out);
1706 if (!out.good()) {cout <<
"Error Opening Output File : " << ofname << endl;
exit(1);}
1707 cout <<
"Create Output File : " << ofname << endl;
1711 sprintf(sout,
"%*s %*s %*s %*s %*s %*s %*s %*s",
1712 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)");
1713 out << sout << endl;
1719 if(
n==0 && gOPT.run.Contains(
"O1")) RUN=
"O1";
1721 if(
n==1 && gOPT.run.Contains(
"O2")) RUN=
"O2";
1727 double interval = (end_date.GetGPS()-beg_date.GetGPS())/
DAY;
1729 TString sbeg_date = beg_date.GetDateString();sbeg_date.Resize(19);
1730 TString send_date = end_date.GetDateString();send_date.Resize(19);
1732 sbeg_date.ReplaceAll(
" ",
"-");
1733 send_date.ReplaceAll(
" ",
"-");
1735 sprintf(sout,
"%*s %*.0f %*s %*.0f %*s %*.2f %*d %*.1f", 4, RUN.Data(), 20, beg_date.GetGPS(), 20, sbeg_date.Data(),
1736 20, end_date.GetGPS(), 20, send_date.Data(), 20, interval, 20, obsTime[
n]/gOPT.trials, 20, obsTime[
n]/
DAY/gOPT.trials);
1737 out << sout << endl;
1745 if(gOPT.pfname==
"")
return;
1748 TString PFNAME = gOPT.pfname(0,gOPT.pfname.Last(
'.'));
1749 if(gOPT.bbh)
sprintf(ofname,
"%s_bbh_config.txt",PFNAME.Data());
1750 else sprintf(ofname,
"%s_nobbh_config.txt",PFNAME.Data());
1753 out.open(ofname,ios::out);
1754 if(!out.good()) {cout <<
"DumpUserOptions : Error Opening File : " << ofname << endl;
exit(1);}
1755 cout <<
"dump: " << ofname << endl;
1758 TString tabs=
"\t\t\t\t";
1762 sprintf(version,
"WAT Version : %s - SVN Revision : %s - Tag/Branch : %s",watversion(
'f'),watversion(
'r'),watversion(
'b'));
1767 char cwb_config_env[1024] =
"";
1768 if(gSystem->Getenv(
"CWB_CONFIG")!=NULL) {
1769 strcpy(cwb_config_env,TString(gSystem->Getenv(
"CWB_CONFIG")).Data());
1771 char cfg_version[256];
1772 TString cfg_branch = GetGitInfos(
"branch",cwb_config_env);
1773 TString cfg_tag = GetGitInfos(
"tag",cwb_config_env);
1774 TString cfg_diff = GetGitInfos(
"diff",cwb_config_env);
1775 if(cfg_branch!=
"") {
1776 if(cfg_diff!=
"") cfg_branch=cfg_branch+
"/M";
1777 sprintf(cfg_version,
"cWB Config Branch\t%s",cfg_branch.Data());
1778 }
else if(cfg_tag!=
"") {
1779 if(cfg_diff!=
"") cfg_branch=cfg_branch+
"/M";
1780 sprintf(cfg_version,
"cWB Config Tag\t%s",cfg_tag.Data());
1782 sprintf(cfg_version,
"cWB Config\t%s",
"Undefined");
1786 out <<
"--------------------------------" << endl;
1787 out <<
"PP IFAR version " << endl;
1788 out <<
"--------------------------------" << endl;
1790 out << version << endl;
1792 out<< cfg_version <<endl;
1793 out<<
"cWB Config Hash\t" << GetGitInfos(
"hash",cwb_config_env) <<endl;
1796 out <<
"--------------------------------" << endl;
1797 out <<
"PP IFAR config options " << endl;
1798 out <<
"--------------------------------" << endl;
1801 out <<
"pp_run " << gOPT.run << endl;
1802 info =
"// run type: allowed types are O1/O2/O1O2 (Default: O2)";
1803 out << tabs << info << endl << endl;
1805 out <<
"pp_search " << gOPT.search << endl;
1806 info =
"// search type: allowed types are BBH,BurstLF,BurstHF,BurstLD,IMBHB + bin1/bin2/... (Default: none)";
1807 out << tabs << info << endl << endl;
1809 out <<
"pp_nifo " << gOPT.nifo << endl;
1810 info =
"// number of detectors (Default: 2)";
1811 out << tabs << info << endl << endl;
1813 out <<
"pp_lag " << gOPT.lag << endl;
1814 info =
"// lag -> used only when the input file name is a root file (Default: -1)";
1815 out << tabs << info << endl << endl;
1817 out <<
"pp_slag " << gOPT.slag << endl;
1818 info =
"// slag -> used only when the input file name is a root file (Default: -1)";
1819 out << tabs << info << endl << endl;
1821 out <<
"pp_chunk " << gOPT.chunk << endl;
1822 info =
"// chunk -> used only when the input file name is a root file (Default: -1)";
1823 out << tabs << info << endl << endl;
1825 out <<
"pp_trials " << gOPT.trials << endl;
1826 info =
"// trials factor (Default: 1)";
1827 out << tabs << info << endl << endl;
1829 out <<
"pp_pfname " << gOPT.pfname << endl;
1830 info =
"// output plot file name, included the directory (Default: none)";
1831 out << tabs << info << endl << endl;
1833 out <<
"pp_zl_style " << gOPT.zl_style << endl;
1834 info =
"// zero lag plot style: step/marker -> zero lag is displayed with step/marker (Default: step)";
1835 out << tabs << info << endl << endl;
1837 out <<
"pp_belt_style " << gOPT.belt_style << endl;
1838 info =
"// belt plot style: step/continous -> belts are displayed with step/continuos poisson distribution (Default: continuos)";
1839 out << tabs << info << endl << endl;
1841 out <<
"pp_ifar_max " << gOPT.ifar_max << endl;
1842 info =
"// max ifar (year) used for plot, if =-1 then it is the maximum ifar from root files (Default: -1)";
1843 out << tabs << info << endl << endl;
1845 out <<
"pp_rho_min " << gOPT.rho_min << endl;
1846 info =
"// min rho[0/1] read from output root files (Default: 4.5)";
1847 out << tabs << info << endl << endl;
1849 out <<
"pp_sfactor " << gOPT.sfactor << endl;
1850 info =
"// factor used to normalize the simulation events for the computation of astrophysical rates (Default: 1)";
1851 out << tabs << info << endl << endl;
1853 out <<
"bbh " << gOPT.bbh << endl;
1854 info =
"// false/true -> if false the known bbh events are excluded from analysis (Default: false)";
1855 out << tabs << info << endl << endl;
1857 out <<
"exit " << gOPT.exit << endl;
1858 info =
"// false/true -> if true program exit ayt the end of the execution (Default: true)";
1859 out << tabs << info << endl << endl;
1861 out <<
"pp_gw151226_ifar " << gOPT.gw151226_ifar << endl;
1862 info =
"// GW151226 IFAR(YEARS): if > 0 the GW151226 event is added to the foreground (Default: 0, not added)";
1863 out << tabs << info << endl << endl;
1865 out <<
"pp_zl_max_ifar " << gOPT.zl_max_ifar << endl;
1866 info =
"// ZL_MAX_IFAR(YEARS): if > 0 all foreground with IFAR>zl_max_ifar is set to zl_max_ifar (Default: 0, not used)";
1867 out << tabs << info << endl << endl;
1874 if(gOPT.pfname==
"")
return;
1877 TString PFNAME = gOPT.pfname(0,gOPT.pfname.Last(
'.'));
1878 if(gOPT.bbh)
sprintf(ofname,
"%s_bbh_background.txt",PFNAME.Data());
1879 else sprintf(ofname,
"%s_nobbh_background.txt",PFNAME.Data());
1882 out.open(ofname,ios::out);
1883 if (!out.good()) {cout <<
"Error Opening Output File : " << ofname << endl;
exit(1);}
1884 cout <<
"Create Output File : " << ofname << endl;
1888 out <<
"#background data : ifar(years), expected, lower_sigma1, lower_sigma2, lower_sigma3, upper_sigma1, upper_sigma2, upper_sigma3" << endl;
1890 for(
int i=0;i<
xIFAR.size();i++) {
1892 double med =
bRATE[i];
1903 out <<
xIFAR[i] <<
" " << med
1904 <<
" " << l900 <<
" " << l990 <<
" " << l999
1905 <<
" " << u900 <<
" " << u990 <<
" " << u999
1915 if(gOPT.pfname==
"")
return;
1918 TString PFNAME = gOPT.pfname(0,gOPT.pfname.Last(
'.'));
1919 if(gOPT.bbh)
sprintf(ofname,
"%s_bbh_foreground.txt",PFNAME.Data());
1920 else sprintf(ofname,
"%s_nobbh_foreground.txt",PFNAME.Data());
1923 out.open(ofname,ios::out);
1924 if (!out.good()) {cout <<
"Error Opening Output File : " << ofname << endl;
exit(1);}
1925 cout <<
"Create Output File : " << ofname << endl;
1929 out <<
"#foreground data : ifar(years), observed" << endl;
1931 for(
int i=0;i<
ZL_NEVT.size();i++) {
1943 if(gOPT.pfname==
"")
return;
1947 TString PFNAME = gOPT.pfname(0,gOPT.pfname.Last(
'.'));
1948 if(gOPT.bbh)
sprintf(ofname,
"%s_bbh_simulation.txt",PFNAME.Data());
1949 else sprintf(ofname,
"%s_nobbh_simulation.txt",PFNAME.Data());
1952 out.open(ofname,ios::out);
1953 if (!out.good()) {cout <<
"Error Opening Output File : " << ofname << endl;
exit(1);}
1954 cout <<
"Create Output File : " << ofname << endl;
1958 out <<
"#simulation data : ifar(years), estimated+background, lower_90.0, upper_90.0" << endl;
1961 int ifar_cmax_index=0;
1964 for(
int i=0;i<ifar_cmax_index;i++) {
1971 out <<
SIM_IFAR[i] <<
" " << med <<
" " << l90 <<
" " << u90 << endl;
int GetPercentiles(double mu, double *q)
wavearray< double > ZL_GPS
void DumpLoudest(double obsTime)
int chunk_id[MAX_RUNS][CHUNK_MAX_SIZE]
vector< TString > O1_BBH_NAME
void DumpPeriod(double *obsTime)
wavearray< double > eySIM_BKG_sup0
int ReadChunkList(TString ifile, int *chunk=NULL, double *start=NULL, double *stop=NULL)
wavearray< double > ySIM_BKG
vector< double > O1_BBH_GPS
vector< TString > O2_BBH_NAME
int chunk[CHUNK_MAX_SIZE]
sprintf(tag,"wave_%s", data_label)
wavearray< double > eyRATEsup0
TString GetNameBBH(double gps)
void DumpSimulation(double ifar_cmax)
int GetChunkID(double gps, TString &run)
void Make_PP_IFAR(TString ifName, TString options)
wavearray< double > eyRATEinf1
int GetPoissonNsup(double mu, double fap)
TGraphAsymmErrors * egrsimbkg0
vector< double > O2_BBH_GPS
wavearray< double > eyRATEinf0
wavearray< double > eySIM_BKG_inf0
double chunk_start[MAX_RUNS][CHUNK_MAX_SIZE]
void GetLiveTime(int nwave, TChain **live, int *lag, int *slag, int *bin, TString *run, double *liveZero, double *liveTot)
wavearray< double > SIM_BKG_NEVT
int GetPoissonNinf(double mu, double fap)
wavearray< double > eyRATEsup1
wavearray< double > exSIM_BKG_IFAR
wavearray< double > eyRATEinf2
wavearray< double > SIM_NEVT
wavearray< double > SIM_IFAR
wavearray< double > ZL_IFAR
wavearray< double > exFAR
double GetGPSBBH(TString name)
void ReadUserOptions(TString options)
wavearray< double > xIFAR
wavearray< double > xSIM_BKG_IFAR
wavearray< double > ZL_NEVT
int ReadFileList(TString ifName, TChain **live, TChain **wave, TChain **mdc, int *lag, int *slag, int *chunk, int *bin, TString *run)
wavearray< double > eyRATEsup2
double chunk_stop[MAX_RUNS][CHUNK_MAX_SIZE]
void MakePlot(TString title, double obsTime, double ifar_cmax)
wavearray< double > bRATE