25 #pragma GCC system_header 33 #include "TObjArray.h" 34 #include "TObjString.h" 37 #include "TGraphAsymmErrors.h" 38 #include "TPaveStats.h" 86 #define PE_MAX_EVENTS 15000 88 #define PE_GW_NAME "GWXXYYZZ" 89 #define PE_DATA_LABEL "wave_" 90 #define PE_WAVE_DIR "output" 92 #define PE_NCYCLES 800 94 #define PE_GPS_EVENT 0 95 #define PE_TCOA_SHIFT 0. 96 #define PE_GPS_ERROR 0.01 97 #define PE_OFF_EVENT 0 98 #define PE_INJ_TIME_STEP 150 99 #define PE_INJ_ONSRC false 108 #define PE_DUMP_CR true 109 #define PE_USE_ONSRC "" 111 #define PE_PLOT_ONSRC false 113 #define PE_SYNC_PHASE false 114 #define PE_SYNC_TIME false 116 #define PE_SENSITIVITY false 117 #define PE_RESIDUALS false 118 #define PE_STATISTICS false 119 #define PE_EFRACTION 0.01 121 #define PE_SIDE "full" 122 #define PE_COVERAGE "local" 124 #define PE_PLOT_CR true 125 #define PE_PLOT_TYPE "time" 126 #define PE_PLOT_FNAME "pewave" 127 #define PE_PLOT_ODIR "" 128 #define PE_PLOT_EFRACTION 0.999 129 #define PE_PLOT_ZOOM 1.0 130 #define PE_PLOT_99PERC false 132 #define PE_MAKE_FF true 133 #define PE_MAKE_OF false 134 #define PE_MAKE_RE true 135 #define PE_MAKE_NE false 136 #define PE_MAKE_ONSRC false 189 double plot_efraction;
257 #define CCUT_WDM_FRES 16 // the WDM frequency resolution (Hz) used to decompose the signal in TF domain 258 #define CCUT_BCHIRP 1.35 // mchirp factor used to select the bottom region boundary 259 #define CCUT_UCHIRP 1.65 // mchirp factor used to select the upper region boundary 260 #define CCUT_LTIME 0.5 // left time from tcoa (sec) used to select the the time region: [tcoa-left_time:tcoa-right_time] 261 #define CCUT_RTIME 0.0 // right time from tcoa (sec) used to select the the time region: [tcoa-left_time:tcoa-right_time] 262 #define CCUT_FMAX 512.0 // hard coded init value for freq max used by the tchirp and fchirp functions 264 #define RCUT_WDM_FRES 8 // the WDM frequency resolution (Hz) used to decompose the signal in TF domain 265 #define RCUT_THR 0.95 // normalized residual energy threshold [0,1] 269 #define LOGL_ENABLED false // true/false -> enable/disable logl computation 270 #define LOGL_FLOW 0 // logl low frequency start 271 #define LOGL_FHIGH 8192 // logl high frequency stop 272 #define LOGL_ARTHR 0.001 // logl amplitude ratio threshold -> min_freq_amp vREC > max_freq_amp vREC 273 #define LOGL_IFO_MASK 0x1111111 // logl ifo mask used to select ifos for logl computation 274 #define LOGL_RESAMPLE 1 // logl resample, used to speedup logl computation. logl is computed every 'resample' samples 281 #define RSTAT_ENABLED false // true/false -> enable/disable rstat computation 282 #define RSTAT_TYPE "median" // rstat1/median 283 #define RSTAT_RTRIALS 0 // number of entries in the null hyphotesis distribution. If 0 then rtrials=gEVENTS 284 #define RSTAT_JTRIALS 0 // number of injections used to build the 'green' distribution. If 0 then jtrials=gEVENTS 290 std::vector<wavearray<double> >
vNUL;
291 std::vector<wavearray<double> >
vREC;
292 std::vector<wavearray<double> >
vINJ;
293 std::vector<wavearray<double> >
vAUX;
294 std::vector<wavearray<double> >
vMED;
295 std::vector<wavearray<double> >
vL50;
296 std::vector<wavearray<double> >
vU50;
297 std::vector<wavearray<double> >
vL90;
298 std::vector<wavearray<double> >
vU90;
299 std::vector<wavearray<double> >
vL99;
300 std::vector<wavearray<double> >
vU99;
302 std::vector<wavearray<double> >
pSNR;
303 std::vector<wavearray<double> >
pFRQ;
304 std::vector<wavearray<double> >
pTIM;
372 vector<double>& oFF, vector<double>& oOF, vector<double>& oRE);
385 void GetFullCoverage(
int nIFO,
int selected,
double* fcov50,
double* fcov90,
double* fcov99);
392 TString pdir,
double P,
double Q,
double tref,
double tcoa,
int ifoid);
411 cout <<
"cwb_pereport - Error : max nifo is 3" << endl;
414 if((gOPT.plot_type!=
"time")&&(gOPT.plot_type!=
"phase")&&(gOPT.plot_type!=
"envelope")&&(gOPT.plot_type!=
"frequency")&&(gOPT.plot_type!=
"spectrum")) {
415 cout <<
"cwb_pereport - Error : plot_type option (" << gOPT.plot_type <<
") not allowed. Available options are: time/phase/envelope/frequency/spectrum" << endl;
418 if((gOPT.coverage!=
"local")&&(gOPT.coverage!=
"full")) {
419 cout <<
"cwb_pereport - Error : coverage option (" << gOPT.coverage <<
") not allowed. Available options are: local/full" << endl;
430 LoadOutputRootFiles(gOPT.nifo, gOPT.data_label, gOPT.wave_dir, gOPT.nevents, gOPT.ifar_thr);
433 if(gOPT.side==
"ccut") {
434 int ccut_wdm_levels =
int(vREC[0].
rate()/gOPT.ccut_wdm_fres/2);
435 cout << endl <<
"RATE " << vREC[0].rate() <<
" WDM levels " << ccut_wdm_levels << endl << endl;
436 gWDM =
new WDM<double>(ccut_wdm_levels, ccut_wdm_levels, 6, 10);
438 if(gOPT.side==
"rcut") {
439 int rcut_wdm_levels =
int(vREC[0].
rate()/gOPT.rcut_wdm_fres/2);
440 cout << endl <<
"RATE " << vREC[0].rate() <<
" WDM levels " << rcut_wdm_levels << endl << endl;
441 gWDM =
new WDM<double>(rcut_wdm_levels, rcut_wdm_levels, 6, 10);
444 gStyle->SetTitleW(0.95);
447 if(gOPT.statistics) {
449 if(gOPT.side==
"ccut") {
451 if(selected==0)
exit(0);
453 gOPT.sensitivity=
false;
454 gOPT.make_onsrc=
false;
459 if(selected==0)
exit(0);
482 if(selected==0)
exit(0);
488 if(gOPT.dump_cr && gOPT.plot_type!=
"phase")
DumpWaveformCR(gOPT.nifo);
498 while(!vFF.empty()) vFF.pop_back(); vFF.clear(); std::vector<double>().swap(vFF);
499 while(!vOF.empty()) vOF.pop_back(); vOF.clear(); std::vector<double>().swap(vOF);
500 while(!vRE.empty()) vRE.pop_back(); vRE.clear(); std::vector<double>().swap(vRE);
502 while(!xFF.empty()) xFF.pop_back(); xFF.clear(); std::vector<double>().swap(xFF);
503 while(!xOF.empty()) xOF.pop_back(); xOF.clear(); std::vector<double>().swap(xOF);
504 while(!xRE.empty()) xRE.pop_back(); xRE.clear(); std::vector<double>().swap(xRE);
505 while(!xNE.empty()) xNE.pop_back(); xNE.clear(); std::vector<double>().swap(xNE);
507 if(gOPT.rstat_enabled==
false) {
514 cout << endl <<
"ComputeStatistics - selected events : " << selected << endl << endl;
515 if(selected==0)
return 0;
520 if(gOPT.side==
"right") {
523 double inj_tcoa = gOPT.inj_time_step+fmod(
vTCOA,1);
528 vector<double>
tstop;
529 if(gOPT.side==
"left") {
532 double inj_tcoa = gOPT.inj_time_step+fmod(
vTCOA,1);
546 vector<wavearray<double> >
vDAT =
vNUL;
for(
int n=0;
n<
nIFO;
n++) vDAT[
n]+=vREC[
n];
555 if(wREC[
i].
size()==0)
continue;
558 if(gOPT.side==
"right") {
561 double inj_tcoa = gOPT.inj_time_step+fmod(
wTCOA[
i],1);
566 vector<double>
tstop;
567 if(gOPT.side==
"left") {
570 double inj_tcoa = gOPT.inj_time_step+fmod(
wTCOA[
i],1);
587 vector<wavearray<double> >
vDAT = wNUL[
i];
for(
int n=0;
n<
nIFO;
n++) vDAT[
n]+=wREC[i][
n];
595 char ofname[256] =
"match_factors.txt";
597 cout <<
"write : " << fName << endl;
600 if (!out.good()) {cout <<
"Error Opening Output File : " << fName << endl;
exit(1);}
604 for(
int n=0;
n<vINJ.size();
n++)
for(
int i=0;
i<vINJ[
n].size();
i++) iSNR+=pow(vINJ[
n][
i],2);
605 for(
int n=0;
n<vREC.size();
n++)
for(
int i=0;i<vREC[
n].size();i++) oSNR+=pow(vREC[
n][i],2);
607 out <<
"tcoa " <<
vTCOA <<
"\tiSNR " << sqrt(iSNR) <<
"\toSNR " << sqrt(oSNR) <<
"\tfactor " <<
vFACTOR 608 <<
"\tff " << vFF[0] <<
"\tof " << vOF[0] <<
"\tre " << vRE[0] <<
"\tne " << vNE[0] << endl;
610 out <<
"tcoa " <<
vTCOA <<
"\tiSNR " << sqrt(iSNR) <<
"\toSNR " << sqrt(oSNR)
611 <<
"\tff " << vFF[0] <<
"\tof " << vOF[0] <<
"\tre " << vRE[0] << endl;
615 for(
int n=0;
n<wINJ[
j].size();
n++)
for(
int i=0;i<wINJ[
j][
n].size();i++) iSNR+=pow(wINJ[
j][
n][i],2);
616 for(
int n=0;
n<wREC[
j].size();
n++)
for(
int i=0;i<wREC[
j][
n].size();i++) oSNR+=pow(wREC[
j][
n][i],2);
618 out <<
"tcoa " <<
wTCOA[
j] <<
"\tiSNR " << sqrt(iSNR) <<
"\toSNR " << sqrt(oSNR) <<
"\tfactor " <<
wFACTOR[
j]
619 <<
"\tff " << vFF[
j+1] <<
"\tof " << vOF[
j+1] <<
"\tre " << vRE[
j+1] <<
"\tne " << vNE[
j+1] << endl;
621 out <<
"tcoa " <<
wTCOA[
j] <<
"\tiSNR " << sqrt(iSNR) <<
"\toSNR " << sqrt(oSNR)
622 <<
"\tff " << vFF[
j+1] <<
"\tof " << vOF[
j+1] <<
"\tre " << vRE[
j+1] << endl;
627 if(gOPT.make_onsrc || gOPT.use_onsrc!=
"") {
633 if(gOPT.use_onsrc!=
"") {
634 cout << endl <<
"GetOnSourceStatistic : " <<
"\tmFF = " << mFF <<
"\tmOF = " << mOF <<
"\tmRE = " << mRE << endl << endl;
639 for(
int n=0;
n<
nIFO;
n++) vINJ[
n]=wINJ[imed][
n];
649 if(gOPT.rstat_rtrials==0) {gOPT.rstat_rtrials=
gEVENTS;cout<<endl <<
"---> Set rstat_rtrials = " << gOPT.rstat_rtrials << endl<<endl;}
650 if(gOPT.rstat_jtrials==0) {gOPT.rstat_jtrials=
gEVENTS;cout<<endl <<
"---> Set rstat_jtrials = " << gOPT.rstat_jtrials << endl<<endl;}
656 std::map<int,bool> runique;
657 while(recId.size()<gOPT.rstat_rtrials) {
659 if(runique[k]==
false) {runique[
k]=
true;recId.push_back(k);}
664 std::map<int,bool> junique;
665 while(injId.size()<gOPT.rstat_jtrials) {
667 if(junique[k]==
false) {junique[
k]=
true;injId.push_back(k);}
671 int kEVENTS = gOPT.rstat_rtrials;
672 int pc = 0;
int npc= 0;
673 int ipc = double(kEVENTS)/10.;
if(ipc==0) ipc=1;
674 cout << endl <<
"Compute offsource distribution : be patient, it takes a while ..." << endl << endl;
675 vector<vector<double> > voFF,voOF,voRE;
676 for(
int k=0;
k<kEVENTS;
k++) {
677 if((npc++)%ipc==0) {
if(kEVENTS>10) {cout << pc<<
"%";
if (pc<100) cout <<
" - ";pc+=10;cout.flush();}}
678 vector<double> oFF,oOF,oRE;
684 if(pc==100) cout << pc<<
"%";;
685 cout << endl << endl;
693 if(gOPT.rstat_type==
"rstat1") {
694 for(
int k=0;
k<kEVENTS;
k++) {
695 int nTOT=0;
int nFF=0;
int nOF=0;
int nRE=0;
696 for(
int i=0;
i<kEVENTS;
i++) {
697 for(
int j=0;
j<gOPT.rstat_jtrials;
j++) {
699 if(voFF[
k][
j]>voFF[
i][
j]) nFF++;
700 if(voOF[
k][j]>voOF[
i][j]) nOF++;
701 if(voRE[
k][j]>voRE[
i][j]) nRE++;
705 vFF.push_back(
double(nFF)/
double(nTOT));
706 vOF.push_back(
double(nOF)/
double(nTOT));
707 vRE.push_back(
double(nRE)/
double(nTOT));
711 if(gOPT.rstat_type==
"median") {
715 int imed = (nentries*50.)/100.;
if(imed>=nentries) imed=nentries-1;
717 for(
int k=0;
k<kEVENTS;
k++) {
719 TMath::Sort(nentries,value,index,
false);
720 vFF.push_back(value[index[imed]]);
723 TMath::Sort(nentries,value,index,
false);
724 vOF.push_back(value[index[imed]]);
727 TMath::Sort(nentries,value,index,
false);
728 vRE.push_back(value[index[imed]]);
740 if(gOPT.rstat_type==
"rstat1") {
741 int nTOT=0;
int nFF=0;
int nOF=0;
int nRE=0;
742 for(
int i=0;
i<kEVENTS;
i++) {
743 for(
int j=0;
j<gOPT.rstat_jtrials;
j++) {
745 if(xFF[
j]>voFF[
i][
j]) nFF++;
746 if(xOF[j]>voOF[
i][j]) nOF++;
747 if(xRE[j]>voRE[
i][j]) nRE++;
751 vFF[0]=double(nFF)/double(nTOT);
752 vOF[0]=double(nOF)/double(nTOT);
753 vRE[0]=double(nRE)/double(nTOT);
755 gOPT.make_onsrc=
false;
758 if(gOPT.rstat_type==
"median") {
762 int imed = (nentries*50.)/100.;
if(imed>=nentries) imed=nentries-1;
765 TMath::Sort(nentries,value,index,
false);
766 vFF[0]=value[index[imed]];
769 TMath::Sort(nentries,value,index,
false);
770 vOF[0]=value[index[imed]];
773 TMath::Sort(nentries,value,index,
false);
774 vRE[0]=value[index[imed]];
788 if(gOPT.side!=
"ccut") {cout <<
"ComputeCCutStatistics Error: enabled only with gOPT.side=ccut" << endl;
exit(1);}
793 cout << endl <<
"ComputeCCutStatistics - selected events : " << selected << endl << endl;
794 if(selected==0)
return 0;
796 cout << endl <<
"Apply CCut : be patient, it takes a while ..." << endl << endl;
800 int ipc = double(nIFO*
gEVENTS)/10.;
if(ipc==0) ipc=1;
804 double inj_tcoa = gOPT.inj_time_step+fmod(
vTCOA,1)-vINJ[
n].start();
816 if((npc++)%ipc==0) {
if(gEVENTS>100) {cout << pc<<
"%";
if (pc<100) cout <<
" - ";pc+=10;cout.flush();}}
817 double inj_tcoa = gOPT.inj_time_step+fmod(
wTCOA[
i],1)-wINJ[
i][
n].start();
827 if(pc==100) cout << pc<<
"%";;
828 cout << endl << endl;
837 cout <<
"PlotWaveforms - Error : sample id exceed max number " <<
gEVENTS << endl;
849 if(
id<0) {wrec=vREC[
n];winj=vINJ[
n];tagid=
"onsource";}
850 else {wrec=wREC[
id][
n];winj=wINJ[
id][
n];tagid=TString::Format(
"sample %d",
id);}
853 if(gOPT.sync_phase || gOPT.sync_time) {
866 for(
int i=0;
i<wres.
size();
i++) wres[
i]-=winj[
i];
877 sprintf(gtitle,
"%s - %s - Residual(Red) - Reconstructed(Black) - Tcoa(Green) - (%s)",gOPT.gw_name.Data(),
gIFO[
n].Data(),tagid.Data());
879 sprintf(gtitle,
"%s - %s - Injected(Red) - Reconstructed(Black) - Tcoa(Green) - (%s)",gOPT.gw_name.Data(),
gIFO[
n].Data(),tagid.Data());
881 plot->
gtitle(gtitle,
"time(sec)",
"amplitude");
886 double tmax;
double amax=0;
892 plot->
graph[0]->GetHistogram()->GetXaxis()->SetRangeUser(bT,eT);
895 TString xtitle = TString::Format(
"Time (sec) : GPS OFFSET = %d",
int(vTREC[
n]));
896 plot->
graph[0]->GetHistogram()->GetXaxis()->SetTitle(xtitle.Data());
898 bool is_tcoa_defined=
false;
901 if(
vTCOA>=0) is_tcoa_defined=
true;
902 inj_tcoa = gOPT.inj_time_step+fmod(
vTCOA,1);
904 if(gOPT.sync_phase || gOPT.sync_time) {
908 if(
wTCOA[
id]>=0) is_tcoa_defined=
true;
909 inj_tcoa = gOPT.inj_time_step+fmod(
wTCOA[
id],1);
911 if(gOPT.sync_phase || gOPT.sync_time) {
918 double dt=1./wline.
rate();
919 for(
int i=0;i<wline.
size();i++) {
920 double time=i*dt+wline.
start();
921 if(
fabs(time-inj_tcoa)<dt) wline[
i]=-1.0;
else wline[
i]=-1000.;
927 gfile=
"x"+
gIFO[
n]+
"_rec_vs_res_"+tagid+
".png";
929 gfile=
"x"+
gIFO[
n]+
"_rec_vs_inj_"+tagid+
".png";
935 gfile=
"x"+
gIFO[
n]+
"_rec_vs_res_"+tagid+
".root";
937 gfile=
"x"+
gIFO[
n]+
"_rec_vs_inj_"+tagid+
".root";
942 cout <<
"created plot file name : " << gfile << endl;
951 cout << endl <<
"ComputeWaveformCR - selected events : " << selected << endl << endl;
952 if(selected==0)
return 0;
954 if(gOPT.logl_enabled && gOPT.plot_type==
"spectrum") {
955 cout << endl <<
"Compute log-likelihood : be patient, it takes a while ..." << endl << endl;
962 int ipc = double(nIFO*wREC[0][0].
size())/10.;
if(ipc==0) ipc=1;
964 float l90_dof,u90_dof;
965 if(gOPT.logl_enabled && gOPT.plot_type==
"spectrum") {
970 l90_dof =
wDOF[index[il90]];
971 u90_dof =
wDOF[index[iu90]];
983 wmed[
n] = wREC[0][
n]; wmed[
n] = 0;
984 wl50[
n] = wREC[0][
n]; wl50[
n] = 0;
985 wu50[
n] = wREC[0][
n]; wu50[
n] = 0;
986 wl90[
n] = wREC[0][
n]; wl90[
n] = 0;
987 wu90[
n] = wREC[0][
n]; wu90[
n] = 0;
988 wl99[
n] = wREC[0][
n]; wl99[
n] = 0;
989 wu99[
n] = wREC[0][
n]; wu99[
n] = 0;
994 for(
int j=0;
j<wREC[0][
n].size();
j++) {
1000 TMath::Sort(nentries,value,index,
false);
1002 int imed = (nentries*50.)/100.;
if(imed>=nentries) imed=nentries-1;
1003 wmed[
n][
j] = value[index[imed]];
1005 int il50 = (nentries*25.)/100.;
if(il50>=nentries) il50=nentries-1;
1006 int iu50 = (nentries*75.)/100.;
if(iu50>=nentries) iu50=nentries-1;
1007 int il90 = (nentries*5.)/100.;
if(il90>=nentries) il90=nentries-1;
1008 int iu90 = (nentries*95.)/100.;
if(iu90>=nentries) iu90=nentries-1;
1009 int il99 = (nentries*0.5)/100.;
if(il99>=nentries) il99=nentries-1;
1010 int iu99 = (nentries*99.5)/100.;
if(iu99>=nentries) iu99=nentries-1;
1012 double med = wmed[
n][
j];
1013 double l50 = value[index[il50]];
1014 double u50 = value[index[iu50]];
1015 double l90 = value[index[il90]];
1016 double u90 = value[index[iu90]];
1017 double l99 = value[index[il99]];
1018 double u99 = value[index[iu99]];
1021 if(!(l50<=u50)) check=
false;
1022 if(!(l90<=u90)) check=
false;
1023 if(!(l99<=u99)) check=
false;
1024 if(!(med>=l50 && med<=u50)) check=
false;
1025 if(!(med>=l90 && med<=u90)) check=
false;
1026 if(!(med>=l99 && med<=u99)) check=
false;
1027 if(!check) {cout <<
"ComputeWaveformCR : standard wrong median, lower, upper bound !!! " << l50 <<
" " << med <<
" " << u50 << endl;}
1028 if(!(med>=l50 && med<=u50)) med=l50;
1031 wl50[
n][
j] =
fabs(med-l50);
1032 wu50[
n][
j] =
fabs(u50-med);
1033 wl90[
n][
j] =
fabs(med-l90);
1034 wu90[
n][
j] =
fabs(u90-med);
1035 wl99[
n][
j] =
fabs(med-l99);
1036 wu99[
n][
j] =
fabs(u99-med);
1039 if(gOPT.logl_enabled && gOPT.plot_type==
"spectrum") {
1040 int ifo_mask=1<<4*
n;
1041 if(!(gOPT.logl_ifo_mask&ifo_mask))
continue;
1042 double freq =
j/vREC[
n].rate();
1043 if((
n*wREC[0][
n].
size()+
j)%ipc==0) {cout << pc<<
"%";
if (pc<100) cout <<
" - ";pc+=10;cout.flush();}
1044 if(vREC[
n][
j]/vREC[
n].max() < gOPT.logl_arthr)
continue;
1045 if(freq>gOPT.logl_flow && freq<gOPT.logl_fhigh &&
j%gOPT.logl_resample==0) {
1046 double xmin=value[index[0]];
1047 double xmax=value[index[nentries-1]];
1048 #ifdef LOGL_TEST_KDE 1049 cout <<
j <<
" freq = " << freq <<
" vREC = " << vREC[
n][
j] <<
" vREC[n][j]/vREC[n].max() = " << vREC[
n][
j]/vREC[
n].max() << endl;
1050 TCanvas* clogl = NULL;
1052 if(
j==LOGL_TEST_KDE) {
1053 clogl =
new TCanvas();
1054 double dbin = (u90-l90)/(nentries/40.);
1055 int nbins = (xmax-xmin)/dbin;
1056 hprob =
new TH1D(
"hprob",
"",nbins,xmin,xmax);
1058 hprob->SetLineColor(kBlue);
1060 hprob->Scale(1./hprob->Integral(),
"width" );
1064 TKDE * kde =
new TKDE(nentries, value, xmin, xmax,
"", rho);
1065 if(
j==LOGL_TEST_KDE) {
1067 kde->GetFunction()->SetLineColor(kRed);
1071 clogl->Print(
"prob_distr_for_logl.png");
1075 double prob = kde->GetValue(vREC[
n][
j]);
1077 if(hprob!=NULL)
delete hprob;
1078 if(clogl!=NULL)
delete clogl;
1083 TKDE * kde =
new TKDE(nentries, value, xmin, xmax,
"", rho);
1091 double prob = kde->GetValue(vREC[
n][j]);
1094 double dbin = (u90-l90)/(nentries/40.);
1095 int nbins = (xmax-xmin)/dbin;
1096 TH1D* hprob =
new TH1D(
"hprob",
"",nbins,xmin,xmax);
1099 hprob->Scale(1./hprob->Integral(),
"width" );
1100 int bin = hprob->FindBin(vREC[
n][j]);
1101 double prob = hprob->GetBinContent(bin);
1105 if(prob<(1./nentries))
continue;
1110 if(freq<fmin) fmin=
freq;
1111 if(freq>fmax) fmax=
freq;
1118 vMED.push_back(wmed[
n]);
1119 vL50.push_back(wl50[n]);
1120 vU50.push_back(wu50[n]);
1121 vL90.push_back(wl90[n]);
1122 vU90.push_back(wu90[n]);
1123 vL99.push_back(wl99[n]);
1124 vU99.push_back(wu99[n]);
1127 if(gOPT.logl_enabled && gOPT.plot_type==
"spectrum") {
1128 if(pc==100) cout << pc<<
"%";
1129 cout << endl << endl;
1131 logl = nlogl>0 ? logl/nlogl : 0;
1133 float l90_logl = l90_dof*logl/
vDOF;
1134 float u90_logl = u90_dof*logl/
vDOF;
1135 TString parm = TString::Format(
"log likelihood = %g [%g,%g] ( frequency bins = %d - DoF = %g [%g:%g]) fmin:fmax = %g:%g (Hz)",
1136 logl,l90_logl,u90_logl,
vDOF,l90_dof,u90_dof,nlogl,fmin,fmax);
1138 cout << parm << endl;
1143 double P = gOPT.plot_efraction;
1144 double estart, estop;
1151 if(bT<estart) estart=bT;
1152 if(eT>estop) estop=eT;
1156 cout <<
"estart=" << estart <<
"\testop=" << estop << endl;
1159 int nstart = (estart-vREC[0].start())*vREC[0].
rate();
1160 int nstop = (estop -vREC[0].start())*vREC[0].
rate();
1169 if(!wREC[
i][
n].
size())
continue;
1173 for(
int j=nstart;
j<nstop;
j++) {
1174 double vl50 = vMED[
n][
j]-
fabs(vL50[
n][
j]);
1175 double vu50 = vMED[
n][
j]+
fabs(vU50[
n][j]);
1176 double vl90 = vMED[
n][
j]-
fabs(vL90[
n][j]);
1177 double vu90 = vMED[
n][
j]+
fabs(vU90[
n][j]);
1178 double vl99 = vMED[
n][
j]-
fabs(vL99[
n][j]);
1179 double vu99 = vMED[
n][
j]+
fabs(vU99[
n][j]);
1182 if(value<vl50 || value>vu50) b50=
true;
1183 if(value<vl90 || value>vu90) b90=
true;
1184 if(value<vl99 || value>vu99) b99=
true;
1191 cout <<
"IFO " <<
gIFO[
n] <<
"\tEffective Coverage at 50% = " <<
int(100.-100.*n50/(
double)selected) << endl;
1192 cout <<
"IFO " <<
gIFO[
n] <<
"\tEffective Coverage at 90% = " <<
int(100.-100.*n90/(
double)selected) << endl;
1193 cout <<
"IFO " <<
gIFO[
n] <<
"\tEffective Coverage at 99% = " <<
int(100.-100.*n99/(
double)selected) << endl;
1202 if(ifar_thr<=0) ifar_thr=-1
e-10;
1206 char beginString[1024];
1208 char endString[1024];
1210 char containString[1024];
1211 sprintf(containString,
"%s",data_label.Data());
1216 for(
int i=0;i<nIFO;i++) sample_wREC[i] = new wavearray<double>;
1224 double* time =
new double[2*nIFO];
1225 float* sSNR =
new float[nIFO];
1226 int*
size =
new int[nIFO];
1234 string*
log =
new string;
1237 bool ifar_exists=
false;
1238 bool tcoa_exists=
false;
1239 bool vnul_exists=
false;
1240 bool vaux_exists=
false;
1244 int nfile = fileList.size();
1246 for(
int n=0;
n<nfile;
n++) {
1247 cout <<
n <<
" " << fileList[
n].Data() << endl;
1249 TFile*
froot =
new TFile(fileList[
n].Data(),
"READ");
1251 cout <<
"LoadOutputRootFiles - Error : Failed to open file : " << fileList[
n].Data() << endl;
1254 TTree*
itree = (TTree*)froot->Get(
"waveburst");
1256 cout <<
"LoadOutputRootFiles - Error : Failed to open tree waveburst from file : " << fileList[
n].Data() << endl;
1262 TIter ifar_next(itree->GetListOfBranches());
1263 while ((
branch=(TBranch*)ifar_next())) {
1264 if(
TString(
"ifar").CompareTo(
branch->GetName())==0) ifar_exists=
true;
1269 TIter tcoa_next(itree->GetListOfBranches());
1270 while ((
branch=(TBranch*)tcoa_next())) {
1271 if(
TString(
"wf_tcoa").CompareTo(
branch->GetName())==0) tcoa_exists=
true;
1277 TIter vnul_next(itree->GetListOfBranches());
1278 while ((
branch=(TBranch*)vnul_next())) {
1279 if(
TString(
"wNUL_0").CompareTo(
branch->GetName())==0) vnul_exists=
true;
1280 if(
TString(
"wAUX_0").CompareTo(
branch->GetName())==0) vaux_exists=
true;
1282 if(!vnul_exists) gOPT.residuals=
false;
1284 if(gOPT.side==
"rcut" && !vaux_exists) {
1285 cout <<
"LoadOutputRootFiles - Error : auxiliary injection do not exist!" << endl;
1286 cout <<
" with option side=rcut must be provided the auxiliary injections" << endl;
1290 for(
int k=0;
k<itree->GetEntries();
k++) {
1292 if(
k%100==0) cout <<
"ENTRY = " <<
k <<
" / " << itree->GetEntries() << endl;
1293 if(!(nevt<max_events || fileList[
n].Contains(
"job0.root")))
continue;
1296 itree->SetBranchAddress(
"ndim",&ndim);
1299 cout <<
"LoadOutputRootFiles - Error : number of ifos=" << ndim
1300 <<
" declared in the output root files is different from the user declared value " << nIFO << endl;
1301 cout << endl <<
"Use NIFO=" << ndim <<
" or check file; " << endl << endl << fileList[
n] << endl << endl;
1305 for(
int i=0;
i<
nIFO;
i++) itree->SetBranchAddress(TString::Format(
"wREC_%d",
i).Data(),&sample_wREC[
i]);
1306 if(gOPT.residuals) {
1307 for(
int i=0;
i<
nIFO;
i++) itree->SetBranchAddress(TString::Format(
"wNUL_%d",
i).Data(),&sample_wNUL[
i]);
1309 for(
int i=0;
i<
nIFO;
i++) itree->SetBranchAddress(TString::Format(
"wINJ_%d",
i).Data(),&sample_wINJ[
i]);
1310 if(gOPT.side==
"rcut") {
1311 for(
int i=0;
i<
nIFO;
i++) itree->SetBranchAddress(TString::Format(
"wAUX_%d",
i).Data(),&sample_wAUX[
i]);
1313 itree->SetBranchAddress(
"time",time);
1314 itree->SetBranchAddress(
"sSNR",sSNR);
1315 itree->SetBranchAddress(
"size",
size);
1316 itree->SetBranchAddress(
"norm",&norm);
1317 itree->SetBranchAddress(
"theta",
theta);
1318 itree->SetBranchAddress(
"phi",
phi);
1319 itree->SetBranchAddress(
"likelihood",&likelihood);
1320 itree->SetBranchAddress(
"factor",&
factor);
1321 itree->SetBranchAddress(
"log",&
log);
1322 if(ifar_exists) itree->SetBranchAddress(
"ifar",&ifar);
1323 if(tcoa_exists) itree->SetBranchAddress(
"wf_tcoa",&tcoa);
1324 else if(gOPT.side!=
"full") {
1325 cout << endl <<
"LoadOutputRootFiles - Error : wf_tcoa not found, side!=full requires tcoa" << endl << endl;
1331 ifar/=(24.*3600.*365.);
1333 bool onsource=
false;
1334 if(
fabs(gOPT.gps_event-time[0])<gOPT.gps_error) onsource=
true;
1335 if(!onsource && ifar<ifar_thr)
continue;
1341 if(sample_wREC[
i]==NULL) {
1342 cout <<
"LoadOutputRootFiles - Error : Object wavearray not exist !!! " << endl;
1349 tcoa+=gOPT.tcoa_shift;
1353 if(
fabs(gOPT.gps_event-time[0])<gOPT.gps_error && fileList[
n].Contains(
"_job0.root")) {
1370 for(
int i=0;i<
nIFO;i++) {
1371 if(gOPT.side==
"rcut") {
1373 sample_wAUX[
i]->start(fmod(sample_wAUX[i]->
start(),gOPT.inj_time_step));
1374 vAUX.push_back(*sample_wAUX[i]);
1377 sample_wINJ[
i]->start(fmod(sample_wINJ[i]->
start(),gOPT.inj_time_step));
1378 vINJ.push_back(*sample_wINJ[i]);
1379 vTREC[
i]=sample_wREC[
i]->
start();
1380 sample_wREC[
i]->
start(fmod(sample_wREC[i]->
start(),gOPT.inj_time_step));
1381 vREC.push_back(*sample_wREC[i]);
1382 if(gOPT.residuals) {
1383 sample_wNUL[
i]->
start(fmod(sample_wNUL[i]->
start(),gOPT.inj_time_step));
1384 vNUL.push_back(*sample_wNUL[i]);
1387 double toff = gOPT.inj_time_step-
int(fmod(gOPT.gps_event,gOPT.inj_time_step))-gOPT.off_event;
1388 cout <<
"EVENT FOUND @ GPS time -> " << time[0] <<
"\tSNR -> " << sqrt(likelihood) <<
"\tIFAR -> " << ifar <<
" yrs" <<
" toff -> " << toff << endl;
1390 cout <<
" File -> " << fileList[
n] << endl << endl;
1391 for(
int i=0;i<
nIFO;i++) vREC[i].
start(
int(vREC[i].
start()+toff)%gOPT.inj_time_step);
1392 for(
int i=0;i<
nIFO;i++) vINJ[i].
start(
int(vINJ[i].
start()+toff)%gOPT.inj_time_step);
1393 if(gOPT.residuals) {
1394 for(
int i=0;i<
nIFO;i++) vNUL[i].
start(
int(vNUL[i].
start()+toff)%gOPT.inj_time_step);
1396 if(gOPT.side==
"rcut") {
1397 for(
int i=0;i<
nIFO;i++) vAUX[i].
start(
int(vAUX[i].
start()+toff)%gOPT.inj_time_step);
1401 TList* ifoList = itree->GetUserInfo();
1403 for (
int i=0;i<ifoList->GetSize();i++) {
1424 for(
int i=0;i<
nIFO;i++) {
1426 if(gOPT.inj_onsrc) {
1427 toff = gOPT.inj_time_step-
int(fmod(gOPT.gps_event,gOPT.inj_time_step))-gOPT.off_event;
1429 sample_wREC[
i]->
start(fmod(sample_wREC[i]->
start()+toff,gOPT.inj_time_step));
1430 wREC[
gEVENTS].push_back(*sample_wREC[i]);
1431 sample_wINJ[
i]->start(fmod(sample_wINJ[i]->
start()+toff,gOPT.inj_time_step));
1432 wINJ[
gEVENTS].push_back(*sample_wINJ[i]);
1433 if(gOPT.residuals) {
1434 sample_wNUL[
i]->
start(fmod(sample_wNUL[i]->
start()+toff,gOPT.inj_time_step));
1435 wNUL[
gEVENTS].push_back(*sample_wNUL[i]);
1437 if(gOPT.side==
"rcut") {
1438 sample_wAUX[
i]->start(fmod(sample_wAUX[i]->
start()+toff,gOPT.inj_time_step));
1439 wAUX[
gEVENTS].push_back(*sample_wAUX[i]);
1446 cout <<
"LoadOutputRootFiles - Warning : Number of events > PE_MAX_EVENTS !!! " <<
PE_MAX_EVENTS << endl;
1456 if(vREC.size()!=nIFO || vINJ.size()!=
nIFO) {
1457 cout <<
"LoadOutputRootFiles - Error : Number of OnSource Events = " << vREC.size()/nIFO <<
" -> must be 1" << endl;
1458 cout <<
" check the onsrc links in the ofsrc merge directory " << endl;
1459 cout <<
" check the onsrc event time " << endl;
1464 cout <<
"LoadOutputRootFiles - Error : Found 0 OffSource Events !!! " << endl;
1470 cout <<
"LoadOutputRootFiles - Error : GPS EVENT NOT FOUND !!! " << endl;
1472 cout <<
"Possible reasons:" << endl;
1474 cout <<
"1) The root file with EVENT has not been included" << endl;
1475 cout <<
"2) gps_error is too rectrictive, current value is " << gOPT.gps_error <<
" , try a new value with option --gps_error=... " << endl;
1480 double toffset = wREC[0][0].start()-vREC[0].start();
1483 cout <<
"LoadOutputRootFiles - Warning : detected event and posterios have a possible inconsistent GPS time" << endl;
1484 cout <<
" check the detected event root file" << endl;
1485 cout <<
" try --off_event=" << gOPT.off_event-toffset << endl;
1490 for(
int i=0;
i<
nIFO;
i++)
delete sample_wREC[
i];
1491 if(gOPT.residuals)
for(
int i=0;
i<
nIFO;
i++)
delete sample_wNUL[
i];
1492 if(gOPT.side==
"rcut")
for(
int i=0;
i<
nIFO;
i++)
delete sample_wAUX[
i];
1493 if(gOPT.statistics)
for(
int i=0;
i<
nIFO;
i++)
delete sample_wINJ[
i];
1502 TString ifar_thr_label = TString::Format(
"%g",gOPT.ifar_thr).ReplaceAll(
".",
"d");
1503 TString ncycles_label = TString::Format(
"%d",gOPT.ncycles);
1506 type_label +=
"ifar_"+ifar_thr_label;
1507 if(gOPT.plot_type==
"phase") type_label+=
"_Phase";
1508 if(gOPT.plot_type==
"time") type_label+=
"_Time";
1509 if(gOPT.plot_type==
"envelope") type_label+=
"_Envelope";
1510 if(gOPT.plot_type==
"frequency") type_label+=
"_Frequency";
1511 if(gOPT.plot_type==
"spectrum") type_label+=
"_Spectrum";
1514 char title[256];
char ofname[256];
1516 if(gOPT.plot_99perc) {
1517 sprintf(title,
"%s (ifar=%sy) : cWB REC (red) - Errors (entries=%d) : med (black) : 50% (dark_grey) : 90% (medium gray) : 99% (light_gray)",
1520 sprintf(title,
"%s (ifar=%sy) : cWB REC (red) - Errors (entries=%d) : med (black) : 50% (dark_grey) : 90% (light gray)",
1524 int K = (gOPT.plot_type==
"spectrum" || gOPT.plot_type==
"phase") ? 1 : 3;
1525 for(
int k=0;
k<
K;
k++) {
1528 tcoa = tcoa-vTREC[
n]+vREC[
n].start();
1529 if(gOPT.sync_phase || gOPT.sync_time) {
1534 if(gOPT.plot_type==
"time" || gOPT.plot_type==
"envelope" || gOPT.plot_type==
"frequency") {
1539 double tref = (tcoa>tmax) ? tcoa : tmax;
1542 if(
k==0) {P=0.65/gOPT.plot_zoom;
if(P>1) P=1; zoom = TString::Format(
"C%d",
int(P*100));}
1543 if(
k==1) {P=0.85/gOPT.plot_zoom;
if(P>1) P=1; zoom = TString::Format(
"B%d",
int(P*100));}
1544 if(
k==2) {P=0.99/gOPT.plot_zoom;
if(P>1) P=1; zoom = TString::Format(
"A%d",
int(P*100));}
1545 double Q=P+0.5*(1-P);
1546 if(gOPT.plot_type==
"spectrum" || gOPT.plot_type==
"phase") zoom=
"A";
1547 sprintf(ofname,
"%s_%s_%s_%s.%s",
gIFO[n].Data(),gOPT.plot_fname.Data(), type_label.Data(), zoom.Data(),
"png");
1548 if(gOPT.residuals) {
1549 PlotWaveformAsymmErrors(ofname, title, vNUL[n], vMED[n], vL50[n], vU50[n], vL90[n], vU90[n], vL99[n], vU99[n], vNUL[n], pdir, P, Q, tref, tcoa, n);
1551 PlotWaveformAsymmErrors(ofname, title, vREC[n], vMED[n], vL50[n], vU50[n], vL90[n], vU90[n], vL99[n], vU99[n], vREC[n], pdir, P, Q, tref, tcoa, n);
1561 TString pdir,
double P,
double Q,
double tref,
double tcoa,
int ifoid) {
1564 if(gOPT.plot_type==
"time") {
1580 if(gOPT.plot_type==
"spectrum") {
1582 }
else if(gOPT.plot_type==
"phase") {
1589 if(gOPT.plot_type==
"phase") xtitle =
"Phase (cycles)";
1590 if(gOPT.plot_type==
"envelope") xtitle = TString::Format(
"Time Envelope (sec) : GPS OFFSET = %d",
int(gOPT.gps_event-gOPT.inj_time_step));
1591 if(gOPT.plot_type==
"time") xtitle = TString::Format(
"Time (sec) : GPS OFFSET = %d",
int(gOPT.gps_event-gOPT.inj_time_step));
1592 if(gOPT.plot_type==
"frequency") xtitle = TString::Format(
"Time Frequency (sec) : GPS OFFSET = %d",
int(gOPT.gps_event-gOPT.inj_time_step));
1593 if(gOPT.plot_type==
"spectrum") xtitle =
"Frequency (Hz)";
1596 egr99->SetLineColor(18);
1597 egr99->SetFillStyle(1001);
1598 egr99->SetFillColor(18);
1599 egr99->GetXaxis()->SetTitle(xtitle);
1600 if(gOPT.plot_type==
"phase") egr99->GetYaxis()->SetTitle(
"degrees");
1601 if(gOPT.plot_type==
"envelope") egr99->GetYaxis()->SetTitle(
"magnitude");
1602 if(gOPT.plot_type==
"time") egr99->GetYaxis()->SetTitle(
"magnitude");
1603 if(gOPT.plot_type==
"frequency") egr99->GetYaxis()->SetTitle(
"Hz");
1604 if(gOPT.plot_type==
"spectrum") egr99->GetYaxis()->SetTitle(
"magnitude");
1605 egr99->SetTitle(title);
1606 egr99->GetXaxis()->SetTitleFont(42);
1607 egr99->GetXaxis()->SetLabelFont(42);
1608 egr99->GetXaxis()->SetLabelOffset(0.012);
1609 egr99->GetXaxis()->SetTitleOffset(1.5);
1610 egr99->GetYaxis()->SetTitleFont(42);
1611 egr99->GetYaxis()->SetLabelFont(42);
1612 egr99->GetYaxis()->SetLabelOffset(0.01);
1613 egr99->GetYaxis()->SetTitleOffset(1.4);
1616 egr90->SetLineColor(17);
1617 egr90->SetFillStyle(1001);
1618 egr90->SetFillColor(17);
1619 egr90->GetXaxis()->SetTitle(xtitle);
1620 if(gOPT.plot_type==
"phase") egr90->GetYaxis()->SetTitle(
"degrees");
1621 if(gOPT.plot_type==
"envelope") egr90->GetYaxis()->SetTitle(
"magnitude");
1622 if(gOPT.plot_type==
"time") egr90->GetYaxis()->SetTitle(
"magnitude");
1623 if(gOPT.plot_type==
"frequency") egr90->GetYaxis()->SetTitle(
"Hz");
1624 if(gOPT.plot_type==
"spectrum") egr90->GetYaxis()->SetTitle(
"magnitude");
1625 egr90->SetTitle(title);
1626 egr90->GetXaxis()->SetTitleFont(42);
1627 egr90->GetXaxis()->SetLabelFont(42);
1628 egr90->GetXaxis()->SetLabelOffset(0.012);
1629 egr90->GetXaxis()->SetTitleOffset(1.5);
1630 egr90->GetYaxis()->SetTitleFont(42);
1631 egr90->GetYaxis()->SetLabelFont(42);
1632 egr90->GetYaxis()->SetLabelOffset(0.01);
1633 egr90->GetYaxis()->SetTitleOffset(1.4);
1636 egr50->SetLineColor(15);
1637 egr50->SetFillStyle(1001);
1638 egr50->SetFillColor(15);
1640 TGraph* agr =
new TGraph(size,x.
data,wmed.
data);
1641 agr->SetLineWidth(1);
1642 agr->SetLineColor(kBlack);
1643 agr->SetLineStyle(1);
1645 TGraph*
gr =
new TGraph(size,x.
data,wrec.
data);
1646 gr->SetLineWidth(1);
1647 gr->SetLineColor(2);
1649 TCanvas*
canvas =
new TCanvas(
"wave_pe_cwb",
"wave_pe_cwb",200,20,800,500);
1653 if(gOPT.plot_type==
"spectrum") {
1658 if(gOPT.plot_type==
"time" || gOPT.plot_type==
"envelope" || gOPT.plot_type==
"frequency") {
1662 if(gOPT.plot_99perc) egr99->GetXaxis()->SetRangeUser(bT, eT);
1663 else egr90->GetXaxis()->SetRangeUser(bT, eT);
1665 if(gOPT.plot_type==
"spectrum") {
1666 if(gOPT.plot_99perc) egr99->GetYaxis()->SetRangeUser(1
e-3, 1.5 * egr99->GetHistogram()->GetMaximum());
1667 else egr90->GetYaxis()->SetRangeUser(1
e-3, 1.5 * egr90->GetHistogram()->GetMaximum());
1668 if(gOPT.plot_99perc) egr99->GetXaxis()->SetRangeUser(20, wrec.
size()/wrec.
rate());
1669 else egr90->GetXaxis()->SetRangeUser(20, wrec.
size()/wrec.
rate());
1672 if(gOPT.plot_99perc) {
1674 egr90->Draw(
"3same");
1678 egr50->Draw(
"3same");
1683 TGraph* grline = NULL;
1684 if(gOPT.plot_type==
"time" || gOPT.plot_type==
"envelope" || gOPT.plot_type==
"frequency") {
1686 double dt=1./wline.
rate();
1688 for(
int i=0;
i<wline.
size();
i++) {
1689 double time=
i*dt+wline.
start();
1690 if(
fabs(time-tcoa)<dt && !bline) {
1691 if(gOPT.plot_type==
"time") wline[
i]=-1.0;
1692 if(gOPT.plot_type==
"envelope") wline[
i]= 0.0;
1693 if(gOPT.plot_type==
"frequency") wline[
i]= 0.0;
1695 }
else wline[
i]=-1000.;
1697 grline =
new TGraph(size,x.
data,wline.
data);
1698 grline->SetLineWidth(1);
1699 grline->SetLineColor(kGreen);
1700 grline->Draw(
"Lsame");
1703 TGraph* grpfrq = NULL;
1704 TGraph* grpsnr = NULL;
1705 if(gOPT.plot_type==
"phase") {
1707 grpsnr =
new TGraph(x.
size(),x.
data,pSNR[ifoid].data);
1708 grpsnr->SetLineWidth(1);
1709 grpsnr->SetLineColor(kBlue);
1710 grpsnr->Draw(
"Lsame");
1712 grpfrq =
new TGraph(x.
size(),x.
data,pFRQ[ifoid].data);
1713 grpfrq->SetLineWidth(1);
1714 grpfrq->SetLineColor(kGreen);
1715 grpfrq->Draw(
"Lsame");
1717 if(gOPT.plot_99perc) egr99->GetXaxis()->SetRangeUser(0, gOPT.ncycles);
1718 else egr90->GetXaxis()->SetRangeUser(0, gOPT.ncycles);
1719 if(gOPT.plot_99perc) egr99->GetYaxis()->SetRangeUser(-180, 180);
1720 else egr90->GetYaxis()->SetRangeUser(-180, 180);
1725 canvas->Print(pfname);
1726 cout <<
"write : " << pfname << endl;
1727 pfname.ReplaceAll(
".png",
".root");
1728 canvas->Print(pfname);
1729 cout <<
"write : " << pfname << endl;
1735 if(gOPT.plot_99perc)
delete egr99;
1738 if(grline!=NULL)
delete grline;
1739 if(grpfrq!=NULL)
delete grpfrq;
1740 if(grpsnr!=NULL)
delete grpsnr;
1751 for(
int j=0;
j<token->GetEntries();
j++) {
1753 TObjString* tok = (TObjString*)token->At(
j);
1754 TString stok = tok->GetString();
1755 stok.ReplaceAll(
" ",
"");
1756 stok.ReplaceAll(
" ",
"");
1758 if(stok.Contains(
"dump_cr=")) {
1760 pe_dump_cr.Remove(0,pe_dump_cr.Last(
'=')+1);
1761 if(pe_dump_cr==
"true") gOPT.dump_cr=
true;
1762 if(pe_dump_cr==
"false") gOPT.dump_cr=
false;
1765 if(stok.Contains(
"use_onsrc=")) {
1767 pe_use_onsrc.Remove(0,pe_use_onsrc.Last(
'=')+1);
1768 if(pe_use_onsrc!=
"mfull" && pe_use_onsrc!=
"mleft" && pe_use_onsrc!=
"efull" && pe_use_onsrc!=
"eleft") pe_use_onsrc=
"";
1769 gOPT.use_onsrc=pe_use_onsrc;
1772 if(stok.Contains(
"sync_phase=")) {
1774 pe_sync_phase.Remove(0,pe_sync_phase.Last(
'=')+1);
1775 if(pe_sync_phase==
"true") gOPT.sync_phase=
true;
1776 if(pe_sync_phase==
"false") gOPT.sync_phase=
false;
1779 if(stok.Contains(
"sync_time=")) {
1781 pe_sync_time.Remove(0,pe_sync_time.Last(
'=')+1);
1782 if(pe_sync_time==
"true") gOPT.sync_time=
true;
1783 if(pe_sync_time==
"false") gOPT.sync_time=
false;
1786 if(stok.Contains(
"sensitivity=")) {
1788 pe_sensitivity.Remove(0,pe_sensitivity.Last(
'=')+1);
1789 if(pe_sensitivity==
"true") gOPT.sensitivity=
true;
1790 if(pe_sensitivity==
"false") gOPT.sensitivity=
false;
1793 if(stok.Contains(
"residuals=")) {
1795 pe_residuals.Remove(0,pe_residuals.Last(
'=')+1);
1796 if(pe_residuals==
"true") gOPT.residuals=
true;
1797 if(pe_residuals==
"false") gOPT.residuals=
false;
1800 if(stok.Contains(
"statistics=")) {
1802 pe_statistics.Remove(0,pe_statistics.Last(
'=')+1);
1803 if(pe_statistics==
"true") gOPT.statistics=
true;
1804 if(pe_statistics==
"false") gOPT.statistics=
false;
1807 if(stok.Contains(
"plot_cr=")) {
1809 pe_plot_cr.Remove(0,pe_plot_cr.Last(
'=')+1);
1810 if(pe_plot_cr==
"true") gOPT.plot_cr=
true;
1811 if(pe_plot_cr==
"false") gOPT.plot_cr=
false;
1814 if(stok.Contains(
"plot_99perc=")) {
1816 pe_plot_99perc.Remove(0,pe_plot_99perc.Last(
'=')+1);
1817 if(pe_plot_99perc==
"true") gOPT.plot_99perc=
true;
1818 if(pe_plot_99perc==
"false") gOPT.plot_99perc=
false;
1821 if(stok.Contains(
"make_ff=")) {
1823 pe_make_ff.Remove(0,pe_make_ff.Last(
'=')+1);
1824 if(pe_make_ff==
"true") gOPT.make_ff=
true;
1825 if(pe_make_ff==
"false") gOPT.make_ff=
false;
1828 if(stok.Contains(
"efraction=")) {
1830 pe_efraction.Remove(0,pe_efraction.Last(
'=')+1);
1831 if(pe_efraction.IsFloat()) gOPT.efraction=pe_efraction.Atof();
1834 if(stok.Contains(
"side=")) {
1836 pe_side.Remove(0,pe_side.Last(
'=')+1);
1840 if(stok.Contains(
"coverage=")) {
1842 pe_coverage.Remove(0,pe_coverage.Last(
'=')+1);
1843 gOPT.coverage=pe_coverage;
1846 if(stok.Contains(
"make_of=")) {
1848 pe_make_of.Remove(0,pe_make_of.Last(
'=')+1);
1849 if(pe_make_of==
"true") gOPT.make_of=
true;
1850 if(pe_make_of==
"false") gOPT.make_of=
false;
1853 if(stok.Contains(
"make_re=")) {
1855 pe_make_re.Remove(0,pe_make_re.Last(
'=')+1);
1856 if(pe_make_re==
"true") gOPT.make_re=
true;
1857 if(pe_make_re==
"false") gOPT.make_re=
false;
1860 if(stok.Contains(
"make_ne=")) {
1862 pe_make_ne.Remove(0,pe_make_ne.Last(
'=')+1);
1863 if(pe_make_ne==
"true") gOPT.make_ne=
true;
1864 if(pe_make_ne==
"false") gOPT.make_ne=
false;
1867 if(stok.Contains(
"make_onsrc=")) {
1869 pe_make_onsrc.Remove(0,pe_make_onsrc.Last(
'=')+1);
1870 if(pe_make_onsrc==
"true") gOPT.make_onsrc=
true;
1871 if(pe_make_onsrc==
"false") gOPT.make_onsrc=
false;
1874 if(stok.Contains(
"gw_name=")) {
1876 pe_gw_name.Remove(0,pe_gw_name.Last(
'=')+1);
1877 gOPT.gw_name=pe_gw_name;
1880 if(stok.Contains(
"data_label=")) {
1882 pe_data_label.Remove(0,pe_data_label.Last(
'=')+1);
1883 gOPT.data_label=pe_data_label;
1886 if(stok.Contains(
"wave_dir=")) {
1888 pe_wave_dir.Remove(0,pe_wave_dir.Last(
'=')+1);
1889 gOPT.wave_dir=pe_wave_dir;
1892 if(stok.Contains(
"nifo=")) {
1894 pe_nifo.Remove(0,pe_nifo.Last(
'=')+1);
1895 if(pe_nifo.IsDigit()) gOPT.nifo=pe_nifo.Atoi();
1898 if(stok.Contains(
"nevents=")) {
1900 pe_nevents.Remove(0,pe_nevents.Last(
'=')+1);
1901 if(pe_nevents.IsDigit()) gOPT.nevents=pe_nevents.Atoi();
1904 if(stok.Contains(
"ncycles=")) {
1906 pe_ncycles.Remove(0,pe_ncycles.Last(
'=')+1);
1907 if(pe_ncycles.IsDigit()) gOPT.ncycles=pe_ncycles.Atoi();
1910 if(stok.Contains(
"ifar_thr=")) {
1912 pe_ifar_thr.Remove(0,pe_ifar_thr.Last(
'=')+1);
1913 if(pe_ifar_thr.IsFloat()) gOPT.ifar_thr=pe_ifar_thr.Atof();
1916 if(stok.Contains(
"gps_event=")) {
1918 pe_gps_event.Remove(0,pe_gps_event.Last(
'=')+1);
1919 if(pe_gps_event.IsFloat()) gOPT.gps_event=pe_gps_event.Atof();
1922 if(stok.Contains(
"tcoa_shift=")) {
1924 pe_tcoa_shift.Remove(0,pe_tcoa_shift.Last(
'=')+1);
1925 if(pe_tcoa_shift.IsFloat()) gOPT.tcoa_shift=pe_tcoa_shift.Atof();
1928 if(stok.Contains(
"gps_error=")) {
1930 pe_gps_error.Remove(0,pe_gps_error.Last(
'=')+1);
1931 if(pe_gps_error.IsFloat()) gOPT.gps_error=pe_gps_error.Atof();
1934 if(stok.Contains(
"off_event=")) {
1936 pe_off_event.Remove(0,pe_off_event.Last(
'=')+1);
1937 if(pe_off_event.IsFloat()) gOPT.off_event=pe_off_event.Atoi();
1940 if(stok.Contains(
"inj_time_step=")) {
1941 TString pe_inj_time_step=stok;
1942 pe_inj_time_step.Remove(0,pe_inj_time_step.Last(
'=')+1);
1943 if(pe_inj_time_step.IsDigit()) {
1944 gOPT.inj_time_step=pe_inj_time_step.Atoi();
1945 if(gOPT.inj_time_step<=0) {
1947 gOPT.inj_onsrc=
true;
1951 cout <<
"cwb_report - Error : input parameter inj_time_step=" << pe_inj_time_step <<
" is not an integer !!! " << endl;
1957 if(stok.Contains(
"ccut=")) {
1959 pe_ccut.Remove(0,pe_ccut.Last(
'=')+1);
1964 if(stok.Contains(
"rcut=")) {
1966 pe_rcut.Remove(0,pe_rcut.Last(
'=')+1);
1971 if(stok.Contains(
"logl=")) {
1973 pe_logl.Remove(0,pe_logl.Last(
'=')+1);
1978 if(stok.Contains(
"rstat=")) {
1980 pe_rstat.Remove(0,pe_rstat.Last(
'=')+1);
1981 gOPT.rstat=pe_rstat;
1985 if(stok.Contains(
"plot_fname=")) {
1987 pe_plot_fname.Remove(0,pe_plot_fname.Last(
'=')+1);
1988 gOPT.plot_fname=pe_plot_fname;
1991 if(stok.Contains(
"plot_odir=")) {
1993 pe_plot_odir.Remove(0,pe_plot_odir.Last(
'=')+1);
1994 gOPT.plot_odir=pe_plot_odir;
1997 if(stok.Contains(
"plot_type=")) {
1999 pe_plot_type.Remove(0,pe_plot_type.Last(
'=')+1);
2000 gOPT.plot_type=pe_plot_type;
2003 if(stok.Contains(
"plot_efraction=")) {
2004 TString pe_plot_efraction=stok;
2005 pe_plot_efraction.Remove(0,pe_plot_efraction.Last(
'=')+1);
2006 if(pe_plot_efraction.IsFloat()) gOPT.plot_efraction=pe_plot_efraction.Atof();
2009 if(stok.Contains(
"plot_zoom=")) {
2011 pe_plot_zoom.Remove(0,pe_plot_zoom.Last(
'=')+1);
2012 if(pe_plot_zoom.IsFloat()) gOPT.plot_zoom=pe_plot_zoom.Atof();
2013 if(gOPT.plot_zoom<=0) gOPT.plot_zoom=1.;
2065 std::streambuf *old = NULL;
2066 std::stringstream buffer;
2068 old = std::cout.rdbuf(buffer.rdbuf());
2073 TString sync_phase = gOPT.sync_phase ?
"true":
"false";
2074 TString sync_time = gOPT.sync_time ?
"true":
"false";
2075 TString sensitivity = gOPT.sensitivity ?
"true":
"false";
2076 TString residuals = gOPT.residuals ?
"true":
"false";
2077 TString statistics = gOPT.statistics ?
"true":
"false";
2078 TString plot_cr = gOPT.plot_cr ?
"true":
"false";
2079 TString plot_99perc = gOPT.plot_99perc ?
"true":
"false";
2080 TString make_ff = gOPT.make_ff ?
"true":
"false";
2081 TString make_of = gOPT.make_of ?
"true":
"false";
2082 TString make_re = gOPT.make_re ?
"true":
"false";
2083 TString make_ne = gOPT.make_ne ?
"true":
"false";
2084 TString make_onsrc = gOPT.make_onsrc ?
"true":
"false";
2085 TString logl_enabled = gOPT.logl_enabled ?
"true":
"false";
2086 TString rstat_enabled = gOPT.rstat_enabled ?
"true":
"false";
2090 cout <<
"-----------------------------------------" << endl;
2091 cout <<
"cwb_pereport config options " << endl;
2093 cout <<
"UTC - "; cout.flush();
2095 cout <<
"-----------------------------------------" << endl << endl;
2097 cout <<
"PE_GW_NAME " << gOPT.gw_name << endl;
2098 cout <<
"PE_DATA_LABEL " << gOPT.data_label << endl;
2099 cout <<
"PE_WAVE_DIR " << gOPT.wave_dir << endl;
2100 cout <<
"PE_NIFO " << gOPT.nifo << endl;
2101 cout <<
"PE_NEVENTS " << gOPT.nevents << endl;
2102 cout <<
"PE_NCYCLES " << gOPT.ncycles << endl;
2103 cout <<
"PE_IFAR_THR " << gOPT.ifar_thr << endl;
2104 cout <<
"PE_GPS_EVENT " << std::setprecision(14) << gOPT.gps_event << std::setprecision(6) << endl;
2105 cout <<
"PE_TCOA_SHIFT " << gOPT.tcoa_shift << endl;
2106 cout <<
"PE_GPS_ERROR " << gOPT.gps_error << endl;
2107 cout <<
"PE_OFF_EVENT " << gOPT.off_event << endl;
2108 cout <<
"PE_INJ_TIME_STEP " << gOPT.inj_time_step << endl;
2109 cout <<
"PE_INJ_ONSRC " << gOPT.inj_onsrc << endl;
2110 cout <<
"PE_CCUT " << gOPT.ccut << endl;
2111 cout <<
"PE_RCUT " << gOPT.rcut << endl;
2112 cout <<
"PE_LOGL " << gOPT.logl << endl;
2113 cout <<
"PE_RSTAT " << gOPT.rstat << endl;
2114 cout <<
"PE_DUMP_CR " << gOPT.dump_cr << endl;
2115 cout <<
"PE_USE_ONSRC " << gOPT.use_onsrc << endl;
2116 cout <<
"PE_SYNC_PHASE " << sync_phase << endl;
2117 cout <<
"PE_SYNC_TIME " << sync_time << endl;
2118 cout <<
"PE_SENSITIVITY " << sensitivity << endl;
2119 cout <<
"PE_RESIDUALS " << residuals << endl;
2120 cout <<
"PE_STATISTICS " << statistics << endl;
2121 cout <<
"PE_EFRACTION " << gOPT.efraction << endl;
2122 cout <<
"PE_SIDE " << gOPT.side << endl;
2123 cout <<
"PE_COVERAGE " << gOPT.coverage << endl;
2124 cout <<
"PE_PLOT_FNAME " << gOPT.plot_fname << endl;
2125 cout <<
"PE_PLOT_ODIR " << gOPT.plot_odir << endl;
2126 cout <<
"PE_PLOT_TYPE " << gOPT.plot_type << endl;
2127 cout <<
"PE_PLOT_EFRACTION " << gOPT.plot_efraction << endl;
2128 cout <<
"PE_PLOT_ZOOM " << gOPT.plot_zoom << endl;
2129 cout <<
"PE_PLOT_CR " << plot_cr << endl;
2130 cout <<
"PE_PLOT_99PERC " << plot_99perc << endl;
2131 cout <<
"PE_MAKE_FF " << make_ff << endl;
2132 cout <<
"PE_MAKE_OF " << make_of << endl;
2133 cout <<
"PE_MAKE_RE " << make_re << endl;
2134 cout <<
"PE_MAKE_NE " << make_ne << endl;
2135 cout <<
"PE_MAKE_ONSRC " << make_onsrc << endl;
2139 cout <<
"CCUT_WDM_FRES " << gOPT.ccut_wdm_fres << endl;
2140 cout <<
"CCUT_BCHIRP " << gOPT.ccut_bchirp << endl;
2141 cout <<
"CCUT_UCHIRP " << gOPT.ccut_uchirp << endl;
2142 cout <<
"CCUT_LTIME " << gOPT.ccut_ltime << endl;
2143 cout <<
"CCUT_RTIME " << gOPT.ccut_rtime << endl;
2144 cout <<
"CCUT_FMAX " << gOPT.ccut_fmax << endl;
2148 cout <<
"RCUT_WDM_FRES " << gOPT.rcut_wdm_fres << endl;
2149 cout <<
"RCUT_THR " << gOPT.rcut_thr << endl;
2153 cout <<
"LOGL_ENABLED " << logl_enabled << endl;
2154 cout <<
"LOGL_FLOW " << gOPT.logl_flow << endl;
2155 cout <<
"LOGL_FHIGH " << gOPT.logl_fhigh << endl;
2156 cout <<
"LOGL_ARTHR " << gOPT.logl_arthr << endl;
2157 cout <<
"LOGL_IFO_MASK " <<
"0x" << std::hex << gOPT.logl_ifo_mask << std::dec << endl;
2158 cout <<
"LOGL_RESAMPLE " << gOPT.logl_resample << endl;
2162 cout <<
"RSTAT_ENABLED " << rstat_enabled << endl;
2163 cout <<
"RSTAT_TYPE " << gOPT.rstat_type << endl;
2164 cout <<
"RSTAT_RTRIALS " << gOPT.rstat_rtrials << endl;
2165 cout <<
"RSTAT_JTRIALS " << gOPT.rstat_jtrials << endl;
2171 std::cout.rdbuf(old);
2176 out << buffer.str() << endl;
2188 sprintf(ofname,
"%s_%s_cr.txt",
gIFO[
n].Data(),gOPT.plot_fname.Data());
2192 if (!out.good()) {cout <<
"Error Opening Output File : " << ofname << endl;
exit(1);}
2193 cout <<
"Create Output File : " << ofname << endl;
2197 if(gOPT.plot_type==
"time" || gOPT.plot_type==
"envelope") {
2198 out <<
"#whitened data : time, amp_cwb_rec, " 2199 <<
"amp_post_median, amp_post_lower_50_cr, amp_post_lower_90_cr, amp_post_upper_50_cr, amp_post_upper_90_cr" << endl;
2200 }
else if(gOPT.plot_type==
"spectrum") {
2201 out <<
"#whitened data : frequency, amp_cwb_rec, " 2202 <<
"amp_post_median, amp_post_lower_50_cr, amp_post_lower_90_cr, amp_post_upper_50_cr, amp_post_upper_90_cr" << endl;
2203 }
else if(gOPT.plot_type==
"phase") {
2204 out <<
"#whitened data : cycles, amp_cwb_rec, " 2205 <<
"amp_post_median, amp_post_lower_50_cr, amp_post_lower_90_cr, amp_post_upper_50_cr, amp_post_upper_90_cr" << endl;
2209 int size = vREC[
n].size();
2210 double dx=1./vREC[
n].rate();
2213 if(gOPT.plot_type==
"time" || gOPT.plot_type==
"envelope") x+=vTREC[
n];
2214 double vl50 = vMED[
n][
i]-
fabs(vL50[
n][
i]);
2215 double vu50 = vMED[
n][
i]+
fabs(vU50[
n][i]);
2216 double vl90 = vMED[
n][
i]-
fabs(vL90[
n][i]);
2217 double vu90 = vMED[
n][
i]+
fabs(vU90[
n][i]);
2220 <<
" " << vREC[
n][
i] <<
" " << vMED[
n][
i]
2221 <<
" " << vl50 <<
" " << vl90 <<
" " << vu50 <<
" " << vu90
2229 sprintf(ofname,
"%s_cr.root",gOPT.plot_fname.Data());
2230 TFile *
froot =
new TFile(ofname,
"RECREATE");
2232 cout <<
"Failed to create file !!! " << ofname << endl;
2237 double tREC = vREC[
n].start();
2238 double tMED = vMED[
n].start();
2239 double tL50 = vL50[
n].start();
2240 double tL90 = vL90[
n].start();
2241 double tL99 = vL99[
n].start();
2242 double tU50 = vU50[
n].start();
2243 double tU90 = vU90[
n].start();
2244 double tU99 = vU99[
n].start();
2246 if(gOPT.plot_type==
"time" || gOPT.plot_type==
"envelope") {
2248 vREC[
n].start(vTREC[
n]);
2249 vMED[
n].start(vTREC[n]);
2250 vL50[
n].start(vTREC[n]);
2251 vL90[
n].start(vTREC[n]);
2252 vL99[
n].start(vTREC[n]);
2253 vU50[
n].start(vTREC[n]);
2254 vU90[
n].start(vTREC[n]);
2255 vU99[
n].start(vTREC[n]);
2259 vREC[
n].Write(TString::Format(
"REC_%s",
gIFO[
n].Data()));
2260 vMED[
n].Write(TString::Format(
"MED_%s",
gIFO[
n].Data()));
2261 vL50[
n].Write(TString::Format(
"L50_%s",
gIFO[
n].Data()));
2262 vL90[
n].Write(TString::Format(
"L90_%s",
gIFO[
n].Data()));
2263 vL99[
n].Write(TString::Format(
"L99_%s",
gIFO[
n].Data()));
2264 vU50[
n].Write(TString::Format(
"U50_%s",
gIFO[
n].Data()));
2265 vU90[
n].Write(TString::Format(
"U90_%s",
gIFO[
n].Data()));
2266 vU99[
n].Write(TString::Format(
"U99_%s",
gIFO[
n].Data()));
2269 vREC[
n].start(tREC);
2270 vMED[
n].start(tMED);
2271 vL50[
n].start(tL50);
2272 vL90[
n].start(tL90);
2273 vL99[
n].start(tL99);
2274 vU50[
n].start(tU50);
2275 vU90[
n].start(tU90);
2276 vU99[
n].start(tU99);
2283 if(type!=
"FF" && type!=
"OF" && type!=
"RE" && type!=
"NE") {
2284 cout <<
"MakeDistributions - Error : plot type not available, must be FF/OF/RE/NE" << endl;
2288 TCanvas* cmf =
new TCanvas(
"MatchingFactor",
"MatchingFactor", 200, 20, 1000, 600);
2289 cmf->SetLogx(
false);
2291 cmf->SetGridx(
true);
2292 cmf->SetGridy(
true);
2294 gStyle->SetOptStat(
"emrou");
2295 gStyle->SetStatFont(63);
2296 gStyle->SetStatFontSize(12);
2297 gStyle->SetStatW(0.15);
2298 gStyle->SetStatH(0.12);
2303 for(
int i=0;
i<vFF.size();
i++) {
2304 if(vFF[
i]<xmin) xmin=vFF[
i];
2305 if(vFF[
i]>xmax) xmax=vFF[
i];
2312 for(
int i=0;
i<vOF.size();
i++) {
2313 if(vOF[
i]<xmin) xmin=vOF[
i];
2314 if(vOF[
i]>xmax) xmax=vOF[
i];
2319 for(
int i=0;
i<vRE.size();
i++) {
2320 if(vRE[
i]<xmin) xmin=vRE[
i];
2321 if(vRE[
i]>xmax) xmax=vRE[
i]+0.1*xmax;
2326 if(xmax>6*xmean) xmax=6*xmean;
2327 if(xmax<vRE[0]) xmax=2*vRE[0];
2330 for(
int i=0;
i<vNE.size();
i++) {
2331 if(vNE[
i]<xmin) xmin=vNE[
i];
2332 if(vNE[
i]>xmax) xmax=vNE[
i]+0.1*xmax;
2337 TH1F* xhist =
new TH1F(
"xhist",
"xhist",100,xmin,xmax);
2339 xhist->SetLineWidth(2);
2340 xhist->SetLineColor(kGreen+2);
2341 for(
int i=1;
i<xFF.size();
i++) {
2342 if(type==
"FF") xhist->Fill(xFF[
i]);
2343 if(type==
"OF") xhist->Fill(xOF[i]);
2344 if(type==
"RE") xhist->Fill(xRE[i]);
2345 if(type==
"NE") xhist->Fill(xNE[i]);
2353 TH1F*
hist =
new TH1F(
"hist",
"hist",100,xmin,xmax);
2355 if(type==
"FF")
for(
int i=1;
i<vFF.size();
i++) hist->Fill(vFF[
i]);
2356 if(type==
"OF")
for(
int i=1;i<vOF.size();i++) hist->Fill(vOF[i]);
2357 if(type==
"RE")
for(
int i=1;i<vRE.size();i++) hist->Fill(vRE[i]);
2358 if(type==
"NE")
for(
int i=1;i<vNE.size();i++) hist->Fill(vNE[i]);
2361 for(
int i=1;i<vFF.size();i++) {
2362 if(type==
"FF") {nTOT++;
if(vFF[i]<vFF[0]) nFF++;}
2363 if(type==
"OF") {nTOT++;
if(vOF[i]<vOF[0]) nOF++;}
2364 if(type==
"RE") {nTOT++;
if(vRE[i]>vRE[0]) nRE++;}
2365 if(type==
"NE") {nTOT++;
if(vNE[i]>vNE[0]) nNE++;}
2368 double pvalueFF = double(nFF)/double(nTOT);
2369 double pvalueOF = double(nOF)/double(nTOT);
2370 double pvalueRE = double(nRE)/double(nTOT);
2371 double pvalueNE = double(nNE)/double(nTOT);
2374 if(type==
"FF") cout <<
"pvalue FF=" << pvalueFF << endl;
2375 if(type==
"OF") cout <<
"pvalue OF=" << pvalueOF << endl;
2376 if(type==
"RE") cout <<
"pvalue RE=" << pvalueRE << endl;
2377 if(type==
"NE") cout <<
"pvalue NE=" << pvalueNE << endl;
2380 hist->SetLineWidth(2);
2383 cmf->Modified(); cmf->Update();
2384 TPaveStats *sthist = (TPaveStats*)hist->FindObject(
"stats");
2385 sthist->SetTextColor(kBlack);
2386 sthist->SetLineColor(kBlack);
2387 if(gOPT.make_onsrc) {
2388 sthist->SetTextColor(kBlue);
2389 xhist->Draw(
"SAMES");
2390 cmf->Modified(); cmf->Update();
2391 TPaveStats *stxhist = (TPaveStats*)xhist->FindObject(
"stats");
2392 stxhist->SetTextColor(kGreen+2);
2393 stxhist->SetLineColor(kBlack);
2394 stxhist->SetY2NDC(.68);
2395 stxhist->SetOptStat(1110);
2397 float yhmax = hist->GetMaximum()>xhist->GetMaximum() ? hist->GetMaximum() : xhist->GetMaximum();
2398 hist->GetYaxis()->SetRangeUser(0.9,1.1*yhmax);
2399 hist->GetYaxis()->SetNdivisions(3);
2401 double mean = hist->GetMean();
2402 double rms = hist->GetRMS();
2409 if(type==
"FF") value[
i]=vFF[i+1];
2410 if(type==
"OF") value[
i]=vOF[i+1];
2411 if(type==
"RE") value[
i]=vRE[i+1];
2412 if(type==
"NE") value[
i]=vNE[i+1];
2414 TMath::Sort(nentries,value,index,
false);
2416 int imed = (nentries*50.)/100.;
if(imed>=nentries) imed=nentries-1;
2417 int il50 = (nentries*25.)/100.;
if(il50>=nentries) il50=nentries-1;
2418 int iu50 = (nentries*75.)/100.;
if(iu50>=nentries) iu50=nentries-1;
2419 int il90 = (nentries*5.)/100.;
if(il90>=nentries) il90=nentries-1;
2420 int iu90 = (nentries*95.)/100.;
if(iu90>=nentries) iu90=nentries-1;
2421 int il99 = (nentries*0.5)/100.;
if(il99>=nentries) il99=nentries-1;
2422 int iu99 = (nentries*99.5)/100.;
if(iu99>=nentries) iu99=nentries-1;
2424 int iu100 = nentries-1;
2426 double med = value[index[imed]];
2427 double l50 = value[index[il50]];
2428 double u50 = value[index[iu50]];
2429 double l90 = value[index[il90]];
2430 double u90 = value[index[iu90]];
2431 double l99 = value[index[il99]];
2432 double u99 = value[index[iu99]];
2433 double l100 = value[index[il100]];
2434 double u100 = value[index[iu100]];
2437 if(type==
"FF") match=vFF[0];
2438 if(type==
"OF") match=vOF[0];
2439 if(type==
"RE") match=vRE[0];
2440 if(type==
"NE") match=vNE[0];
2443 if(type==
"FF") pvalue=pvalueFF;
2444 if(type==
"OF") pvalue=pvalueOF;
2445 if(type==
"RE") pvalue=pvalueRE;
2446 if(type==
"NE") pvalue=pvalueNE;
2449 if(type==
"FF") xtitle=
"Fitting Factor";
2450 if(type==
"OF") xtitle=
"Overlap Factor";
2451 if(type==
"RE") xtitle=
"Residual Energy";
2452 if(type==
"NE") xtitle=
"Null Energy";
2454 hist->GetXaxis()->SetTitle(xtitle);
2455 hist->GetXaxis()->SetTitleOffset(1.4);
2456 hist->GetXaxis()->SetLabelOffset(0.02);
2457 hist->GetXaxis()->SetNoExponent();
2459 hist->GetYaxis()->SetTitle(
"counts");
2460 hist->GetYaxis()->SetTitleOffset(1.6);
2461 hist->GetYaxis()->SetLabelOffset(0.02);
2462 hist->GetYaxis()->SetNoExponent();
2463 if(gOPT.rstat_enabled) hist->GetXaxis()->SetTitle(
"R statistic");
2465 if(gOPT.rstat_enabled) {
2466 sprintf(htitle,
"%s %s (%s) - on-source (red - R-stat=%0.4f, pvalue=%0.4f) vs off-source (blue)",
2467 gOPT.gw_name.Data(),xtitle.Data(),gOPT.side.Data(),match,pvalue);
2469 sprintf(htitle,
"%s %s (%s) - cWB (red - %s=%0.4f, pvalue=%0.4f) vs off-source (blue)",
2470 gOPT.gw_name.Data(),xtitle.Data(),gOPT.side.Data(),type.Data(),match,pvalue);
2472 hist->SetTitle(htitle);
2473 hist->SetName(
"Statistic");
2476 float ymax = hist->GetMaximum();
2478 if(type==
"FF") xval=vFF[0];
2479 if(type==
"OF") xval=vOF[0];
2480 if(type==
"RE") xval=vRE[0];
2481 if(type==
"NE") xval=vNE[0];
2482 TLine *
line =
new TLine(xval,0,xval,ymax);
2483 line->SetLineWidth(2);
2484 line->SetLineColor(kRed);
2494 xtitle.ReplaceAll(
" ",
"");
2496 sprintf(ofname,
"%s_%s.png",gOPT.plot_fname.Data(),xtitle.Data());
2499 cout <<
"write : " << fName << endl;
2500 fName.ReplaceAll(
".png",
".root");
2502 cout <<
"write : " << fName << endl;
2506 fName.ReplaceAll(
".root",
".txt");
2507 TString params = TString::Format(
"%s : %s %0.4f pvalue %0.4f median %0.4f l99 %0.4f l90 %0.4f l50 %0.4f u50 %0.4f u90 %0.4f u99 %0.4f",
2508 gOPT.gw_name.Data(),xtitle.Data(),match,pvalue,med,l99,l90,l50,u50,u90,u99);
2511 if(gOPT.side==
"ccut") {
2512 params = TString::Format(
"%s : %s %0.4f pvalue %0.4f ccut_wdm_fres %d ccut_bchirp %0.4f ccut_uchirp %0.4f ccut_ltime %0.4f ccut_rtime %0.4f",
2513 gOPT.gw_name.Data(),xtitle.Data(),match,pvalue,gOPT.ccut_wdm_fres,gOPT.ccut_bchirp,gOPT.ccut_uchirp,gOPT.ccut_ltime,gOPT.ccut_rtime);
2517 if(gOPT.side==
"ccut") {
2518 DumpStatistics(
"pestat_ccut.lst",
"id\tpvalue\tresidual",
false);
2519 for(
int n=0;
n<vFF.size();
n++) {
2520 int nRE=0;
for(
int i=1;i<vFF.size();i++)
if(vRE[i]>vRE[
n]) nRE++;
2521 double pvalueRE = nRE/(double)(vRE.size()-1);
2522 TString parm = TString::Format(
"%d\t%.6f\t%.6f",n,pvalueRE,vRE[n]);
2530 fName=sfName;fName.ReplaceAll(
".txt",
"_statistic.txt");
2532 TString parm = TString::Format(
"%f",value[index[i]]);
2539 int fmed =
wFACTOR[index[imed]];
2540 int fl50 =
wFACTOR[index[il50]];
2541 int fu50 =
wFACTOR[index[iu50]];
2542 int fl90 =
wFACTOR[index[il90]];
2543 int fu90 =
wFACTOR[index[iu90]];
2544 int fl99 =
wFACTOR[index[il99]];
2545 int fu99 =
wFACTOR[index[iu99]];
2546 int fl100 =
wFACTOR[index[il100]];
2547 int fu100 =
wFACTOR[index[iu100]];
2548 fName=sfName;fName.ReplaceAll(
".txt",
"_factor.txt");
2549 TString params = TString::Format(
"%s : %s %0.4f pvalue %0.4f median %d l100 %d l99 %d l90 %d l50 %d u50 %d u90 %d u99 %d u100 %d",
2550 gOPT.gw_name.Data(),xtitle.Data(),match,pvalue,fmed,fl100,fl99,fl90,fl50,fu50,fu90,fu99,fu100);
2554 if(gOPT.sensitivity) {
2556 double dphase50,dtime50,damp50;
2557 double dphase90,dtime90,damp90;
2559 double dff_phase,dff_time,dff_amp;
2562 printf(
"\n\n------> FF Phase Sensitivity (l50=%.2f - u50=%.2f) = %.4f\n\n",l50,u50,dff_phase);
2565 printf(
"\n\n------> FF Time Sensitivity (l50=%.2f - u50=%.2f) = %.4f\n\n",l50,u50,dff_time);
2568 printf(
"\n\n------> FF Amp Sensitivity (l50=%.2f - u50=%.2f) = %.4f\n\n",l50,u50,dff_amp);
2569 params = TString::Format(
"%s : %s\tdff_phase\t%0.4f\tdff_time\t%0.4f\tdff_amp\t%0.4f\tdphase50\t%0.4f\tdtime50\t%0.5f\tdamp50\t%0.4f\tdphase90\t%0.4f\tdtime90\t%0.5f\tdamp90\t%0.4f",
2570 gOPT.gw_name.Data(),xtitle.Data(),dff_phase,dff_time,dff_amp,dphase50,dtime50,damp50,dphase90,dtime90,damp90);
2573 double dof_phase,dof_time,dof_amp;
2576 printf(
"\n\n------> OF Phase Sensitivity (l50=%.2f - u50=%.2f) = %.4f\n\n",l50,u50,dof_phase);
2579 printf(
"\n\n------> OF Time Sensitivity (l50=%.2f - u50=%.2f) = %.4f\n\n",l50,u50,dof_time);
2582 printf(
"\n\n------> OF Amp Sensitivity (l50=%.2f - u50=%.2f) = %.4f\n\n",l50,u50,dof_amp);
2583 params = TString::Format(
"%s : %s\tdof_phase\t%0.4f\tdof_time\t%0.4f\tdof_amp\t%0.4f\tdphase50\t%0.4f\tdtime50\t%0.5f\tdamp50\t%0.4f\tdphase90\t%0.4f\tdtime90\t%0.5f\tdamp90\t%0.4f",
2584 gOPT.gw_name.Data(),xtitle.Data(),dof_phase,dof_time,dof_amp,dphase50,dtime50,damp50,dphase90,dtime90,damp90);
2587 double dre_phase,dre_time,dre_amp;
2590 printf(
"\n\n------> RE Phase Sensitivity (l50=%.2f - u50=%.2f) = %.4f\n\n",l50,u50,dre_phase);
2593 printf(
"\n\n------> RE Time Sensitivity (l50=%.2f - u50=%.2f) = %.4f\n\n",l50,u50,dre_time);
2596 printf(
"\n\n------> RE Amp Sensitivity (l50=%.2f - u50=%.2f) = %.4f\n\n",l50,u50,dre_amp);
2597 params = TString::Format(
"%s : %s\tdre_phase\t%0.4f\tdre_time\t%0.4f\tdre_amp\t%0.4f\tdphase50\t%0.4f\tdtime50\t%0.5f\tdamp50\t%0.4f\tdphase90\t%0.4f\tdtime90\t%0.5f\tdamp90\t%0.4f",
2598 gOPT.gw_name.Data(),xtitle.Data(),dre_phase,dre_time,dre_amp,dphase50,dtime50,damp50,dphase90,dtime90,damp90);
2602 fName=sfName;fName.ReplaceAll(
".txt",
"_sensitivity.txt");
2608 if(gOPT.make_onsrc) {
2609 int xnentries=xFF.size();
2610 int* xindex =
new int[xnentries];
2611 float* xvalue =
new float[xnentries];
2612 for(
int i=0;i<xnentries;i++) {
2613 if(type==
"FF") xvalue[
i]=xFF[
i];
2614 if(type==
"OF") xvalue[
i]=xOF[
i];
2615 if(type==
"RE") xvalue[
i]=xRE[
i];
2616 if(type==
"NE") xvalue[
i]=xNE[
i];
2618 TMath::Sort(xnentries,xvalue,xindex,
false);
2619 int ixl50 = (xnentries*25.)/100.;
if(ixl50>=xnentries) ixl50=xnentries-1;
2620 int ixu50 = (xnentries*75.)/100.;
if(ixu50>=xnentries) ixu50=xnentries-1;
2621 int ixl90 = (xnentries*5.)/100.;
if(ixl90>=xnentries) ixl90=xnentries-1;
2622 int ixu90 = (xnentries*95.)/100.;
if(ixu90>=xnentries) ixu90=xnentries-1;
2623 int ixl99 = (xnentries*0.5)/100.;
if(ixl99>=xnentries) ixl99=xnentries-1;
2624 int ixu99 = (xnentries*99.5)/100.;
if(ixu99>=xnentries) ixu99=xnentries-1;
2625 double xl50 = xvalue[xindex[ixl50]];
2626 double xu50 = xvalue[xindex[ixu50]];
2627 double xl90 = xvalue[xindex[ixl90]];
2628 double xu90 = xvalue[xindex[ixu90]];
2629 double xl99 = xvalue[xindex[il99]];
2630 double xu99 = xvalue[xindex[ixu99]];
2632 int bxl50 = hist->FindBin(xl50);
2633 int bxu50 = hist->FindBin(xu50);
2634 int bxl90 = hist->FindBin(xl90);
2635 int bxu90 = hist->FindBin(xu90);
2636 int bxl99 = hist->FindBin(xl99);
2637 int bxu99 = hist->FindBin(xu99);
2638 hist->Scale(1./hist->Integral());
2640 for(
int i=bxl50;i<=bxu50;i++) prob50+=hist->GetBinContent(i);
2642 for(
int i=bxl90;i<=bxu90;i++) prob90+=hist->GetBinContent(i);
2644 for(
int i=bxl99;i<=bxu99;i++) prob99+=hist->GetBinContent(i);
2646 fName=sfName;fName.ReplaceAll(
".txt",
"_onsource_prob.txt");
2647 params = TString::Format(
"%s : prob50 %0.4f prob90 %0.4f prob99 %0.4f",
2648 gOPT.gw_name.Data(),prob50,prob90,prob99);
2650 cout << endl << xtitle <<
" on-source probability -> " << params << endl << endl;
2653 fName=sfName;fName.ReplaceAll(
".txt",
"_onsource_statistic.txt");
2654 for(
int i=0;i<xnentries;i++) {
2655 TString parm = TString::Format(
"%f",xvalue[xindex[i]]);
2690 double tdelay = MDC.
GetDelay(ifo,
"",phi,theta);
2691 double ifo_tcoa = geocentric_tcoa+tdelay;
2701 double tdelay = MDC.
GetDelay(ifo,
"",phi,theta);
2710 if(app) out.open(ofname.Data(),ios::app);
2711 else out.open(ofname.Data(),
ios::out);
2713 out << params.Data() << endl;
2720 if((match!=
"ff")&&(match!=
"of")&&(match!=
"re")) {dmatch=dphase=0.;
return;}
2722 vector<wavearray<double> > xINJ =
vINJ;
2725 lfound=ufound=
false;
2726 double lphase,uphase;
2729 for(
int i=0;
i<180;
i++) {
2730 if(lfound&&ufound)
continue;
2733 if(match==
"ff" || match==
"of") {
2734 if((!ufound)&&(value>upper)) uphase=
i+1;
else ufound=
true;
2735 if((!lfound)&&(value>lower)) lphase=
i+1;
else lfound=
true;
2737 if((!ufound)&&(value<upper)) uphase=
i+1;
else ufound=
true;
2738 if((!lfound)&&(value<lower)) lphase=
i+1;
else lfound=
true;
2742 dmatch = (uphase!=lphase) ? (upper-lower)/(uphase-lphase) : 0;
2743 dmatch/=(upper+lower)/2.;
2744 dmatch=
fabs(dmatch);
2745 dphase=
fabs(uphase-lphase);
2751 if((match!=
"ff")&&(match!=
"of")&&(match!=
"re")) {dmatch=dtime=0.;
return;}
2753 vector<wavearray<double> > xINJ =
vINJ;
2758 lfound=ufound=
false;
2762 for(
int i=0;
i<10000;
i++) {
2763 if(lfound&&ufound)
continue;
2767 if(match==
"ff" || match==
"of") {
2768 if((!ufound)&&(value>upper)) utime=
t;
else ufound=
true;
2769 if((!lfound)&&(value>lower)) ltime=
t;
else lfound=
true;
2771 if((!ufound)&&(value<upper)) utime=
t;
else ufound=
true;
2772 if((!lfound)&&(value<lower)) ltime=
t;
else lfound=
true;
2776 dmatch = (utime!=ltime) ? (upper-lower)/(utime-ltime) : 0;
2777 dmatch/=(upper+lower)/2.;
2778 dmatch=
fabs(dmatch);
2779 dtime=
fabs(utime-ltime);
2785 if((match!=
"of")&&(match!=
"re")) {dmatch=damp=0.;
return;}
2794 lfound=ufound=
false;
2795 vector<wavearray<double> > xINJ =
vINJ;
2796 for(
int n=0;
n<xINJ.size();
n++) xINJ[
n]*=pow(da,-200);
2797 for(
int i=0;
i<401;
i++) {
2798 if(lfound&&ufound)
continue;
2799 double a = pow(da,(
i-200));
2801 if((!ufound)&&(value>upper)) uamp=
a;
else ufound=
true;
2802 if((!lfound)&&(value>lower)) lamp=
a;
else lfound=
true;
2804 for(
int n=0;
n<xINJ.size();
n++) xINJ[
n]*=da;
2806 dmatch = (uamp!=lamp) ? (upper-lower)/(uamp-lamp) : 0;
2807 dmatch/=(upper+lower)/2.;
2808 dmatch=
fabs(dmatch);
2809 damp=
fabs(uamp-lamp);
2815 lfound=ufound=
false;
2816 vector<wavearray<double> > xINJ =
vINJ;
2817 for(
int i=0;
i>-200;
i--) {
2818 if(lfound&&ufound)
continue;
2819 double a = pow(da,
i);
2821 if((!ufound)&&(value<upper)) uamp=
a;
else ufound=
true;
2822 if((!lfound)&&(value<lower)) lamp=
a;
else lfound=
true;
2824 for(
int n=0;
n<xINJ.size();
n++) xINJ[
n]*=1./da;
2826 double damp1=
fabs(uamp-lamp);
2827 double dmatch1 = (uamp!=lamp) ? (upper-lower)/(uamp-lamp) : 0;
2828 dmatch1/=(upper+lower)/2.;
2832 lfound=ufound=
false;
2834 for(
int i=0;
i<200;
i++) {
2835 if(lfound&&ufound)
continue;
2836 double a = pow(da,
i);
2838 if((!ufound)&&(value<upper)) uamp=
a;
else ufound=
true;
2839 if((!lfound)&&(value<lower)) lamp=
a;
else lfound=
true;
2841 for(
int n=0;
n<xINJ.size();
n++) xINJ[
n]*=da;
2843 double damp2=
fabs(uamp-lamp);
2844 double dmatch2 = (uamp!=lamp) ? (upper-lower)/(uamp-lamp) : 0;
2845 dmatch2/=(upper+lower)/2.;
2847 dmatch=(
fabs(dmatch1)+
fabs(dmatch2))/2.;
2848 damp=(damp1+damp2)/2.;
2866 double dt = 1./wf.
rate();
2868 float inj_fcoa = fwf[
n];
2870 double tshift = inj_fcoa>0 ? sync_time+(1./inj_fcoa)*(sync_phase/360.) : sync_time;
2879 if(wREC[
id].
size()==0)
return -1.;
2883 gRandom->SetSeed(150914+
id);
2886 vector<int> irnd(nTRY);
2887 for(
int i=0;
i<nTRY;
i++) irnd[
i] =
int(gRandom->Uniform(0,
gEVENTS));
2894 std::vector<wavearray<double> > wrec(nIFO);
2895 for(
int j=0;
j<nTRY;
j++) {
2897 if(wINJ[i].
size()==0)
continue;
2903 double sync_phase, sync_time, sync_xcor;
2904 if(gOPT.sync_time && !gOPT.sync_phase) {
2906 sprintf(sout,
"wINJ Time Sync -> ifo = %*s - evtId = %*d / %*d - sync_time = %*.4f sec - sync_xcor = %*.3f",
2907 2,
gIFO[n].Data(), 5, i, 5 , nTRY, 7, sync_time, 6, sync_xcor);
2910 if(gOPT.sync_phase && !gOPT.sync_time) {
2912 sprintf(sout,
"wINJ Phase Sync -> ifo = %*s - evtId = %*d / %*d - sync_phase = %*.1f deg - sync_xcor = %*.3f",
2913 2,
gIFO[n].Data(), 5, i, 5 , nTRY, 6, sync_phase, 6, sync_xcor);
2916 if(gOPT.sync_phase && gOPT.sync_time) {
2918 sprintf(sout,
"wINJ TimePhase Sync -> ifo = %*s - evtId = %*d / %*d - sync_time = %*.4f sec - sync_phase = %*.1f deg - sync_xcor = %*.3f",
2919 2,
gIFO[n].Data(), 5, i, 5 , nTRY, 7, sync_time, 6, sync_phase, 6, sync_xcor);
2925 vector<double>
tstop(nIFO);
2928 double inj_tcoa = gOPT.inj_time_step+fmod(
wTCOA[i],1);
2940 float pvalue=(float)M/(
float)
N;
2952 cout << endl <<
"Compute onsource distribution : be patient, it takes a while ..." << endl << endl;
2959 if(wREC[
i].
size()) {
2962 wREC[
i][
n] = wINJ[
i][
n]; wREC[
i][
n]=0;
2970 int ipc = double(
gEVENTS)/10.;
if(ipc==0) ipc=1;
2972 if(
i%ipc==0) {
if(gEVENTS>100) {cout << pc<<
"%";
if (pc<100) cout <<
" - ";pc+=10;cout.flush();}}
2975 double sync_phase, sync_time, sync_xcor;
2976 if(!gOPT.sync_phase) {
2978 sprintf(sout,
"Time Sync -> ifo = %*s - evtId = %*d / %*d - sync_time = %*.4f sec - sync_xcor = %*.3f",
2979 2,
gIFO[n].Data(), 5,
i+1, 5 , gEVENTS, 7, sync_time, 6, sync_xcor);
2982 if(gOPT.sync_phase && gOPT.sync_time) {
2984 sprintf(sout,
"TimePhase Sync -> ifo = %*s - evtId = %*d / %*d - sync_time = %*.4f sec - sync_phase = %*.1f deg - sync_xcor = %*.3f",
2985 2,
gIFO[n].Data(), 5,
i+1, 5 , gEVENTS, 7, sync_time, 6, sync_phase, 6, sync_xcor);
2990 if(pc==100) cout << pc<<
"%";;
2991 cout << endl << endl;
2994 std::vector<double> zFF,zRE;
2997 if(wREC[
i].
size()==0)
continue;
3000 if(gOPT.side==
"right") {
3001 tstart.resize(nIFO);
3003 double inj_tcoa = gOPT.inj_time_step+fmod(
vTCOA,1);
3008 vector<double>
tstop;
3009 if(gOPT.side==
"left") {
3012 double inj_tcoa = gOPT.inj_time_step+fmod(
vTCOA,1);
3025 if(gOPT.residuals) {
3026 vector<wavearray<double> >
vDAT =
vNUL;
for(
int n=0;
n<
nIFO;
n++) vDAT[
n]+=vREC[
n];
3032 if(gOPT.use_onsrc==
"mfull" || gOPT.use_onsrc==
"mleft") {
3034 if(gOPT.use_onsrc==
"mfull") {
3039 double inj_tcoa = gOPT.inj_time_step+fmod(
vTCOA,1);
3047 if(gOPT.use_onsrc==
"efull") {
3052 double inj_tcoa = gOPT.inj_time_step+fmod(
vTCOA,1);
3062 if(gOPT.use_onsrc!=
"") {
3064 int nentries = (gOPT.use_onsrc==
"mfull" || gOPT.use_onsrc==
"mleft") ? zFF.size() : zRE.size();
3069 for(
int i=0;
i<
nentries;
i++) value[
i] = (gOPT.use_onsrc==
"mfull" || gOPT.use_onsrc==
"mleft") ? zFF[
i] : zRE[
i];
3070 TMath::Sort(nentries,value,index,
false);
3072 imed =
int((nentries*50.)/100.);
3075 mFF = xFF[index[imed]];
3076 mOF = xOF[index[imed]];
3077 mRE = xRE[index[imed]];
3090 vector<double>& oFF, vector<double>& oOF, vector<double>& oRE) {
3101 int kEVENTS = gOPT.rstat_jtrials;
3104 std::vector<wavearray<double> > oREC = recId>=0 ? wREC[recId] :
vREC;
3109 for(
int k=0;
k<kEVENTS;
k++) {
3116 for(
int k=0;
k<kEVENTS;
k++) {
3123 if(gOPT.sync_phase) {
3125 sprintf(sout,
"TimePhase Sync -> ifo = %*s - evtId = %*d / %*d - sync_time = %*.4f sec - sync_phase = %*.1f deg - sync_xcor = %*.3f",
3126 2,
gIFO[n].Data(), 5, i+1, 5 ,
gEVENTS, 7, sync_time[n], 6, sync_phase[n], 6, sync_xcor[n]);
3129 sprintf(sout,
"Time Sync -> ifo = %*s - evtId = %*d / %*d - sync_time = %*.4f sec - sync_xcor = %*.3f",
3130 2,
gIFO[n].Data(), 5, i+1, 5 ,
gEVENTS, 7, sync_time[n], 6, sync_xcor[n]);
3165 for(
int k=0;
k<kEVENTS;
k++) {
3168 if(wREC[i].
size()==0)
continue;
3171 if(gOPT.side==
"right") {
3172 tstart.resize(nIFO);
3174 double inj_tcoa = gOPT.inj_time_step+fmod(
vTCOA,1);
3179 vector<double>
tstop;
3180 if(gOPT.side==
"left") {
3183 double inj_tcoa = gOPT.inj_time_step+fmod(
vTCOA,1);
3188 if(oINJ[i].
size()!=oREC.size()) {
3189 cout <<
"GetOffSourceStatistic - Error: the elements of input injId vector are not unique !!!" << endl;
3209 if(type!=
"FF" && type!=
"OF" && type!=
"RE") {
3210 cout <<
"MakePvalueDistribution - Error : plot type not available, must be FF/OF/REE" << endl;
3214 TCanvas* cpd =
new TCanvas(
"PvalueDistribution",
"PvalueDistribution", 200, 20, 1000, 600);
3215 cpd->SetLogx(
false);
3217 cpd->SetGridx(
true);
3218 cpd->SetGridy(
true);
3220 gStyle->SetOptStat(
"emr");
3223 TH1F*
hist =
new TH1F(
"hpvalue",
"hpvalue",100,0,1);
3225 hist->SetLineWidth(2);
3226 hist->SetLineColor(kGreen+2);
3233 if(type==
"FF") value[
i]=vFF[
i+1];
3234 if(type==
"OF") value[
i]=vOF[
i+1];
3235 if(type==
"RE") value[
i]=vRE[
i+1];
3237 TMath::Sort(nentries,value,index,
false);
3239 int onsize=xFF.size();
3240 float *pvalue =
new float[onsize];
3241 for(
int i=0;
i<onsize;
i++) {
3243 if(type==
"FF") x=xFF[
i];
3244 if(type==
"OF") x=xOF[
i];
3245 if(type==
"RE") x=xRE[
i];
3250 int imax=nentries-1;
3252 imed = imin+
int((imax-imin)*50./100.);
3253 if(imed>=imax) imed=imax;
3254 double xmed=value[index[imed]];
3255 imin = (x<xmed) ? imin : imed;
3256 imax = (x<xmed) ? imed : imax;
3257 if(imax==imin+1) loop=
false;
3259 if(type==
"FF") pvalue[
i]=double(imed)/double(nentries);
3260 if(type==
"OF") pvalue[
i]=double(imed)/double(nentries);
3261 if(type==
"RE") pvalue[
i]=double(nentries-imed)/double(nentries);
3262 hist->Fill(pvalue[
i]);
3268 int *pindex =
new int[onsize];
3269 TMath::Sort(onsize,pvalue,pindex,
false);
3270 float pvalue_med = pvalue[pindex[
int(onsize*50./100.)]];
3271 float pvalue_l90 = pvalue[pindex[
int(onsize* 5./100.)]];
3272 float pvalue_u90 = pvalue[pindex[
int(onsize*95./100.)]];
3274 hist->GetXaxis()->SetTitle(
"pvalue");
3275 hist->GetXaxis()->SetTitleOffset(1.4);
3276 hist->GetXaxis()->SetLabelOffset(0.02);
3277 hist->GetXaxis()->SetNoExponent();
3279 hist->GetYaxis()->SetTitle(
"counts");
3280 hist->GetYaxis()->SetTitleOffset(1.6);
3281 hist->GetYaxis()->SetLabelOffset(0.02);
3282 hist->GetYaxis()->SetNoExponent();
3283 hist->GetYaxis()->SetNdivisions(3);
3286 if(type==
"FF") xtitle=
"Fitting Factor";
3287 if(type==
"OF") xtitle=
"Overlap Factor";
3288 if(type==
"RE") xtitle=
"Residual Energy";
3291 sprintf(htitle,
"%s %s (%s) - %s on-source p-value distribution (l90=%f, med=%f, u90=%f)",
3292 gOPT.gw_name.Data(),xtitle.Data(),gOPT.side.Data(),type.Data(),pvalue_l90,pvalue_med,pvalue_u90);
3293 hist->SetTitle(htitle);
3294 hist->SetName(
"Statistic");
3298 float ymax = hist->GetMaximum();
3299 TLine *line_med =
new TLine(pvalue_med,0,pvalue_med,ymax);
3300 line_med->SetLineWidth(2);
3301 line_med->SetLineColor(kRed);
3303 TLine *line_l90 =
new TLine(pvalue_l90,0,pvalue_l90,ymax);
3304 line_l90->SetLineWidth(2);
3305 line_l90->SetLineColor(kBlue);
3307 TLine *line_u90 =
new TLine(pvalue_u90,0,pvalue_u90,ymax);
3308 line_u90->SetLineWidth(2);
3309 line_u90->SetLineColor(kBlue);
3314 TPaveStats *ptstats = (TPaveStats*)cpd->GetPrimitive(
"stats");
3315 ptstats->SetLineColor(kBlack);
3319 xtitle.ReplaceAll(
" ",
"");
3321 sprintf(ofname,
"%s_%s_%s.png",gOPT.plot_fname.Data(),
"onsource_pvalue_distribution",xtitle.Data());
3324 cout <<
"write : " << fName << endl;
3325 fName.ReplaceAll(
".png",
".root");
3327 cout <<
"write : " << fName << endl;
3330 sprintf(ofname,
"%s_%s_%s.txt",gOPT.plot_fname.Data(),xtitle.Data(),
"onsource_pvalue_statistic");
3332 for(
int i=0;
i<onsize;
i++) {
3333 TString parm = TString::Format(
"%f",pvalue[pindex[
i]]);
3353 if(type!=
"statistics" && type!=
"waveform")
return 0;
3356 if(type==
"statistics" || gOPT.plot_type==
"phase") {
3363 if(wREC[
i].
size()) {
3370 if(selected==0)
return 0;
3377 if(wREC[
i].
size()) {
3383 wREC[
i][
n] = vREC[
n]; wREC[
i][
n]=0;
3384 if(gOPT.residuals) wNUL[
i][
n] = vNUL[
n]; wNUL[
i][
n]=0;
3385 if(gOPT.side==
"rcut") wAUX[
i][
n] = vAUX[
n]; wAUX[
i][
n]=0;
3388 if(selected==0)
return 0;
3392 if(gOPT.sync_phase || gOPT.sync_time) {
3397 wavearray<double>* wref = type==
"statistics" || gOPT.plot_type==
"phase" ? &vINJ[
n] : &vREC[
n];
3398 wavearray<double>* wsht = type==
"statistics" || gOPT.plot_type==
"phase" ? &vREC[
n] : &vREC[
n];
3401 double sync_phase, sync_time, sync_xcor;
3402 if(gOPT.sync_time && !gOPT.sync_phase) {
3405 sprintf(sout,
"Time Sync -> ifo = %*s - sync_time = %*.4f sec - sync_xcor = %*.3f",
3406 2,
gIFO[
n].Data(), 7, sync_time, 6, sync_xcor);
3407 cout << sout << endl;
3410 if(gOPT.sync_phase && !gOPT.sync_time) {
3413 sprintf(sout,
"Phase Sync -> ifo = %*s - sync_phase = %*.1f deg - sync_xcor = %*.3f",
3414 2,
gIFO[
n].Data(), 6, sync_phase, 6, sync_xcor);
3415 cout << sout << endl;
3418 if(gOPT.sync_phase && gOPT.sync_time) {
3422 sprintf(sout,
"TimePhase Sync -> ifo = %*s - sync_time = %*.4f sec - sync_phase = %*.1f deg - sync_xcor = %*.3f",
3423 2,
gIFO[
n].Data(), 7, sync_time, 6, sync_phase, 6, sync_xcor);
3424 cout << sout << endl;
3433 wavearray<double>* wref = type==
"statistics" || gOPT.plot_type==
"phase" ? &wINJ[
i][
n] : &vREC[
n];
3434 wavearray<double>* wsht = type==
"statistics" || gOPT.plot_type==
"phase" ? &wREC[
i][
n] : &wREC[
i][
n];
3437 double sync_phase, sync_time, sync_xcor;
3438 if(gOPT.sync_time && !gOPT.sync_phase) {
3440 sprintf(sout,
"Time Sync -> ifo = %*s - evtId = %*d / %*d - sync_time = %*.4f sec - sync_xcor = %*.3f",
3441 2,
gIFO[
n].Data(), 5,
i+1, 5 , gEVENTS, 7, sync_time, 6, sync_xcor);
3442 cout << sout << endl;
3445 if(gOPT.sync_phase && !gOPT.sync_time) {
3447 sprintf(sout,
"Phase Sync -> ifo = %*s - evtId = %*d / %*d - sync_phase = %*.1f deg - sync_xcor = %*.3f",
3448 2,
gIFO[
n].Data(), 5,
i+1, 5 , gEVENTS, 6, sync_phase, 6, sync_xcor);
3449 cout << sout << endl;
3452 if(gOPT.sync_phase && gOPT.sync_time) {
3454 sprintf(sout,
"TimePhase Sync -> ifo = %*s - evtId = %*d / %*d - sync_time = %*.4f sec - sync_phase = %*.1f deg - sync_xcor = %*.3f",
3455 2,
gIFO[
n].Data(), 5,
i+1, 5 , gEVENTS, 7, sync_time, 6, sync_phase, 6, sync_xcor);
3456 cout << sout << endl;
3463 if(gOPT.side==
"rcut") {
3464 cout << endl <<
"Apply RCut : be patient, it takes a while ..." << endl << endl;
3466 int ipc = double(
gEVENTS)/10.;
if(ipc==0) ipc=1;
3469 if(
n==nIFO-1 &&
i%ipc==0) {
if(gEVENTS>100) {cout << pc<<
"%";
if (pc<100) cout <<
" - ";pc+=10;cout.flush();}}
3474 vREC[
n] =
GetRCut(&vREC[n],&vAUX[n]);
3476 if(pc==100) cout << pc<<
"%";;
3477 cout << endl << endl;
3481 if(type==
"waveform") {
3501 if(gOPT.plot_type==
"phase") {
3505 wREC[
i][
n].resize(gOPT.ncycles);
3514 vREC[
n].resize(gOPT.ncycles);
3517 pFRQ[
n]*=180./pFRQ[
n].max();
3518 pSNR[
n]*=180./pSNR[
n].max();
3530 for(
int i=0;
i<token->GetEntries();
i++) {
3531 TObjString* otoken = (TObjString*)token->At(
i);
3532 TString stoken = otoken->GetString();
3535 if(i<token->GetEntries()-1) {
3536 if(stoken==
"spin1" || stoken==
"spin2") {
3537 otoken = (TObjString*)token->At(
i+3);
3538 return otoken->GetString();
3540 otoken = (TObjString*)token->At(
i+1);
3541 return otoken->GetString();
3546 if(token)
delete token;
3556 const auto&
fchirp =
static_cast<double(*)(
double,
double,
double,
double,
double)
>(CWB::mdc::SimIMRSEOBNRv4ROMFrequencyOfTime);
3557 const auto& tchirp =
static_cast<double(*)(
double,
double,
double,
double,
double)
>(CWB::mdc::SimIMRSEOBNRv4ROMTimeOfFrequency);
3567 double fmax= ts->
rate()/2.>gOPT.ccut_fmax ? gOPT.ccut_fmax : ts->
rate()/2.;
3571 double dF = (fmax-fmin)/nPx;
3573 double F = fmin+
i*dF;
3574 Fb[
i] = gOPT.ccut_bchirp*
F;
3575 Fu[
i] = gOPT.ccut_uchirp*
F;
3576 double t=tchirp(F,m1,m2,s1z,s2z);
3578 cout <<
"cwb_pereport:GetCCut - update gOPT.ccut_fmax frequency to " << F
3579 <<
" Hz in order to avoid errors in LAL functions XLALSimIMRSEOBNRv4ROMFrequencyOfTime/XLALSimIMRSEOBNRv4ROMTimeOfFrequency" << endl;
3580 gOPT.ccut_fmax=fmin+(
i-1)*dF;
3586 TSpline3 tbchirp(
"tbchirp",Fb,T,nPx);
3587 TSpline3 tuchirp(
"tuchirp",Fu,T,nPx);
3588 TSpline3
fbchirp(
"fbchirp",T,Fb,nPx);
3589 TSpline3
fuchirp(
"fuchirp",T,Fu,nPx);
3592 double dt = 1./(2*
df);
3597 double tl = tcoa-gOPT.ccut_ltime;
3598 double tr = tcoa-gOPT.ccut_rtime;
3606 double tm = time-dt/2;
3607 double tM = time+dt/2;
3609 if(tm<tl-dt || tM>tr+dt) {
3617 double fb = fbchirp.Eval(time);
3618 double fu = fuchirp.Eval(time);
3620 if(TMath::IsNaN(fb)) fb = ts->
rate()/2.;
3621 if(TMath::IsNaN(fu)) fu = ts->
rate()/2.;
3623 double f1 = fbchirp.Eval(tm);
3624 double f2 = fbchirp.Eval(tM);
3625 double f3 = fuchirp.Eval(tm);
3626 double f4 = fuchirp.Eval(tM);
3632 double fm = freq-df/2;
3633 double fM = freq+df/2;
3635 if(fm<fmin || fM>fmax) {
3641 double t1 = tbchirp.Eval(fm);
3642 double t2 = tbchirp.Eval(fM);
3643 double t3 = tuchirp.Eval(fm);
3644 double t4 = tuchirp.Eval(fM);
3647 bool ctime = (tM>tl && tm<tr) ?
true :
false;
3650 bool cfreq = (fM>fb && fm<fu) ?
true :
false;
3652 double x1=
t1,x2=t2,x3=t3,x4=t4,xm=tm,xM=tM;
3653 double y1=f1,y2=
f2,y3=f3,y4=f4,ym=fm,yM=fM;
3656 if(tl>tm && tl<tM) {xm=tl; f1 = fbchirp.Eval(xm); f3 = fuchirp.Eval(xm);}
3657 if(tr>tm && tr<tM) {xM=tr; f2 = fbchirp.Eval(xM); f4 = fuchirp.Eval(xM);}
3659 y1=f1,y2=
f2,y3=f3,y4=f4;
3666 if(t1>xm && t1<xM) cline=
true;
3667 if(t2>xm && t2<xM) cline=
true;
3668 if(t3>xm && t3<xM) cline=
true;
3669 if(t4>xm && t4<xM) cline=
true;
3671 if(f1>ym && f1<yM) cline=
true;
3672 if(f2>ym && f2<yM) cline=
true;
3673 if(f3>ym && f3<yM) cline=
true;
3674 if(f4>ym && f4<yM) cline=
true;
3676 double Ap=(xM-xm)*(yM-ym);
3681 if(y1<ym) y1=ym;
if(y1>yM) y1=yM;
3682 if(y2<ym) y2=ym;
if(y2>yM) y2=yM;
3683 if(y3<ym) y3=ym;
if(y3>yM) y3=yM;
3684 if(y4<ym) y4=ym;
if(y4>yM) y4=yM;
3691 if(t1<xm) {x1=xm; y1 = fbchirp.Eval(x1);}
3692 if(t1>xM) {x1=xM; y1 = fbchirp.Eval(x1);}
3693 if(t2<xm) {x2=xm; y2 = fbchirp.Eval(x2);}
3694 if(t2>xM) {x2=xM; y2 = fbchirp.Eval(x2);}
3697 if(y1<ym) y1=ym;
if(y1>yM) y1=yM;
3698 if(y2<ym) y2=ym;
if(y2>yM) y2=yM;
3701 if(y1 >ym && y2==yM) Ab = (x2-xm)*(yM-y1)/2;
3702 if(y1 >ym && y2 <yM) Ab = (xM-xm)*(yM-y2)+(xM-xm)*(y2-y1)/2;
3703 if(y1==ym && y2==yM) Ab = (x1-xm)*(yM-ym)+(x2-x1)*(yM-ym)/2;
3704 if(y1==ym && y2 <yM) Ab = Ap-(xM-x1)*(y2-ym)/2;
3711 if(t3<xm) {x3=xm; y3 = fuchirp.Eval(x3);}
3712 if(t3>xM) {x3=xM; y3 = fuchirp.Eval(x3);}
3713 if(t4<xm) {x4=xm; y4 = fuchirp.Eval(x4);}
3714 if(t4>xM) {x4=xM; y4 = fuchirp.Eval(x4);}
3717 if(y3<ym) y3=ym;
if(y3>yM) y3=yM;
3718 if(y4<ym) y4=ym;
if(y4>yM) y4=yM;
3721 if(y3 >ym && y4==yM) Au = Ap-(x4-xm)*(yM-y3)/2;
3722 if(y3 >ym && y4 <yM) Au = (xM-xm)*(y3-ym)+(xM-xm)*(y4-y3)/2;
3723 if(y3==ym && y4==yM) Au = (xM-x4)*(yM-ym)+(x4-x3)*(yM-ym)/2;
3724 if(y3==ym && y4 <yM) Au = (xM-x3)*(y4-ym)/2;
3726 if(Ab<0) Ab=0;
if(Ab>Ap) Ab=Ap;
3727 if(Au<0) Au=0;
if(Au>Au) Au=Au;
3728 double A = Ab+Au; A-=Ap;
3730 if(A<0) {cout <<
"GetCCut Warning: pixel area < 0 " << endl; A=0;}
3731 if(A>Ap) {cout <<
"GetCCut Warning: pixel area > Ap " << endl; A=Ap;}
3732 double R=sqrt(A/0.5);
3742 if((ctime && cfreq) && !cline) {
3744 double R = (x4<=tl || x1>=tr) ? 0 : sqrt(Ap/0.5);
3758 if((ctime && cline)||(ctime && cfreq)) {
3771 Et+=(a00*a00+a90*a90)/2;
3790 if(token->GetEntries()!=5) {
3792 cout <<
"cwb_pereport - Error : ccut format - must be: wdm_fres:bchirp:uchirp:ltime:rtime" << endl;
3793 cout <<
" Default setup is: 16:1.35:1.65:0.5:0.0" << endl;
3794 cout <<
" To setup a default value use *" << endl;
3795 cout <<
" Example: *:1.25:1.75:*:*" << endl;
3799 for(
int j=0;
j<token->GetEntries();
j++) {
3800 TObjString* tok = (TObjString*)token->At(
j);
3801 TString stok = tok->GetString();
3803 if(stok==
"*")
continue;
3807 if(wdm_fres.IsDigit()) gOPT.ccut_wdm_fres=wdm_fres.Atoi();
3808 else {cout<<
"cwb_pereport - Error : wdm_fres is not integer"<<endl;
exit(1);}
3812 if(mc_lower_factor.IsFloat()) gOPT.ccut_bchirp=mc_lower_factor.Atof();
3813 else {cout<<
"cwb_pereport - Error : mc_lower_factor is not float"<<endl;
exit(1);}
3817 if(mc_upper_factor.IsFloat()) gOPT.ccut_uchirp=mc_upper_factor.Atof();
3818 else {cout<<
"cwb_pereport - Error : mc_upper_factor is not float"<<endl;
exit(1);}
3822 if(left_time.IsFloat()) gOPT.ccut_ltime=left_time.Atof();
3823 else {cout<<
"cwb_pereport - Error : left_time is not float"<<endl;
exit(1);}
3827 if(right_time.IsFloat()) gOPT.ccut_rtime=right_time.Atof();
3828 else {cout<<
"cwb_pereport - Error : right_time is not float"<<endl;
exit(1);}
3832 int x=gOPT.ccut_wdm_fres;
3833 if(!((x != 0) && ((x & (~x + 1)) == x)) || gOPT.ccut_wdm_fres<=0) {
3834 cout<<
"cwb_pereport : upTDF parameter non valid : must be power of 2 : "<<gOPT.ccut_wdm_fres<<endl;
3837 if(gOPT.ccut_bchirp < 0) {
3838 cout<<
"cwb_pereport - Error :.ccut_bchirp must be >= 0"<<endl;
3841 if(gOPT.ccut_bchirp > gOPT.ccut_uchirp) {
3842 cout<<
"cwb_pereport - Error :.ccut_bchirp must be < ccut_uchirp"<<endl;
3845 if(gOPT.ccut_rtime < 0) {
3846 cout<<
"cwb_pereport - Error :.ccut_rtime >=0"<<endl;
3849 if(gOPT.ccut_ltime < gOPT.ccut_rtime) {
3850 cout<<
"cwb_pereport - Error :.ccut_ltime must be >.ccut_rtime"<<endl;
3865 int esize = slices*
layers;
3866 float* energy =
new float[esize];
3874 energy[
j+
i*
layers] = A00*A00+A90*A90;
3883 int *
index =
new int[esize];
3884 TMath::Sort(esize,energy,index,
true);
3886 for(
int k=0;
k<esize;
k++) {
3889 if(ecum <= etot*gOPT.rcut_thr) {
3893 int i = (m-
j)/layers;
3917 if(token->GetEntries()!=2) {
3919 cout <<
"cwb_pereport - Error : rcut format - must be: wdm_fres:thr" << endl;
3920 cout <<
" Default setup is: 64:1.0" << endl;
3921 cout <<
" To setup a default value use *" << endl;
3922 cout <<
" Example: *:0.9" << endl;
3926 for(
int j=0;
j<token->GetEntries();
j++) {
3927 TObjString* tok = (TObjString*)token->At(
j);
3928 TString stok = tok->GetString();
3930 if(stok==
"*")
continue;
3934 if(wdm_fres.IsDigit()) gOPT.rcut_wdm_fres=wdm_fres.Atoi();
3935 else {cout<<
"cwb_pereport - Error : wdm_fres is not integer"<<endl;
exit(1);}
3939 if(thr.IsFloat()) gOPT.rcut_thr=thr.Atof();
3940 else {cout<<
"cwb_pereport - Error : thr is not float"<<endl;
exit(1);}
3944 int x=gOPT.rcut_wdm_fres;
3945 if(!((x != 0) && ((x & (~x + 1)) == x)) || gOPT.rcut_wdm_fres<=0) {
3946 cout<<
"cwb_pereport : upTDF parameter non valid : must be power of 2 : "<<gOPT.rcut_wdm_fres<<endl;
3949 if(gOPT.rcut_thr < 0 || gOPT.rcut_thr > 1) {
3950 cout<<
"cwb_pereport - Error :rcut_thr must be >= 0 && <=1"<<endl;
3967 if(token->GetEntries()!=6) {
3969 cout <<
"cwb_pereport - Error : logl format - must be: enabled:flow:fhigh:arthr:ifo_mask:resample" << endl;
3970 cout <<
" Default setup is: false:0:8192:0.001:0x11111111:1" << endl;
3971 cout <<
" Example: true:20:100:*:0x100:* (select only the third ifo)" << endl;
3975 for(
int j=0;
j<token->GetEntries();
j++) {
3976 TObjString* tok = (TObjString*)token->At(
j);
3977 TString stok = tok->GetString();
3979 if(stok==
"*")
continue;
3983 enabled.Remove(0,enabled.Last(
'=')+1);
3984 if(enabled==
"true") gOPT.logl_enabled=
true;
3985 if(enabled==
"false") gOPT.logl_enabled=
false;
3989 if(flow.IsFloat()) gOPT.logl_flow=flow.Atof();
3990 else {cout<<
"cwb_pereport - Error : logl flow is not float"<<endl;
exit(1);}
3994 if(fhigh.IsFloat()) gOPT.logl_fhigh=fhigh.Atof();
3995 else {cout<<
"cwb_pereport - Error : logl fhigh is not float"<<endl;
exit(1);}
3999 if(arthr.IsFloat()) gOPT.logl_arthr=arthr.Atof();
4000 else {cout<<
"cwb_pereport - Error : logl arthr is not float"<<endl;
exit(1);}
4004 if(ifo_mask.IsHex()) {
4005 std::string sifo_mask = ifo_mask.Data();
4006 gOPT.logl_ifo_mask=std::stoi(sifo_mask, 0, 16);
4007 }
else {cout<<
"cwb_pereport - Error : logl ifo_mask is not hex"<<endl;
exit(1);}
4011 if(resample.IsDigit()) gOPT.logl_resample=resample.Atoi();
4012 else {cout<<
"cwb_pereport - Error : logl resample is not integer"<<endl;
exit(1);}
4016 if(gOPT.logl_flow > gOPT.logl_fhigh) {
4017 cout<<
"cwb_pereport - Error : logl_flow must be < logl_fhigh "<<endl;
4020 if(gOPT.logl_arthr>=1) {
4021 cout<<
"cwb_pereport - Error : logl_arthr must be < 1"<<endl;
4036 if(token->GetEntries()!=4) {
4038 cout <<
"cwb_pereport - Error : rstat format - must be: true:median:rtrials:jtrials" << endl;
4039 cout <<
" Default setup is: false:median:0:0" << endl;
4040 cout <<
" Example: true:median:1000:100 " << endl;
4044 for(
int j=0;
j<token->GetEntries();
j++) {
4045 TObjString* tok = (TObjString*)token->At(
j);
4046 TString stok = tok->GetString();
4048 if(stok==
"*")
continue;
4052 enabled.Remove(0,enabled.Last(
'=')+1);
4053 if(enabled==
"true") gOPT.rstat_enabled=
true;
4054 if(enabled==
"false") gOPT.rstat_enabled=
false;
4058 type.Remove(0,type.Last(
'=')+1);
4059 if((type!=
"rstat1")&&(type!=
"median")) {
4060 cout<<
"cwb_pereport - Error : available options for rstat_type are: rstat1/median "<<endl;
4062 }
else gOPT.rstat_type=type;
4066 if(rtrials.IsDigit()) gOPT.rstat_rtrials=rtrials.Atoi();
4067 else {cout<<
"cwb_pereport - Error : rstat rtrials is not integer"<<endl;
exit(1);}
4071 if(jtrials.IsDigit()) gOPT.rstat_jtrials=jtrials.Atoi();
4072 else {cout<<
"cwb_pereport - Error : rstat jtrials is not integer"<<endl;
exit(1);}
4076 if(gOPT.rstat_enabled==
false) {
4080 if(gOPT.rstat_rtrials < 0) {
4081 cout<<
"cwb_pereport - Error : rstat_rtrials must be >=0 "<<endl;
4084 if(gOPT.rstat_jtrials < 0) {
4085 cout<<
"cwb_pereport - Error : rstat_jtrials must be >=0 "<<endl;
4093 #define MAX_TRIALS 30 4094 #define MAX_ECOV 1.0 4099 cout << endl <<
"ComputeWaveformFCR - selected events : " << selected << endl << endl;
4100 if(selected==0)
return 0;
4108 for(
int n=0;
n<
nIFO;
n++) {bcov50[
n]=0.; bcov90[
n]=0.; bcov99[
n]=0.; }
4109 for(
int n=0;
n<
nIFO;
n++) { cov50[
n]=50.; cov90[
n]=90.; cov99[
n]=99.; }
4110 for(
int n=0;
n<
nIFO;
n++) {ucov50[
n]=100.; ucov90[
n]=100.; ucov99[
n]=100.;}
4124 cout <<
"Trials = " << trials <<
"\tIFO " <<
gIFO[
n] <<
"\tFull/Local Coverage at 50% = " << (
int)fcov50[
n] <<
" / " << cov50[
n] << endl;
4125 cout <<
"Trials = " << trials <<
"\tIFO " <<
gIFO[
n] <<
"\tFull/Local Coverage at 90% = " << (
int)fcov90[
n] <<
" / " << cov90[
n] << endl;
4126 cout <<
"Trials = " << trials <<
"\tIFO " <<
gIFO[
n] <<
"\tFull/Local Coverage at 99% = " << (
int)fcov99[
n] <<
" / " << cov99[
n] << endl;
4133 if(fcov50[
n]<50.) {bcov50[
n]=cov50[
n]; cov50[
n] += (ucov50[
n]- cov50[
n])/2.;}
4134 else {ucov50[
n]=cov50[
n]; cov50[
n] -= ( cov50[
n]-bcov50[
n])/2.;}
4138 if(fcov90[
n]<90.) {bcov90[
n]=cov90[
n]; cov90[
n] += (ucov90[
n]- cov90[
n])/2.;}
4139 else {ucov90[
n]=cov90[
n]; cov90[
n] -= ( cov90[
n]-bcov90[
n])/2.;}
4143 if(fcov99[
n]<99.) {bcov99[
n]=cov99[
n]; cov99[
n] += (ucov99[
n]- cov99[
n])/2.;}
4144 else {ucov99[
n]=cov99[
n]; cov99[
n] -= ( cov99[
n]-bcov99[
n])/2.;}
4154 parm = TString::Format(
"%s : Trials = %d/%d \tIFO %s \tFull/Local Coverage at 50% = %.4f / %.4f",
4157 parm = TString::Format(
"%s : Trials = %d/%d \tIFO %s \tFull/Local Coverage at 90% = %.4f / %.4f",
4160 parm = TString::Format(
"%s : Trials = %d/%d \tIFO %s \tFull/Local Coverage at 99% = %.4f / %.4f",
4172 while(!vMED.empty()) vMED.pop_back();
4173 vMED.clear(); std::vector<wavearray<double> >().swap(vMED);
4174 while(!vL50.empty()) vL50.pop_back();
4175 vL50.clear(); std::vector<wavearray<double> >().swap(vL50);
4176 while(!vU50.empty()) vU50.pop_back();
4177 vU50.clear(); std::vector<wavearray<double> >().swap(vU50);
4178 while(!vL90.empty()) vL90.pop_back();
4179 vL90.clear(); std::vector<wavearray<double> >().swap(vL90);
4180 while(!vU90.empty()) vU90.pop_back();
4181 vU90.clear(); std::vector<wavearray<double> >().swap(vU90);
4182 while(!vL99.empty()) vL99.pop_back();
4183 vL99.clear(); std::vector<wavearray<double> >().swap(vL99);
4184 while(!vU99.empty()) vU99.pop_back();
4185 vU99.clear(); std::vector<wavearray<double> >().swap(vU99);
4196 wmed[
n] = wREC[0][
n]; wmed[
n] = 0;
4197 wl50[
n] = wREC[0][
n]; wl50[
n] = 0;
4198 wu50[
n] = wREC[0][
n]; wu50[
n] = 0;
4199 wl90[
n] = wREC[0][
n]; wl90[
n] = 0;
4200 wu90[
n] = wREC[0][
n]; wu90[
n] = 0;
4201 wl99[
n] = wREC[0][
n]; wl99[
n] = 0;
4202 wu99[
n] = wREC[0][
n]; wu99[
n] = 0;
4207 for(
int j=0;
j<wREC[0][
n].size();
j++) {
4208 if(gOPT.residuals) {
4213 TMath::Sort(nentries,value,index,
false);
4215 int imed = (nentries*50.)/100.;
if(imed>=nentries) imed=nentries-1;
4216 wmed[
n][
j] = value[index[imed]];
4218 int il50 = (nentries*(50.-cov50[
n]/2.))/100.;
if(il50>=nentries) il50=nentries-1;
4219 int iu50 = (nentries*(50.+cov50[
n]/2.))/100.;
if(iu50>=nentries) iu50=nentries-1;
4220 int il90 = (nentries*(50.-cov90[
n]/2.))/100.;
if(il90>=nentries) il90=nentries-1;
4221 int iu90 = (nentries*(50.+cov90[
n]/2.))/100.;
if(iu90>=nentries) iu90=nentries-1;
4222 int il99 = (nentries*(50.-cov99[
n]/2.))/100.;
if(il99>=nentries) il99=nentries-1;
4223 int iu99 = (nentries*(50.+cov99[
n]/2.))/100.;
if(iu99>=nentries) iu99=nentries-1;
4225 double med = wmed[
n][
j];
4226 double l50 = value[index[il50]];
4227 double u50 = value[index[iu50]];
4228 double l90 = value[index[il90]];
4229 double u90 = value[index[iu90]];
4230 double l99 = value[index[il99]];
4231 double u99 = value[index[iu99]];
4234 if(!(l50<=u50)) check=
false;
4235 if(!(l90<=u90)) check=
false;
4236 if(!(l99<=u99)) check=
false;
4237 if(!(med>=l50 && med<=u50)) check=
false;
4238 if(!(med>=l90 && med<=u90)) check=
false;
4239 if(!(med>=l99 && med<=u99)) check=
false;
4240 if(!check) {cout <<
"ComputeWaveformFCR : standard wrong median, lower, upper bound !!! " << l50 <<
" " << med <<
" " << u50 << endl;}
4241 if(!(med>=l50 && med<=u50)) med=l50;
4244 wl50[
n][
j] =
fabs(med-l50);
4245 wu50[
n][
j] =
fabs(u50-med);
4246 wl90[
n][
j] =
fabs(med-l90);
4247 wu90[
n][
j] =
fabs(u90-med);
4248 wl99[
n][
j] =
fabs(med-l99);
4249 wu99[
n][
j] =
fabs(u99-med);
4254 vMED.push_back(wmed[
n]);
4255 vL50.push_back(wl50[n]);
4256 vU50.push_back(wu50[n]);
4257 vL90.push_back(wl90[n]);
4258 vU90.push_back(wu90[n]);
4259 vL99.push_back(wl99[n]);
4260 vU99.push_back(wu99[n]);
4268 double P = gOPT.plot_efraction;
4269 double estart, estop;
4276 if(bT<estart) estart=bT;
4277 if(eT>estop) estop=eT;
4281 cout <<
"estart=" << estart <<
"\testop=" << estop << endl;
4284 int nstart = (estart-vREC[0].start())*vREC[0].
rate();
4285 int nstop = (estop -vREC[0].start())*vREC[0].
rate();
4294 if(!wREC[
i][
n].
size())
continue;
4298 for(
int j=nstart;
j<nstop;
j++) {
4299 double vl50 = vMED[
n][
j]-
fabs(vL50[
n][
j]);
4300 double vu50 = vMED[
n][
j]+
fabs(vU50[
n][j]);
4301 double vl90 = vMED[
n][
j]-
fabs(vL90[
n][j]);
4302 double vu90 = vMED[
n][
j]+
fabs(vU90[
n][j]);
4303 double vl99 = vMED[
n][
j]-
fabs(vL99[
n][j]);
4304 double vu99 = vMED[
n][
j]+
fabs(vU99[
n][j]);
4307 if(value<vl50 || value>vu50) b50=
true;
4308 if(value<vl90 || value>vu90) b90=
true;
4309 if(value<vl99 || value>vu99) b99=
true;
4315 fcov50[
n] = (100.-100.*n50/(double)selected);
4316 fcov90[
n] = (100.-100.*n90/(double)selected);
4317 fcov99[
n] = (100.-100.*n99/(double)selected);
wavearray< double > t(hp.size())
std::vector< wavearray< double > > pSNR
detectorParams getDetectorParams()
std::vector< wavearray< double > > vU50
std::vector< double > xOF
void GetRstatParms(TString options)
void gtitle(TString title="", TString xtitle="", TString ytitle="")
void ComputeTimeSensitivity(TString match, double lower, double upper, double &dmatch, double &dtime)
void DumpWaveformCR(int nIFO)
void GetOffSourceStatistic(int nIFO, int recId, vector< int > injId, vector< double > &oFF, vector< double > &oOF, vector< double > &oRE)
void MakeDistributions(TString type="FF")
std::vector< wavearray< double > > wNUL[PE_MAX_EVENTS]
double min(double x, double y)
virtual void rate(double r)
wavearray< double > a(hp.size())
std::vector< double > vTREC
std::vector< wavearray< double > > vDAT
std::vector< double > vRE
int ComputeStatistics(int nIFO)
double GetSyncTcoa(wavearray< double > wf, double sync_time, double sync_phase, double tcoa)
std::vector< wavearray< double > > vU99
void putSample(DataType_t a, int n, double m)
static void PhaseShift(wavearray< double > &x, double pShift=0.)
cout<< endl;cout<< "ts size = "<< ts.size()<< " ts rate = "<< ts.rate()<< endl;tf.Forward(ts, wdm);int levels=tf.getLevel();cout<< "tf size = "<< tf.size()<< endl;double dF=tf.resolution();double dT=1./(2 *dF);cout<< "rate(hz) : "<< RATE<< "\ layers : "<< nLAYERS<< "\ dF(hz) : "<< dF<< "\ dT(ms) : "<< dT *1000.<< endl;int itime=TIME_PIXEL_INDEX;int ifreq=FREQ_PIXEL_INDEX;int index=(levels+1) *itime+ifreq;double time=itime *dT;double freq=(ifreq >0) ? ifreq *dF :dF/4;cout<< endl;cout<< "PIXEL TIME = "<< time<< " sec "<< endl;cout<< "PIXEL FREQ = "<< freq<< " Hz "<< endl;cout<< endl;wavearray< double > x
std::vector< wavearray< double > > vAUX
double GetInjTcoa(double geocentric_tcoa, network *NET, TString ifo, double theta, double phi)
CWB::frame fr(FRLIST_NAME)
void GetRCutParms(TString options)
std::vector< TGraph * > graph
plot gtitle(gtitle,"frequency (Hz)","strain/#sqrt{Hz}")
void MakePvalueDistribution(TString type="FF")
std::vector< wavearray< double > > wINJ[PE_MAX_EVENTS]
int GetOnSourceStatistic(int nIFO, double &mFF, double &mOF, double &mRE)
double wFACTOR[PE_MAX_EVENTS]
std::vector< double > oSNR[NIFO_MAX]
std::vector< wavearray< double > > pTIM
virtual void start(double s)
double GetDelay(TString ifo1, TString ifo2, double phi, double theta)
std::vector< double > xFF
int ComputeWaveformCR(int nIFO)
virtual size_t size() const
void GetLoglParms(TString options)
std::vector< wavearray< double > > vL99
std::vector< wavearray< double > > vINJ
std::vector< double > vOF
void GetCCutParms(TString options)
static double GetMatchFactor(TString match, vector< wavearray< double > > &w1, vector< wavearray< double > > &w2, vector< double > tstart=DEFAULT_VECtOR_DOUBLE, vector< double > tstop=DEFAULT_VECtOR_DOUBLE)
float wPHI[PE_MAX_EVENTS]
static wavearray< double > GetEnvelope(wavearray< double > *x)
double GetCCut(wavearray< double > *ts, double tcoa, double m1, double m2, double s1z, double s2z)
static wavearray< double > GetAligned(wavearray< double > *w1, wavearray< double > *w2)
TString GetParameterFromInjLog(TString log, TString param)
void Resample(const wavearray< DataType_t > &, double, int=6)
#define PE_PLOT_EFRACTION
printf("total live time: non-zero lags = %10.1f \, liveTot)
std::vector< wavearray< double > > vL50
std::vector< double > iSNR[NIFO_MAX]
std::vector< wavearray< double > > wREC[PE_MAX_EVENTS]
void DumpStatistics(TString ofname, TString params, bool app)
void PrintUserOptions(TString ofname="")
std::vector< wavearray< double > > vMED
void cwb_pereport(TString options)
void ComputeAmpSensitivity(TString match, double lower, double upper, double &dmatch, double &damp)
std::vector< wavearray< double > > vREC
float wDOF[PE_MAX_EVENTS]
void PlotWaveformAsymmErrors(TString ofname, TString title, wavearray< double > wrec, wavearray< double > wmed, wavearray< double > wl50, wavearray< double > wu50, wavearray< double > wl90, wavearray< double > wu90, wavearray< double > wl99, wavearray< double > wu99, wavearray< double > wref, TString pdir, double P, double Q, double tref, double tcoa, int ifoid)
static double TimeSync(wavearray< double > &w1, wavearray< double > &w2, double &sync_time)
static double GetTimeBoundaries(wavearray< double > x, double P, double &bT, double &eT, double T=-1., double Q=-1.)
std::vector< wavearray< double > > wAUX[PE_MAX_EVENTS]
void LoadOutputRootFiles(int nIFO, TString data_label, TString output_dir, int max_events=PE_MAX_EVENTS, double ifar_thr=0)
static void TimeShift(wavearray< double > &x, double tShift=0.)
std::vector< double > xRE
void PlotWaveformsCR(int nIFO)
std::vector< wavearray< double > > vL90
int SyncWaveforms(int nIFO, TString type)
float TestStatistic(int nIFO, int id, float ref)
static wavearray< double > GetDiff(wavearray< double > *w1, wavearray< double > *w2)
wavearray< double > ts(N)
cout<< "Starting reading output directory ..."<< endl;vector< TString > fileList
static double PhaseSync(wavearray< double > &w1, wavearray< double > &w2, double &sync_phase)
int ComputeCCutStatistics(int nIFO)
static int Align(wavearray< double > &w1, wavearray< double > &w2)
double fabs(const Complex &x)
void Forward(int n=-1)
param: wavelet - n is number of steps (-1 means full decomposition)
sprintf(tfres,"(1/%g)x(%g) (sec)x(Hz)", 2 *df, df)
std::vector< wavearray< double > > vU90
std::vector< wavearray< double > > vNUL
double wTCOA[PE_MAX_EVENTS]
std::vector< wavearray< double > > pFRQ
static double TimePhaseSync(wavearray< double > &w1, wavearray< double > &w2, double &sync_time, double &sync_phase)
DataType_t getSample(int n, double m)
void ComputePhaseSensitivity(TString match, double lower, double upper, double &dmatch, double &dphase)
double GetDelay(network *NET, TString ifo, double theta, double phi)
float wTHETA[PE_MAX_EVENTS]
void PlotWaveforms(int nIFO, int id, bool residual=false)
std::vector< double > vFF
void ReadUserOptions(TString options)
void GetFullCoverage(int nIFO, int selected, double *fcov50, double *fcov90, double *fcov99)
void Inverse(int n=-1)
param: n - number of steps (-1 means full reconstruction)
wavearray< double > GetRCut(wavearray< double > *ts, wavearray< double > *aux)
std::vector< double > vNE
float wSNR[PE_MAX_EVENTS][NIFO_MAX]
void Draw(GWAT_DRAW type=GWAT_TIME, TString options="ALP", Color_t color=kBlack)
static wavearray< double > GetSpectrum(wavearray< double > *x, bool oneside=false)
int ComputeWaveformFCR(int nIFO)
std::vector< double > xNE