21 #pragma GCC system_header 28 #include "TObjArray.h" 29 #include "TObjString.h" 30 #include "TPaletteAxis.h" 31 #include "TMultiLayerPerceptron.h" 32 #include "TMLPAnalyzer.h" 65 #define minANN_av -0.2 72 #define ANNth_min -0.5 73 #define RHOth_max 10.0 94 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){
96 if (uf==0&&av_on_nNN!=0) cout<<
"all events were not used for the training procedure"<<endl;
97 if(uf==0) {ni=1; consider_all=1; av_on_nNN=0;}
108 if (NN_FILE.CompareTo(
"")){
111 if (NN_FILE2.CompareTo(
"")){
114 if (NN_FILE3.CompareTo(
"")){
117 if (NN_FILE4.CompareTo(
"")){
120 if (NN_FILE5.CompareTo(
"")){
123 if (NN_FILE6.CompareTo(
"")){
126 if (NN_FILE7.CompareTo(
"")){
129 if (NN_FILE8.CompareTo(
"")){
136 char NNi2[nNN][1024];
137 sprintf(NNi2[0],
"%s",NN_FILE.Data());
138 if(nNN>1)
sprintf(NNi2[1],
"%s",NN_FILE2.Data());
139 if(nNN>2)
sprintf(NNi2[2],
"%s",NN_FILE3.Data());
140 if(nNN>3)
sprintf(NNi2[3],
"%s",NN_FILE4.Data());
141 if(nNN>4)
sprintf(NNi2[4],
"%s",NN_FILE5.Data());
142 if(nNN>5)
sprintf(NNi2[5],
"%s",NN_FILE6.Data());
143 if(nNN>6)
sprintf(NNi2[6],
"%s",NN_FILE7.Data());
144 if(nNN>7)
sprintf(NNi2[7],
"%s",NN_FILE8.Data());
146 if(nNN==1) {av_on_nNN=1; consider_all=0; ni=0;}
148 for (
int u=0;u<nNN;u++){
151 if (NNi2[u][p]==
'N'){
152 if((NNi2[u][p+1]==
'N')&&(NNi2[u][p+2]==
'\/')) {
154 while (NNi2[u][hh]!=
'\0'){NNi[u][hh-p-3]=NNi2[u][
hh];hh=hh+1;}
166 sprintf(Filei2,
"%s",TEST_FILE.Data());
168 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]==
'\/')) {
170 while (Filei2[hh]!=
'\0') {Filei[hh-q-7]=Filei2[
hh];hh=hh+1;
172 for (
int h0=hh-q-7;h0<1024;h0++) Filei[h0]=
'\0';
178 cout<<Filei<<
" original String: "<<Filei2<<endl;
183 if(nNN>1) NNi0[1]=NNi[1];
184 if(nNN>2) NNi0[2]=NNi[2];
185 if(nNN>3) NNi0[3]=NNi[3];
186 if(nNN>4) NNi0[4]=NNi[4];
187 if(nNN>5) NNi0[5]=NNi[5];
188 if(nNN>6) NNi0[6]=NNi[6];
189 if(nNN>7) NNi0[7]=NNi[7];
194 for (
int u=0;u<nNN;u++){
195 NNi0[u].ReplaceAll(
".root",
"");
197 Filei0.ReplaceAll(
".root",
"");
201 TMultiLayerPerceptron* mlp[nNN];
207 for (
int yy=0;
yy<nNN;
yy++){TotBg[
yy]=0;FA0[
yy]=0;FD0[
yy]=0;}
221 for (
int u=0;u<nNN;u++){
222 fnet[u]=TFile::Open(NNi2[u]);
223 mlp[u]=(TMultiLayerPerceptron*)fnet[u]->Get(
"TMultiLayerPerceptron");
225 cout<<
"dopo TMLP"<<endl;
226 if(mlp[u]==NULL) {cout <<
"Error getting mlp" << endl;
exit(1);}
227 infot[u]=(TTree*)fnet[u]->Get(
"info");
229 infot[u]->SetBranchAddress(
"Rand_start_Sig",&NNs[u]);
230 infot[u]->SetBranchAddress(
"Rand_start_Bg",&NNb[u]);
231 infot[u]->SetBranchAddress(
"#trainSig",&NNnTS[u]);
232 infot[u]->SetBranchAddress(
"#trainBg",&NNnTB[u]);
233 infot[u]->GetEntry(0);
234 cout<<
"n "<<u<<
" b "<<NNb[u]<<
" min_NNb "<<min_NNb<<endl;
236 if(NNs[u]<min_NNs) min_NNs=NNs[u];
237 if(NNb[u]<min_NNb) min_NNb=NNb[u];
238 if(NNs[u]>max_NNs) max_NNs=NNs[u];
239 if(NNb[u]>max_NNb) max_NNb=NNb[u];
240 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;
251 cout<<
" min_NNb "<<min_NNb<<
" b "<<b<<endl;
252 cout<<
"Def. tree e mlp"<<endl;
255 TFile* fTEST =TFile::Open(TEST_FILE.Data());
256 cout<<
"Def. tree e mlp"<<endl;
257 TTree* NNTree=(TTree*)fTEST->Get(
"nnTree");
258 cout<<
"Def. tree e mlp"<<endl;
259 int entries=NNTree->GetEntries();
262 cout<<
"entries: "<<entries<<endl;
263 cout<<
" NNTree->GetEntries() "<<NNTree->GetEntries()<<endl;
273 NNTree->SetBranchAddress(
"#Entries_type",&entriesTot);
274 NNTree->SetBranchAddress(
"Matrix_dim",&ndim);
275 NNTree->SetBranchAddress(
"#inputs",&ninp);
276 NNTree->SetBranchAddress(
"amplitude_mode",&y);
279 sig_entries=entriesTot;
280 NNTree->GetEntry(entries-1);
281 bg_entries=entriesTot;
282 cout<<
"sig "<<sig_entries<<
" bg "<<bg_entries<<endl;
285 cout<<
"NDIM: "<<NDIM<<endl;
286 cout<<
"nINP: "<<nINP<<endl;
287 cout<<
"sig e: "<<sig_entries<<endl;
288 cout<<
"bg e: "<<bg_entries<<endl;
292 if (sig_entries>bg_entries) minevents=bg_entries;
293 else minevents=sig_entries;
300 cout<<
"TS "<<TS<<
" TB "<<
TB<<
" minevents "<<minevents<<endl;
305 cout<<
"Error: Bg index<sig_entries: new set of b parameter-> b="<<b<<
" instead of b="<<a<<endl;
311 cout<<
"Error: Sig index>sig_entries: new set of s parameter-> s="<<b<<
" instead of s="<<a<<endl;
313 if((TS>sig_entries-
s||
TB>(bg_entries-(b-sig_entries)))&&(TS==
TB)) {TS=minevents-
s;
TB=minevents-(b-sig_entries);
316 cout<<
"Error:S>sig_entries or TB>bg_entries, to maintain ugual number of analysed events TS=TB="<<
TB<<endl;
318 if((TS>sig_entries-
s||
TB>bg_entries-(b-sig_entries))&&(TS!=
TB)) {
319 if(TS>sig_entries) TS=sig_entries-
s;
320 if (
TB>bg_entries)
TB=bg_entries-(b-sig_entries);
321 cout<<
"Error:S>sig_entries or TB>bg_entries, new TS and TB values are thus define-> TS="<<TS<<
" TB="<<
TB<<endl;
326 sprintf(NOMEtot,
"%s",NOMEtot_S.Data());
327 cout<<
"output name: "<<NOMEtot<<endl;
333 NNTree->SetBranchAddress(
"Files_name",&FILE_NAME);
336 NNTree->GetEntry(entries-1);
338 cout<<
"fine ifdef RHO_CC"<<endl;
341 TChain sigTree(
"waveburst");
342 sigTree.Add(SIG_FILE.Data());
345 cout <<
"sig entries2 : " << sig_entries2 << endl;
347 TChain bgTree(
"waveburst");
348 bgTree.Add(BG_FILE.Data());
351 cout <<
"bg entries2 : " << bg_entries2 << endl;
353 cout<<
"b: "<<b<<endl;
354 cout<<
"s: "<<
s<<endl;
358 for (
int jj=0; jj<nINP;jj++) x[jj]=0.;
359 char ilabel[nINP][16];
362 for(
int i=0;
i<nINP;
i++) {
364 NNTree->SetBranchAddress(ilabel[i], &x[i]);
368 sprintf(ofile,
"average_file/%s.root",NOMEtot);
369 TFile*
f =
new TFile(ofile,
"RECREATE");
370 TTree* NNTree2=
new TTree(
"Parameters",
"Parameters");
371 NNTree2->SetDirectory(f);
374 NNTree->SetBranchAddress(
"duration", &DtTree);
378 for(
int y=0; y<nNN; y++) out[y]=0.;
392 NNTree2->Branch(
"Center_of_Gravity",&CoG,
"Center_of_Gravity/I");
393 NNTree2->Branch(
"duration",&Dt,
"duration/D");
395 NNTree2->Branch(
"Average",&average,
"Average/D");
396 NNTree2->Branch(
"StandardDevaition",&std,
"StandardDeviation/D");
397 NNTree2->Branch(
"cc",&NNcc,
"cc/D");
398 NNTree2->Branch(
"Mchirp",&Mc,
"Mchirp/D");
399 NNTree2->Branch(
"Mchirp_injected",&Mc_inj,
"Mchirp_injected/D");
400 NNTree2->Branch(
"rho",&NNrho,
"rho/D");
401 NNTree2->Branch(
"index",&index_ev,
"index/I");
404 NNTree2->Branch(
"Test_file",&TestFile,
"Test_file/C");
406 for(
int u=0;u<nNN;u++){
412 sprintf(NNoutl2,
"NNout%i/D",u);
414 sprintf(NNnamel2,
"NNname%i/C",u);
415 NNTree2->Branch(NNoutl,&out[u],NNoutl2);
416 NNTree2->Branch(NNnamel,&NNi[u],NNnamel2);
420 NNTree2->Branch(
"TestFile",&Testf,
"TestFile/C");
421 sprintf(Testf,
"%s",TEST_FILE.Data());
430 for(
int n=
s;
n<sig_entries;
n++) {
432 for(
int u=0;u<nNN;u++){
433 if (uf!=0&&
n>NNs[u]&&
n<(NNs[u]+NNnTS[u])) countNN=countNN+1;
439 if(countNN==0&&av_on_nNN!=0) scount=scount+1;
442 if(countNN==1&&consider_all==0&&av_on_nNN==0) scount=scount+1;
443 if(countNN<2&&consider_all!=0) scount=scount+1;
444 if(countNN>1){cout<<
"Error: training non independent"<<
n<<endl;
exit(0);}
445 cout<<
"n "<<
n<<
"; countNN "<<countNN<<
"; scount "<< scount<<
"; consider_all "<<consider_all<<
"; av_on_nNN "<<av_on_nNN<<endl;
446 if(scount==TS)
break;}
450 cout<<
" nTestS "<< nTestS<<
" TS "<<TS<<endl;
465 for(
int n=b;
n<sig_entries+bg_entries;
n++) {
467 for(
int u=0;u<nNN;u++){
468 if (uf!=0&&
n>NNb[u]&&
n<(NNb[u]+NNnTB[u])) countNN=countNN+1;
470 if(countNN==0&&av_on_nNN!=0) bcount=bcount+1;
472 if(countNN==1&&consider_all==0&&av_on_nNN==0) bcount=bcount+1;
473 if(countNN<2&&consider_all!=0) bcount=bcount+1;
474 if(countNN>1){cout<<
"Error: training non independent"<<
n<<endl;
exit(0);}
475 if(bcount==
TB)
break;
480 if(uf!=0) nTestS=nTestS-1;
481 if(uf!=0) nTestB=nTestB-1;
484 cout<<
"TS "<<TS<<
" TB "<<
TB<<
" nTestS "<<nTestS<<
" nTestB "<<nTestB<<endl;
486 if(nTestB>nTestS) {nTestB=nTestS;
TB=nTestS; TS=nTestS;}
487 else {nTestS=nTestB;
TB=nTestB; TS=nTestB;}
490 if(nTestS<TS) TS= nTestS;
494 NNTree2->Branch(
"#TestSig",&TS,
"#TestSig/I");
496 cout<<
"nTestS: "<<nTestS<<
" TS: "<<TS<<endl;
497 cout<<
"dopo def tree"<<endl;
498 cout<<
"s test "<<
s<<
" s+TS "<<
s+TS<<
" b "<<b<<
" b+ TB "<<b+
TB<<
" nTestS "<<nTestS<<
" TB "<<
TB<<
" nTestB "<<nTestB<<endl;
501 for (
int i=0;
i<nINP;
i++) params[
i]=0.;
507 TString txt_originaldata(NOMEtot_S);
508 txt_originaldata.ReplaceAll(
".root",
"_originalData.txt");
510 char txt_originaldata_c[1024];
511 sprintf(txt_originaldata_c,
"txt_files/%s.txt",txt_originaldata.Data());
512 ofstream od_txt(txt_originaldata_c);
516 for(
int n=
s;
n<sig_entries;
n++) {
524 for(
int u=0;u<nNN;u++){
525 if (uf!=0&&
n>=NNs[u]&&
n<(NNs[u]+NNnTS[u])) { indNN=u;countNN=countNN+1;}
527 if (countNN>1){cout<<
"Error: training non independent";
exit(0);}
528 if(nNN==1){cout<<
"out==Averege:only 1NN is considered"<<endl;}
529 if(consider_all==0&&av_on_nNN==0&&countNN==0)
continue;
530 if(consider_all==0&&av_on_nNN!=0&&countNN!=0) {sigskip=sigskip+1;
continue; }
536 NNcc=(double)signal.
netcc[0];
537 NNrho=(
double)signal.
rho[1];
539 Mc_inj=(
double)signal.
chirp[0];
542 cout<<
"DtTree "<<DtTree<<endl;
544 sprintf(TestFile,
"%s",TEST_FILE.Data());
551 for (
int i=0;
i<nINP;
i++){
558 ti_0+=(double)x[
i]*ti_i;
559 fi_0+=(double)x[
i]*fi_i;
560 sprintf(line_od2,
"%s %1.5f",line_od2, x[
i]);
562 sprintf(line_od2,
"%s \n",line_od2);
564 if (ti_0<fi_0) CoG=1;
569 for (
int u=0;u<nNN;u++) {
571 double output=mlp[u]->Evaluate(0,params);
581 for (
int u=0;u<nNN;u++){
582 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;}
585 average=average/(c_nNN0);
586 if((c_nNN0)!=1)std=pow((std/(nNN-1-countNN)-average*average),0.5);
590 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);
593 if (average<0.6) FD=FD+1;
598 cout<<
" cc "<<NNcc<<
" NNrho "<<NNrho<<
" Mc_inj "<< Mc_inj<<endl;
603 cout<<txt_originaldata_c<<endl;
606 cout<<
" S_eff "<<S_eff<<
" s "<<
s<<
" b "<<b<<
" sigskip "<<sigskip<<endl;
612 for(
int n=b;
n<sig_entries+bg_entries;
n++) {
620 for(
int u=0;u<nNN;u++){
621 cout<<
" uf "<<uf<<
" n "<<
n<<
" u "<<u<<
" NN b[u] "<<NNb[u]<<
" NNb[u]+NNnTB[u]"<<NNb[u]+NNnTB[u]<<endl;
622 if (uf!=0&&
n>=NNb[u]&&
n<(NNb[u]+NNnTB[u])) { indNN=u;countNN=countNN+1; }
624 if (countNN>1){cout<<
"Error: training non independent";
exit(0);}
625 if(nNN==1){cout<<
"out==Averege:only 1NN is considered"<<endl;}
626 cout<<
"consider_all "<<consider_all<<
" av_on_nNN "<<av_on_nNN<<
" countNN "<<countNN<<
" indNN "<<indNN<<endl;
627 if(consider_all==0&&av_on_nNN==0&&countNN==0)
continue;
628 if(consider_all==0&&av_on_nNN!=0&&countNN!=0) { cout<<
" n skipped "<<
n<<endl; bgskip=bgskip+1;
continue;}
630 cout<<
"BKG->n: "<<
n<<
"Bg index"<<(
n-sig_entries)<<endl;
633 NNcc=(double)background.
netcc[0];
635 NNrho=(
double)background.
rho[1];
637 Mc_inj=(
double)background.
chirp[0];
641 cout<<
"background.duration[0] "<<background.
duration[0]<<
" background.duration[1] "<<background.
duration[1]<<
" background.duration[2] "<<background.
duration[2]<<endl;
646 sprintf(TestFile,
"%s",TEST_FILE.Data());
648 for (
int i=0;
i<nINP;
i++){
654 ti_0+=(double)x[
i]*ti_i;
655 fi_0+=(double)x[
i]*fi_i;
658 if (ti_0<fi_0) CoG=1;
661 for(
int u=0;u<nNN;u++) {
662 double output=mlp[u]->Evaluate(0,params);
669 for (
int u=0;u<nNN;u++){
670 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;}}
674 average=average/(c_nNN0);
675 if((c_nNN0)!=1)std=pow((std/(nNN-1-countNN)-average*average),0.5);
678 if(nnsu==6) cont_su=cont_su+1;
679 if(nnsu>4) cont_su5=cont_su5+1;
680 if(nnsu>3) cont_su4=cont_su4+1;
681 if(nnsu>2) cont_su3=cont_su3+1;
687 if(average>0.6) FA=FA+1;
698 cout<<
"B_eff "<<B_eff<<
" TB "<<
TB<<endl;
708 for (
int yy=0;
yy<nNN;
yy++){
711 if(TotBg[
yy]!=0){freq_c[
yy]=(double)FA0[
yy]/TotBg[
yy];
714 if(freq_c[
yy]!=0) {meanf=freq_c[
yy]+meanf;cont=cont+1;
717 dev=freq_c[
yy]*freq_c[
yy]+dev;
720 if(cont==0) cout<<
"Error cont==0"<<endl;
721 if(cont!=0) meanf=meanf/cont;
723 for (
int yy=0;
yy<nNN;
yy++){
726 if(freq_c[
yy]!=0)dev+=(freq_c[
yy]-meanf)*(freq_c[
yy]-meanf);
728 double McFAdes=FAdes;
729 int FAth_n=FAdes*B_eff;
730 int McFAth_n=FAdes*B_eff;
731 cout<<
"FAth_n "<<FAth_n<<
" FAdes*B_eff "<<FAdes*B_eff<<endl;
736 Annth(ofile, FAth_n, FDth_n, thresFA);
737 Mcth(ofile, McFAth_n, McFDth_n, McthresFA);
745 if(cont!=0) dev=pow(dev/(cont-1),0.5);
746 cout<<
"meanf "<<meanf<<
" dev "<<dev<<endl;
747 cout<<
" FA average "<<FA<<endl;
748 cout<<
" cont_su "<<cont_su<<
" cont_su5 "<<cont_su5<<
" cont_su4 "<<cont_su4<<
" cont_su3 "<<cont_su3<<endl;
750 cout<<
" S_eff "<<S_eff<<
" B_eff "<<B_eff<<
" s "<<
s<<
" b "<<b<<
" bgskip "<<bgskip<<
" sigskip "<<sigskip<<endl;
751 cout<<
" FA0[1] "<<FA0[1]<<
" TotBg[1] "<<TotBg[1]<<endl;
752 cout<<
" FD0[1] "<<FD0[1]<<
" TotBg[1] "<<TotBg[1]<<endl;
754 double FDdes=(double)FDth_n/S_eff;
755 double McFDdes=(double)McFDth_n/S_eff;
756 FAdes=(double)FAth_n/B_eff;
757 McFAdes=(double)McFAth_n/B_eff;
758 cout<<
"FAth_n "<<FAth_n<<
" FAdes: "<<FAdes<<
" ANN_av_FDdes "<<FDdes<<
" ANN_av_FDth_n "<<FDth_n<<
" ANN_av_thresFA "<<thresFA<<endl;
759 cout<<
"McFAth_n "<<McFAth_n<<
" McFAdes: "<<McFAdes<<
" Mc_FDdes "<<McFDdes<<
" McFDth_n "<<McFDth_n<<
" McthresFA "<<McthresFA<<endl;
764 name.ReplaceAll(
"average_file/",
"");
765 TFile* fTEST =TFile::Open(ifile.Data());
766 TTree* NNTree2=(TTree*)fTEST->Get(
"Parameters");
771 NNTree2->SetBranchAddress(
"Average",&av);
772 NNTree2->SetBranchAddress(
"cc",&cc);
773 NNTree2->SetBranchAddress(
"rho",&rho);
774 NNTree2->SetBranchAddress(
"#TestSig",&nSi);
775 NNTree2->GetEntry(0);
777 cout<<
"nSig: "<<nSig<<
" nSi: "<<nSi<<endl;
778 cout<<
" BG: "<<NNTree2->GetEntries()-nSi<<endl;
780 cout<<
"dentro funzione dopodef"<<endl;
782 double* rhoSig[ncurve];
783 for (
int i=0;
i<ncurve;
i++) rhoSig[
i]=
new double[nSig];
784 cout<<
"dopo def rhoSig"<<endl;
788 int const nBg=NNTree2->GetEntries()-nSig;
789 for (
int i=0;
i<ncurve;
i++) {
791 for (
int j=0;
j<nSig;
j++) rhoSig[
i][
j]=0.;
793 cout<<
"dopo def rhoSig"<<endl;
794 double* rhoBg[ncurve];
795 for (
int i=0;
i<ncurve;
i++) rhoBg[
i]=
new double[nBg];
798 for (
int i=0;
i<ncurve;
i++) {
800 for (
int j=0;
j<nBg;
j++) rhoBg[
i][
j]=0.;
802 cout<<
"dopo def rhoBg"<<endl;
804 for (
int i=0;
i<
nCC;
i++) ccTh[
i]=0.;
806 for (
int i=0;
i<
nANN;
i++) NNTh[
i]=0.;
812 cout<<NNTree2->GetEntries()<<endl;
813 for(
int n=0;
n<NNTree2->GetEntries();
n++){
815 NNTree2->GetEntry(
n);
816 cout<<
"rho "<<rho<<
" cc "<<cc<<
" av "<<av<<endl;
819 if(cc<ccTh[
i])
continue;
821 if(
j==0) NNTh[
j]=-1000.;
827 if(av<NNTh[
j])
continue;
831 NBg[i*nANN+
j]= NBg[i*nANN+
j]+1;
832 while(rhoBg[i*nANN+j][ni]!=0)ni=ni+1;
833 rhoBg[i*nANN+
j][ni]=
rho;
838 NSig[i*nANN+
j]= NSig[i*nANN+
j]+1;
839 while(rhoSig[i*nANN+j][ni]!=0)ni=ni+1;
840 rhoSig[i*nANN+
j][ni]=
rho;
848 cout<<
"dopo riempimento variabili"<<endl;
850 for (
int i=0;
i<ncurve;
i++) indexS[
i]=
new int[nSig];
853 for (
int y=0;
y<ncurve;
y++) {
866 TMath::Sort(nSig,rhoSig[
y],indexS[y],
false);
868 for (
int k=0;
k<nSig;
k++) {
873 int ij=indexS[
y][
k-1];
875 if(rhoSig[y][ii]!=0) {
878 if(rhoSig[y][ii]!=rhoSig[y][ij]) gS[
y]->SetPoint(igS_p++,rhoSig[y][ii],yy);
879 cout<<
"igS"<<igS<<
" x "<<rhoSig[
y][ii]<<
" y: "<<yy<<endl;
884 if(rhoSig[y][ii]!=0){
886 gS[
y]->SetPoint(0,rhoSig[y][ii],yy);
897 for (
int i=0;
i<ncurve;
i++) indexB[
i]=
new int[nBg];
900 for (
int y=0;
y<ncurve;
y++) {
904 TMath::Sort(nBg,rhoBg[
y],indexB[y],
false);
906 for (
int k=0;
k<nBg;
k++) {
910 int ij=indexB[
y][
k-1];
912 if(rhoBg[y][ii]!=0) {
915 if(rhoBg[y][ii]!=rhoBg[y][ij]) gB[
y]->SetPoint(igB_p++,rhoBg[y][ii],yy);
921 if(rhoBg[y][ii]!=0) {
923 gB[
y]->SetPoint(0,rhoBg[y][ii],yy);
930 cout<<
"dopo inserimento puntiB"<<endl;
933 TCanvas* cS=
new TCanvas(
"Efficiency_vs_rho",
"Efficiency_vs_rho",0,0,1200,700);
937 TMultiGraph* mg1=
new TMultiGraph();
939 gS[0]->SetMarkerColor(2);
940 gS[0]->SetLineColor(2);
941 mg1->SetTitle(
"cc=0.5;rho;#Events");
942 if(gS[0]->GetN()!=0) mg1->Add(gS[0]);
945 gS[
h]->SetMarkerColor(3);
946 gS[
h]->SetLineColor(3);
948 if(gS[
h]->GetN()!=0) mg1->Add(gS[
h]);
954 TMultiGraph* mg2=
new TMultiGraph();
956 gS[
nANN]->SetMarkerColor(2);
957 gS[
nANN]->SetLineColor(2);
958 mg2->SetTitle(
"cc=0.55;rho;#Events");
959 if(gS[nANN]->GetN()!=0) mg2->Add(gS[nANN]);
961 gS[nANN+
h]->SetMarkerColor(3);
962 gS[nANN+
h]->SetLineColor(3);
964 if(gS[nANN+
h]->GetN()!=0) mg2->Add(gS[nANN+
h]);
970 TMultiGraph* mg3=
new TMultiGraph();
972 gS[nANN*2]->SetMarkerColor(2);
973 gS[nANN*2]->SetLineColor(2);
974 mg3->SetTitle(
"cc=0.6;rho;#Events");
975 if(gS[nANN*2]->GetN()!=0) mg3->Add(gS[nANN*2]);
977 gS[2*nANN+
h]->SetMarkerColor(3);
978 gS[2*nANN+
h]->SetLineColor(3);
980 if(gS[2*nANN+
h]->GetN()!=0) mg3->Add(gS[2*nANN+
h]);
986 TMultiGraph* mg4=
new TMultiGraph();
988 gS[nANN*3]->SetMarkerColor(2);
989 gS[nANN*3]->SetLineColor(2);
990 mg4->SetTitle(
"cc=0.65;rho;#Events");
991 if(gS[nANN*3]->GetN()!=0) mg4->Add(gS[nANN*3]);
994 gS[3*nANN+
h]->SetMarkerColor(3);
995 gS[3*nANN+
h]->SetLineColor(3);
997 if(gS[3*nANN+
h]->GetN()!=0) mg4->Add(gS[3*nANN+
h]);
1001 cout<<
"nuovo canv"<<endl;
1002 TCanvas* cB=
new TCanvas(
"Number_vs_rho",
"Number_vs_rho",0,0,1200,700);
1004 cB->cd(1)->SetLogy();
1005 TMultiGraph* mg1B=
new TMultiGraph();
1007 gB[0]->SetMarkerColor(2);
1008 gB[0]->SetLineColor(2);
1009 mg1B->SetTitle(
"cc=0.5;rho;#Events");
1010 if(gB[0]->GetN()!=0) mg1B->Add(gB[0]);
1012 gB[
h]->SetMarkerColor(3);
1013 gB[
h]->SetLineColor(3);
1015 if(gB[
h]->GetN()!=0) mg1B->Add(gB[
h]);
1019 cB->cd(2)->SetLogy();
1020 TMultiGraph* mg2B=
new TMultiGraph();
1022 gB[
nANN]->SetMarkerColor(2);
1023 gB[
nANN]->SetLineColor(2);
1024 mg2B->SetTitle(
"cc=0.55;rho;#Events");
1025 if(gB[nANN]->GetN()!=0) mg2B->Add(gB[nANN]);
1027 gB[nANN+
h]->SetMarkerColor(3);
1028 gB[nANN+
h]->SetLineColor(3);
1030 if(gB[nANN+
h]->GetN()!=0) mg2B->Add(gB[nANN+
h]);
1034 cB->cd(3)->SetLogy();
1035 TMultiGraph* mg3B=
new TMultiGraph();
1037 gB[2*
nANN]->SetMarkerColor(2);
1038 gB[2*
nANN]->SetLineColor(2);
1039 mg3B->SetTitle(
"cc=0.6;rho;#Events");
1040 if(gB[2*nANN]->GetN()!=0) mg3B->Add(gB[2*nANN]);
1042 gB[2*nANN+
h]->SetMarkerColor(3);
1043 gB[2*nANN+
h]->SetLineColor(3);
1045 if(gB[2*nANN+
h]->GetN()!=0) mg3B->Add(gB[2*nANN+
h]);
1049 cB->cd(4)->SetLogy();
1050 TMultiGraph* mg4B=
new TMultiGraph();
1052 gB[3*
nANN]->SetMarkerColor(2);
1053 gB[3*
nANN]->SetLineColor(2);
1054 mg4B->SetTitle(
"cc=0.65;rho;#Events");
1055 if(gB[3*nANN]->GetN()!=0) mg4B->Add(gB[3*nANN]);
1057 gB[3*nANN+
h]->SetMarkerColor(3);
1058 gB[3*nANN+
h]->SetLineColor(3);
1060 if(gB[3*nANN+
h]->GetN()!=0) mg4B->Add(gB[3*nANN+
h]);
1072 char CnameS2root[1024];
1073 char CnameB2root[1024];
1074 CnameS.ReplaceAll(
".root",
".png");
1075 CnameB.ReplaceAll(
".root",
".png");
1076 sprintf(CnameS2,
"logN_rho_av/logN_rho_S_dANN%1.2f_%s",
deltaANN,CnameS.Data());
1077 sprintf(CnameB2,
"logN_rho_av/logN_rho_B_dANN%1.2f_%s",
deltaANN,CnameB.Data());
1078 sprintf(CnameS2root,
"logN_rho_av/logN_rho_S_dANN%1.2f_%s",
deltaANN,CnameSroot.Data());
1079 sprintf(CnameB2root,
"logN_rho_av/logN_rho_B_dANN%1.2f_%s",
deltaANN,CnameBroot.Data());
1080 cS->SaveAs(CnameS2);
1081 cB->SaveAs(CnameB2);
1082 cS->Print(CnameS2root);
1083 cB->Print(CnameB2root);
1091 name.ReplaceAll(
"average_file/",
"");
1092 TFile* fTEST =TFile::Open(ifile.Data());
1093 TTree* NNTree2=(TTree*)fTEST->Get(
"Parameters");
1098 NNTree2->SetBranchAddress(
"Average",&av);
1099 NNTree2->SetBranchAddress(
"cc",&cc);
1100 NNTree2->SetBranchAddress(
"rho",&rho);
1101 NNTree2->SetBranchAddress(
"#TestSig",&nSi);
1102 NNTree2->GetEntry(0);
1104 cout<<
"nSig: "<<nSig<<
" nSi: "<<nSi<<endl;
1108 double* ANNSig[ncurve2];
1109 for (
int i=0;
i<ncurve2;
i++) ANNSig[
i]=
new double[nSig];
1113 int const nBg=NNTree2->GetEntries()-nSig;
1114 for (
int i=0;
i<ncurve2;
i++) {
1116 for (
int j=0;
j<nSig;
j++) ANNSig[
i][
j]=0.;
1118 double* ANNBg[ncurve2];
1119 for (
int i=0;
i<ncurve2;
i++) ANNBg[
i]=
new double[nBg];
1123 for (
int i=0;
i<ncurve2;
i++) {
1125 for (
int j=0;
j<nBg;
j++) ANNBg[
i][
j]=0.;
1128 for (
int i=0;
i<
nCC;
i++) ccTh[
i]=0.;
1130 for (
int i=0;
i<
nRHO;
i++) rhoTh[
i]=0.;
1137 for(
int n=0;
n<NNTree2->GetEntries();
n++){
1138 NNTree2->GetEntry(
n);
1139 cout<<
"rho "<<rho<<
" cc "<<cc<<
" av "<<av<<endl;
1143 if(cc<ccTh[
i])
continue;
1147 if(rho<rhoTh[
j])
continue;
1150 NBg[i*nRHO+
j]= NBg[i*nRHO+
j]+1;
1151 if(i*nRHO+j==0) cout<<
" NBg[i*nRHO+j] "<<NBg[i*nRHO+
j]<<endl;
1152 while(ANNBg[i*nRHO+j][ni]!=0)ni=ni+1;
1153 ANNBg[i*nRHO+
j][ni]=av;
1158 NSig[i*nRHO+
j]= NSig[i*nRHO+
j]+1;
1159 if(i*nRHO+j==0) cout<<
" NSig[i*nRHO+j] "<<NSig[i*nRHO+
j]<<endl;
1160 while(ANNSig[i*nRHO+j][ni]!=0)ni=ni+1;
1161 ANNSig[i*nRHO+
j][ni]=av;
1167 int* indexS[ncurve2];
1168 for (
int i=0;
i<ncurve2;
i++) indexS[
i]=
new int[nSig];
1170 TGraph * gS[ncurve2];
1171 for (
int y=0;
y<ncurve2;
y++) {
1175 TMath::Sort(nSig,ANNSig[
y],indexS[y],
false);
1176 for (
int k=0;
k<nSig;
k++) {
1177 int ii=indexS[
y][
k];
1181 int ij=indexS[
y][
k-1];
1183 if(ANNSig[y][ii]!=0) {
1186 if(ANNSig[y][ii]!=ANNSig[y][ij]) gS[
y]->SetPoint(igS_p++,ANNSig[y][ii],yy);
1193 if(ANNSig[y][ii]!=0){
1195 gS[
y]->SetPoint(0,ANNSig[y][ii],yy);
1206 int* indexB[ncurve2];
1207 for (
int i=0;
i<ncurve2;
i++) indexB[
i]=
new int[nBg];
1209 TGraph * gB[ncurve2];
1210 for (
int y=0;
y<ncurve2;
y++) {
1214 TMath::Sort(nBg,ANNBg[
y],indexB[y],
false);
1216 for (
int k=0;
k<nBg;
k++) {
1217 int ii=indexB[
y][
k];
1218 int ik=indexB[
y][
k-1];
1221 int ij=indexB[
y][
k-1];
1223 if(ANNBg[y][ii]!=0) {
1225 if(y==0 && yy==FAth_n+1) {thresFA=ANNBg[
y][ii];}
1226 if (y==0 && yy<FAth_n+1)
if(ANNBg[y][ii]==ANNBg[y][ik]){FAth_n=FAth_n-1;}
1227 if(y==0) cout<<
"yy "<<yy<<
" y "<<y<<
" FAth_n "<<FAth_n<<
" thresFA "<<thresFA<<
" ANNBg[y][ii] "<<ANNBg[
y][ii]<<endl;
1229 if(ANNBg[y][ii]!=ANNBg[y][ij]) gB[
y]->SetPoint(igB_p++,ANNBg[y][ii],yy);
1235 if(ANNBg[y][ii]!=0) {
1237 gB[
y]->SetPoint(0,ANNBg[y][ii],yy);
1248 for(
int ni=1;ni<nSig;ni++){
1249 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;
1251 if (ANNSig[0][indexS[0][ni]]<=thresFA) FDth_n=FDth_n+1;
1256 TCanvas* cS=
new TCanvas(
"Efficiency_vs_ANN",
"Efficiency_vs_ANN",0,0,1200,700);
1260 TMultiGraph* mg1=
new TMultiGraph();
1261 mg1->SetTitle(
"cc: no_cut;ANN;#Events");
1263 gS[
h]->SetLineColor(4);
1264 if(gS[
h]->GetN()!=0) mg1->Add(gS[
h]);
1269 TMultiGraph* mg2=
new TMultiGraph();
1270 mg2->SetTitle(
"cc=0.55;ANN;#Events");
1272 gS[nRHO+
h]->SetLineColor(4);
1273 if(gS[nRHO+
h]->GetN()!=0) mg2->Add(gS[nRHO+
h]);
1279 TMultiGraph* mg3=
new TMultiGraph();
1280 mg3->SetTitle(
"cc=0.6;ANN;#Events");
1282 gS[2*nRHO+
h]->SetLineColor(4);
1283 if(gS[2*nRHO+
h]->GetN()!=0) mg3->Add(gS[2*nRHO+
h]);
1288 TMultiGraph* mg4=
new TMultiGraph();
1289 mg4->SetTitle(
"cc=0.65;ANN;#Events");
1291 gS[3*nRHO+
h]->SetLineColor(4);
1292 if(gS[3*nRHO+
h]->GetN()!=0) mg4->Add(gS[3*nRHO+
h]);
1296 TCanvas* cB=
new TCanvas(
"Number_vs_ANN",
"Number_vs_ANN",0,0,1200,700);
1298 cB->cd(1)->SetLogy();
1299 TMultiGraph* mg1B=
new TMultiGraph();
1300 mg1B->SetTitle(
"cc: no_cut;ANN;#Events");
1302 gB[
h]->SetLineColor(4);
1303 if(gB[
h]->GetN()!=0) mg1B->Add(gB[
h]);
1306 cB->cd(2)->SetLogy();
1307 TMultiGraph* mg2B=
new TMultiGraph();
1308 mg2B->SetTitle(
"cc=0.55;ANN;#Events");
1310 gB[nRHO+
h]->SetLineColor(4);
1311 if(gB[nRHO+
h]->GetN()!=0) mg2B->Add(gB[nRHO+
h]);
1314 cB->cd(3)->SetLogy();
1315 TMultiGraph* mg3B=
new TMultiGraph();
1316 mg3B->SetTitle(
"cc=0.6;ANN;#Events");
1318 gB[2*nRHO+
h]->SetLineColor(4);
1319 if(gB[2*nRHO+
h]->GetN()!=0) mg3B->Add(gB[2*nRHO+
h]);
1322 cB->cd(4)->SetLogy();
1323 TMultiGraph* mg4B=
new TMultiGraph();
1324 mg4B->SetTitle(
"cc=0.65;ANN;#Events");
1326 gB[3*nRHO+
h]->SetLineColor(4);
1327 if(gB[3*nRHO+
h]->GetN()!=0) mg4B->Add(gB[3*nRHO+
h]);
1339 char CnameS2root[1024];
1340 char CnameB2root[1024];
1341 CnameS.ReplaceAll(
".root",
".png");
1342 CnameB.ReplaceAll(
".root",
".png");
1343 sprintf(CnameS2,
"ANNthres_av/N_ANN_S_%s",CnameS.Data());
1344 sprintf(CnameB2,
"ANNthres_av/N_ANN_B_%s",CnameB.Data());
1345 sprintf(CnameS2root,
"ANNthres_av/N_ANN_S_%s",CnameSroot.Data());
1346 sprintf(CnameB2root,
"ANNthres_av/N_ANN_B_%s",CnameBroot.Data());
1347 cS->SaveAs(CnameS2);
1348 cB->SaveAs(CnameB2);
1349 cS->Print(CnameS2root);
1350 cB->Print(CnameB2root);
1361 name.ReplaceAll(
"outfile/",
"");
1362 name.ReplaceAll(
"average_file/",
"");
1363 TFile* fTEST =TFile::Open(ifile.Data());
1364 TTree* NNTree2=(TTree*)fTEST->Get(
"Parameters");
1374 NNTree2->SetBranchAddress(
"Mchirp",&Mc);
1375 NNTree2->SetBranchAddress(
"Average",&av);
1376 NNTree2->SetBranchAddress(
"cc",&cc);
1377 NNTree2->SetBranchAddress(
"rho",&rho);
1378 NNTree2->SetBranchAddress(
"Mchirp_injected",&Mc_inj);
1379 NNTree2->SetBranchAddress(
"#TestSig",&nSi);
1380 NNTree2->GetEntry(0);
1382 cout<<
"nSig: "<<nSig<<
" nSi: "<<nSi<<endl;
1385 double* McSig[ncurve2];
1386 for (
int i=0;
i<ncurve2;
i++) McSig[
i]=
new double[nSig];
1390 int const nBg=NNTree2->GetEntries()-nSig;
1391 for (
int i=0;
i<ncurve2;
i++) {
1393 for (
int j=0;
j<nSig;
j++) McSig[
i][
j]=0.;
1395 double* McBg[ncurve2];
1396 for (
int i=0;
i<ncurve2;
i++) McBg[
i]=
new double[nBg];
1400 for (
int i=0;
i<ncurve2;
i++) {
1402 for (
int j=0;
j<nBg;
j++) McBg[
i][
j]=0.;
1405 for (
int i=0;
i<
nCC;
i++) ccTh[
i]=0.;
1407 for (
int i=0;
i<
nRHO;
i++) rhoTh[
i]=0.;
1413 for(
int n=0;
n<NNTree2->GetEntries();
n++){
1414 NNTree2->GetEntry(
n);
1415 cout<<
"rho "<<rho<<
" cc "<<cc<<
" av "<<av<<endl;
1419 if(cc<ccTh[
i])
continue;
1423 if(rho<rhoTh[
j])
continue;
1426 NBg[i*nRHO+
j]= NBg[i*nRHO+
j]+1;
1427 if(i*nRHO+j==0) cout<<
" NBg[i*nRHO+j] "<<NBg[i*nRHO+
j]<<endl;
1428 while(McBg[i*nRHO+j][ni]!=0)ni=ni+1;
1429 McBg[i*nRHO+
j][ni]=Mc;
1434 NSig[i*nRHO+
j]= NSig[i*nRHO+
j]+1;
1435 if(i*nRHO+j==0) cout<<
" NSig[i*nRHO+j] "<<NSig[i*nRHO+
j]<<endl;
1436 while(McSig[i*nRHO+j][ni]!=0)ni=ni+1;
1437 McSig[i*nRHO+
j][ni]=Mc;
1444 int* indexS[ncurve2];
1445 for (
int i=0;
i<ncurve2;
i++) indexS[
i]=
new int[nSig];
1447 TGraph * gS[ncurve2];
1448 for (
int y=0;
y<ncurve2;
y++) {
1452 TMath::Sort(nSig,McSig[
y],indexS[y],
false);
1453 for (
int k=0;
k<nSig;
k++) {
1454 int ii=indexS[
y][
k];
1458 int ij=indexS[
y][
k-1];
1460 if(McSig[y][ii]!=0) {
1463 if(McSig[y][ii]!=McSig[y][ij]) gS[
y]->SetPoint(igS_p++,McSig[y][ii],yy);
1470 if(McSig[y][ii]!=0){
1472 gS[
y]->SetPoint(0,McSig[y][ii],yy);
1482 int* indexB[ncurve2];
1483 for (
int i=0;
i<ncurve2;
i++) indexB[
i]=
new int[nBg];
1485 TGraph * gB[ncurve2];
1486 for (
int y=0;
y<ncurve2;
y++) {
1490 TMath::Sort(nBg,McBg[
y],indexB[y],
false);
1492 for (
int k=0;
k<nBg;
k++) {
1493 int ii=indexB[
y][
k];
1494 int ik=indexB[
y][
k-1];
1497 int ij=indexB[
y][
k-1];
1499 if(McBg[y][ii]!=0) {
1501 if(y==0 && yy==McFAth_n+1) {McthresFA=McBg[
y][ii];
1503 if (y==0 && yy<McFAth_n+1) { cout<<
"dentro primo if"<<endl;
1505 if(McBg[y][ii]>McBg[y][ik]){McFAth_n=McFAth_n;cout<<
"maggiore ii "<<
" diff"<<(McBg[
y][ii]-McBg[
y][ik])<<endl;}
1506 if(McBg[y][ii]<McBg[y][ik]){McFAth_n=McFAth_n;cout<<
"minore ii"<<endl;}
1507 if(McBg[y][ii]==McBg[y][ik]){McFAth_n=McFAth_n-1;cout<<
"uguale"<<endl;}
1510 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;
1512 if(McBg[y][ii]!=McBg[y][ij]) gB[
y]->SetPoint(igB_p++,McBg[y][ii],yy);
1518 if(McBg[y][ii]!=0) {
1520 gB[
y]->SetPoint(0,McBg[y][ii],yy);
1529 for(
int ni=1;ni<nSig;ni++){
1530 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;
1532 if (McSig[0][indexS[0][ni]]<=McthresFA) McFDth_n=McFDth_n+1;
1536 TCanvas* cS=
new TCanvas(
"Efficiency_vs_Mchirp",
"Efficiency_vs_Mchirp",0,0,1200,700);
1540 TMultiGraph* mg1=
new TMultiGraph();
1541 mg1->SetTitle(
"cc: no_cut;Mchirp;#Events");
1543 gS[
h]->SetLineColor(4);
1544 if(gS[
h]->GetN()!=0) mg1->Add(gS[
h]);
1549 TMultiGraph* mg2=
new TMultiGraph();
1550 mg2->SetTitle(
"cc=0.55;Mchirp;#Events");
1552 gS[nRHO+
h]->SetLineColor(4);
1553 if(gS[nRHO+
h]->GetN()!=0) mg2->Add(gS[nRHO+
h]);
1559 TMultiGraph* mg3=
new TMultiGraph();
1560 mg3->SetTitle(
"cc=0.6;Mchirp;#Events");
1562 gS[2*nRHO+
h]->SetLineColor(4);
1563 if(gS[2*nRHO+
h]->GetN()!=0) mg3->Add(gS[2*nRHO+
h]);
1568 TMultiGraph* mg4=
new TMultiGraph();
1569 mg4->SetTitle(
"cc=0.65;Mchirp;#Events");
1571 gS[3*nRHO+
h]->SetLineColor(4);
1572 if(gS[3*nRHO+
h]->GetN()!=0) mg4->Add(gS[3*nRHO+
h]);
1576 TCanvas* cB=
new TCanvas(
"Number_vs_Mchirp",
"Number_vs_Mchirp",0,0,1200,700);
1578 cB->cd(1)->SetLogy();
1579 TMultiGraph* mg1B=
new TMultiGraph();
1580 mg1B->SetTitle(
"cc: no_cut;Mchirp;#Events");
1582 gB[
h]->SetLineColor(4);
1583 if(gB[
h]->GetN()!=0) mg1B->Add(gB[
h]);
1586 cB->cd(2)->SetLogy();
1587 TMultiGraph* mg2B=
new TMultiGraph();
1588 mg2B->SetTitle(
"cc=0.55;Mchirp;#Events");
1590 gB[nRHO+
h]->SetLineColor(4);
1591 if(gB[nRHO+
h]->GetN()!=0) mg2B->Add(gB[nRHO+
h]);
1594 cB->cd(3)->SetLogy();
1595 TMultiGraph* mg3B=
new TMultiGraph();
1596 mg3B->SetTitle(
"cc=0.6;Mchirp;#Events");
1598 gB[2*nRHO+
h]->SetLineColor(4);
1599 if(gB[2*nRHO+
h]->GetN()!=0) mg3B->Add(gB[2*nRHO+
h]);
1602 cB->cd(4)->SetLogy();
1603 TMultiGraph* mg4B=
new TMultiGraph();
1604 mg4B->SetTitle(
"cc=0.6;Mchirp;#Events");
1606 gB[3*nRHO+
h]->SetLineColor(4);
1607 if(gB[3*nRHO+
h]->GetN()!=0) mg4B->Add(gB[3*nRHO+
h]);
1618 char CnameS2root[1024];
1619 char CnameB2root[1024];
1620 CnameS.ReplaceAll(
".root",
".png");
1621 CnameB.ReplaceAll(
".root",
".png");
1622 sprintf(CnameS2,
"Mcthres/N_Mc_S_%s",CnameS.Data());
1623 sprintf(CnameB2,
"Mcthres/N_Mc_B_%s",CnameB.Data());
1624 sprintf(CnameS2root,
"Mcthres/N_Mc_S_%s",CnameSroot.Data());
1625 sprintf(CnameB2root,
"Mcthres/N_Mc_B_%s",CnameBroot.Data());
1626 cS->SaveAs(CnameS2);
1627 cB->SaveAs(CnameB2);
1628 cS->Print(CnameS2root);
1629 cB->Print(CnameB2root);
1636 name.ReplaceAll(
"outfile/",
"");
1637 name.ReplaceAll(
"average_file/",
"");
1638 TFile* fTEST =TFile::Open(ifile.Data());
1639 TTree* NNTree2=(TTree*)fTEST->Get(
"Parameters");
1647 NNTree2->SetBranchAddress(
"Average",&av);
1648 NNTree2->SetBranchAddress(
"cc",&cc);
1649 NNTree2->SetBranchAddress(
"rho",&rho);
1650 NNTree2->SetBranchAddress(
"#TestSig",&nSi);
1651 NNTree2->GetEntry(0);
1653 cout<<
"nSig: "<<nSig<<
" nSi: "<<nSi<<endl;
1654 int const nBg=NNTree2->GetEntries()-nSig;
1655 cout<<
"nBg: "<<nBg<<
" Entries: "<<NNTree2->GetEntries()<<endl;
1662 for (
int n = 0;
n <NNTree2->GetEntries();
n++){
1663 NNTree2->GetEntry(
n);
1665 gS[0]->SetPoint(
n,cc,av);
1666 cout<<
"Sig_graph1: x="<<cc<<
" y: "<<av<<endl;
1669 gB[0]->SetPoint(
n-nSig,cc,av);
1670 cout<<
"Bg_graph1: x="<<cc<<
" y: "<<av<<endl;
1691 gS[0]->SetMarkerColor(2);
1692 gB[0]->SetMarkerColor(4);
1693 gS[0]->SetMarkerStyle(6);
1694 gB[0]->SetMarkerStyle(7);
1696 TCanvas*
c=
new TCanvas(
"Plots",
"Plots",0,0,1200,700);
1699 TMultiGraph* mg1=
new TMultiGraph();
1700 mg1->SetTitle(
"Av_cc");
1701 if(gB[0]->GetN()!=0) mg1->Add(gB[0]);
1702 if(gS[0]->GetN()!=0) mg1->Add(gS[0]);
1704 mg1->GetHistogram()->GetXaxis()->SetTitle(
"cc");
1705 mg1->GetHistogram()->GetYaxis()->SetTitle(
"Average on ANN ouputs");
1708 TMultiGraph* mg2=
new TMultiGraph();
1709 mg2->SetTitle(
"Av_cc");
1710 if(gS[0]->GetN()!=0) mg2->Add(gS[0]);
1711 if(gB[0]->GetN()!=0) mg2->Add(gB[0]);
1713 mg2->GetHistogram()->GetXaxis()->SetTitle(
"cc");
1714 mg2->GetHistogram()->GetYaxis()->SetTitle(
"Average on ANN ouputs");
1716 cout<<
" name "<<name<<endl;
1720 char Cname2root[1024];
1721 Cname.ReplaceAll(
".root",
".png");
1722 sprintf(Cname2,
"average_png/out_Plots_%s",Cname.Data());
1723 sprintf(Cname2root,
"average_png/out_Plots_%s",Cnameroot.Data());
1725 c->Print(Cname2root);
1763 name.ReplaceAll(
"outfile/",
"");
1764 name.ReplaceAll(
"average_file/",
"");
1765 TFile* fTEST =TFile::Open(ifile.Data());
1766 TTree* NNTree2=(TTree*)fTEST->Get(
"Parameters");
1776 NNTree2->SetBranchAddress(
"Mchirp",&Mc);
1777 NNTree2->SetBranchAddress(
"Average",&av);
1778 NNTree2->SetBranchAddress(
"cc",&cc);
1779 NNTree2->SetBranchAddress(
"rho",&rho);
1780 NNTree2->SetBranchAddress(
"Mchirp_injected",&Mc_inj);
1781 NNTree2->SetBranchAddress(
"#TestSig",&nSi);
1782 NNTree2->GetEntry(0);
1784 cout<<
"nSig: "<<nSig<<
" nSi: "<<nSi<<endl;
1786 int const nBg=NNTree2->GetEntries()-nSig;
1794 TCanvas* ANN_Mc_c3D=
new TCanvas(
"ANN_average_vs_Mc_reconstructed",
"ANN_average_vs_Mc_reconstructed",0,0,1200,700);
1795 ANN_Mc_c3D->Divide(1,2);
1799 ANN_Mc_BKG3D->SetDirectory(0);
1800 ANN_Mc_BKG3D->SetStats(0);
1801 ANN_Mc_SIG3D->SetDirectory(0);
1802 ANN_Mc_SIG3D->SetStats(0);
1804 TCanvas* ANN_cc_c3D=
new TCanvas(
"ANN_average_vs_cc",
"ANN_average_vs_cc",0,0,1200,700);
1805 ANN_cc_c3D->Divide(1,2);
1808 ANN_cc_SIG3D->SetDirectory(0);
1809 ANN_cc_SIG3D->SetStats(0);
1810 ANN_cc_BKG3D->SetDirectory(0);
1811 ANN_cc_BKG3D->SetStats(0);
1816 TCanvas* Mc_inj_c=
new TCanvas(
"ANN_vs_Mc_injected",
"ANN_vs_Mc_injected",0,0,1200,700);
1817 Mc_inj_c->Divide(1,2);
1821 Mc_inj_gMc->SetDirectory(0);
1822 Mc_inj_gMc->SetStats(0);
1823 Mc_inj_g->SetDirectory(0);
1824 Mc_inj_g->SetStats(0);
1825 double deltaMc_inj=0;
1827 double deltaANN_av_M=0;
1834 txt_name0.ReplaceAll(
".root",
".txt");
1835 char txt_name[1024];
1836 sprintf(txt_name,
"txt_files/%s",txt_name0.Data());
1837 ofstream file_txt_out(txt_name);
1843 for (
int n = 0;
n <NNTree2->GetEntries();
n++){
1844 NNTree2->GetEntry(
n);
1846 if(
n<nSig&&
n!=nSig) {
1847 Mc_inj_gMc->Fill(Mc_inj,Mc);
1848 Mc_inj_g->Fill(Mc_inj,av);
1849 gS[0]->SetPoint(
n,Mc,av);
1850 cout<<
" n "<<
n<<
" Mc "<<Mc<<
" av "<<av<<
" M_inj "<<Mc_inj<<endl;
1851 cout<<
"Sig_graph1: x="<<cc<<
" y: "<<av<<endl;
1853 ANN_Mc_SIG3D->Fill(Mc,av);
1854 ANN_cc_SIG3D->Fill(cc,av);
1855 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);
1857 cout<<
" n "<<
n<<
" nSig "<<nSig<<endl;
1861 gB[0]->SetPoint(
n-nSig,Mc,av);
1862 ANN_Mc_BKG3D->Fill(Mc,av);
1863 ANN_cc_BKG3D->Fill(cc,av);
1865 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);
1873 gS[0]->SetMarkerColor(2);
1874 gB[0]->SetMarkerColor(4);
1875 gS[0]->SetMarkerStyle(6);
1876 gB[0]->SetMarkerStyle(7);
1879 ANN_Mc_SIG3D->GetXaxis()->SetTitle(
"SIG:Mchirp_reconstructed");
1880 ANN_Mc_SIG3D->GetYaxis()->SetTitle(
"SIG:ANN_average");
1881 ANN_Mc_SIG3D->GetZaxis()->SetTitle(
"count");
1882 ANN_Mc_SIG3D->Draw(
"colz");
1884 ANN_Mc_BKG3D->GetXaxis()->SetTitle(
"BKG:Mchirp_reconstructed");
1885 ANN_Mc_BKG3D->GetYaxis()->SetTitle(
"BKG:ANN_average");
1886 ANN_Mc_BKG3D->GetZaxis()->SetTitle(
"count");
1887 ANN_Mc_BKG3D->Draw(
"colz");
1891 TString ANN_Mc_rootname3D(name);
1892 char ANN_Mc_cname23D[1024];
1893 char ANN_Mc_crootname23D[1024];
1894 ANN_Mc_name3D.ReplaceAll(
".root",
".png");
1895 sprintf(ANN_Mc_cname23D,
"average_png/nSig%i_nBg%i_3DMc_ANNav_Plots_%s",nSig,nBg,ANN_Mc_name3D.Data());
1896 sprintf(ANN_Mc_crootname23D,
"average_png/nSig%i_nBg%i_3DMc_ANNav_Plots_%s",nSig,nBg,ANN_Mc_rootname3D.Data());
1897 ANN_Mc_c3D->SaveAs(ANN_Mc_cname23D);
1898 ANN_Mc_c3D->Print(ANN_Mc_crootname23D);
1902 ANN_cc_SIG3D->GetXaxis()->SetTitle(
"SIG:cc");
1903 ANN_cc_SIG3D->GetYaxis()->SetTitle(
"SIG:ANN_average");
1904 ANN_cc_SIG3D->GetZaxis()->SetTitle(
"count");
1905 ANN_cc_SIG3D->Draw(
"colz");
1907 ANN_cc_BKG3D->GetXaxis()->SetTitle(
"BKG:cc");
1908 ANN_cc_BKG3D->GetYaxis()->SetTitle(
"BKG:ANN_average");
1909 ANN_cc_BKG3D->GetZaxis()->SetTitle(
"count");
1910 ANN_cc_BKG3D->Draw(
"colz");
1914 TString ANN_cc_crootname3D(name);
1915 char ANN_cc_cname23D[1024];
1916 char ANN_cc_crootname23D[1024];
1917 ANN_cc_cname3D.ReplaceAll(
".root",
".png");
1918 sprintf(ANN_cc_cname23D,
"average_png/nSig%i_nBg%i_3DANNav_cc_Plots_%s",nSig,nBg,ANN_cc_cname3D.Data());
1919 sprintf(ANN_cc_crootname23D,
"average_png/nSig%i_nBg%i_3DANNav_cc_Plots_%s",nSig,nBg,ANN_cc_crootname3D.Data());
1920 ANN_cc_c3D->SaveAs(ANN_cc_cname23D);
1921 ANN_cc_c3D->Print(ANN_cc_crootname23D);
1924 Mc_inj_g->GetXaxis()->SetTitle(
"Mchirp_injected");
1925 Mc_inj_g->GetYaxis()->SetTitle(
"ANN_average");
1926 Mc_inj_g->GetZaxis()->SetTitle(
"count");
1927 Mc_inj_g->Draw(
"colz");
1929 Mc_inj_gMc->GetXaxis()->SetTitle(
"Mchirp_injected");
1930 Mc_inj_gMc->GetYaxis()->SetTitle(
"Mchirp_reconstructed");
1931 Mc_inj_gMc->GetZaxis()->SetTitle(
"count");
1932 Mc_inj_gMc->Draw(
"colz");
1936 TString Mc_inj_crootname(name);
1937 char Mc_inj_cname2[1024];
1938 char Mc_inj_crootname2[1024];
1939 Mc_inj_cname.ReplaceAll(
".root",
".png");
1940 sprintf(Mc_inj_cname2,
"average_png/nSig%i_nBg%i_Mc_inj_Plots_%s",nSig,nBg,Mc_inj_cname.Data());
1941 sprintf(Mc_inj_crootname2,
"average_png/nSig%i_nBg%i_Mc_inj_Plots_%s",nSig,nBg,Mc_inj_crootname.Data());
1942 Mc_inj_c->SaveAs(Mc_inj_cname2);
1943 Mc_inj_c->Print(Mc_inj_crootname2);
1946 TCanvas*
c=
new TCanvas(
"Plots",
"Plots",0,0,1200,700);
1949 TMultiGraph* mg1=
new TMultiGraph();
1950 mg1->SetTitle(
"Av_Mc");
1951 if(gB[0]->GetN()!=0) mg1->Add(gB[0]);
1952 if(gS[0]->GetN()!=0) mg1->Add(gS[0]);
1954 mg1->GetHistogram()->GetXaxis()->SetTitle(
"Mchirp");
1955 mg1->GetHistogram()->GetYaxis()->SetTitle(
"Average on ANN ouputs");
1957 TMultiGraph* mg2=
new TMultiGraph();
1958 mg2->SetTitle(
"Av_Mc");
1959 if(gS[0]->GetN()!=0) mg2->Add(gS[0]);
1960 if(gB[0]->GetN()!=0) mg2->Add(gB[0]);
1962 mg2->GetHistogram()->GetXaxis()->SetTitle(
"Mchirp");
1963 mg2->GetHistogram()->GetYaxis()->SetTitle(
"Average on ANN ouputs");
1965 cout<<
" name "<<name<<endl;
1969 char Cname2root[1024];
1970 Cname.ReplaceAll(
".root",
".png");
1971 sprintf(Cname2,
"average_png/nSig%i_nBg%i_Mc_Plots_%s",nSig,nBg,Cname.Data());
1972 sprintf(Cname2root,
"average_png/nSig%i_nBg%i_Mc_Plots_%s",nSig,nBg,Cnameroot.Data());
1973 cout<<
"Cname2 "<<Cname2<<endl;
1975 c->Print(Cname2root);
1976 cout<<
" gS[0]->GetN() "<<gS[0]->GetN()<<endl;
1978 cout<<
" nSig "<<nSig<<
" nBg "<<nBg<<
" aa1 "<<aa1<<endl;
1985 name.ReplaceAll(
"outfile/",
"");
1986 name.ReplaceAll(
"average_file/",
"");
1987 TFile* fTEST =TFile::Open(ifile.Data());
1988 TTree* NNTree2=(TTree*)fTEST->Get(
"Parameters");
1996 NNTree2->SetBranchAddress(
"Mchirp",&Mc);
1997 NNTree2->SetBranchAddress(
"Average",&av);
1998 NNTree2->SetBranchAddress(
"cc",&cc);
1999 NNTree2->SetBranchAddress(
"rho",&rho);
2000 NNTree2->SetBranchAddress(
"Mchirp_injected",&Mc_inj);
2001 NNTree2->SetBranchAddress(
"#TestSig",&nSi);
2002 NNTree2->GetEntry(0);
2004 cout<<
"nSig: "<<nSig<<
" nSi: "<<nSi<<endl;
2005 int const nBg=NNTree2->GetEntries()-nSig;
2006 int const nTot=NNTree2->GetEntries();
2008 int nBgSur[3][n_points];
2009 int nSigSur[3][n_points];
2010 double zax[3][n_points];
2012 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.;}
2027 double deltaANNth=0.;
2028 double deltaRHOth=0.;
2034 TCanvas* SNR_c=
new TCanvas(
"SIG-BKG_reduction",
"SIG-BKG_reduction",0,0,1200,700);
2040 SNR3Dcc0->SetDirectory(0);
2041 SNR3Dcc0->SetStats(0);
2042 SNR3Dcc1->SetDirectory(0);
2043 SNR3Dcc1->SetStats(0);
2044 SNR3Dcc2->SetDirectory(0);
2045 SNR3Dcc2->SetStats(0);
2047 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;}
2048 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;}
2050 cout<<
"fino def cose"<<endl;
2085 for (
int u=0; u<nTot; u++){
2086 NNTree2->GetEntry(u);
2087 for (
int y=0;
y<3;
y++){
2093 if(u<nSig) nSigSur[
y][j+N_ANNth*
i]=nSigSur[
y][j+N_ANNth*
i]+1;
2094 else nBgSur[
y][j+N_ANNth*
i]=nBgSur[
y][j+N_ANNth*
i]+1;
2109 nBgSur0=nBgSur[0][0];
2111 nSigSur0=nSigSur[0][0];
2112 if(nBgSur0==0){nBgSur0=nBg;}
2113 if(nSigSur0==0){nSigSur0=nSig;}
2115 cout<<
"dopo ciclo"<<
" nSigSur0 "<<nSigSur0<<
" nBgSur0 "<<nBgSur0<<endl;
2119 if(nSigSur[u][
i+
j*N_ANNth]==0) {
2120 if (nSigSur[u][
i+
j*N_ANNth]==0 && nBgSur[u][
i+
j*N_ANNth]==0) zax[u][
i+
j*
N_ANNth]=-1;
2126 num=(double)nBgSur[u][
i+
j*N_ANNth]/nBgSur0;
2127 den=(double)nSigSur0/nSigSur[u][
i+
j*N_ANNth];
2128 zax[u][
i+
j*
N_ANNth]=(double)num/den; count_zax=count_zax+1;
2129 cout<<(double)(nBgSur[u][
i+
j*N_ANNth]/nBgSur0)*(nSigSur0/nSigSur[u][
i+
j*
N_ANNth])<<endl;
2137 SNR3Dcc0->Fill(pANNth[
i]+ deltaANNth/2.,pRHOth[
j]+ deltaRHOth/2.,zax[0][
i+
j*N_ANNth]);
2138 SNR3Dcc1->Fill(pANNth[
i]+ deltaANNth/2.,pRHOth[
j]+ deltaRHOth/2.,zax[1][
i+
j*N_ANNth]);
2139 SNR3Dcc2->Fill(pANNth[
i]+ deltaANNth/2.,pRHOth[
j]+ deltaRHOth/2.,zax[2][
i+
j*N_ANNth]);
2142 for(
int yy=0;
yy<3;
yy++) {
2143 cout<<
" pCCth "<<pCCth[
yy]<<endl;
2144 for (
int ii=N_ANNth-1; ii>-1; ii--) {
2145 cout<<
" pANNth[i] "<<pANNth[ii]<<endl;
2146 for (
int jj=N_RHOth-1; jj>-1;jj--){
2147 cout<<
" pRHOth[jj] "<<pRHOth[jj]<<endl;
2148 cout<<
" nBgSur[yy][ii+N_ANNth*jj] "<<nBgSur[
yy][ii+N_ANNth*jj]<<endl;
2149 cout<<
" nSigSur[yy][ii+N_ANNth*jj] "<<nSigSur[
yy][ii+N_ANNth*jj]<<endl;
2150 cout<<
" zax[0][i+j*N_ANNth]"<<zax[
yy][ii+jj*
N_ANNth]<<endl;
2151 cout<<
" (double)(nBgSur[u][i+j*N_ANNth]/nBgSur0)"<<(double)nBgSur[
yy][ii+jj*N_ANNth]/nBgSur0<<endl;
2156 cout<<
"coutn_zax "<<count_zax<<endl;
2158 SNR3Dcc0->GetXaxis()->SetTitle(
"ANN_average_thresholds");
2159 SNR3Dcc0->GetYaxis()->SetTitle(
"RHO_thresholds");
2160 SNR3Dcc0->GetZaxis()->SetTitle(
"normBKG/normSIG");
2161 SNR3Dcc0->Draw(
"colz");
2164 SNR3Dcc1->GetXaxis()->SetTitle(
"ANN_average_thresholds");
2165 SNR3Dcc1->GetYaxis()->SetTitle(
"RHO_thresholds");
2166 SNR3Dcc1->GetZaxis()->SetTitle(
"normBKG/normSIG");
2167 SNR3Dcc1->Draw(
"colz");
2170 SNR3Dcc2->GetXaxis()->SetTitle(
"ANN_average_thresholds");
2171 SNR3Dcc2->GetYaxis()->SetTitle(
"RHO_thresholds");
2172 SNR3Dcc2->GetZaxis()->SetTitle(
"normBKG/normSIG");
2173 SNR3Dcc2->Draw(
"colz");
2178 char SNR_c_nroot[1024];
2179 SNR_n.ReplaceAll(
".root",
".png");
2180 sprintf(SNR_c_n,
"SNR_plots/nSig%i_nBg%i_invSNR_Plots_%s",nSig,nBg,SNR_n.Data());
2181 sprintf(SNR_c_nroot,
"SNR_plots/nSig%i_nBg%i_invSNR_Plots_%s",nSig,nBg,SNR_nroot.Data());
2182 SNR_c->SaveAs(SNR_c_n);
2183 SNR_c->Print(SNR_c_nroot);
2191 name.ReplaceAll(
"outfile/",
"");
2192 name.ReplaceAll(
"average_file/",
"");
2193 TFile* fTEST =TFile::Open(ifile.Data());
2194 TTree* NNTree2=(TTree*)fTEST->Get(
"Parameters");
2203 NNTree2->SetBranchAddress(
"Center_of_Gravity",&CoG);
2204 NNTree2->SetBranchAddress(
"Mchirp",&Mc);
2205 NNTree2->SetBranchAddress(
"Average",&av);
2206 NNTree2->SetBranchAddress(
"cc",&cc);
2207 NNTree2->SetBranchAddress(
"rho",&rho);
2208 NNTree2->SetBranchAddress(
"Mchirp_injected",&Mc_inj);
2209 NNTree2->SetBranchAddress(
"#TestSig",&nSi);
2210 NNTree2->GetEntry(0);
2212 cout<<
"nSig: "<<nSig<<
" nSi: "<<nSi<<endl;
2213 int const nTot=NNTree2->GetEntries();
2214 int const nBg=nTot-nSig;
2216 TCanvas* CoG_c=
new TCanvas(
"SIG-BKG_reduction",
"SIG-BKG_reduction",0,0,1200,700);
2223 TH1D* ibkgCC=
new TH1D(
"Number_of_events_vs_CC",
"Number_of_events_vs_CC",50,0.,1.);
2224 TH1D* isigCC=
new TH1D(
"Number_of_events_vs_CC",
"Number_of_events_vs_CC",50,0.,1.);
2225 TH1D* ibkgRHO=
new TH1D(
"Number_of_events_vs_RHO",
"Number_of_events_vs_RHO",50,0.,50.);
2226 TH1D* isigRHO=
new TH1D(
"Number_of_events_vs_RHO",
"Number_of_events_vs_RHO",50,0.,50.);
2227 TH1D* ibkgANN=
new TH1D(
"Number_of_events_vs_ANN",
"Number_of_events_vs_ANN",50,-0.2,1.2);
2228 TH1D* isigANN=
new TH1D(
"Number_of_events_vs_ANN",
"Number_of_events_vs_ANN",50,-0.2,1.2);
2230 CoG1Sig->SetDirectory(0);
2231 CoG1Sig->SetStats(0);
2232 CoG0Sig->SetDirectory(0);
2233 CoG0Sig->SetStats(0);
2234 CoG1Bg->SetDirectory(0);
2235 CoG1Bg->SetStats(0);
2236 CoG0Bg->SetDirectory(0);
2237 CoG0Bg->SetStats(0);
2238 ibkgCC->SetDirectory(0);
2239 ibkgCC->SetStats(0);
2240 isigRHO->SetDirectory(0);
2241 isigRHO->SetStats(0);
2242 ibkgANN->SetDirectory(0);
2243 ibkgANN->SetStats(0);
2244 isigCC->SetDirectory(0);
2245 isigCC->SetStats(0);
2246 ibkgRHO->SetDirectory(0);
2247 ibkgRHO->SetStats(0);
2248 isigANN->SetDirectory(0);
2249 isigANN->SetStats(0);
2251 for (
int n=0;
n<nTot;
n++){
2252 NNTree2->GetEntry(
n);
2254 if(CoG==0) {CoG0Sig->Fill(av);}
2255 else {CoG1Sig->Fill(av);}
2261 if(CoG==0) {CoG0Bg->Fill(av);}
2262 else {CoG1Bg->Fill(av);}
2268 cout<<
" CoG "<<CoG<<endl;
2271 imp->SetDirectory(0);
2278 for(
int i=0;
i<4;
i++) max[
i]=0;
2280 max[0]=CoG1Sig->GetMaximum();
2281 max[1]=CoG0Sig->GetMaximum();
2282 max[2]=CoG1Bg->GetMaximum();
2283 max[3]=CoG0Bg->GetMaximum();
2287 for(
int i=0;
i<4;
i++)
if(max_n<max[
i]) max_n=max[
i] ;
2290 imp->SetLineColor(10);
2292 imp->GetXaxis()->SetTitle(
"ANN");
2293 imp->GetYaxis()->SetTitle(
"Count");
2296 isigCC->SetFillStyle(3018);
2297 isigRHO->SetFillStyle(3018);
2298 isigANN->SetFillStyle(3018);
2299 ibkgCC->SetFillStyle(3004);
2300 ibkgRHO->SetFillStyle(3004);
2301 ibkgANN->SetFillStyle(3004);
2302 CoG1Sig->SetFillStyle(3018);
2303 CoG0Sig->SetFillStyle(3018);
2304 CoG0Bg->SetFillStyle(3004);
2305 CoG1Bg->SetFillStyle(3004);
2306 ibkgCC->SetLineColor(4);
2307 ibkgANN->SetLineColor(4);
2308 ibkgRHO->SetLineColor(4);
2309 isigCC->SetLineColor(2);
2310 isigANN->SetLineColor(2);
2311 isigRHO->SetLineColor(2);
2312 ibkgCC->SetFillColor(4);
2313 ibkgANN->SetFillColor(4);
2314 ibkgRHO->SetFillColor(4);
2315 isigCC->SetFillColor(2);
2316 isigANN->SetFillColor(2);
2317 isigRHO->SetFillColor(2);
2318 CoG1Sig->SetFillColor(2);
2319 CoG0Sig->SetFillColor(6);
2320 CoG0Bg->SetFillColor(4);
2321 CoG1Bg->SetFillColor(9);
2322 CoG1Sig->SetLineColor(2);
2323 CoG0Sig->SetLineColor(6);
2324 CoG0Bg->SetLineColor(4);
2325 CoG1Bg->SetLineColor(9);
2330 CoG1Sig->Draw(
"same");
2331 CoG0Sig->Draw(
"same");
2332 CoG0Bg->Draw(
"same");
2333 CoG1Bg->Draw(
"same");
2340 char CoG_c_nroot[1024];
2341 CoG_n.ReplaceAll(
".root",
".png");
2342 sprintf(CoG_c_n,
"CoG_plots/nSig%i_nBg%i_CoG_Plots_%s",nSig,nBg,CoG_n.Data());
2343 sprintf(CoG_c_nroot,
"CoG_plots/nSig%i_nBg%i_CoG_Plots_%s",nSig,nBg,CoG_nroot.Data());
2344 CoG_c->SaveAs(CoG_c_n);
2345 CoG_c->Print(CoG_c_nroot);
2347 TCanvas* Istogram=
new TCanvas(
"SIG-BKG_reduction",
"SIG-BKG_reduction",0,0,1200,400);
2349 Istogram->Divide(3,1);
2351 if (ibkgCC->GetMaximum()>isigCC->GetMaximum()) {ibkgCC->GetXaxis()->SetTitle(
"Network Correlation Coefficient"); ibkgCC->GetYaxis()->SetTitle(
"Count"); ibkgCC->Draw(); isigCC->Draw(
"same");}
2352 else {isigCC->GetXaxis()->SetTitle(
"Network Correlation Coefficient"); isigCC->GetXaxis()->SetTitle(
"Count"); isigCC->Draw();ibkgCC->Draw(
"same");}
2354 if (ibkgRHO->GetMaximum()>isigRHO->GetMaximum()) {ibkgRHO->GetXaxis()->SetTitle(
"Effective Correlated SNR"); ibkgRHO->GetYaxis()->SetTitle(
"Count"); ibkgCC->Draw(); ibkgRHO->Draw(); isigRHO->Draw(
"same");}
2355 else {isigRHO->GetXaxis()->SetTitle(
"Effective Correlated SNR"); isigRHO->GetXaxis()->SetTitle(
"Count"); isigRHO->Draw();ibkgRHO->Draw(
"same");}
2357 if (ibkgANN->GetMaximum()>isigANN->GetMaximum()) {ibkgANN->GetXaxis()->SetTitle(
"ANN parameter"); ibkgANN->GetYaxis()->SetTitle(
"Count"); ibkgANN->Draw(); isigANN->Draw(
"same");}
2358 else {isigANN->GetXaxis()->SetTitle(
"ANN parameter"); isigANN->GetYaxis()->SetTitle(
"Count"); isigANN->Draw();ibkgANN->Draw(
"same");}
2362 char isto_c_n[1024];
2363 char isto_c_nroot[1024];
2364 isto_n.ReplaceAll(
".root",
".png");
2365 sprintf(isto_c_n,
"Istograms/nSig%i_nBg%i_istograms_%s",nSig,nBg,isto_n.Data());
2366 sprintf(isto_c_nroot,
"Istograms/nSig%i_nBg%i_istograms_%s",nSig,nBg,isto_nroot.Data());
2367 Istogram->SaveAs(isto_c_n);
2368 Istogram->Print(isto_c_nroot);
2374 name.ReplaceAll(
"outfile/",
"");
2375 name.ReplaceAll(
"average_file/",
"");
2376 TFile* fTEST =TFile::Open(ifile.Data());
2377 TTree* NNTree2=(TTree*)fTEST->Get(
"Parameters");
2389 NNTree2->SetBranchAddress(
"Center_of_Gravity",&CoG);
2390 NNTree2->SetBranchAddress(
"duration",&Dt);
2391 NNTree2->SetBranchAddress(
"Mchirp",&Mc);
2392 NNTree2->SetBranchAddress(
"Average",&av);
2393 NNTree2->SetBranchAddress(
"cc",&cc);
2394 NNTree2->SetBranchAddress(
"rho",&rho);
2395 NNTree2->SetBranchAddress(
"Mchirp_injected",&Mc_inj);
2396 NNTree2->SetBranchAddress(
"#TestSig",&nSi);
2397 NNTree2->GetEntry(0);
2399 cout<<
"nSig: "<<nSig<<
" nSi: "<<nSi<<endl;
2400 int const nTot=NNTree2->GetEntries();
2401 int const nBg=nTot-nSig;
2403 TCanvas* Dt_c=
new TCanvas(
"Duration",
"Duration",0,0,1200,700);
2408 cout<<
"maxDt "<<maxDt<<
" minDt "<<minDt<<endl;
2410 for(
int i=0;
i<nTot;
i++){
2411 NNTree2->GetEntry(
i);
2412 if(Dt>maxDt) maxDt=Dt;
2413 if(Dt<minDt) minDt=Dt;
2419 TH1D* imp=
new TH1D(
"Duration",
"Duration",100,0.,2.);
2420 TH1D* Dt_hB=
new TH1D(
"Duration",
"Duration",100,0.,2.);
2421 TH1D* Dt_hS=
new TH1D(
"Duration",
"Duration",100,0.,2.);
2423 imp->SetDirectory(0);
2425 Dt_hS->SetDirectory(0);
2427 Dt_hB->SetDirectory(0);
2430 for (
int n=0;
n<nTot;
n++){
2431 NNTree2->GetEntry(
n);
2432 if (
n<nSig) Dt_hS->Fill(Dt);
2433 else Dt_hB->Fill(Dt);
2436 Dt_hS->SetFillStyle(3018);
2437 Dt_hB->SetFillStyle(3004);
2438 Dt_hS->SetFillColor(2);
2439 Dt_hB->SetFillColor(4);
2440 Dt_hS->SetLineColor(2);
2441 Dt_hB->SetLineColor(4);
2445 for(
int i=0;
i<2;
i++) max[
i]=0;
2447 max[0]=Dt_hS->GetMaximum();
2448 max[1]=Dt_hB->GetMaximum();
2451 for(
int i=0;
i<2;
i++)
if(max_n<max[
i]) max_n=max[
i] ;
2453 imp->Fill(minDt,max_n);
2454 imp->SetLineColor(10);
2456 imp->GetXaxis()->SetTitle(
"Duration");
2457 imp->GetYaxis()->SetTitle(
"Count");
2459 Dt_hS->Draw(
"same");
2460 Dt_hB->Draw(
"same");
2465 char CoG_c_nroot[1024];
2466 CoG_n.ReplaceAll(
".root",
".png");
2467 sprintf(CoG_c_n,
"Duration_plots/nSig%i_nBg%i_invSNR_Plots_%s",nSig,nBg,CoG_n.Data());
2468 sprintf(CoG_c_nroot,
"Duration_plots/nSig%i_nBg%i_invSNR_Plots_%s",nSig,nBg,CoG_nroot.Data());
2469 Dt_c->SaveAs(CoG_c_n);
2470 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<< "\ 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
void SNR_plots(TString ifile)
cout<< "SNR "<< xsnr<< endl;wavearray< double > f
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 \");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)