3 #pragma GCC system_header
10 #include "TObjArray.h"
11 #include "TObjString.h"
12 #include "TPaletteAxis.h"
13 #include "TMultiLayerPerceptron.h"
14 #include "TMLPAnalyzer.h"
47 #define minANN_av -0.2
54 #define ANNth_min -0.5
55 #define RHOth_max 10.0
76 void Average_FAout_moreGraphs_3(
double FAdes,
TString NN_FILE,
TString NN_FILE2,
TString NN_FILE3,
TString NN_FILE4,
TString NN_FILE5,
TString NN_FILE6,
TString NN_FILE7,
TString NN_FILE8,
TString TEST_FILE,
TString NOMEtot_S,
int TS=0,
int TB=0,
int s=0,
int b=0,
int uf=1,
int consider_all=0,
int av_on_nNN=0){
78 if (uf==0&&av_on_nNN!=0) cout<<
"all events were not used for the training procedure"<<endl;
79 if(uf==0) {ni=1; consider_all=1; av_on_nNN=0;}
90 if (NN_FILE.CompareTo(
"")){
93 if (NN_FILE2.CompareTo(
"")){
96 if (NN_FILE3.CompareTo(
"")){
99 if (NN_FILE4.CompareTo(
"")){
102 if (NN_FILE5.CompareTo(
"")){
105 if (NN_FILE6.CompareTo(
"")){
108 if (NN_FILE7.CompareTo(
"")){
111 if (NN_FILE8.CompareTo(
"")){
118 char NNi2[nNN][1024];
119 sprintf(NNi2[0],
"%s",NN_FILE.Data());
120 if(nNN>1)
sprintf(NNi2[1],
"%s",NN_FILE2.Data());
121 if(nNN>2)
sprintf(NNi2[2],
"%s",NN_FILE3.Data());
122 if(nNN>3)
sprintf(NNi2[3],
"%s",NN_FILE4.Data());
123 if(nNN>4)
sprintf(NNi2[4],
"%s",NN_FILE5.Data());
124 if(nNN>5)
sprintf(NNi2[5],
"%s",NN_FILE6.Data());
125 if(nNN>6)
sprintf(NNi2[6],
"%s",NN_FILE7.Data());
126 if(nNN>7)
sprintf(NNi2[7],
"%s",NN_FILE8.Data());
128 if(nNN==1) {av_on_nNN=1; consider_all=0; ni=0;}
130 for (
int u=0;u<nNN;u++){
133 if (NNi2[u][p]==
'N'){
134 if((NNi2[u][p+1]==
'N')&&(NNi2[u][p+2]==
'\/')) {
136 while (NNi2[u][hh]!=
'\0'){NNi[u][hh-p-3]=NNi2[u][hh];hh=hh+1;}
148 sprintf(Filei2,
"%s",TEST_FILE.Data());
150 if(Filei2[q]==
'n'&&Filei2[q+1]==
'n'&&Filei2[q+2]==
'T'&&Filei2[q+3]==
'R'&&Filei2[q+4]==
'E'&&(Filei2[q+5]==
'E')&&(Filei2[q+6]==
'\/')) {
152 while (Filei2[hh]!=
'\0') {Filei[hh-q-7]=Filei2[hh];hh=hh+1;
154 for (
int h0=hh-q-7;h0<1024;h0++) Filei[h0]=
'\0';
160 cout<<Filei<<
" original String: "<<Filei2<<endl;
165 if(nNN>1) NNi0[1]=NNi[1];
166 if(nNN>2) NNi0[2]=NNi[2];
167 if(nNN>3) NNi0[3]=NNi[3];
168 if(nNN>4) NNi0[4]=NNi[4];
169 if(nNN>5) NNi0[5]=NNi[5];
170 if(nNN>6) NNi0[6]=NNi[6];
171 if(nNN>7) NNi0[7]=NNi[7];
176 for (
int u=0;u<nNN;u++){
177 NNi0[u].ReplaceAll(
".root",
"");
179 Filei0.ReplaceAll(
".root",
"");
183 TMultiLayerPerceptron* mlp[nNN];
189 for (
int yy=0;
yy<nNN;
yy++){TotBg[
yy]=0;FA0[
yy]=0;FD0[
yy]=0;}
203 for (
int u=0;u<nNN;u++){
204 fnet[u]=TFile::Open(NNi2[u]);
205 mlp[u]=(TMultiLayerPerceptron*)fnet[u]->
Get(
"TMultiLayerPerceptron");
207 cout<<
"dopo TMLP"<<endl;
208 if(mlp[u]==NULL) {cout <<
"Error getting mlp" << endl;
exit(1);}
209 infot[u]=(TTree*)fnet[u]->
Get(
"info");
211 infot[u]->SetBranchAddress(
"Rand_start_Sig",&NNs[u]);
212 infot[u]->SetBranchAddress(
"Rand_start_Bg",&NNb[u]);
213 infot[u]->SetBranchAddress(
"#trainSig",&NNnTS[u]);
214 infot[u]->SetBranchAddress(
"#trainBg",&NNnTB[u]);
215 infot[u]->GetEntry(0);
216 cout<<
"n "<<u<<
" b "<<NNb[u]<<
" min_NNb "<<min_NNb<<endl;
218 if(NNs[u]<min_NNs) min_NNs=NNs[u];
219 if(NNb[u]<min_NNb) min_NNb=NNb[u];
220 if(NNs[u]>max_NNs) max_NNs=NNs[u];
221 if(NNb[u]>max_NNb) max_NNb=NNb[u];
222 cout<<
"n "<<u<<
" s "<<NNs[u]<<
" b "<<NNb[u]<<
" s fin "<<NNs[u]+NNnTS[u]<<
" b fin "<<NNb[u]+NNnTB[u]<<
" nTS "<<NNnTS[u]<<
" nTB "<<NNnTB[u]<<endl;
233 cout<<
" min_NNb "<<min_NNb<<
" b "<<b<<endl;
234 cout<<
"Def. tree e mlp"<<endl;
237 TFile* fTEST =TFile::Open(TEST_FILE.Data());
238 cout<<
"Def. tree e mlp"<<endl;
239 TTree* NNTree=(TTree*)fTEST->Get(
"nnTree");
240 cout<<
"Def. tree e mlp"<<endl;
241 int entries=NNTree->GetEntries();
244 cout<<
"entries: "<<entries<<endl;
245 cout<<
" NNTree->GetEntries() "<<NNTree->GetEntries()<<endl;
255 NNTree->SetBranchAddress(
"#Entries_type",&entriesTot);
256 NNTree->SetBranchAddress(
"Matrix_dim",&ndim);
257 NNTree->SetBranchAddress(
"#inputs",&ninp);
258 NNTree->SetBranchAddress(
"amplitude_mode",&y);
261 sig_entries=entriesTot;
262 NNTree->GetEntry(entries-1);
263 bg_entries=entriesTot;
264 cout<<
"sig "<<sig_entries<<
" bg "<<bg_entries<<endl;
267 cout<<
"NDIM: "<<NDIM<<endl;
268 cout<<
"nINP: "<<nINP<<endl;
269 cout<<
"sig e: "<<sig_entries<<endl;
270 cout<<
"bg e: "<<bg_entries<<endl;
274 if (sig_entries>bg_entries) minevents=bg_entries;
275 else minevents=sig_entries;
282 cout<<
"TS "<<TS<<
" TB "<<
TB<<
" minevents "<<minevents<<endl;
287 cout<<
"Error: Bg index<sig_entries: new set of b parameter-> b="<<b<<
" instead of b="<<a<<endl;
293 cout<<
"Error: Sig index>sig_entries: new set of s parameter-> s="<<b<<
" instead of s="<<a<<endl;
295 if((TS>sig_entries-
s||
TB>(bg_entries-(b-sig_entries)))&&(TS==
TB)) {TS=minevents-
s;
TB=minevents-(b-sig_entries);
298 cout<<
"Error:S>sig_entries or TB>bg_entries, to maintain ugual number of analysed events TS=TB="<<
TB<<endl;
300 if((TS>sig_entries-
s||
TB>bg_entries-(b-sig_entries))&&(TS!=
TB)) {
301 if(TS>sig_entries) TS=sig_entries-
s;
302 if (
TB>bg_entries)
TB=bg_entries-(b-sig_entries);
303 cout<<
"Error:S>sig_entries or TB>bg_entries, new TS and TB values are thus define-> TS="<<TS<<
" TB="<<
TB<<endl;
308 sprintf(NOMEtot,
"%s",NOMEtot_S.Data());
309 cout<<
"output name: "<<NOMEtot<<endl;
315 NNTree->SetBranchAddress(
"Files_name",&FILE_NAME);
318 NNTree->GetEntry(entries-1);
320 cout<<
"fine ifdef RHO_CC"<<endl;
323 TChain sigTree(
"waveburst");
324 sigTree.Add(SIG_FILE.Data());
327 cout <<
"sig entries2 : " << sig_entries2 << endl;
329 TChain bgTree(
"waveburst");
330 bgTree.Add(BG_FILE.Data());
333 cout <<
"bg entries2 : " << bg_entries2 << endl;
335 cout<<
"b: "<<b<<endl;
336 cout<<
"s: "<<
s<<endl;
340 for (
int jj=0; jj<nINP;jj++) x[jj]=0.;
341 char ilabel[nINP][16];
344 for(
int i=0;
i<nINP;
i++) {
346 NNTree->SetBranchAddress(ilabel[i], &x[i]);
350 sprintf(ofile,
"average_file/%s.root",NOMEtot);
351 TFile*
f =
new TFile(ofile,
"RECREATE");
352 TTree* NNTree2=
new TTree(
"Parameters",
"Parameters");
353 NNTree2->SetDirectory(f);
356 NNTree->SetBranchAddress(
"duration", &DtTree);
360 for(
int y=0; y<nNN; y++) out[y]=0.;
374 NNTree2->Branch(
"Center_of_Gravity",&CoG,
"Center_of_Gravity/I");
375 NNTree2->Branch(
"duration",&Dt,
"duration/D");
377 NNTree2->Branch(
"Average",&average,
"Average/D");
378 NNTree2->Branch(
"StandardDevaition",&std,
"StandardDeviation/D");
379 NNTree2->Branch(
"cc",&NNcc,
"cc/D");
380 NNTree2->Branch(
"Mchirp",&Mc,
"Mchirp/D");
381 NNTree2->Branch(
"Mchirp_injected",&Mc_inj,
"Mchirp_injected/D");
382 NNTree2->Branch(
"rho",&NNrho,
"rho/D");
383 NNTree2->Branch(
"index",&index_ev,
"index/I");
386 NNTree2->Branch(
"Test_file",&TestFile,
"Test_file/C");
388 for(
int u=0;u<nNN;u++){
394 sprintf(NNoutl2,
"NNout%i/D",u);
396 sprintf(NNnamel2,
"NNname%i/C",u);
397 NNTree2->Branch(NNoutl,&out[u],NNoutl2);
398 NNTree2->Branch(NNnamel,&NNi[u],NNnamel2);
402 NNTree2->Branch(
"TestFile",&Testf,
"TestFile/C");
403 sprintf(Testf,
"%s",TEST_FILE.Data());
412 for(
int n=
s;
n<sig_entries;
n++) {
414 for(
int u=0;u<nNN;u++){
415 if (uf!=0&&
n>NNs[u]&&
n<(NNs[u]+NNnTS[u])) countNN=countNN+1;
421 if(countNN==0&&av_on_nNN!=0) scount=scount+1;
424 if(countNN==1&&consider_all==0&&av_on_nNN==0) scount=scount+1;
425 if(countNN<2&&consider_all!=0) scount=scount+1;
426 if(countNN>1){cout<<
"Error: training non independent"<<
n<<endl;
exit(0);}
427 cout<<
"n "<<
n<<
"; countNN "<<countNN<<
"; scount "<< scount<<
"; consider_all "<<consider_all<<
"; av_on_nNN "<<av_on_nNN<<endl;
428 if(scount==TS)
break;}
432 cout<<
" nTestS "<< nTestS<<
" TS "<<TS<<endl;
447 for(
int n=b;
n<sig_entries+bg_entries;
n++) {
449 for(
int u=0;u<nNN;u++){
450 if (uf!=0&&
n>NNb[u]&&
n<(NNb[u]+NNnTB[u])) countNN=countNN+1;
452 if(countNN==0&&av_on_nNN!=0) bcount=bcount+1;
454 if(countNN==1&&consider_all==0&&av_on_nNN==0) bcount=bcount+1;
455 if(countNN<2&&consider_all!=0) bcount=bcount+1;
456 if(countNN>1){cout<<
"Error: training non independent"<<
n<<endl;
exit(0);}
457 if(bcount==
TB)
break;
462 if(uf!=0) nTestS=nTestS-1;
463 if(uf!=0) nTestB=nTestB-1;
466 cout<<
"TS "<<TS<<
" TB "<<
TB<<
" nTestS "<<nTestS<<
" nTestB "<<nTestB<<endl;
468 if(nTestB>nTestS) {nTestB=nTestS;
TB=nTestS; TS=nTestS;}
469 else {nTestS=nTestB;
TB=nTestB; TS=nTestB;}
472 if(nTestS<TS) TS= nTestS;
476 NNTree2->Branch(
"#TestSig",&TS,
"#TestSig/I");
478 cout<<
"nTestS: "<<nTestS<<
" TS: "<<TS<<endl;
479 cout<<
"dopo def tree"<<endl;
480 cout<<
"s test "<<
s<<
" s+TS "<<
s+TS<<
" b "<<b<<
" b+ TB "<<b+
TB<<
" nTestS "<<nTestS<<
" TB "<<
TB<<
" nTestB "<<nTestB<<endl;
483 for (
int i=0;
i<nINP;
i++) params[
i]=0.;
489 TString txt_originaldata(NOMEtot_S);
490 txt_originaldata.ReplaceAll(
".root",
"_originalData.txt");
492 char txt_originaldata_c[1024];
493 sprintf(txt_originaldata_c,
"txt_files/%s.txt",txt_originaldata.Data());
494 ofstream od_txt(txt_originaldata_c);
498 for(
int n=
s;
n<sig_entries;
n++) {
506 for(
int u=0;u<nNN;u++){
507 if (uf!=0&&
n>=NNs[u]&&
n<(NNs[u]+NNnTS[u])) { indNN=u;countNN=countNN+1;}
509 if (countNN>1){cout<<
"Error: training non independent";
exit(0);}
510 if(nNN==1){cout<<
"out==Averege:only 1NN is considered"<<endl;}
511 if(consider_all==0&&av_on_nNN==0&&countNN==0)
continue;
512 if(consider_all==0&&av_on_nNN!=0&&countNN!=0) {sigskip=sigskip+1;
continue; }
518 NNcc=(double)signal.
netcc[0];
519 NNrho=(
double)signal.
rho[1];
521 Mc_inj=(
double)signal.
chirp[0];
524 cout<<
"DtTree "<<DtTree<<endl;
526 sprintf(TestFile,
"%s",TEST_FILE.Data());
533 for (
int i=0;
i<nINP;
i++){
540 ti_0+=(double)x[
i]*ti_i;
541 fi_0+=(double)x[
i]*fi_i;
542 sprintf(line_od2,
"%s %1.5f",line_od2, x[
i]);
544 sprintf(line_od2,
"%s \n",line_od2);
546 if (ti_0<fi_0) CoG=1;
551 for (
int u=0;u<nNN;u++) {
553 double output=mlp[u]->Evaluate(0,params);
563 for (
int u=0;u<nNN;u++){
564 if((u!=indNN&&ni==0)||uf==0) {average=out[u]+average;std+=out[u]*out[u];c_nNN0=c_nNN0+1;
if(out[u]<0.6) FD0[u]=FD0[u]+1;}
567 average=average/(c_nNN0);
568 if((c_nNN0)!=1)std=pow((std/(nNN-1-countNN)-average*average),0.5);
572 sprintf(line_od3,
"ev_ind %i average %1.5f Mc %1.5f Mc_inj %1.5f n %i \n",index_ev, average,Mc,Mc_inj,
n);
575 if (average<0.6) FD=FD+1;
580 cout<<
" cc "<<NNcc<<
" NNrho "<<NNrho<<
" Mc_inj "<< Mc_inj<<endl;
585 cout<<txt_originaldata_c<<endl;
588 cout<<
" S_eff "<<S_eff<<
" s "<<
s<<
" b "<<b<<
" sigskip "<<sigskip<<endl;
594 for(
int n=b;
n<sig_entries+bg_entries;
n++) {
602 for(
int u=0;u<nNN;u++){
603 cout<<
" uf "<<uf<<
" n "<<
n<<
" u "<<u<<
" NN b[u] "<<NNb[u]<<
" NNb[u]+NNnTB[u]"<<NNb[u]+NNnTB[u]<<endl;
604 if (uf!=0&&
n>=NNb[u]&&
n<(NNb[u]+NNnTB[u])) { indNN=u;countNN=countNN+1; }
606 if (countNN>1){cout<<
"Error: training non independent";
exit(0);}
607 if(nNN==1){cout<<
"out==Averege:only 1NN is considered"<<endl;}
608 cout<<
"consider_all "<<consider_all<<
" av_on_nNN "<<av_on_nNN<<
" countNN "<<countNN<<
" indNN "<<indNN<<endl;
609 if(consider_all==0&&av_on_nNN==0&&countNN==0)
continue;
610 if(consider_all==0&&av_on_nNN!=0&&countNN!=0) { cout<<
" n skipped "<<
n<<endl; bgskip=bgskip+1;
continue;}
612 cout<<
"BKG->n: "<<
n<<
"Bg index"<<(
n-sig_entries)<<endl;
615 NNcc=(double)background.
netcc[0];
617 NNrho=(
double)background.
rho[1];
619 Mc_inj=(
double)background.
chirp[0];
623 cout<<
"background.duration[0] "<<background.
duration[0]<<
" background.duration[1] "<<background.
duration[1]<<
" background.duration[2] "<<background.
duration[2]<<endl;
628 sprintf(TestFile,
"%s",TEST_FILE.Data());
630 for (
int i=0;
i<nINP;
i++){
636 ti_0+=(double)x[
i]*ti_i;
637 fi_0+=(double)x[
i]*fi_i;
640 if (ti_0<fi_0) CoG=1;
643 for(
int u=0;u<nNN;u++) {
644 double output=mlp[u]->Evaluate(0,params);
651 for (
int u=0;u<nNN;u++){
652 if((u!=indNN&&ni==0)||uf==0) {average=out[u]+average;std+=out[u]*out[u];c_nNN0=c_nNN0+1; TotBg[u]=TotBg[u]+1;
if(out[u]>0.6) {FA0[u]=FA0[u]+1;nnsu=nnsu+1;}}
656 average=average/(c_nNN0);
657 if((c_nNN0)!=1)std=pow((std/(nNN-1-countNN)-average*average),0.5);
660 if(nnsu==6) cont_su=cont_su+1;
661 if(nnsu>4) cont_su5=cont_su5+1;
662 if(nnsu>3) cont_su4=cont_su4+1;
663 if(nnsu>2) cont_su3=cont_su3+1;
669 if(average>0.6) FA=FA+1;
680 cout<<
"B_eff "<<B_eff<<
" TB "<<
TB<<endl;
690 for (
int yy=0;
yy<nNN;
yy++){
693 if(TotBg[
yy]!=0){freq_c[
yy]=(double)FA0[
yy]/TotBg[
yy];
696 if(freq_c[
yy]!=0) {meanf=freq_c[
yy]+meanf;cont=cont+1;
699 dev=freq_c[
yy]*freq_c[
yy]+dev;
702 if(cont==0) cout<<
"Error cont==0"<<endl;
703 if(cont!=0) meanf=meanf/cont;
705 for (
int yy=0;
yy<nNN;
yy++){
708 if(freq_c[
yy]!=0)dev+=(freq_c[
yy]-meanf)*(freq_c[
yy]-meanf);
710 double McFAdes=FAdes;
711 int FAth_n=FAdes*B_eff;
712 int McFAth_n=FAdes*B_eff;
713 cout<<
"FAth_n "<<FAth_n<<
" FAdes*B_eff "<<FAdes*B_eff<<endl;
718 Annth(ofile, FAth_n, FDth_n, thresFA);
719 Mcth(ofile, McFAth_n, McFDth_n, McthresFA);
727 if(cont!=0) dev=pow(dev/(cont-1),0.5);
728 cout<<
"meanf "<<meanf<<
" dev "<<dev<<endl;
729 cout<<
" FA average "<<FA<<endl;
730 cout<<
" cont_su "<<cont_su<<
" cont_su5 "<<cont_su5<<
" cont_su4 "<<cont_su4<<
" cont_su3 "<<cont_su3<<endl;
732 cout<<
" S_eff "<<S_eff<<
" B_eff "<<B_eff<<
" s "<<
s<<
" b "<<b<<
" bgskip "<<bgskip<<
" sigskip "<<sigskip<<endl;
733 cout<<
" FA0[1] "<<FA0[1]<<
" TotBg[1] "<<TotBg[1]<<endl;
734 cout<<
" FD0[1] "<<FD0[1]<<
" TotBg[1] "<<TotBg[1]<<endl;
736 double FDdes=(double)FDth_n/S_eff;
737 double McFDdes=(double)McFDth_n/S_eff;
738 FAdes=(double)FAth_n/B_eff;
739 McFAdes=(double)McFAth_n/B_eff;
740 cout<<
"FAth_n "<<FAth_n<<
" FAdes: "<<FAdes<<
" ANN_av_FDdes "<<FDdes<<
" ANN_av_FDth_n "<<FDth_n<<
" ANN_av_thresFA "<<thresFA<<endl;
741 cout<<
"McFAth_n "<<McFAth_n<<
" McFAdes: "<<McFAdes<<
" Mc_FDdes "<<McFDdes<<
" McFDth_n "<<McFDth_n<<
" McthresFA "<<McthresFA<<endl;
746 name.ReplaceAll(
"average_file/",
"");
747 TFile* fTEST =TFile::Open(ifile.Data());
748 TTree* NNTree2=(TTree*)fTEST->Get(
"Parameters");
753 NNTree2->SetBranchAddress(
"Average",&av);
754 NNTree2->SetBranchAddress(
"cc",&cc);
755 NNTree2->SetBranchAddress(
"rho",&rho);
756 NNTree2->SetBranchAddress(
"#TestSig",&nSi);
757 NNTree2->GetEntry(0);
759 cout<<
"nSig: "<<nSig<<
" nSi: "<<nSi<<endl;
760 cout<<
" BG: "<<NNTree2->GetEntries()-nSi<<endl;
762 cout<<
"dentro funzione dopodef"<<endl;
764 double* rhoSig[ncurve];
765 for (
int i=0;
i<ncurve;
i++) rhoSig[
i]=
new double[nSig];
766 cout<<
"dopo def rhoSig"<<endl;
770 int const nBg=NNTree2->GetEntries()-nSig;
771 for (
int i=0;
i<ncurve;
i++) {
773 for (
int j=0;
j<nSig;
j++) rhoSig[
i][
j]=0.;
775 cout<<
"dopo def rhoSig"<<endl;
776 double* rhoBg[ncurve];
777 for (
int i=0;
i<ncurve;
i++) rhoBg[
i]=
new double[nBg];
780 for (
int i=0;
i<ncurve;
i++) {
782 for (
int j=0;
j<nBg;
j++) rhoBg[
i][
j]=0.;
784 cout<<
"dopo def rhoBg"<<endl;
786 for (
int i=0;
i<
nCC;
i++) ccTh[
i]=0.;
788 for (
int i=0;
i<
nANN;
i++) NNTh[
i]=0.;
794 cout<<NNTree2->GetEntries()<<endl;
795 for(
int n=0;
n<NNTree2->GetEntries();
n++){
797 NNTree2->GetEntry(
n);
798 cout<<
"rho "<<rho<<
" cc "<<cc<<
" av "<<av<<endl;
801 if(cc<ccTh[
i])
continue;
803 if(
j==0) NNTh[
j]=-1000.;
809 if(av<NNTh[
j])
continue;
813 NBg[i*nANN+
j]= NBg[i*nANN+
j]+1;
814 while(rhoBg[i*nANN+j][ni]!=0)ni=ni+1;
815 rhoBg[i*nANN+
j][ni]=
rho;
820 NSig[i*nANN+
j]= NSig[i*nANN+
j]+1;
821 while(rhoSig[i*nANN+j][ni]!=0)ni=ni+1;
822 rhoSig[i*nANN+
j][ni]=
rho;
830 cout<<
"dopo riempimento variabili"<<endl;
832 for (
int i=0;
i<ncurve;
i++) indexS[
i]=
new int[nSig];
835 for (
int y=0;
y<ncurve;
y++) {
848 TMath::Sort(nSig,rhoSig[
y],indexS[y],
false);
850 for (
int k=0;
k<nSig;
k++) {
855 int ij=indexS[
y][
k-1];
857 if(rhoSig[y][ii]!=0) {
860 if(rhoSig[y][ii]!=rhoSig[y][ij]) gS[
y]->SetPoint(igS_p++,rhoSig[y][ii],yy);
861 cout<<
"igS"<<igS<<
" x "<<rhoSig[
y][ii]<<
" y: "<<yy<<endl;
866 if(rhoSig[y][ii]!=0){
868 gS[
y]->SetPoint(0,rhoSig[y][ii],yy);
879 for (
int i=0;
i<ncurve;
i++) indexB[
i]=
new int[nBg];
882 for (
int y=0;
y<ncurve;
y++) {
886 TMath::Sort(nBg,rhoBg[
y],indexB[y],
false);
888 for (
int k=0;
k<nBg;
k++) {
892 int ij=indexB[
y][
k-1];
894 if(rhoBg[y][ii]!=0) {
897 if(rhoBg[y][ii]!=rhoBg[y][ij]) gB[
y]->SetPoint(igB_p++,rhoBg[y][ii],yy);
903 if(rhoBg[y][ii]!=0) {
905 gB[
y]->SetPoint(0,rhoBg[y][ii],yy);
912 cout<<
"dopo inserimento puntiB"<<endl;
915 TCanvas* cS=
new TCanvas(
"Efficiency_vs_rho",
"Efficiency_vs_rho",0,0,1200,700);
919 TMultiGraph* mg1=
new TMultiGraph();
921 gS[0]->SetMarkerColor(2);
922 gS[0]->SetLineColor(2);
923 mg1->SetTitle(
"cc=0.5;rho;#Events");
924 if(gS[0]->GetN()!=0) mg1->Add(gS[0]);
927 gS[
h]->SetMarkerColor(3);
928 gS[
h]->SetLineColor(3);
930 if(gS[
h]->GetN()!=0) mg1->Add(gS[
h]);
936 TMultiGraph* mg2=
new TMultiGraph();
938 gS[
nANN]->SetMarkerColor(2);
939 gS[
nANN]->SetLineColor(2);
940 mg2->SetTitle(
"cc=0.55;rho;#Events");
941 if(gS[nANN]->GetN()!=0) mg2->Add(gS[nANN]);
943 gS[nANN+
h]->SetMarkerColor(3);
944 gS[nANN+
h]->SetLineColor(3);
946 if(gS[nANN+
h]->GetN()!=0) mg2->Add(gS[nANN+
h]);
952 TMultiGraph* mg3=
new TMultiGraph();
954 gS[nANN*2]->SetMarkerColor(2);
955 gS[nANN*2]->SetLineColor(2);
956 mg3->SetTitle(
"cc=0.6;rho;#Events");
957 if(gS[nANN*2]->GetN()!=0) mg3->Add(gS[nANN*2]);
959 gS[2*nANN+
h]->SetMarkerColor(3);
960 gS[2*nANN+
h]->SetLineColor(3);
962 if(gS[2*nANN+
h]->GetN()!=0) mg3->Add(gS[2*nANN+
h]);
968 TMultiGraph* mg4=
new TMultiGraph();
970 gS[nANN*3]->SetMarkerColor(2);
971 gS[nANN*3]->SetLineColor(2);
972 mg4->SetTitle(
"cc=0.65;rho;#Events");
973 if(gS[nANN*3]->GetN()!=0) mg4->Add(gS[nANN*3]);
976 gS[3*nANN+
h]->SetMarkerColor(3);
977 gS[3*nANN+
h]->SetLineColor(3);
979 if(gS[3*nANN+
h]->GetN()!=0) mg4->Add(gS[3*nANN+
h]);
983 cout<<
"nuovo canv"<<endl;
984 TCanvas* cB=
new TCanvas(
"Number_vs_rho",
"Number_vs_rho",0,0,1200,700);
986 cB->cd(1)->SetLogy();
987 TMultiGraph* mg1B=
new TMultiGraph();
989 gB[0]->SetMarkerColor(2);
990 gB[0]->SetLineColor(2);
991 mg1B->SetTitle(
"cc=0.5;rho;#Events");
992 if(gB[0]->GetN()!=0) mg1B->Add(gB[0]);
994 gB[
h]->SetMarkerColor(3);
995 gB[
h]->SetLineColor(3);
997 if(gB[
h]->GetN()!=0) mg1B->Add(gB[
h]);
1001 cB->cd(2)->SetLogy();
1002 TMultiGraph* mg2B=
new TMultiGraph();
1004 gB[
nANN]->SetMarkerColor(2);
1005 gB[
nANN]->SetLineColor(2);
1006 mg2B->SetTitle(
"cc=0.55;rho;#Events");
1007 if(gB[nANN]->GetN()!=0) mg2B->Add(gB[nANN]);
1009 gB[nANN+
h]->SetMarkerColor(3);
1010 gB[nANN+
h]->SetLineColor(3);
1012 if(gB[nANN+
h]->GetN()!=0) mg2B->Add(gB[nANN+
h]);
1016 cB->cd(3)->SetLogy();
1017 TMultiGraph* mg3B=
new TMultiGraph();
1019 gB[2*
nANN]->SetMarkerColor(2);
1020 gB[2*
nANN]->SetLineColor(2);
1021 mg3B->SetTitle(
"cc=0.6;rho;#Events");
1022 if(gB[2*nANN]->GetN()!=0) mg3B->Add(gB[2*nANN]);
1024 gB[2*nANN+
h]->SetMarkerColor(3);
1025 gB[2*nANN+
h]->SetLineColor(3);
1027 if(gB[2*nANN+
h]->GetN()!=0) mg3B->Add(gB[2*nANN+
h]);
1031 cB->cd(4)->SetLogy();
1032 TMultiGraph* mg4B=
new TMultiGraph();
1034 gB[3*
nANN]->SetMarkerColor(2);
1035 gB[3*
nANN]->SetLineColor(2);
1036 mg4B->SetTitle(
"cc=0.65;rho;#Events");
1037 if(gB[3*nANN]->GetN()!=0) mg4B->Add(gB[3*nANN]);
1039 gB[3*nANN+
h]->SetMarkerColor(3);
1040 gB[3*nANN+
h]->SetLineColor(3);
1042 if(gB[3*nANN+
h]->GetN()!=0) mg4B->Add(gB[3*nANN+
h]);
1054 char CnameS2root[1024];
1055 char CnameB2root[1024];
1056 CnameS.ReplaceAll(
".root",
".png");
1057 CnameB.ReplaceAll(
".root",
".png");
1058 sprintf(CnameS2,
"logN_rho_av/logN_rho_S_dANN%1.2f_%s",
deltaANN,CnameS.Data());
1059 sprintf(CnameB2,
"logN_rho_av/logN_rho_B_dANN%1.2f_%s",
deltaANN,CnameB.Data());
1060 sprintf(CnameS2root,
"logN_rho_av/logN_rho_S_dANN%1.2f_%s",
deltaANN,CnameSroot.Data());
1061 sprintf(CnameB2root,
"logN_rho_av/logN_rho_B_dANN%1.2f_%s",
deltaANN,CnameBroot.Data());
1062 cS->SaveAs(CnameS2);
1063 cB->SaveAs(CnameB2);
1064 cS->Print(CnameS2root);
1065 cB->Print(CnameB2root);
1073 name.ReplaceAll(
"average_file/",
"");
1074 TFile* fTEST =TFile::Open(ifile.Data());
1075 TTree* NNTree2=(TTree*)fTEST->Get(
"Parameters");
1080 NNTree2->SetBranchAddress(
"Average",&av);
1081 NNTree2->SetBranchAddress(
"cc",&cc);
1082 NNTree2->SetBranchAddress(
"rho",&rho);
1083 NNTree2->SetBranchAddress(
"#TestSig",&nSi);
1084 NNTree2->GetEntry(0);
1086 cout<<
"nSig: "<<nSig<<
" nSi: "<<nSi<<endl;
1090 double* ANNSig[ncurve2];
1091 for (
int i=0;
i<ncurve2;
i++) ANNSig[
i]=
new double[nSig];
1095 int const nBg=NNTree2->GetEntries()-nSig;
1096 for (
int i=0;
i<ncurve2;
i++) {
1098 for (
int j=0;
j<nSig;
j++) ANNSig[
i][
j]=0.;
1100 double* ANNBg[ncurve2];
1101 for (
int i=0;
i<ncurve2;
i++) ANNBg[
i]=
new double[nBg];
1105 for (
int i=0;
i<ncurve2;
i++) {
1107 for (
int j=0;
j<nBg;
j++) ANNBg[
i][
j]=0.;
1110 for (
int i=0;
i<
nCC;
i++) ccTh[
i]=0.;
1112 for (
int i=0;
i<
nRHO;
i++) rhoTh[
i]=0.;
1119 for(
int n=0;
n<NNTree2->GetEntries();
n++){
1120 NNTree2->GetEntry(
n);
1121 cout<<
"rho "<<rho<<
" cc "<<cc<<
" av "<<av<<endl;
1125 if(cc<ccTh[
i])
continue;
1129 if(rho<rhoTh[
j])
continue;
1132 NBg[i*nRHO+
j]= NBg[i*nRHO+
j]+1;
1133 if(i*nRHO+j==0) cout<<
" NBg[i*nRHO+j] "<<NBg[i*nRHO+
j]<<endl;
1134 while(ANNBg[i*nRHO+j][ni]!=0)ni=ni+1;
1135 ANNBg[i*nRHO+
j][ni]=av;
1140 NSig[i*nRHO+
j]= NSig[i*nRHO+
j]+1;
1141 if(i*nRHO+j==0) cout<<
" NSig[i*nRHO+j] "<<NSig[i*nRHO+
j]<<endl;
1142 while(ANNSig[i*nRHO+j][ni]!=0)ni=ni+1;
1143 ANNSig[i*nRHO+
j][ni]=av;
1149 int* indexS[ncurve2];
1150 for (
int i=0;
i<ncurve2;
i++) indexS[
i]=
new int[nSig];
1152 TGraph * gS[ncurve2];
1153 for (
int y=0;
y<ncurve2;
y++) {
1157 TMath::Sort(nSig,ANNSig[
y],indexS[y],
false);
1158 for (
int k=0;
k<nSig;
k++) {
1159 int ii=indexS[
y][
k];
1163 int ij=indexS[
y][
k-1];
1165 if(ANNSig[y][ii]!=0) {
1168 if(ANNSig[y][ii]!=ANNSig[y][ij]) gS[
y]->SetPoint(igS_p++,ANNSig[y][ii],yy);
1175 if(ANNSig[y][ii]!=0){
1177 gS[
y]->SetPoint(0,ANNSig[y][ii],yy);
1188 int* indexB[ncurve2];
1189 for (
int i=0;
i<ncurve2;
i++) indexB[
i]=
new int[nBg];
1191 TGraph * gB[ncurve2];
1192 for (
int y=0;
y<ncurve2;
y++) {
1196 TMath::Sort(nBg,ANNBg[
y],indexB[y],
false);
1198 for (
int k=0;
k<nBg;
k++) {
1199 int ii=indexB[
y][
k];
1200 int ik=indexB[
y][
k-1];
1203 int ij=indexB[
y][
k-1];
1205 if(ANNBg[y][ii]!=0) {
1207 if(y==0 && yy==FAth_n+1) {thresFA=ANNBg[
y][ii];}
1208 if (y==0 && yy<FAth_n+1)
if(ANNBg[y][ii]==ANNBg[y][ik]){FAth_n=FAth_n-1;}
1209 if(y==0) cout<<
"yy "<<yy<<
" y "<<y<<
" FAth_n "<<FAth_n<<
" thresFA "<<thresFA<<
" ANNBg[y][ii] "<<ANNBg[
y][ii]<<endl;
1211 if(ANNBg[y][ii]!=ANNBg[y][ij]) gB[
y]->SetPoint(igB_p++,ANNBg[y][ii],yy);
1217 if(ANNBg[y][ii]!=0) {
1219 gB[
y]->SetPoint(0,ANNBg[y][ii],yy);
1230 for(
int ni=1;ni<nSig;ni++){
1231 cout<<
"FAth_n "<<FAth_n<<
" thresFA "<<thresFA<<
" ANNSig[0][indexS[0][ni]] "<<ANNSig[0][indexS[0][ni]]<<
" FDth_n "<<FDth_n<<
" NSig[0]-(ni-1 )"<<NSig[0]-(ni-1)<<
" NSig[0] "<<NSig[0]<<endl;
1233 if (ANNSig[0][indexS[0][ni]]<=thresFA) FDth_n=FDth_n+1;
1238 TCanvas* cS=
new TCanvas(
"Efficiency_vs_ANN",
"Efficiency_vs_ANN",0,0,1200,700);
1242 TMultiGraph* mg1=
new TMultiGraph();
1243 mg1->SetTitle(
"cc: no_cut;ANN;#Events");
1245 gS[
h]->SetLineColor(4);
1246 if(gS[
h]->GetN()!=0) mg1->Add(gS[
h]);
1251 TMultiGraph* mg2=
new TMultiGraph();
1252 mg2->SetTitle(
"cc=0.55;ANN;#Events");
1254 gS[nRHO+
h]->SetLineColor(4);
1255 if(gS[nRHO+
h]->GetN()!=0) mg2->Add(gS[nRHO+
h]);
1261 TMultiGraph* mg3=
new TMultiGraph();
1262 mg3->SetTitle(
"cc=0.6;ANN;#Events");
1264 gS[2*nRHO+
h]->SetLineColor(4);
1265 if(gS[2*nRHO+
h]->GetN()!=0) mg3->Add(gS[2*nRHO+
h]);
1270 TMultiGraph* mg4=
new TMultiGraph();
1271 mg4->SetTitle(
"cc=0.65;ANN;#Events");
1273 gS[3*nRHO+
h]->SetLineColor(4);
1274 if(gS[3*nRHO+
h]->GetN()!=0) mg4->Add(gS[3*nRHO+
h]);
1278 TCanvas* cB=
new TCanvas(
"Number_vs_ANN",
"Number_vs_ANN",0,0,1200,700);
1280 cB->cd(1)->SetLogy();
1281 TMultiGraph* mg1B=
new TMultiGraph();
1282 mg1B->SetTitle(
"cc: no_cut;ANN;#Events");
1284 gB[
h]->SetLineColor(4);
1285 if(gB[
h]->GetN()!=0) mg1B->Add(gB[
h]);
1288 cB->cd(2)->SetLogy();
1289 TMultiGraph* mg2B=
new TMultiGraph();
1290 mg2B->SetTitle(
"cc=0.55;ANN;#Events");
1292 gB[nRHO+
h]->SetLineColor(4);
1293 if(gB[nRHO+
h]->GetN()!=0) mg2B->Add(gB[nRHO+
h]);
1296 cB->cd(3)->SetLogy();
1297 TMultiGraph* mg3B=
new TMultiGraph();
1298 mg3B->SetTitle(
"cc=0.6;ANN;#Events");
1300 gB[2*nRHO+
h]->SetLineColor(4);
1301 if(gB[2*nRHO+
h]->GetN()!=0) mg3B->Add(gB[2*nRHO+
h]);
1304 cB->cd(4)->SetLogy();
1305 TMultiGraph* mg4B=
new TMultiGraph();
1306 mg4B->SetTitle(
"cc=0.65;ANN;#Events");
1308 gB[3*nRHO+
h]->SetLineColor(4);
1309 if(gB[3*nRHO+
h]->GetN()!=0) mg4B->Add(gB[3*nRHO+
h]);
1321 char CnameS2root[1024];
1322 char CnameB2root[1024];
1323 CnameS.ReplaceAll(
".root",
".png");
1324 CnameB.ReplaceAll(
".root",
".png");
1325 sprintf(CnameS2,
"ANNthres_av/N_ANN_S_%s",CnameS.Data());
1326 sprintf(CnameB2,
"ANNthres_av/N_ANN_B_%s",CnameB.Data());
1327 sprintf(CnameS2root,
"ANNthres_av/N_ANN_S_%s",CnameSroot.Data());
1328 sprintf(CnameB2root,
"ANNthres_av/N_ANN_B_%s",CnameBroot.Data());
1329 cS->SaveAs(CnameS2);
1330 cB->SaveAs(CnameB2);
1331 cS->Print(CnameS2root);
1332 cB->Print(CnameB2root);
1343 name.ReplaceAll(
"outfile/",
"");
1344 name.ReplaceAll(
"average_file/",
"");
1345 TFile* fTEST =TFile::Open(ifile.Data());
1346 TTree* NNTree2=(TTree*)fTEST->Get(
"Parameters");
1356 NNTree2->SetBranchAddress(
"Mchirp",&Mc);
1357 NNTree2->SetBranchAddress(
"Average",&av);
1358 NNTree2->SetBranchAddress(
"cc",&cc);
1359 NNTree2->SetBranchAddress(
"rho",&rho);
1360 NNTree2->SetBranchAddress(
"Mchirp_injected",&Mc_inj);
1361 NNTree2->SetBranchAddress(
"#TestSig",&nSi);
1362 NNTree2->GetEntry(0);
1364 cout<<
"nSig: "<<nSig<<
" nSi: "<<nSi<<endl;
1367 double* McSig[ncurve2];
1368 for (
int i=0;
i<ncurve2;
i++) McSig[
i]=
new double[nSig];
1372 int const nBg=NNTree2->GetEntries()-nSig;
1373 for (
int i=0;
i<ncurve2;
i++) {
1375 for (
int j=0;
j<nSig;
j++) McSig[
i][
j]=0.;
1377 double* McBg[ncurve2];
1378 for (
int i=0;
i<ncurve2;
i++) McBg[
i]=
new double[nBg];
1382 for (
int i=0;
i<ncurve2;
i++) {
1384 for (
int j=0;
j<nBg;
j++) McBg[
i][
j]=0.;
1387 for (
int i=0;
i<
nCC;
i++) ccTh[
i]=0.;
1389 for (
int i=0;
i<
nRHO;
i++) rhoTh[
i]=0.;
1395 for(
int n=0;
n<NNTree2->GetEntries();
n++){
1396 NNTree2->GetEntry(
n);
1397 cout<<
"rho "<<rho<<
" cc "<<cc<<
" av "<<av<<endl;
1401 if(cc<ccTh[
i])
continue;
1405 if(rho<rhoTh[
j])
continue;
1408 NBg[i*nRHO+
j]= NBg[i*nRHO+
j]+1;
1409 if(i*nRHO+j==0) cout<<
" NBg[i*nRHO+j] "<<NBg[i*nRHO+
j]<<endl;
1410 while(McBg[i*nRHO+j][ni]!=0)ni=ni+1;
1411 McBg[i*nRHO+
j][ni]=Mc;
1416 NSig[i*nRHO+
j]= NSig[i*nRHO+
j]+1;
1417 if(i*nRHO+j==0) cout<<
" NSig[i*nRHO+j] "<<NSig[i*nRHO+
j]<<endl;
1418 while(McSig[i*nRHO+j][ni]!=0)ni=ni+1;
1419 McSig[i*nRHO+
j][ni]=Mc;
1426 int* indexS[ncurve2];
1427 for (
int i=0;
i<ncurve2;
i++) indexS[
i]=
new int[nSig];
1429 TGraph * gS[ncurve2];
1430 for (
int y=0;
y<ncurve2;
y++) {
1434 TMath::Sort(nSig,McSig[
y],indexS[y],
false);
1435 for (
int k=0;
k<nSig;
k++) {
1436 int ii=indexS[
y][
k];
1440 int ij=indexS[
y][
k-1];
1442 if(McSig[y][ii]!=0) {
1445 if(McSig[y][ii]!=McSig[y][ij]) gS[
y]->SetPoint(igS_p++,McSig[y][ii],yy);
1452 if(McSig[y][ii]!=0){
1454 gS[
y]->SetPoint(0,McSig[y][ii],yy);
1464 int* indexB[ncurve2];
1465 for (
int i=0;
i<ncurve2;
i++) indexB[
i]=
new int[nBg];
1467 TGraph * gB[ncurve2];
1468 for (
int y=0;
y<ncurve2;
y++) {
1472 TMath::Sort(nBg,McBg[
y],indexB[y],
false);
1474 for (
int k=0;
k<nBg;
k++) {
1475 int ii=indexB[
y][
k];
1476 int ik=indexB[
y][
k-1];
1479 int ij=indexB[
y][
k-1];
1481 if(McBg[y][ii]!=0) {
1483 if(y==0 && yy==McFAth_n+1) {McthresFA=McBg[
y][ii];
1485 if (y==0 && yy<McFAth_n+1) { cout<<
"dentro primo if"<<endl;
1487 if(McBg[y][ii]>McBg[y][ik]){McFAth_n=McFAth_n;cout<<
"maggiore ii "<<
" diff"<<(McBg[
y][ii]-McBg[
y][ik])<<endl;}
1488 if(McBg[y][ii]<McBg[y][ik]){McFAth_n=McFAth_n;cout<<
"minore ii"<<endl;}
1489 if(McBg[y][ii]==McBg[y][ik]){McFAth_n=McFAth_n-1;cout<<
"uguale"<<endl;}
1492 if(y==0) cout<<
"ii "<<ii<<
" yy "<<yy<<
" y "<<y<<
" McFAth_n "<<McFAth_n<<
"McthresFA "<<McthresFA<<
" McBg[y][ii] "<<McBg[
y][ii]<<
" McBg[y][indexB[y][k-1] "<<McBg[
y][indexB[
y][
k-1]]<<endl;
1494 if(McBg[y][ii]!=McBg[y][ij]) gB[
y]->SetPoint(igB_p++,McBg[y][ii],yy);
1500 if(McBg[y][ii]!=0) {
1502 gB[
y]->SetPoint(0,McBg[y][ii],yy);
1511 for(
int ni=1;ni<nSig;ni++){
1512 cout<<
"McFAth_n "<<McFAth_n<<
" McthresFA "<<McthresFA<<
" McSig[0][indexS[0][ni]] "<<McSig[0][indexS[0][ni]]<<
" McFDth_n "<<McFDth_n<<
" NSig[0]-(ni-1 )"<<NSig[0]-(ni-1)<<
" NSig[0] "<<NSig[0]<<endl;
1514 if (McSig[0][indexS[0][ni]]<=McthresFA) McFDth_n=McFDth_n+1;
1518 TCanvas* cS=
new TCanvas(
"Efficiency_vs_Mchirp",
"Efficiency_vs_Mchirp",0,0,1200,700);
1522 TMultiGraph* mg1=
new TMultiGraph();
1523 mg1->SetTitle(
"cc: no_cut;Mchirp;#Events");
1525 gS[
h]->SetLineColor(4);
1526 if(gS[
h]->GetN()!=0) mg1->Add(gS[
h]);
1531 TMultiGraph* mg2=
new TMultiGraph();
1532 mg2->SetTitle(
"cc=0.55;Mchirp;#Events");
1534 gS[nRHO+
h]->SetLineColor(4);
1535 if(gS[nRHO+
h]->GetN()!=0) mg2->Add(gS[nRHO+
h]);
1541 TMultiGraph* mg3=
new TMultiGraph();
1542 mg3->SetTitle(
"cc=0.6;Mchirp;#Events");
1544 gS[2*nRHO+
h]->SetLineColor(4);
1545 if(gS[2*nRHO+
h]->GetN()!=0) mg3->Add(gS[2*nRHO+
h]);
1550 TMultiGraph* mg4=
new TMultiGraph();
1551 mg4->SetTitle(
"cc=0.65;Mchirp;#Events");
1553 gS[3*nRHO+
h]->SetLineColor(4);
1554 if(gS[3*nRHO+
h]->GetN()!=0) mg4->Add(gS[3*nRHO+
h]);
1558 TCanvas* cB=
new TCanvas(
"Number_vs_Mchirp",
"Number_vs_Mchirp",0,0,1200,700);
1560 cB->cd(1)->SetLogy();
1561 TMultiGraph* mg1B=
new TMultiGraph();
1562 mg1B->SetTitle(
"cc: no_cut;Mchirp;#Events");
1564 gB[
h]->SetLineColor(4);
1565 if(gB[
h]->GetN()!=0) mg1B->Add(gB[
h]);
1568 cB->cd(2)->SetLogy();
1569 TMultiGraph* mg2B=
new TMultiGraph();
1570 mg2B->SetTitle(
"cc=0.55;Mchirp;#Events");
1572 gB[nRHO+
h]->SetLineColor(4);
1573 if(gB[nRHO+
h]->GetN()!=0) mg2B->Add(gB[nRHO+
h]);
1576 cB->cd(3)->SetLogy();
1577 TMultiGraph* mg3B=
new TMultiGraph();
1578 mg3B->SetTitle(
"cc=0.6;Mchirp;#Events");
1580 gB[2*nRHO+
h]->SetLineColor(4);
1581 if(gB[2*nRHO+
h]->GetN()!=0) mg3B->Add(gB[2*nRHO+
h]);
1584 cB->cd(4)->SetLogy();
1585 TMultiGraph* mg4B=
new TMultiGraph();
1586 mg4B->SetTitle(
"cc=0.6;Mchirp;#Events");
1588 gB[3*nRHO+
h]->SetLineColor(4);
1589 if(gB[3*nRHO+
h]->GetN()!=0) mg4B->Add(gB[3*nRHO+
h]);
1600 char CnameS2root[1024];
1601 char CnameB2root[1024];
1602 CnameS.ReplaceAll(
".root",
".png");
1603 CnameB.ReplaceAll(
".root",
".png");
1604 sprintf(CnameS2,
"Mcthres/N_Mc_S_%s",CnameS.Data());
1605 sprintf(CnameB2,
"Mcthres/N_Mc_B_%s",CnameB.Data());
1606 sprintf(CnameS2root,
"Mcthres/N_Mc_S_%s",CnameSroot.Data());
1607 sprintf(CnameB2root,
"Mcthres/N_Mc_B_%s",CnameBroot.Data());
1608 cS->SaveAs(CnameS2);
1609 cB->SaveAs(CnameB2);
1610 cS->Print(CnameS2root);
1611 cB->Print(CnameB2root);
1618 name.ReplaceAll(
"outfile/",
"");
1619 name.ReplaceAll(
"average_file/",
"");
1620 TFile* fTEST =TFile::Open(ifile.Data());
1621 TTree* NNTree2=(TTree*)fTEST->Get(
"Parameters");
1629 NNTree2->SetBranchAddress(
"Average",&av);
1630 NNTree2->SetBranchAddress(
"cc",&cc);
1631 NNTree2->SetBranchAddress(
"rho",&rho);
1632 NNTree2->SetBranchAddress(
"#TestSig",&nSi);
1633 NNTree2->GetEntry(0);
1635 cout<<
"nSig: "<<nSig<<
" nSi: "<<nSi<<endl;
1636 int const nBg=NNTree2->GetEntries()-nSig;
1637 cout<<
"nBg: "<<nBg<<
" Entries: "<<NNTree2->GetEntries()<<endl;
1644 for (
int n = 0;
n <NNTree2->GetEntries();
n++){
1645 NNTree2->GetEntry(
n);
1647 gS[0]->SetPoint(
n,cc,av);
1648 cout<<
"Sig_graph1: x="<<cc<<
" y: "<<av<<endl;
1651 gB[0]->SetPoint(
n-nSig,cc,av);
1652 cout<<
"Bg_graph1: x="<<cc<<
" y: "<<av<<endl;
1673 gS[0]->SetMarkerColor(2);
1674 gB[0]->SetMarkerColor(4);
1675 gS[0]->SetMarkerStyle(6);
1676 gB[0]->SetMarkerStyle(7);
1678 TCanvas*
c=
new TCanvas(
"Plots",
"Plots",0,0,1200,700);
1681 TMultiGraph* mg1=
new TMultiGraph();
1682 mg1->SetTitle(
"Av_cc");
1683 if(gB[0]->GetN()!=0) mg1->Add(gB[0]);
1684 if(gS[0]->GetN()!=0) mg1->Add(gS[0]);
1686 mg1->GetHistogram()->GetXaxis()->SetTitle(
"cc");
1687 mg1->GetHistogram()->GetYaxis()->SetTitle(
"Average on ANN ouputs");
1690 TMultiGraph* mg2=
new TMultiGraph();
1691 mg2->SetTitle(
"Av_cc");
1692 if(gS[0]->GetN()!=0) mg2->Add(gS[0]);
1693 if(gB[0]->GetN()!=0) mg2->Add(gB[0]);
1695 mg2->GetHistogram()->GetXaxis()->SetTitle(
"cc");
1696 mg2->GetHistogram()->GetYaxis()->SetTitle(
"Average on ANN ouputs");
1698 cout<<
" name "<<name<<endl;
1702 char Cname2root[1024];
1703 Cname.ReplaceAll(
".root",
".png");
1704 sprintf(Cname2,
"average_png/out_Plots_%s",Cname.Data());
1705 sprintf(Cname2root,
"average_png/out_Plots_%s",Cnameroot.Data());
1707 c->Print(Cname2root);
1745 name.ReplaceAll(
"outfile/",
"");
1746 name.ReplaceAll(
"average_file/",
"");
1747 TFile* fTEST =TFile::Open(ifile.Data());
1748 TTree* NNTree2=(TTree*)fTEST->Get(
"Parameters");
1758 NNTree2->SetBranchAddress(
"Mchirp",&Mc);
1759 NNTree2->SetBranchAddress(
"Average",&av);
1760 NNTree2->SetBranchAddress(
"cc",&cc);
1761 NNTree2->SetBranchAddress(
"rho",&rho);
1762 NNTree2->SetBranchAddress(
"Mchirp_injected",&Mc_inj);
1763 NNTree2->SetBranchAddress(
"#TestSig",&nSi);
1764 NNTree2->GetEntry(0);
1766 cout<<
"nSig: "<<nSig<<
" nSi: "<<nSi<<endl;
1768 int const nBg=NNTree2->GetEntries()-nSig;
1776 TCanvas* ANN_Mc_c3D=
new TCanvas(
"ANN_average_vs_Mc_reconstructed",
"ANN_average_vs_Mc_reconstructed",0,0,1200,700);
1777 ANN_Mc_c3D->Divide(1,2);
1781 ANN_Mc_BKG3D->SetDirectory(0);
1782 ANN_Mc_BKG3D->SetStats(0);
1783 ANN_Mc_SIG3D->SetDirectory(0);
1784 ANN_Mc_SIG3D->SetStats(0);
1786 TCanvas* ANN_cc_c3D=
new TCanvas(
"ANN_average_vs_cc",
"ANN_average_vs_cc",0,0,1200,700);
1787 ANN_cc_c3D->Divide(1,2);
1790 ANN_cc_SIG3D->SetDirectory(0);
1791 ANN_cc_SIG3D->SetStats(0);
1792 ANN_cc_BKG3D->SetDirectory(0);
1793 ANN_cc_BKG3D->SetStats(0);
1798 TCanvas* Mc_inj_c=
new TCanvas(
"ANN_vs_Mc_injected",
"ANN_vs_Mc_injected",0,0,1200,700);
1799 Mc_inj_c->Divide(1,2);
1803 Mc_inj_gMc->SetDirectory(0);
1804 Mc_inj_gMc->SetStats(0);
1805 Mc_inj_g->SetDirectory(0);
1806 Mc_inj_g->SetStats(0);
1807 double deltaMc_inj=0;
1809 double deltaANN_av_M=0;
1816 txt_name0.ReplaceAll(
".root",
".txt");
1817 char txt_name[1024];
1818 sprintf(txt_name,
"txt_files/%s",txt_name0.Data());
1819 ofstream file_txt_out(txt_name);
1825 for (
int n = 0;
n <NNTree2->GetEntries();
n++){
1826 NNTree2->GetEntry(
n);
1828 if(
n<nSig&&
n!=nSig) {
1829 Mc_inj_gMc->Fill(Mc_inj,Mc);
1830 Mc_inj_g->Fill(Mc_inj,av);
1831 gS[0]->SetPoint(
n,Mc,av);
1832 cout<<
" n "<<
n<<
" Mc "<<Mc<<
" av "<<av<<
" M_inj "<<Mc_inj<<endl;
1833 cout<<
"Sig_graph1: x="<<cc<<
" y: "<<av<<endl;
1835 ANN_Mc_SIG3D->Fill(Mc,av);
1836 ANN_cc_SIG3D->Fill(cc,av);
1837 sprintf(line,
"SIG:Average_%1.5f; Mc_rec_%1.5f; Mc_inj_%1.5f; event %i; count_%i; nSig_%i\n",av,Mc,Mc_inj,
n,aa1,nSig);
1839 cout<<
" n "<<
n<<
" nSig "<<nSig<<endl;
1843 gB[0]->SetPoint(
n-nSig,Mc,av);
1844 ANN_Mc_BKG3D->Fill(Mc,av);
1845 ANN_cc_BKG3D->Fill(cc,av);
1847 sprintf(line,
"BKG:Average %1.5f; Mc_rec %1.5f; Mc_inj_%1.5f; event %i; count_%i\n",av,Mc,Mc_inj,
n,bb1);
1855 gS[0]->SetMarkerColor(2);
1856 gB[0]->SetMarkerColor(4);
1857 gS[0]->SetMarkerStyle(6);
1858 gB[0]->SetMarkerStyle(7);
1861 ANN_Mc_SIG3D->GetXaxis()->SetTitle(
"SIG:Mchirp_reconstructed");
1862 ANN_Mc_SIG3D->GetYaxis()->SetTitle(
"SIG:ANN_average");
1863 ANN_Mc_SIG3D->GetZaxis()->SetTitle(
"count");
1864 ANN_Mc_SIG3D->Draw(
"colz");
1866 ANN_Mc_BKG3D->GetXaxis()->SetTitle(
"BKG:Mchirp_reconstructed");
1867 ANN_Mc_BKG3D->GetYaxis()->SetTitle(
"BKG:ANN_average");
1868 ANN_Mc_BKG3D->GetZaxis()->SetTitle(
"count");
1869 ANN_Mc_BKG3D->Draw(
"colz");
1873 TString ANN_Mc_rootname3D(name);
1874 char ANN_Mc_cname23D[1024];
1875 char ANN_Mc_crootname23D[1024];
1876 ANN_Mc_name3D.ReplaceAll(
".root",
".png");
1877 sprintf(ANN_Mc_cname23D,
"average_png/nSig%i_nBg%i_3DMc_ANNav_Plots_%s",nSig,nBg,ANN_Mc_name3D.Data());
1878 sprintf(ANN_Mc_crootname23D,
"average_png/nSig%i_nBg%i_3DMc_ANNav_Plots_%s",nSig,nBg,ANN_Mc_rootname3D.Data());
1879 ANN_Mc_c3D->SaveAs(ANN_Mc_cname23D);
1880 ANN_Mc_c3D->Print(ANN_Mc_crootname23D);
1884 ANN_cc_SIG3D->GetXaxis()->SetTitle(
"SIG:cc");
1885 ANN_cc_SIG3D->GetYaxis()->SetTitle(
"SIG:ANN_average");
1886 ANN_cc_SIG3D->GetZaxis()->SetTitle(
"count");
1887 ANN_cc_SIG3D->Draw(
"colz");
1889 ANN_cc_BKG3D->GetXaxis()->SetTitle(
"BKG:cc");
1890 ANN_cc_BKG3D->GetYaxis()->SetTitle(
"BKG:ANN_average");
1891 ANN_cc_BKG3D->GetZaxis()->SetTitle(
"count");
1892 ANN_cc_BKG3D->Draw(
"colz");
1896 TString ANN_cc_crootname3D(name);
1897 char ANN_cc_cname23D[1024];
1898 char ANN_cc_crootname23D[1024];
1899 ANN_cc_cname3D.ReplaceAll(
".root",
".png");
1900 sprintf(ANN_cc_cname23D,
"average_png/nSig%i_nBg%i_3DANNav_cc_Plots_%s",nSig,nBg,ANN_cc_cname3D.Data());
1901 sprintf(ANN_cc_crootname23D,
"average_png/nSig%i_nBg%i_3DANNav_cc_Plots_%s",nSig,nBg,ANN_cc_crootname3D.Data());
1902 ANN_cc_c3D->SaveAs(ANN_cc_cname23D);
1903 ANN_cc_c3D->Print(ANN_cc_crootname23D);
1906 Mc_inj_g->GetXaxis()->SetTitle(
"Mchirp_injected");
1907 Mc_inj_g->GetYaxis()->SetTitle(
"ANN_average");
1908 Mc_inj_g->GetZaxis()->SetTitle(
"count");
1909 Mc_inj_g->Draw(
"colz");
1911 Mc_inj_gMc->GetXaxis()->SetTitle(
"Mchirp_injected");
1912 Mc_inj_gMc->GetYaxis()->SetTitle(
"Mchirp_reconstructed");
1913 Mc_inj_gMc->GetZaxis()->SetTitle(
"count");
1914 Mc_inj_gMc->Draw(
"colz");
1918 TString Mc_inj_crootname(name);
1919 char Mc_inj_cname2[1024];
1920 char Mc_inj_crootname2[1024];
1921 Mc_inj_cname.ReplaceAll(
".root",
".png");
1922 sprintf(Mc_inj_cname2,
"average_png/nSig%i_nBg%i_Mc_inj_Plots_%s",nSig,nBg,Mc_inj_cname.Data());
1923 sprintf(Mc_inj_crootname2,
"average_png/nSig%i_nBg%i_Mc_inj_Plots_%s",nSig,nBg,Mc_inj_crootname.Data());
1924 Mc_inj_c->SaveAs(Mc_inj_cname2);
1925 Mc_inj_c->Print(Mc_inj_crootname2);
1928 TCanvas*
c=
new TCanvas(
"Plots",
"Plots",0,0,1200,700);
1931 TMultiGraph* mg1=
new TMultiGraph();
1932 mg1->SetTitle(
"Av_Mc");
1933 if(gB[0]->GetN()!=0) mg1->Add(gB[0]);
1934 if(gS[0]->GetN()!=0) mg1->Add(gS[0]);
1936 mg1->GetHistogram()->GetXaxis()->SetTitle(
"Mchirp");
1937 mg1->GetHistogram()->GetYaxis()->SetTitle(
"Average on ANN ouputs");
1939 TMultiGraph* mg2=
new TMultiGraph();
1940 mg2->SetTitle(
"Av_Mc");
1941 if(gS[0]->GetN()!=0) mg2->Add(gS[0]);
1942 if(gB[0]->GetN()!=0) mg2->Add(gB[0]);
1944 mg2->GetHistogram()->GetXaxis()->SetTitle(
"Mchirp");
1945 mg2->GetHistogram()->GetYaxis()->SetTitle(
"Average on ANN ouputs");
1947 cout<<
" name "<<name<<endl;
1951 char Cname2root[1024];
1952 Cname.ReplaceAll(
".root",
".png");
1953 sprintf(Cname2,
"average_png/nSig%i_nBg%i_Mc_Plots_%s",nSig,nBg,Cname.Data());
1954 sprintf(Cname2root,
"average_png/nSig%i_nBg%i_Mc_Plots_%s",nSig,nBg,Cnameroot.Data());
1955 cout<<
"Cname2 "<<Cname2<<endl;
1957 c->Print(Cname2root);
1958 cout<<
" gS[0]->GetN() "<<gS[0]->GetN()<<endl;
1960 cout<<
" nSig "<<nSig<<
" nBg "<<nBg<<
" aa1 "<<aa1<<endl;
1967 name.ReplaceAll(
"outfile/",
"");
1968 name.ReplaceAll(
"average_file/",
"");
1969 TFile* fTEST =TFile::Open(ifile.Data());
1970 TTree* NNTree2=(TTree*)fTEST->Get(
"Parameters");
1978 NNTree2->SetBranchAddress(
"Mchirp",&Mc);
1979 NNTree2->SetBranchAddress(
"Average",&av);
1980 NNTree2->SetBranchAddress(
"cc",&cc);
1981 NNTree2->SetBranchAddress(
"rho",&rho);
1982 NNTree2->SetBranchAddress(
"Mchirp_injected",&Mc_inj);
1983 NNTree2->SetBranchAddress(
"#TestSig",&nSi);
1984 NNTree2->GetEntry(0);
1986 cout<<
"nSig: "<<nSig<<
" nSi: "<<nSi<<endl;
1987 int const nBg=NNTree2->GetEntries()-nSig;
1988 int const nTot=NNTree2->GetEntries();
1990 int nBgSur[3][n_points];
1991 int nSigSur[3][n_points];
1992 double zax[3][n_points];
1994 for (
int i=0;
i<3;
i++)
for (
int u=0; u<n_points; u++) {nBgSur[
i][u]=0; nSigSur[
i][u]=0;zax[
i][u]=0.;}
2009 double deltaANNth=0.;
2010 double deltaRHOth=0.;
2016 TCanvas* SNR_c=
new TCanvas(
"SIG-BKG_reduction",
"SIG-BKG_reduction",0,0,1200,700);
2022 SNR3Dcc0->SetDirectory(0);
2023 SNR3Dcc0->SetStats(0);
2024 SNR3Dcc1->SetDirectory(0);
2025 SNR3Dcc1->SetStats(0);
2026 SNR3Dcc2->SetDirectory(0);
2027 SNR3Dcc2->SetStats(0);
2029 for (
int u=0; u<
N_ANNth; u++) { pANNth[u]=0.; pANNth[u]=
ANNth_min+u*deltaANNth; cout<<
" pANNth[u] "<<pANNth[u]<<
" u "<<u<<endl;}
2030 for (
int u=0; u<
N_RHOth; u++) { pRHOth[u]=0.; pRHOth[u]=
RHOth_min+u*deltaRHOth; cout<<
" pRHOth[u] "<<pRHOth[u]<<
" u "<<u<<endl;}
2032 cout<<
"fino def cose"<<endl;
2067 for (
int u=0; u<nTot; u++){
2068 NNTree2->GetEntry(u);
2069 for (
int y=0;
y<3;
y++){
2075 if(u<nSig) nSigSur[
y][j+N_ANNth*
i]=nSigSur[
y][j+N_ANNth*
i]+1;
2076 else nBgSur[
y][j+N_ANNth*
i]=nBgSur[
y][j+N_ANNth*
i]+1;
2091 nBgSur0=nBgSur[0][0];
2093 nSigSur0=nSigSur[0][0];
2094 if(nBgSur0==0){nBgSur0=nBg;}
2095 if(nSigSur0==0){nSigSur0=nSig;}
2097 cout<<
"dopo ciclo"<<
" nSigSur0 "<<nSigSur0<<
" nBgSur0 "<<nBgSur0<<endl;
2101 if(nSigSur[u][
i+
j*N_ANNth]==0) {
2102 if (nSigSur[u][
i+
j*N_ANNth]==0 && nBgSur[u][
i+
j*N_ANNth]==0) zax[u][
i+
j*
N_ANNth]=-1;
2108 num=(double)nBgSur[u][
i+
j*N_ANNth]/nBgSur0;
2109 den=(double)nSigSur0/nSigSur[u][
i+
j*N_ANNth];
2110 zax[u][
i+
j*
N_ANNth]=(double)num/den; count_zax=count_zax+1;
2111 cout<<(double)(nBgSur[u][
i+
j*N_ANNth]/nBgSur0)*(nSigSur0/nSigSur[u][
i+
j*
N_ANNth])<<endl;
2119 SNR3Dcc0->Fill(pANNth[
i]+ deltaANNth/2.,pRHOth[
j]+ deltaRHOth/2.,zax[0][
i+
j*N_ANNth]);
2120 SNR3Dcc1->Fill(pANNth[
i]+ deltaANNth/2.,pRHOth[
j]+ deltaRHOth/2.,zax[1][
i+
j*N_ANNth]);
2121 SNR3Dcc2->Fill(pANNth[
i]+ deltaANNth/2.,pRHOth[
j]+ deltaRHOth/2.,zax[2][
i+
j*N_ANNth]);
2124 for(
int yy=0;
yy<3;
yy++) {
2125 cout<<
" pCCth "<<pCCth[
yy]<<endl;
2126 for (
int ii=N_ANNth-1; ii>-1; ii--) {
2127 cout<<
" pANNth[i] "<<pANNth[ii]<<endl;
2128 for (
int jj=N_RHOth-1; jj>-1;jj--){
2129 cout<<
" pRHOth[jj] "<<pRHOth[jj]<<endl;
2130 cout<<
" nBgSur[yy][ii+N_ANNth*jj] "<<nBgSur[
yy][ii+N_ANNth*jj]<<endl;
2131 cout<<
" nSigSur[yy][ii+N_ANNth*jj] "<<nSigSur[
yy][ii+N_ANNth*jj]<<endl;
2132 cout<<
" zax[0][i+j*N_ANNth]"<<zax[
yy][ii+jj*
N_ANNth]<<endl;
2133 cout<<
" (double)(nBgSur[u][i+j*N_ANNth]/nBgSur0)"<<(double)nBgSur[
yy][ii+jj*N_ANNth]/nBgSur0<<endl;
2138 cout<<
"coutn_zax "<<count_zax<<endl;
2140 SNR3Dcc0->GetXaxis()->SetTitle(
"ANN_average_thresholds");
2141 SNR3Dcc0->GetYaxis()->SetTitle(
"RHO_thresholds");
2142 SNR3Dcc0->GetZaxis()->SetTitle(
"normBKG/normSIG");
2143 SNR3Dcc0->Draw(
"colz");
2146 SNR3Dcc1->GetXaxis()->SetTitle(
"ANN_average_thresholds");
2147 SNR3Dcc1->GetYaxis()->SetTitle(
"RHO_thresholds");
2148 SNR3Dcc1->GetZaxis()->SetTitle(
"normBKG/normSIG");
2149 SNR3Dcc1->Draw(
"colz");
2152 SNR3Dcc2->GetXaxis()->SetTitle(
"ANN_average_thresholds");
2153 SNR3Dcc2->GetYaxis()->SetTitle(
"RHO_thresholds");
2154 SNR3Dcc2->GetZaxis()->SetTitle(
"normBKG/normSIG");
2155 SNR3Dcc2->Draw(
"colz");
2160 char SNR_c_nroot[1024];
2161 SNR_n.ReplaceAll(
".root",
".png");
2162 sprintf(SNR_c_n,
"SNR_plots/nSig%i_nBg%i_invSNR_Plots_%s",nSig,nBg,SNR_n.Data());
2163 sprintf(SNR_c_nroot,
"SNR_plots/nSig%i_nBg%i_invSNR_Plots_%s",nSig,nBg,SNR_nroot.Data());
2164 SNR_c->SaveAs(SNR_c_n);
2165 SNR_c->Print(SNR_c_nroot);
2173 name.ReplaceAll(
"outfile/",
"");
2174 name.ReplaceAll(
"average_file/",
"");
2175 TFile* fTEST =TFile::Open(ifile.Data());
2176 TTree* NNTree2=(TTree*)fTEST->Get(
"Parameters");
2185 NNTree2->SetBranchAddress(
"Center_of_Gravity",&CoG);
2186 NNTree2->SetBranchAddress(
"Mchirp",&Mc);
2187 NNTree2->SetBranchAddress(
"Average",&av);
2188 NNTree2->SetBranchAddress(
"cc",&cc);
2189 NNTree2->SetBranchAddress(
"rho",&rho);
2190 NNTree2->SetBranchAddress(
"Mchirp_injected",&Mc_inj);
2191 NNTree2->SetBranchAddress(
"#TestSig",&nSi);
2192 NNTree2->GetEntry(0);
2194 cout<<
"nSig: "<<nSig<<
" nSi: "<<nSi<<endl;
2195 int const nTot=NNTree2->GetEntries();
2196 int const nBg=nTot-nSig;
2198 TCanvas* CoG_c=
new TCanvas(
"SIG-BKG_reduction",
"SIG-BKG_reduction",0,0,1200,700);
2205 TH1D* ibkgCC=
new TH1D(
"Number_of_events_vs_CC",
"Number_of_events_vs_CC",50,0.,1.);
2206 TH1D* isigCC=
new TH1D(
"Number_of_events_vs_CC",
"Number_of_events_vs_CC",50,0.,1.);
2207 TH1D* ibkgRHO=
new TH1D(
"Number_of_events_vs_RHO",
"Number_of_events_vs_RHO",50,0.,50.);
2208 TH1D* isigRHO=
new TH1D(
"Number_of_events_vs_RHO",
"Number_of_events_vs_RHO",50,0.,50.);
2209 TH1D* ibkgANN=
new TH1D(
"Number_of_events_vs_ANN",
"Number_of_events_vs_ANN",50,-0.2,1.2);
2210 TH1D* isigANN=
new TH1D(
"Number_of_events_vs_ANN",
"Number_of_events_vs_ANN",50,-0.2,1.2);
2212 CoG1Sig->SetDirectory(0);
2213 CoG1Sig->SetStats(0);
2214 CoG0Sig->SetDirectory(0);
2215 CoG0Sig->SetStats(0);
2216 CoG1Bg->SetDirectory(0);
2217 CoG1Bg->SetStats(0);
2218 CoG0Bg->SetDirectory(0);
2219 CoG0Bg->SetStats(0);
2220 ibkgCC->SetDirectory(0);
2221 ibkgCC->SetStats(0);
2222 isigRHO->SetDirectory(0);
2223 isigRHO->SetStats(0);
2224 ibkgANN->SetDirectory(0);
2225 ibkgANN->SetStats(0);
2226 isigCC->SetDirectory(0);
2227 isigCC->SetStats(0);
2228 ibkgRHO->SetDirectory(0);
2229 ibkgRHO->SetStats(0);
2230 isigANN->SetDirectory(0);
2231 isigANN->SetStats(0);
2233 for (
int n=0;
n<nTot;
n++){
2234 NNTree2->GetEntry(
n);
2236 if(CoG==0) {CoG0Sig->Fill(av);}
2237 else {CoG1Sig->Fill(av);}
2243 if(CoG==0) {CoG0Bg->Fill(av);}
2244 else {CoG1Bg->Fill(av);}
2250 cout<<
" CoG "<<CoG<<endl;
2253 imp->SetDirectory(0);
2260 for(
int i=0;
i<4;
i++) max[
i]=0;
2262 max[0]=CoG1Sig->GetMaximum();
2263 max[1]=CoG0Sig->GetMaximum();
2264 max[2]=CoG1Bg->GetMaximum();
2265 max[3]=CoG0Bg->GetMaximum();
2269 for(
int i=0;
i<4;
i++)
if(max_n<max[
i]) max_n=max[
i] ;
2272 imp->SetLineColor(10);
2274 imp->GetXaxis()->SetTitle(
"ANN");
2275 imp->GetYaxis()->SetTitle(
"Count");
2278 isigCC->SetFillStyle(3018);
2279 isigRHO->SetFillStyle(3018);
2280 isigANN->SetFillStyle(3018);
2281 ibkgCC->SetFillStyle(3004);
2282 ibkgRHO->SetFillStyle(3004);
2283 ibkgANN->SetFillStyle(3004);
2284 CoG1Sig->SetFillStyle(3018);
2285 CoG0Sig->SetFillStyle(3018);
2286 CoG0Bg->SetFillStyle(3004);
2287 CoG1Bg->SetFillStyle(3004);
2288 ibkgCC->SetLineColor(4);
2289 ibkgANN->SetLineColor(4);
2290 ibkgRHO->SetLineColor(4);
2291 isigCC->SetLineColor(2);
2292 isigANN->SetLineColor(2);
2293 isigRHO->SetLineColor(2);
2294 ibkgCC->SetFillColor(4);
2295 ibkgANN->SetFillColor(4);
2296 ibkgRHO->SetFillColor(4);
2297 isigCC->SetFillColor(2);
2298 isigANN->SetFillColor(2);
2299 isigRHO->SetFillColor(2);
2300 CoG1Sig->SetFillColor(2);
2301 CoG0Sig->SetFillColor(6);
2302 CoG0Bg->SetFillColor(4);
2303 CoG1Bg->SetFillColor(9);
2304 CoG1Sig->SetLineColor(2);
2305 CoG0Sig->SetLineColor(6);
2306 CoG0Bg->SetLineColor(4);
2307 CoG1Bg->SetLineColor(9);
2312 CoG1Sig->Draw(
"same");
2313 CoG0Sig->Draw(
"same");
2314 CoG0Bg->Draw(
"same");
2315 CoG1Bg->Draw(
"same");
2322 char CoG_c_nroot[1024];
2323 CoG_n.ReplaceAll(
".root",
".png");
2324 sprintf(CoG_c_n,
"CoG_plots/nSig%i_nBg%i_CoG_Plots_%s",nSig,nBg,CoG_n.Data());
2325 sprintf(CoG_c_nroot,
"CoG_plots/nSig%i_nBg%i_CoG_Plots_%s",nSig,nBg,CoG_nroot.Data());
2326 CoG_c->SaveAs(CoG_c_n);
2327 CoG_c->Print(CoG_c_nroot);
2329 TCanvas* Istogram=
new TCanvas(
"SIG-BKG_reduction",
"SIG-BKG_reduction",0,0,1200,400);
2331 Istogram->Divide(3,1);
2333 if (ibkgCC->GetMaximum()>isigCC->GetMaximum()) {ibkgCC->GetXaxis()->SetTitle(
"Network Correlation Coefficient"); ibkgCC->GetYaxis()->SetTitle(
"Count"); ibkgCC->Draw(); isigCC->Draw(
"same");}
2334 else {isigCC->GetXaxis()->SetTitle(
"Network Correlation Coefficient"); isigCC->GetXaxis()->SetTitle(
"Count"); isigCC->Draw();ibkgCC->Draw(
"same");}
2336 if (ibkgRHO->GetMaximum()>isigRHO->GetMaximum()) {ibkgRHO->GetXaxis()->SetTitle(
"Effective Correlated SNR"); ibkgRHO->GetYaxis()->SetTitle(
"Count"); ibkgCC->Draw(); ibkgRHO->Draw(); isigRHO->Draw(
"same");}
2337 else {isigRHO->GetXaxis()->SetTitle(
"Effective Correlated SNR"); isigRHO->GetXaxis()->SetTitle(
"Count"); isigRHO->Draw();ibkgRHO->Draw(
"same");}
2339 if (ibkgANN->GetMaximum()>isigANN->GetMaximum()) {ibkgANN->GetXaxis()->SetTitle(
"ANN parameter"); ibkgANN->GetYaxis()->SetTitle(
"Count"); ibkgANN->Draw(); isigANN->Draw(
"same");}
2340 else {isigANN->GetXaxis()->SetTitle(
"ANN parameter"); isigANN->GetYaxis()->SetTitle(
"Count"); isigANN->Draw();ibkgANN->Draw(
"same");}
2344 char isto_c_n[1024];
2345 char isto_c_nroot[1024];
2346 isto_n.ReplaceAll(
".root",
".png");
2347 sprintf(isto_c_n,
"Istograms/nSig%i_nBg%i_istograms_%s",nSig,nBg,isto_n.Data());
2348 sprintf(isto_c_nroot,
"Istograms/nSig%i_nBg%i_istograms_%s",nSig,nBg,isto_nroot.Data());
2349 Istogram->SaveAs(isto_c_n);
2350 Istogram->Print(isto_c_nroot);
2356 name.ReplaceAll(
"outfile/",
"");
2357 name.ReplaceAll(
"average_file/",
"");
2358 TFile* fTEST =TFile::Open(ifile.Data());
2359 TTree* NNTree2=(TTree*)fTEST->Get(
"Parameters");
2371 NNTree2->SetBranchAddress(
"Center_of_Gravity",&CoG);
2372 NNTree2->SetBranchAddress(
"duration",&Dt);
2373 NNTree2->SetBranchAddress(
"Mchirp",&Mc);
2374 NNTree2->SetBranchAddress(
"Average",&av);
2375 NNTree2->SetBranchAddress(
"cc",&cc);
2376 NNTree2->SetBranchAddress(
"rho",&rho);
2377 NNTree2->SetBranchAddress(
"Mchirp_injected",&Mc_inj);
2378 NNTree2->SetBranchAddress(
"#TestSig",&nSi);
2379 NNTree2->GetEntry(0);
2381 cout<<
"nSig: "<<nSig<<
" nSi: "<<nSi<<endl;
2382 int const nTot=NNTree2->GetEntries();
2383 int const nBg=nTot-nSig;
2385 TCanvas* Dt_c=
new TCanvas(
"Duration",
"Duration",0,0,1200,700);
2390 cout<<
"maxDt "<<maxDt<<
" minDt "<<minDt<<endl;
2392 for(
int i=0;
i<nTot;
i++){
2393 NNTree2->GetEntry(
i);
2394 if(Dt>maxDt) maxDt=
Dt;
2395 if(Dt<minDt) minDt=
Dt;
2401 TH1D* imp=
new TH1D(
"Duration",
"Duration",100,0.,2.);
2402 TH1D* Dt_hB=
new TH1D(
"Duration",
"Duration",100,0.,2.);
2403 TH1D* Dt_hS=
new TH1D(
"Duration",
"Duration",100,0.,2.);
2405 imp->SetDirectory(0);
2407 Dt_hS->SetDirectory(0);
2409 Dt_hB->SetDirectory(0);
2412 for (
int n=0;
n<nTot;
n++){
2413 NNTree2->GetEntry(
n);
2414 if (
n<nSig) Dt_hS->Fill(Dt);
2415 else Dt_hB->Fill(Dt);
2418 Dt_hS->SetFillStyle(3018);
2419 Dt_hB->SetFillStyle(3004);
2420 Dt_hS->SetFillColor(2);
2421 Dt_hB->SetFillColor(4);
2422 Dt_hS->SetLineColor(2);
2423 Dt_hB->SetLineColor(4);
2427 for(
int i=0;
i<2;
i++) max[
i]=0;
2429 max[0]=Dt_hS->GetMaximum();
2430 max[1]=Dt_hB->GetMaximum();
2433 for(
int i=0;
i<2;
i++)
if(max_n<max[
i]) max_n=max[
i] ;
2435 imp->Fill(minDt,max_n);
2436 imp->SetLineColor(10);
2438 imp->GetXaxis()->SetTitle(
"Duration");
2439 imp->GetYaxis()->SetTitle(
"Count");
2441 Dt_hS->Draw(
"same");
2442 Dt_hB->Draw(
"same");
2447 char CoG_c_nroot[1024];
2448 CoG_n.ReplaceAll(
".root",
".png");
2449 sprintf(CoG_c_n,
"Duration_plots/nSig%i_nBg%i_invSNR_Plots_%s",nSig,nBg,CoG_n.Data());
2450 sprintf(CoG_c_nroot,
"Duration_plots/nSig%i_nBg%i_invSNR_Plots_%s",nSig,nBg,CoG_nroot.Data());
2451 Dt_c->SaveAs(CoG_c_n);
2452 Dt_c->Print(CoG_c_nroot);
Float_t * rho
biased null statistics
Float_t * duration
max cluster time relative to segment start
wavearray< double > a(hp.size())
void Mcth(TString ifile, int &McFAth_n, int &McFDth_n, double &McthresFA)
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<< "\t layers : "<< nLAYERS<< "\t dF(hz) : "<< dF<< "\t 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
cout<<"Comparison bkg events above threshold: "<< entriesx<< endl;double *rhox=cnet.GetV1();comph=(TH1D *) gDirectory-> Get("hcomp")
void SNR_plots(TString ifile)
void graph(TString ifile)
void PlotsAv_Mc(TString ifile)
cout<< "Injected signals: "<< mdc.GetEntries()<< endl;cout<< "Injected signals in histogram factor_events_inj: "<< NEVTS<< endl;float myifar, ecor, m1, m2, netcc[3], neted, penalty;float rho[2];float chirp[6];float range[2];float frequency[2];float iSNR[3], sSNR[3];sim.SetBranchAddress("mass", mass);sim.SetBranchAddress("factor",&factor);sim.SetBranchAddress("range", range);sim.SetBranchAddress("chirp", chirp);sim.SetBranchAddress("rho", rho);sim.SetBranchAddress("netcc", netcc);sim.SetBranchAddress("neted",&neted);sim.SetBranchAddress("ifar",&myifar);sim.SetBranchAddress("ecor",&ecor);sim.SetBranchAddress("penalty",&penalty);sim.SetBranchAddress("time", mytime);sim.SetBranchAddress("iSNR", iSNR);sim.SetBranchAddress("sSNR", sSNR);sim.SetBranchAddress("spin", spin);sim.SetBranchAddress("frequency", frequency);float **volume=new float *[NBINS_mass1];float **volume_first_shell=new float *[NBINS_mass1];float **radius=new float *[NBINS_mass1];float **error_volume=new float *[NBINS_mass1];float **error_volume_first_shell=new float *[NBINS_mass1];float **error_radius=new float *[NBINS_mass1];for(int i=0;i< NBINS_mass1;i++){volume[i]=new float[NBINS_mass2];volume_first_shell[i]=new float[NBINS_mass2];radius[i]=new float[NBINS_mass2];error_volume[i]=new float[NBINS_mass2];error_volume_first_shell[i]=new float[NBINS_mass2];error_radius[i]=new float[NBINS_mass2];for(int j=0;j< NBINS_mass2;j++){volume[i][j]=0.;volume_first_shell[i][j]=0.;radius[i][j]=0.;error_volume[i][j]=0.;error_volume_first_shell[i][j]=0.;error_radius[i][j]=0.;}}float **spin_mtot_volume=new float *[NBINS_MTOT+1];float **spin_mtot_radius=new float *[NBINS_MTOT+1];float **error_spin_mtot_volume=new float *[NBINS_MTOT+1];float **error_spin_mtot_radius=new float *[NBINS_MTOT+1];for(int i=0;i< NBINS_MTOT+1;i++){spin_mtot_volume[i]=new float[NBINS_SPIN+1];spin_mtot_radius[i]=new float[NBINS_SPIN+1];error_spin_mtot_volume[i]=new float[NBINS_SPIN+1];error_spin_mtot_radius[i]=new float[NBINS_SPIN+1];for(int j=0;j< NBINS_SPIN+1;j++){spin_mtot_volume[i][j]=0.;error_spin_mtot_volume[i][j]=0.;spin_mtot_radius[i][j]=0.;error_spin_mtot_radius[i][j]=0.;}}char fname[1024];sprintf(fname,"%s/recovered_signals.txt", netdir);ofstream fev;fev.open(fname, std::ofstream::out);sprintf(line,"#GPS@L1 FAR[Hz] eFAR[Hz] Pval ""ePval factor rho frequency iSNR sSNR \n");fev<< line<< endl;ofstream *fev_single=new ofstream[nfactor];for(int l=1;l< nfactor+1;l++){sprintf(fname,"%s/recovered_signals_%d.txt", netdir, l);fev_single[l-1].open(fname, std::ofstream::out);fev_single[l-1]<< line<< endl;}double Vrho[RHO_NBINS], eVrho[RHO_NBINS], Rrho[RHO_NBINS], eRrho[RHO_NBINS], Trho[RHO_NBINS];for(int i=0;i< RHO_NBINS;i++){Vrho[i]=0.;eVrho[i]=0.;Rrho[i]=0.;eRrho[i]=0.;Trho[i]=RHO_MIN+i *RHO_BIN;}double dV, dV1, dV_spin_mtot, nevts, internal_volume;int nT;int countv=0;int cnt=0;int cnt2=0;int cntfreq=0;bool bcut=false;double liveTot=sim.GetMaximum("ifar");double BKG_LIVETIME_yr=liveTot/CYS;double BKG_LIVETIME_Myr=BKG_LIVETIME_yr/(1.e6);cout.precision(14);cout<< "Total live time ---> background
Float_t * netcc
effective correlated SNR
void CoG_plots(TString ifile)
void Annth(TString ifile, int &FAth_n, int &FDth_n, double &thresFA)
sprintf(tfres,"(1/%g)x(%g) (sec)x(Hz)", 2 *df, df)
void PlotsAv_cc(TString ifile)
void Average_FAout_moreGraphs_3(double FAdes, TString NN_FILE, TString NN_FILE2, TString NN_FILE3, TString NN_FILE4, TString NN_FILE5, TString NN_FILE6, TString NN_FILE7, TString NN_FILE8, TString TEST_FILE, TString NOMEtot_S, int TS=0, int TB=0, int s=0, int b=0, int uf=1, int consider_all=0, int av_on_nNN=0)
Float_t * chirp
range to source: [0/1]-rec/inj
void duration_plot(TString ifile)