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 76 #define x_asym 0.00009999999999999999999999999999 78 #define min_yasym -0.1 112 void JoinCutANN_Mchirp_ROCcurves_rho2(
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){
115 if (uf==0&&av_on_nNN!=0) cout<<
"all events were not used for the training procedure"<<endl;
116 if(uf==0) {ni=1; consider_all=1; av_on_nNN=0;}
127 if (NN_FILE.CompareTo(
"")){
130 if (NN_FILE2.CompareTo(
"")){
133 if (NN_FILE3.CompareTo(
"")){
136 if (NN_FILE4.CompareTo(
"")){
139 if (NN_FILE5.CompareTo(
"")){
142 if (NN_FILE6.CompareTo(
"")){
145 if (NN_FILE7.CompareTo(
"")){
148 if (NN_FILE8.CompareTo(
"")){
155 char NNi2[nNN][1024];
156 sprintf(NNi2[0],
"%s",NN_FILE.Data());
157 if(nNN>1)
sprintf(NNi2[1],
"%s",NN_FILE2.Data());
158 if(nNN>2)
sprintf(NNi2[2],
"%s",NN_FILE3.Data());
159 if(nNN>3)
sprintf(NNi2[3],
"%s",NN_FILE4.Data());
160 if(nNN>4)
sprintf(NNi2[4],
"%s",NN_FILE5.Data());
161 if(nNN>5)
sprintf(NNi2[5],
"%s",NN_FILE6.Data());
162 if(nNN>6)
sprintf(NNi2[6],
"%s",NN_FILE7.Data());
163 if(nNN>7)
sprintf(NNi2[7],
"%s",NN_FILE8.Data());
165 if(nNN==1) {av_on_nNN=1; consider_all=0; ni=0;}
167 for (
int u=0;u<nNN;u++){
170 if (NNi2[u][p]==
'N'){
171 if((NNi2[u][p+1]==
'N')&&(NNi2[u][p+2]==
'\/')) {
173 while (NNi2[u][hh]!=
'\0'){NNi[u][hh-p-3]=NNi2[u][
hh];hh=hh+1;}
185 sprintf(Filei2,
"%s",TEST_FILE.Data());
187 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]==
'\/')) {
189 while (Filei2[hh]!=
'\0') {Filei[hh-q-7]=Filei2[
hh];hh=hh+1;
191 for (
int h0=hh-q-7;h0<1024;h0++) Filei[h0]=
'\0';
197 cout<<Filei<<
" original String: "<<Filei2<<endl;
202 if(nNN>1) NNi0[1]=NNi[1];
203 if(nNN>2) NNi0[2]=NNi[2];
204 if(nNN>3) NNi0[3]=NNi[3];
205 if(nNN>4) NNi0[4]=NNi[4];
206 if(nNN>5) NNi0[5]=NNi[5];
207 if(nNN>6) NNi0[6]=NNi[6];
208 if(nNN>7) NNi0[7]=NNi[7];
213 for (
int u=0;u<nNN;u++){
214 NNi0[u].ReplaceAll(
".root",
"");
216 Filei0.ReplaceAll(
".root",
"");
220 TMultiLayerPerceptron* mlp[nNN];
226 for (
int yy=0;
yy<nNN;
yy++){TotBg[
yy]=0;FA0[
yy]=0;FD0[
yy]=0;}
240 for (
int u=0;u<nNN;u++){
241 fnet[u]=TFile::Open(NNi2[u]);
242 mlp[u]=(TMultiLayerPerceptron*)fnet[u]->Get(
"TMultiLayerPerceptron");
244 cout<<
"dopo TMLP"<<endl;
245 if(mlp[u]==NULL) {cout <<
"Error getting mlp" << endl;
exit(1);}
246 infot[u]=(TTree*)fnet[u]->Get(
"info");
248 infot[u]->SetBranchAddress(
"Rand_start_Sig",&NNs[u]);
249 infot[u]->SetBranchAddress(
"Rand_start_Bg",&NNb[u]);
250 infot[u]->SetBranchAddress(
"#trainSig",&NNnTS[u]);
251 infot[u]->SetBranchAddress(
"#trainBg",&NNnTB[u]);
252 infot[u]->GetEntry(0);
253 cout<<
"n "<<u<<
" b "<<NNb[u]<<
" min_NNb "<<min_NNb<<endl;
255 if(NNs[u]<min_NNs) min_NNs=NNs[u];
256 if(NNb[u]<min_NNb) min_NNb=NNb[u];
257 if(NNs[u]>max_NNs) max_NNs=NNs[u];
258 if(NNb[u]>max_NNb) max_NNb=NNb[u];
259 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;
270 cout<<
" min_NNb "<<min_NNb<<
" b "<<b<<endl;
271 cout<<
"Def. tree e mlp"<<endl;
274 TFile* fTEST =TFile::Open(TEST_FILE.Data());
275 cout<<
"Def. tree e mlp"<<endl;
276 TTree* NNTree=(TTree*)fTEST->Get(
"nnTree");
277 cout<<
"Def. tree e mlp"<<endl;
278 int entries=NNTree->GetEntries();
281 cout<<
"entries: "<<entries<<endl;
282 cout<<
" NNTree->GetEntries() "<<NNTree->GetEntries()<<endl;
292 NNTree->SetBranchAddress(
"#Entries_type",&entriesTot);
293 NNTree->SetBranchAddress(
"Matrix_dim",&ndim);
294 NNTree->SetBranchAddress(
"#inputs",&ninp);
295 NNTree->SetBranchAddress(
"amplitude_mode",&y);
298 sig_entries=entriesTot;
299 NNTree->GetEntry(entries-1);
300 bg_entries=entriesTot;
301 cout<<
"sig "<<sig_entries<<
" bg "<<bg_entries<<endl;
304 cout<<
"NDIM: "<<NDIM<<endl;
305 cout<<
"nINP: "<<nINP<<endl;
306 cout<<
"sig e: "<<sig_entries<<endl;
307 cout<<
"bg e: "<<bg_entries<<endl;
311 if (sig_entries>bg_entries) minevents=bg_entries;
312 else minevents=sig_entries;
319 cout<<
"TS "<<TS<<
" TB "<<
TB<<
" minevents "<<minevents<<endl;
324 cout<<
"Error: Bg index<sig_entries: new set of b parameter-> b="<<b<<
" instead of b="<<a<<endl;
330 cout<<
"Error: Sig index>sig_entries: new set of s parameter-> s="<<b<<
" instead of s="<<a<<endl;
332 if((TS>sig_entries-
s||
TB>(bg_entries-(b-sig_entries)))&&(TS==
TB)) {TS=minevents-
s;
TB=minevents-(b-sig_entries);
335 cout<<
"Error:S>sig_entries or TB>bg_entries, to maintain ugual number of analysed events TS=TB="<<
TB<<endl;
337 if((TS>sig_entries-
s||
TB>bg_entries-(b-sig_entries))&&(TS!=
TB)) {
338 if(TS>sig_entries) TS=sig_entries-
s;
339 if (
TB>bg_entries)
TB=bg_entries-(b-sig_entries);
340 cout<<
"Error:S>sig_entries or TB>bg_entries, new TS and TB values are thus define-> TS="<<TS<<
" TB="<<
TB<<endl;
345 sprintf(NOMEtot,
"%s",NOMEtot_S.Data());
346 cout<<
"output name: "<<NOMEtot<<endl;
352 NNTree->SetBranchAddress(
"Files_name",&FILE_NAME);
355 NNTree->GetEntry(entries-1);
357 cout<<
"fine ifdef RHO_CC"<<endl;
360 TChain sigTree(
"waveburst");
361 sigTree.Add(SIG_FILE.Data());
364 cout <<
"sig entries2 : " << sig_entries2 << endl;
366 TChain bgTree(
"waveburst");
367 bgTree.Add(BG_FILE.Data());
370 cout <<
"bg entries2 : " << bg_entries2 << endl;
372 cout<<
"b: "<<b<<endl;
373 cout<<
"s: "<<
s<<endl;
377 for (
int jj=0; jj<nINP;jj++) x[jj]=0.;
378 char ilabel[nINP][16];
381 for(
int i=0;
i<nINP;
i++) {
383 NNTree->SetBranchAddress(ilabel[i], &x[i]);
387 sprintf(ofile,
"average_file/%s.root",NOMEtot);
388 TFile*
f =
new TFile(ofile,
"RECREATE");
389 TTree* NNTree2=
new TTree(
"Parameters",
"Parameters");
390 NNTree2->SetDirectory(f);
395 for(
int y=0; y<nNN; y++) out[y]=0.;
407 NNTree2->Branch(
"Center_of_Gravity",&CoG,
"Center_of_Gravity/I");
408 NNTree2->Branch(
"Average",&average,
"Average/D");
409 NNTree2->Branch(
"StandardDevaition",&std,
"StandardDeviation/D");
410 NNTree2->Branch(
"cc",&NNcc,
"cc/D");
411 NNTree2->Branch(
"Mchirp",&Mc,
"Mchirp/D");
412 NNTree2->Branch(
"Mchirp_injected",&Mc_inj,
"Mchirp_injected/D");
413 NNTree2->Branch(
"rho",&NNrho,
"rho/D");
414 NNTree2->Branch(
"index",&index_ev,
"index/I");
417 NNTree2->Branch(
"Test_file",&TestFile,
"Test_file/C");
419 for(
int u=0;u<nNN;u++){
425 sprintf(NNoutl2,
"NNout%i/D",u);
427 sprintf(NNnamel2,
"NNname%i/C",u);
428 NNTree2->Branch(NNoutl,&out[u],NNoutl2);
429 NNTree2->Branch(NNnamel,&NNi[u],NNnamel2);
433 NNTree2->Branch(
"TestFile",&Testf,
"TestFile/C");
434 sprintf(Testf,
"%s",TEST_FILE.Data());
443 for(
int n=
s;
n<sig_entries;
n++) {
445 for(
int u=0;u<nNN;u++){
446 if (uf!=0&&
n>NNs[u]&&
n<(NNs[u]+NNnTS[u])) countNN=countNN+1;
452 if(countNN==0&&av_on_nNN!=0) scount=scount+1;
455 if(countNN==1&&consider_all==0&&av_on_nNN==0) scount=scount+1;
456 if(countNN<2&&consider_all!=0) scount=scount+1;
457 if(countNN>1){cout<<
"Error: training non independent"<<
n<<endl;
exit(0);}
458 cout<<
"n "<<
n<<
"; countNN "<<countNN<<
"; scount "<< scount<<
"; consider_all "<<consider_all<<
"; av_on_nNN "<<av_on_nNN<<endl;
459 if(scount==TS)
break;}
463 cout<<
" nTestS "<< nTestS<<
" TS "<<TS<<endl;
478 for(
int n=b;
n<sig_entries+bg_entries;
n++) {
480 for(
int u=0;u<nNN;u++){
481 if (uf!=0&&
n>NNb[u]&&
n<(NNb[u]+NNnTB[u])) countNN=countNN+1;
483 if(countNN==0&&av_on_nNN!=0) bcount=bcount+1;
485 if(countNN==1&&consider_all==0&&av_on_nNN==0) bcount=bcount+1;
486 if(countNN<2&&consider_all!=0) bcount=bcount+1;
487 if(countNN>1){cout<<
"Error: training non independent"<<
n<<endl;
exit(0);}
488 if(bcount==
TB)
break;
493 if(uf!=0) nTestS=nTestS-1;
494 if(uf!=0) nTestB=nTestB-1;
497 cout<<
"TS "<<TS<<
" TB "<<
TB<<
" nTestS "<<nTestS<<
" nTestB "<<nTestB<<endl;
499 if(nTestB>nTestS) {nTestB=nTestS;
TB=nTestS; TS=nTestS;}
500 else {nTestS=nTestB;
TB=nTestB; TS=nTestB;}
503 if(nTestS<TS) TS= nTestS;
507 NNTree2->Branch(
"#TestSig",&TS,
"#TestSig/I");
509 cout<<
"nTestS: "<<nTestS<<
" TS: "<<TS<<endl;
510 cout<<
"dopo def tree"<<endl;
511 cout<<
"s test "<<
s<<
" s+TS "<<
s+TS<<
" b "<<b<<
" b+ TB "<<b+
TB<<
" nTestS "<<nTestS<<
" TB "<<
TB<<
" nTestB "<<nTestB<<endl;
514 for (
int i=0;
i<nINP;
i++) params[
i]=0.;
520 TString txt_originaldata(NOMEtot_S);
521 txt_originaldata.ReplaceAll(
".root",
"_originalData.txt");
523 char txt_originaldata_c[1024];
524 sprintf(txt_originaldata_c,
"txt_files/%s.txt",txt_originaldata.Data());
525 ofstream od_txt(txt_originaldata_c);
529 for(
int n=
s;
n<sig_entries;
n++) {
537 for(
int u=0;u<nNN;u++){
538 if (uf!=0&&
n>=NNs[u]&&
n<(NNs[u]+NNnTS[u])) { indNN=u;countNN=countNN+1;}
540 if (countNN>1){cout<<
"Error: training non independent";
exit(0);}
541 if(nNN==1){cout<<
"out==Averege:only 1NN is considered"<<endl;}
542 if(consider_all==0&&av_on_nNN==0&&countNN==0)
continue;
543 if(consider_all==0&&av_on_nNN!=0&&countNN!=0) {sigskip=sigskip+1;
continue; }
549 NNcc=(double)signal.
netcc[0];
550 NNrho=(
double)signal.
rho[1];
552 Mc_inj=(
double)signal.
chirp[0];
554 sprintf(TestFile,
"%s",TEST_FILE.Data());
560 for (
int i=0;
i<nINP;
i++){
567 ti_0+=(double)x[
i]*ti_i;
568 fi_0+=(double)x[
i]*fi_i;
569 sprintf(line_od2,
"%s %1.5f",line_od2, x[
i]);
571 sprintf(line_od2,
"%s \n",line_od2);
573 if (ti_0<fi_0) CoG=1;
578 for (
int u=0;u<nNN;u++) {
580 double output=mlp[u]->Evaluate(0,params);
590 for (
int u=0;u<nNN;u++){
591 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;}
594 average=average/(c_nNN0);
595 if((c_nNN0)!=1)std=pow((std/(nNN-1-countNN)-average*average),0.5);
599 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);
602 if (average<0.6) FD=FD+1;
607 cout<<
" cc "<<NNcc<<
" NNrho "<<NNrho<<
" Mc_inj "<< Mc_inj<<endl;
612 cout<<txt_originaldata_c<<endl;
615 cout<<
" S_eff "<<S_eff<<
" s "<<
s<<
" b "<<b<<
" sigskip "<<sigskip<<endl;
621 for(
int n=b;
n<sig_entries+bg_entries;
n++) {
629 for(
int u=0;u<nNN;u++){
630 cout<<
" uf "<<uf<<
" n "<<
n<<
" u "<<u<<
" NN b[u] "<<NNb[u]<<
" NNb[u]+NNnTB[u]"<<NNb[u]+NNnTB[u]<<endl;
631 if (uf!=0&&
n>=NNb[u]&&
n<(NNb[u]+NNnTB[u])) { indNN=u;countNN=countNN+1; }
633 if (countNN>1){cout<<
"Error: training non independent";
exit(0);}
634 if(nNN==1){cout<<
"out==Averege:only 1NN is considered"<<endl;}
635 cout<<
"consider_all "<<consider_all<<
" av_on_nNN "<<av_on_nNN<<
" countNN "<<countNN<<
" indNN "<<indNN<<endl;
636 if(consider_all==0&&av_on_nNN==0&&countNN==0)
continue;
637 if(consider_all==0&&av_on_nNN!=0&&countNN!=0) { cout<<
" n skipped "<<
n<<endl; bgskip=bgskip+1;
continue;}
639 cout<<
"BKG->n: "<<
n<<
"Bg index"<<(
n-sig_entries)<<endl;
642 NNcc=(double)background.
netcc[0];
644 NNrho=(
double)background.
rho[1];
646 Mc_inj=(
double)background.
chirp[0];
651 sprintf(TestFile,
"%s",TEST_FILE.Data());
653 for (
int i=0;
i<nINP;
i++){
659 ti_0+=(double)x[
i]*ti_i;
660 fi_0+=(double)x[
i]*fi_i;
663 if (ti_0<fi_0) CoG=1;
666 for(
int u=0;u<nNN;u++) {
667 double output=mlp[u]->Evaluate(0,params);
674 for (
int u=0;u<nNN;u++){
675 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;}}
679 average=average/(c_nNN0);
680 if((c_nNN0)!=1)std=pow((std/(nNN-1-countNN)-average*average),0.5);
683 if(nnsu==6) cont_su=cont_su+1;
684 if(nnsu>4) cont_su5=cont_su5+1;
685 if(nnsu>3) cont_su4=cont_su4+1;
686 if(nnsu>2) cont_su3=cont_su3+1;
692 if(average>0.6) FA=FA+1;
703 cout<<
"B_eff "<<B_eff<<
" TB "<<
TB<<endl;
713 for (
int yy=0;
yy<nNN;
yy++){
716 if(TotBg[
yy]!=0){freq_c[
yy]=(double)FA0[
yy]/TotBg[
yy];
719 if(freq_c[
yy]!=0) {meanf=freq_c[
yy]+meanf;cont=cont+1;
722 dev=freq_c[
yy]*freq_c[
yy]+dev;
725 if(cont==0) cout<<
"Error cont==0"<<endl;
726 if(cont!=0) meanf=meanf/cont;
728 for (
int yy=0;
yy<nNN;
yy++){
731 if(freq_c[
yy]!=0)dev+=(freq_c[
yy]-meanf)*(freq_c[
yy]-meanf);
733 double McFAdes=FAdes;
734 int FAth_n=FAdes*B_eff;
735 int McFAth_n=FAdes*B_eff;
736 cout<<
"FAth_n "<<FAth_n<<
" FAdes*B_eff "<<FAdes*B_eff<<endl;
749 if(cont!=0) dev=pow(dev/(cont-1),0.5);
750 cout<<
"meanf "<<meanf<<
" dev "<<dev<<endl;
751 cout<<
" FA average "<<FA<<endl;
752 cout<<
" cont_su "<<cont_su<<
" cont_su5 "<<cont_su5<<
" cont_su4 "<<cont_su4<<
" cont_su3 "<<cont_su3<<endl;
754 cout<<
" S_eff "<<S_eff<<
" B_eff "<<B_eff<<
" s "<<
s<<
" b "<<b<<
" bgskip "<<bgskip<<
" sigskip "<<sigskip<<endl;
755 cout<<
" FA0[1] "<<FA0[1]<<
" TotBg[1] "<<TotBg[1]<<endl;
756 cout<<
" FD0[1] "<<FD0[1]<<
" TotBg[1] "<<TotBg[1]<<endl;
758 double FDdes=(double)FDth_n/S_eff;
759 double McFDdes=(double)McFDth_n/S_eff;
760 FAdes=(double)FAth_n/B_eff;
761 McFAdes=(double)McFAth_n/B_eff;
762 cout<<
"FAth_n "<<FAth_n<<
" FAdes: "<<FAdes<<
" ANN_av_FDdes "<<FDdes<<
" ANN_av_FDth_n "<<FDth_n<<
" ANN_av_thresFA "<<thresFA<<endl;
763 cout<<
"McFAth_n "<<McFAth_n<<
" McFAdes: "<<McFAdes<<
" Mc_FDdes "<<McFDdes<<
" McFDth_n "<<McFDth_n<<
" McthresFA "<<McthresFA<<endl;
768 name.ReplaceAll(
"average_file/",
"");
769 TFile* fTEST =TFile::Open(ifile.Data());
770 TTree* NNTree2=(TTree*)fTEST->Get(
"Parameters");
775 NNTree2->SetBranchAddress(
"Average",&av);
776 NNTree2->SetBranchAddress(
"cc",&cc);
777 NNTree2->SetBranchAddress(
"rho",&rho);
778 NNTree2->SetBranchAddress(
"#TestSig",&nSi);
779 NNTree2->GetEntry(0);
781 cout<<
"nSig: "<<nSig<<
" nSi: "<<nSi<<endl;
782 cout<<
" BG: "<<NNTree2->GetEntries()-nSi<<endl;
784 cout<<
"dentro funzione dopodef"<<endl;
786 double* rhoSig[ncurve];
787 for (
int i=0;
i<ncurve;
i++) rhoSig[
i]=
new double[nSig];
788 cout<<
"dopo def rhoSig"<<endl;
792 int const nBg=NNTree2->GetEntries()-nSig;
793 for (
int i=0;
i<ncurve;
i++) {
795 for (
int j=0;
j<nSig;
j++) rhoSig[
i][
j]=0.;
797 cout<<
"dopo def rhoSig"<<endl;
798 double* rhoBg[ncurve];
799 for (
int i=0;
i<ncurve;
i++) rhoBg[
i]=
new double[nBg];
802 for (
int i=0;
i<ncurve;
i++) {
804 for (
int j=0;
j<nBg;
j++) rhoBg[
i][
j]=0.;
806 cout<<
"dopo def rhoBg"<<endl;
808 for (
int i=0;
i<
nCC;
i++) ccTh[
i]=0.;
810 for (
int i=0;
i<
nANN;
i++) NNTh[
i]=0.;
816 cout<<NNTree2->GetEntries()<<endl;
817 for(
int n=0;
n<NNTree2->GetEntries();
n++){
819 NNTree2->GetEntry(
n);
820 cout<<
"rho "<<rho<<
" cc "<<cc<<
" av "<<av<<endl;
823 if(cc<ccTh[
i])
continue;
825 if(
j==0) NNTh[
j]=-1000.;
831 if(av<NNTh[
j])
continue;
835 NBg[i*nANN+
j]= NBg[i*nANN+
j]+1;
836 while(rhoBg[i*nANN+j][ni]!=0)ni=ni+1;
837 rhoBg[i*nANN+
j][ni]=
rho;
842 NSig[i*nANN+
j]= NSig[i*nANN+
j]+1;
843 while(rhoSig[i*nANN+j][ni]!=0)ni=ni+1;
844 rhoSig[i*nANN+
j][ni]=
rho;
852 cout<<
"dopo riempimento variabili"<<endl;
854 for (
int i=0;
i<ncurve;
i++) indexS[
i]=
new int[nSig];
857 for (
int y=0;
y<ncurve;
y++) {
870 TMath::Sort(nSig,rhoSig[
y],indexS[y],
false);
872 for (
int k=0;
k<nSig;
k++) {
877 int ij=indexS[
y][
k-1];
879 if(rhoSig[y][ii]!=0) {
882 if(rhoSig[y][ii]!=rhoSig[y][ij]) gS[
y]->SetPoint(igS_p++,rhoSig[y][ii],yy);
883 cout<<
"igS"<<igS<<
" x "<<rhoSig[
y][ii]<<
" y: "<<yy<<endl;
888 if(rhoSig[y][ii]!=0){
890 gS[
y]->SetPoint(0,rhoSig[y][ii],yy);
901 for (
int i=0;
i<ncurve;
i++) indexB[
i]=
new int[nBg];
904 for (
int y=0;
y<ncurve;
y++) {
908 TMath::Sort(nBg,rhoBg[
y],indexB[y],
false);
910 for (
int k=0;
k<nBg;
k++) {
914 int ij=indexB[
y][
k-1];
916 if(rhoBg[y][ii]!=0) {
919 if(rhoBg[y][ii]!=rhoBg[y][ij]) gB[
y]->SetPoint(igB_p++,rhoBg[y][ii],yy);
925 if(rhoBg[y][ii]!=0) {
927 gB[
y]->SetPoint(0,rhoBg[y][ii],yy);
934 cout<<
"dopo inserimento puntiB"<<endl;
937 TCanvas* cS=
new TCanvas(
"Efficiency_vs_rho",
"Efficiency_vs_rho",0,0,1200,700);
941 TMultiGraph* mg1=
new TMultiGraph();
943 gS[0]->SetMarkerColor(2);
944 gS[0]->SetLineColor(2);
945 mg1->SetTitle(
"cc=0.5;rho;#Events");
946 if(gS[0]->GetN()!=0) mg1->Add(gS[0]);
949 gS[
h]->SetMarkerColor(3);
950 gS[
h]->SetLineColor(3);
952 if(gS[
h]->GetN()!=0) mg1->Add(gS[
h]);
958 TMultiGraph* mg2=
new TMultiGraph();
960 gS[
nANN]->SetMarkerColor(2);
961 gS[
nANN]->SetLineColor(2);
962 mg2->SetTitle(
"cc=0.55;rho;#Events");
963 if(gS[nANN]->GetN()!=0) mg2->Add(gS[nANN]);
965 gS[nANN+
h]->SetMarkerColor(3);
966 gS[nANN+
h]->SetLineColor(3);
968 if(gS[nANN+
h]->GetN()!=0) mg2->Add(gS[nANN+
h]);
974 TMultiGraph* mg3=
new TMultiGraph();
976 gS[nANN*2]->SetMarkerColor(2);
977 gS[nANN*2]->SetLineColor(2);
978 mg3->SetTitle(
"cc=0.6;rho;#Events");
979 if(gS[nANN*2]->GetN()!=0) mg3->Add(gS[nANN*2]);
981 gS[2*nANN+
h]->SetMarkerColor(3);
982 gS[2*nANN+
h]->SetLineColor(3);
984 if(gS[2*nANN+
h]->GetN()!=0) mg3->Add(gS[2*nANN+
h]);
990 TMultiGraph* mg4=
new TMultiGraph();
992 gS[nANN*3]->SetMarkerColor(2);
993 gS[nANN*3]->SetLineColor(2);
994 mg4->SetTitle(
"cc=0.65;rho;#Events");
995 if(gS[nANN*3]->GetN()!=0) mg4->Add(gS[nANN*3]);
998 gS[3*nANN+
h]->SetMarkerColor(3);
999 gS[3*nANN+
h]->SetLineColor(3);
1001 if(gS[3*nANN+
h]->GetN()!=0) mg4->Add(gS[3*nANN+
h]);
1005 cout<<
"nuovo canv"<<endl;
1006 TCanvas* cB=
new TCanvas(
"Number_vs_rho",
"Number_vs_rho",0,0,1200,700);
1008 cB->cd(1)->SetLogy();
1009 TMultiGraph* mg1B=
new TMultiGraph();
1011 gB[0]->SetMarkerColor(2);
1012 gB[0]->SetLineColor(2);
1013 mg1B->SetTitle(
"cc=0.5;rho;#Events");
1014 if(gB[0]->GetN()!=0) mg1B->Add(gB[0]);
1016 gB[
h]->SetMarkerColor(3);
1017 gB[
h]->SetLineColor(3);
1019 if(gB[
h]->GetN()!=0) mg1B->Add(gB[
h]);
1023 cB->cd(2)->SetLogy();
1024 TMultiGraph* mg2B=
new TMultiGraph();
1026 gB[
nANN]->SetMarkerColor(2);
1027 gB[
nANN]->SetLineColor(2);
1028 mg2B->SetTitle(
"cc=0.55;rho;#Events");
1029 if(gB[nANN]->GetN()!=0) mg2B->Add(gB[nANN]);
1031 gB[nANN+
h]->SetMarkerColor(3);
1032 gB[nANN+
h]->SetLineColor(3);
1034 if(gB[nANN+
h]->GetN()!=0) mg2B->Add(gB[nANN+
h]);
1038 cB->cd(3)->SetLogy();
1039 TMultiGraph* mg3B=
new TMultiGraph();
1041 gB[2*
nANN]->SetMarkerColor(2);
1042 gB[2*
nANN]->SetLineColor(2);
1043 mg3B->SetTitle(
"cc=0.6;rho;#Events");
1044 if(gB[2*nANN]->GetN()!=0) mg3B->Add(gB[2*nANN]);
1046 gB[2*nANN+
h]->SetMarkerColor(3);
1047 gB[2*nANN+
h]->SetLineColor(3);
1049 if(gB[2*nANN+
h]->GetN()!=0) mg3B->Add(gB[2*nANN+
h]);
1053 cB->cd(4)->SetLogy();
1054 TMultiGraph* mg4B=
new TMultiGraph();
1056 gB[3*
nANN]->SetMarkerColor(2);
1057 gB[3*
nANN]->SetLineColor(2);
1058 mg4B->SetTitle(
"cc=0.65;rho;#Events");
1059 if(gB[3*nANN]->GetN()!=0) mg4B->Add(gB[3*nANN]);
1061 gB[3*nANN+
h]->SetMarkerColor(3);
1062 gB[3*nANN+
h]->SetLineColor(3);
1064 if(gB[3*nANN+
h]->GetN()!=0) mg4B->Add(gB[3*nANN+
h]);
1076 char CnameS2root[1024];
1077 char CnameB2root[1024];
1078 CnameS.ReplaceAll(
".root",
".png");
1079 CnameB.ReplaceAll(
".root",
".png");
1080 sprintf(CnameS2,
"logN_rho_av/logN_rho_S_dANN%1.2f_%s",
deltaANN,CnameS.Data());
1081 sprintf(CnameB2,
"logN_rho_av/logN_rho_B_dANN%1.2f_%s",
deltaANN,CnameB.Data());
1082 sprintf(CnameS2root,
"logN_rho_av/logN_rho_S_dANN%1.2f_%s",
deltaANN,CnameSroot.Data());
1083 sprintf(CnameB2root,
"logN_rho_av/logN_rho_B_dANN%1.2f_%s",
deltaANN,CnameBroot.Data());
1084 cS->SaveAs(CnameS2);
1085 cB->SaveAs(CnameB2);
1086 cS->Print(CnameS2root);
1087 cB->Print(CnameB2root);
1095 name.ReplaceAll(
"average_file/",
"");
1096 TFile* fTEST =TFile::Open(ifile.Data());
1097 TTree* NNTree2=(TTree*)fTEST->Get(
"Parameters");
1102 NNTree2->SetBranchAddress(
"Average",&av);
1103 NNTree2->SetBranchAddress(
"cc",&cc);
1104 NNTree2->SetBranchAddress(
"rho",&rho);
1105 NNTree2->SetBranchAddress(
"#TestSig",&nSi);
1106 NNTree2->GetEntry(0);
1108 cout<<
"nSig: "<<nSig<<
" nSi: "<<nSi<<endl;
1112 double* ANNSig[ncurve2];
1113 for (
int i=0;
i<ncurve2;
i++) ANNSig[
i]=
new double[nSig];
1117 int const nBg=NNTree2->GetEntries()-nSig;
1118 for (
int i=0;
i<ncurve2;
i++) {
1120 for (
int j=0;
j<nSig;
j++) ANNSig[
i][
j]=0.;
1122 double* ANNBg[ncurve2];
1123 for (
int i=0;
i<ncurve2;
i++) ANNBg[
i]=
new double[nBg];
1127 for (
int i=0;
i<ncurve2;
i++) {
1129 for (
int j=0;
j<nBg;
j++) ANNBg[
i][
j]=0.;
1132 for (
int i=0;
i<
nCC;
i++) ccTh[
i]=0.;
1134 for (
int i=0;
i<
nRHO;
i++) rhoTh[
i]=0.;
1141 for(
int n=0;
n<NNTree2->GetEntries();
n++){
1142 NNTree2->GetEntry(
n);
1143 cout<<
"rho "<<rho<<
" cc "<<cc<<
" av "<<av<<endl;
1147 if(cc<ccTh[
i])
continue;
1151 if(rho<rhoTh[
j])
continue;
1154 NBg[i*nRHO+
j]= NBg[i*nRHO+
j]+1;
1155 if(i*nRHO+j==0) cout<<
" NBg[i*nRHO+j] "<<NBg[i*nRHO+
j]<<endl;
1156 while(ANNBg[i*nRHO+j][ni]!=0)ni=ni+1;
1157 ANNBg[i*nRHO+
j][ni]=av;
1162 NSig[i*nRHO+
j]= NSig[i*nRHO+
j]+1;
1163 if(i*nRHO+j==0) cout<<
" NSig[i*nRHO+j] "<<NSig[i*nRHO+
j]<<endl;
1164 while(ANNSig[i*nRHO+j][ni]!=0)ni=ni+1;
1165 ANNSig[i*nRHO+
j][ni]=av;
1171 int* indexS[ncurve2];
1172 for (
int i=0;
i<ncurve2;
i++) indexS[
i]=
new int[nSig];
1174 TGraph * gS[ncurve2];
1175 for (
int y=0;
y<ncurve2;
y++) {
1179 TMath::Sort(nSig,ANNSig[
y],indexS[y],
false);
1180 for (
int k=0;
k<nSig;
k++) {
1181 int ii=indexS[
y][
k];
1185 int ij=indexS[
y][
k-1];
1187 if(ANNSig[y][ii]!=0) {
1190 if(ANNSig[y][ii]!=ANNSig[y][ij]) gS[
y]->SetPoint(igS_p++,ANNSig[y][ii],yy);
1197 if(ANNSig[y][ii]!=0){
1199 gS[
y]->SetPoint(0,ANNSig[y][ii],yy);
1210 int* indexB[ncurve2];
1211 for (
int i=0;
i<ncurve2;
i++) indexB[
i]=
new int[nBg];
1213 TGraph * gB[ncurve2];
1214 for (
int y=0;
y<ncurve2;
y++) {
1218 TMath::Sort(nBg,ANNBg[
y],indexB[y],
false);
1220 for (
int k=0;
k<nBg;
k++) {
1221 int ii=indexB[
y][
k];
1222 int ik=indexB[
y][
k-1];
1225 int ij=indexB[
y][
k-1];
1227 if(ANNBg[y][ii]!=0) {
1229 if(y==0 && yy==FAth_n+1) {thresFA=ANNBg[
y][ii];}
1230 if (y==0 && yy<FAth_n+1)
if(ANNBg[y][ii]==ANNBg[y][ik]){FAth_n=FAth_n-1;}
1231 if(y==0) cout<<
"yy "<<yy<<
" y "<<y<<
" FAth_n "<<FAth_n<<
" thresFA "<<thresFA<<
" ANNBg[y][ii] "<<ANNBg[
y][ii]<<endl;
1233 if(ANNBg[y][ii]!=ANNBg[y][ij]) gB[
y]->SetPoint(igB_p++,ANNBg[y][ii],yy);
1239 if(ANNBg[y][ii]!=0) {
1241 gB[
y]->SetPoint(0,ANNBg[y][ii],yy);
1252 for(
int ni=1;ni<nSig;ni++){
1253 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;
1255 if (ANNSig[0][indexS[0][ni]]<=thresFA) FDth_n=FDth_n+1;
1260 TCanvas* cS=
new TCanvas(
"Efficiency_vs_ANN",
"Efficiency_vs_ANN",0,0,1200,700);
1264 TMultiGraph* mg1=
new TMultiGraph();
1265 mg1->SetTitle(
"cc: no_cut;ANN;#Events");
1267 gS[
h]->SetLineColor(4);
1268 if(gS[
h]->GetN()!=0) mg1->Add(gS[
h]);
1273 TMultiGraph* mg2=
new TMultiGraph();
1274 mg2->SetTitle(
"cc=0.55;ANN;#Events");
1276 gS[nRHO+
h]->SetLineColor(4);
1277 if(gS[nRHO+
h]->GetN()!=0) mg2->Add(gS[nRHO+
h]);
1283 TMultiGraph* mg3=
new TMultiGraph();
1284 mg3->SetTitle(
"cc=0.6;ANN;#Events");
1286 gS[2*nRHO+
h]->SetLineColor(4);
1287 if(gS[2*nRHO+
h]->GetN()!=0) mg3->Add(gS[2*nRHO+
h]);
1292 TMultiGraph* mg4=
new TMultiGraph();
1293 mg4->SetTitle(
"cc=0.65;ANN;#Events");
1295 gS[3*nRHO+
h]->SetLineColor(4);
1296 if(gS[3*nRHO+
h]->GetN()!=0) mg4->Add(gS[3*nRHO+
h]);
1300 TCanvas* cB=
new TCanvas(
"Number_vs_ANN",
"Number_vs_ANN",0,0,1200,700);
1302 cB->cd(1)->SetLogy();
1303 TMultiGraph* mg1B=
new TMultiGraph();
1304 mg1B->SetTitle(
"cc: no_cut;ANN;#Events");
1306 gB[
h]->SetLineColor(4);
1307 if(gB[
h]->GetN()!=0) mg1B->Add(gB[
h]);
1310 cB->cd(2)->SetLogy();
1311 TMultiGraph* mg2B=
new TMultiGraph();
1312 mg2B->SetTitle(
"cc=0.55;ANN;#Events");
1314 gB[nRHO+
h]->SetLineColor(4);
1315 if(gB[nRHO+
h]->GetN()!=0) mg2B->Add(gB[nRHO+
h]);
1318 cB->cd(3)->SetLogy();
1319 TMultiGraph* mg3B=
new TMultiGraph();
1320 mg3B->SetTitle(
"cc=0.6;ANN;#Events");
1322 gB[2*nRHO+
h]->SetLineColor(4);
1323 if(gB[2*nRHO+
h]->GetN()!=0) mg3B->Add(gB[2*nRHO+
h]);
1326 cB->cd(4)->SetLogy();
1327 TMultiGraph* mg4B=
new TMultiGraph();
1328 mg4B->SetTitle(
"cc=0.65;ANN;#Events");
1330 gB[3*nRHO+
h]->SetLineColor(4);
1331 if(gB[3*nRHO+
h]->GetN()!=0) mg4B->Add(gB[3*nRHO+
h]);
1343 char CnameS2root[1024];
1344 char CnameB2root[1024];
1345 CnameS.ReplaceAll(
".root",
".png");
1346 CnameB.ReplaceAll(
".root",
".png");
1347 sprintf(CnameS2,
"ANNthres_av/N_ANN_S_%s",CnameS.Data());
1348 sprintf(CnameB2,
"ANNthres_av/N_ANN_B_%s",CnameB.Data());
1349 sprintf(CnameS2root,
"ANNthres_av/N_ANN_S_%s",CnameSroot.Data());
1350 sprintf(CnameB2root,
"ANNthres_av/N_ANN_B_%s",CnameBroot.Data());
1351 cS->SaveAs(CnameS2);
1352 cB->SaveAs(CnameB2);
1353 cS->Print(CnameS2root);
1354 cB->Print(CnameB2root);
1365 name.ReplaceAll(
"outfile/",
"");
1366 name.ReplaceAll(
"average_file/",
"");
1367 TFile* fTEST =TFile::Open(ifile.Data());
1368 TTree* NNTree2=(TTree*)fTEST->Get(
"Parameters");
1378 NNTree2->SetBranchAddress(
"Mchirp",&Mc);
1379 NNTree2->SetBranchAddress(
"Average",&av);
1380 NNTree2->SetBranchAddress(
"cc",&cc);
1381 NNTree2->SetBranchAddress(
"rho",&rho);
1382 NNTree2->SetBranchAddress(
"Mchirp_injected",&Mc_inj);
1383 NNTree2->SetBranchAddress(
"#TestSig",&nSi);
1384 NNTree2->GetEntry(0);
1386 cout<<
"nSig: "<<nSig<<
" nSi: "<<nSi<<endl;
1389 double* McSig[ncurve2];
1390 for (
int i=0;
i<ncurve2;
i++) McSig[
i]=
new double[nSig];
1394 int const nBg=NNTree2->GetEntries()-nSig;
1395 for (
int i=0;
i<ncurve2;
i++) {
1397 for (
int j=0;
j<nSig;
j++) McSig[
i][
j]=0.;
1399 double* McBg[ncurve2];
1400 for (
int i=0;
i<ncurve2;
i++) McBg[
i]=
new double[nBg];
1404 for (
int i=0;
i<ncurve2;
i++) {
1406 for (
int j=0;
j<nBg;
j++) McBg[
i][
j]=0.;
1409 for (
int i=0;
i<
nCC;
i++) ccTh[
i]=0.;
1411 for (
int i=0;
i<
nRHO;
i++) rhoTh[
i]=0.;
1417 for(
int n=0;
n<NNTree2->GetEntries();
n++){
1418 NNTree2->GetEntry(
n);
1419 cout<<
"rho "<<rho<<
" cc "<<cc<<
" av "<<av<<endl;
1423 if(cc<ccTh[
i])
continue;
1427 if(rho<rhoTh[
j])
continue;
1430 NBg[i*nRHO+
j]= NBg[i*nRHO+
j]+1;
1431 if(i*nRHO+j==0) cout<<
" NBg[i*nRHO+j] "<<NBg[i*nRHO+
j]<<endl;
1432 while(McBg[i*nRHO+j][ni]!=0)ni=ni+1;
1433 McBg[i*nRHO+
j][ni]=Mc;
1438 NSig[i*nRHO+
j]= NSig[i*nRHO+
j]+1;
1439 if(i*nRHO+j==0) cout<<
" NSig[i*nRHO+j] "<<NSig[i*nRHO+
j]<<endl;
1440 while(McSig[i*nRHO+j][ni]!=0)ni=ni+1;
1441 McSig[i*nRHO+
j][ni]=Mc;
1448 int* indexS[ncurve2];
1449 for (
int i=0;
i<ncurve2;
i++) indexS[
i]=
new int[nSig];
1451 TGraph * gS[ncurve2];
1452 for (
int y=0;
y<ncurve2;
y++) {
1456 TMath::Sort(nSig,McSig[
y],indexS[y],
false);
1457 for (
int k=0;
k<nSig;
k++) {
1458 int ii=indexS[
y][
k];
1462 int ij=indexS[
y][
k-1];
1464 if(McSig[y][ii]!=0) {
1467 if(McSig[y][ii]!=McSig[y][ij]) gS[
y]->SetPoint(igS_p++,McSig[y][ii],yy);
1474 if(McSig[y][ii]!=0){
1476 gS[
y]->SetPoint(0,McSig[y][ii],yy);
1486 int* indexB[ncurve2];
1487 for (
int i=0;
i<ncurve2;
i++) indexB[
i]=
new int[nBg];
1489 TGraph * gB[ncurve2];
1490 for (
int y=0;
y<ncurve2;
y++) {
1494 TMath::Sort(nBg,McBg[
y],indexB[y],
false);
1496 for (
int k=0;
k<nBg;
k++) {
1497 int ii=indexB[
y][
k];
1498 int ik=indexB[
y][
k-1];
1501 int ij=indexB[
y][
k-1];
1503 if(McBg[y][ii]!=0) {
1505 if(y==0 && yy==McFAth_n+1) {McthresFA=McBg[
y][ii];
1507 if (y==0 && yy<McFAth_n+1) { cout<<
"dentro primo if"<<endl;
1509 if(McBg[y][ii]>McBg[y][ik]){McFAth_n=McFAth_n;cout<<
"maggiore ii "<<
" diff"<<(McBg[
y][ii]-McBg[
y][ik])<<endl;}
1510 if(McBg[y][ii]<McBg[y][ik]){McFAth_n=McFAth_n;cout<<
"minore ii"<<endl;}
1511 if(McBg[y][ii]==McBg[y][ik]){McFAth_n=McFAth_n-1;cout<<
"uguale"<<endl;}
1514 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;
1516 if(McBg[y][ii]!=McBg[y][ij]) gB[
y]->SetPoint(igB_p++,McBg[y][ii],yy);
1522 if(McBg[y][ii]!=0) {
1524 gB[
y]->SetPoint(0,McBg[y][ii],yy);
1533 for(
int ni=1;ni<nSig;ni++){
1534 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;
1536 if (McSig[0][indexS[0][ni]]<=McthresFA) McFDth_n=McFDth_n+1;
1540 TCanvas* cS=
new TCanvas(
"Efficiency_vs_Mchirp",
"Efficiency_vs_Mchirp",0,0,1200,700);
1544 TMultiGraph* mg1=
new TMultiGraph();
1545 mg1->SetTitle(
"cc: no_cut;Mchirp;#Events");
1547 gS[
h]->SetLineColor(4);
1548 if(gS[
h]->GetN()!=0) mg1->Add(gS[
h]);
1553 TMultiGraph* mg2=
new TMultiGraph();
1554 mg2->SetTitle(
"cc=0.55;Mchirp;#Events");
1556 gS[nRHO+
h]->SetLineColor(4);
1557 if(gS[nRHO+
h]->GetN()!=0) mg2->Add(gS[nRHO+
h]);
1563 TMultiGraph* mg3=
new TMultiGraph();
1564 mg3->SetTitle(
"cc=0.6;Mchirp;#Events");
1566 gS[2*nRHO+
h]->SetLineColor(4);
1567 if(gS[2*nRHO+
h]->GetN()!=0) mg3->Add(gS[2*nRHO+
h]);
1572 TMultiGraph* mg4=
new TMultiGraph();
1573 mg4->SetTitle(
"cc=0.65;Mchirp;#Events");
1575 gS[3*nRHO+
h]->SetLineColor(4);
1576 if(gS[3*nRHO+
h]->GetN()!=0) mg4->Add(gS[3*nRHO+
h]);
1580 TCanvas* cB=
new TCanvas(
"Number_vs_Mchirp",
"Number_vs_Mchirp",0,0,1200,700);
1582 cB->cd(1)->SetLogy();
1583 TMultiGraph* mg1B=
new TMultiGraph();
1584 mg1B->SetTitle(
"cc: no_cut;Mchirp;#Events");
1586 gB[
h]->SetLineColor(4);
1587 if(gB[
h]->GetN()!=0) mg1B->Add(gB[
h]);
1590 cB->cd(2)->SetLogy();
1591 TMultiGraph* mg2B=
new TMultiGraph();
1592 mg2B->SetTitle(
"cc=0.55;Mchirp;#Events");
1594 gB[nRHO+
h]->SetLineColor(4);
1595 if(gB[nRHO+
h]->GetN()!=0) mg2B->Add(gB[nRHO+
h]);
1598 cB->cd(3)->SetLogy();
1599 TMultiGraph* mg3B=
new TMultiGraph();
1600 mg3B->SetTitle(
"cc=0.6;Mchirp;#Events");
1602 gB[2*nRHO+
h]->SetLineColor(4);
1603 if(gB[2*nRHO+
h]->GetN()!=0) mg3B->Add(gB[2*nRHO+
h]);
1606 cB->cd(4)->SetLogy();
1607 TMultiGraph* mg4B=
new TMultiGraph();
1608 mg4B->SetTitle(
"cc=0.6;Mchirp;#Events");
1610 gB[3*nRHO+
h]->SetLineColor(4);
1611 if(gB[3*nRHO+
h]->GetN()!=0) mg4B->Add(gB[3*nRHO+
h]);
1622 char CnameS2root[1024];
1623 char CnameB2root[1024];
1624 CnameS.ReplaceAll(
".root",
".png");
1625 CnameB.ReplaceAll(
".root",
".png");
1626 sprintf(CnameS2,
"Mcthres/N_Mc_S_%s",CnameS.Data());
1627 sprintf(CnameB2,
"Mcthres/N_Mc_B_%s",CnameB.Data());
1628 sprintf(CnameS2root,
"Mcthres/N_Mc_S_%s",CnameSroot.Data());
1629 sprintf(CnameB2root,
"Mcthres/N_Mc_B_%s",CnameBroot.Data());
1630 cS->SaveAs(CnameS2);
1631 cB->SaveAs(CnameB2);
1632 cS->Print(CnameS2root);
1633 cB->Print(CnameB2root);
1640 name.ReplaceAll(
"outfile/",
"");
1641 name.ReplaceAll(
"average_file/",
"");
1642 TFile* fTEST =TFile::Open(ifile.Data());
1643 TTree* NNTree2=(TTree*)fTEST->Get(
"Parameters");
1651 NNTree2->SetBranchAddress(
"Average",&av);
1652 NNTree2->SetBranchAddress(
"cc",&cc);
1653 NNTree2->SetBranchAddress(
"rho",&rho);
1654 NNTree2->SetBranchAddress(
"#TestSig",&nSi);
1655 NNTree2->GetEntry(0);
1657 cout<<
"nSig: "<<nSig<<
" nSi: "<<nSi<<endl;
1658 int const nBg=NNTree2->GetEntries()-nSig;
1659 cout<<
"nBg: "<<nBg<<
" Entries: "<<NNTree2->GetEntries()<<endl;
1666 for (
int n = 0;
n <NNTree2->GetEntries();
n++){
1667 NNTree2->GetEntry(
n);
1669 gS[0]->SetPoint(
n,cc,av);
1670 cout<<
"Sig_graph1: x="<<cc<<
" y: "<<av<<endl;
1673 gB[0]->SetPoint(
n-nSig,cc,av);
1674 cout<<
"Bg_graph1: x="<<cc<<
" y: "<<av<<endl;
1695 gS[0]->SetMarkerColor(2);
1696 gB[0]->SetMarkerColor(4);
1697 gS[0]->SetMarkerStyle(6);
1698 gB[0]->SetMarkerStyle(7);
1700 TCanvas*
c=
new TCanvas(
"Plots",
"Plots",0,0,1200,700);
1703 TMultiGraph* mg1=
new TMultiGraph();
1704 mg1->SetTitle(
"Av_cc");
1705 if(gB[0]->GetN()!=0) mg1->Add(gB[0]);
1706 if(gS[0]->GetN()!=0) mg1->Add(gS[0]);
1708 mg1->GetHistogram()->GetXaxis()->SetTitle(
"cc");
1709 mg1->GetHistogram()->GetYaxis()->SetTitle(
"Average on ANN ouputs");
1712 TMultiGraph* mg2=
new TMultiGraph();
1713 mg2->SetTitle(
"Av_cc");
1714 if(gS[0]->GetN()!=0) mg2->Add(gS[0]);
1715 if(gB[0]->GetN()!=0) mg2->Add(gB[0]);
1717 mg2->GetHistogram()->GetXaxis()->SetTitle(
"cc");
1718 mg2->GetHistogram()->GetYaxis()->SetTitle(
"Average on ANN ouputs");
1720 cout<<
" name "<<name<<endl;
1724 char Cname2root[1024];
1725 Cname.ReplaceAll(
".root",
".png");
1726 sprintf(Cname2,
"average_png/out_Plots_%s",Cname.Data());
1727 sprintf(Cname2root,
"average_png/out_Plots_%s",Cnameroot.Data());
1729 c->Print(Cname2root);
1767 name.ReplaceAll(
"outfile/",
"");
1768 name.ReplaceAll(
"average_file/",
"");
1769 TFile* fTEST =TFile::Open(ifile.Data());
1770 TTree* NNTree2=(TTree*)fTEST->Get(
"Parameters");
1780 NNTree2->SetBranchAddress(
"Mchirp",&Mc);
1781 NNTree2->SetBranchAddress(
"Average",&av);
1782 NNTree2->SetBranchAddress(
"cc",&cc);
1783 NNTree2->SetBranchAddress(
"rho",&rho);
1784 NNTree2->SetBranchAddress(
"Mchirp_injected",&Mc_inj);
1785 NNTree2->SetBranchAddress(
"#TestSig",&nSi);
1786 NNTree2->GetEntry(0);
1788 cout<<
"nSig: "<<nSig<<
" nSi: "<<nSi<<endl;
1790 int const nBg=NNTree2->GetEntries()-nSig;
1798 TCanvas* ANN_Mc_c3D=
new TCanvas(
"ANN_average_vs_Mc_reconstructed",
"ANN_average_vs_Mc_reconstructed",0,0,1200,700);
1799 ANN_Mc_c3D->Divide(1,2);
1803 ANN_Mc_BKG3D->SetDirectory(0);
1804 ANN_Mc_BKG3D->SetStats(0);
1805 ANN_Mc_SIG3D->SetDirectory(0);
1806 ANN_Mc_SIG3D->SetStats(0);
1808 TCanvas* ANN_cc_c3D=
new TCanvas(
"ANN_average_vs_cc",
"ANN_average_vs_cc",0,0,1200,700);
1809 ANN_cc_c3D->Divide(1,2);
1812 ANN_cc_SIG3D->SetDirectory(0);
1813 ANN_cc_SIG3D->SetStats(0);
1814 ANN_cc_BKG3D->SetDirectory(0);
1815 ANN_cc_BKG3D->SetStats(0);
1820 TCanvas* Mc_inj_c=
new TCanvas(
"ANN_vs_Mc_injected",
"ANN_vs_Mc_injected",0,0,1200,700);
1821 Mc_inj_c->Divide(1,2);
1825 Mc_inj_gMc->SetDirectory(0);
1826 Mc_inj_gMc->SetStats(0);
1827 Mc_inj_g->SetDirectory(0);
1828 Mc_inj_g->SetStats(0);
1829 double deltaMc_inj=0;
1831 double deltaANN_av_M=0;
1838 txt_name0.ReplaceAll(
".root",
".txt");
1839 char txt_name[1024];
1840 sprintf(txt_name,
"txt_files/%s",txt_name0.Data());
1841 ofstream file_txt_out(txt_name);
1847 for (
int n = 0;
n <NNTree2->GetEntries();
n++){
1848 NNTree2->GetEntry(
n);
1850 if(
n<nSig&&
n!=nSig) {
1851 Mc_inj_gMc->Fill(Mc_inj,Mc);
1852 Mc_inj_g->Fill(Mc_inj,av);
1853 gS[0]->SetPoint(
n,Mc,av);
1854 cout<<
" n "<<
n<<
" Mc "<<Mc<<
" av "<<av<<
" M_inj "<<Mc_inj<<endl;
1855 cout<<
"Sig_graph1: x="<<cc<<
" y: "<<av<<endl;
1857 ANN_Mc_SIG3D->Fill(Mc,av);
1858 ANN_cc_SIG3D->Fill(cc,av);
1859 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);
1861 cout<<
" n "<<
n<<
" nSig "<<nSig<<endl;
1865 gB[0]->SetPoint(
n-nSig,Mc,av);
1866 ANN_Mc_BKG3D->Fill(Mc,av);
1867 ANN_cc_BKG3D->Fill(cc,av);
1869 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);
1877 gS[0]->SetMarkerColor(2);
1878 gB[0]->SetMarkerColor(4);
1879 gS[0]->SetMarkerStyle(6);
1880 gB[0]->SetMarkerStyle(7);
1883 ANN_Mc_SIG3D->GetXaxis()->SetTitle(
"SIG:Mchirp_reconstructed");
1884 ANN_Mc_SIG3D->GetYaxis()->SetTitle(
"SIG:ANN_average");
1885 ANN_Mc_SIG3D->GetZaxis()->SetTitle(
"count");
1886 ANN_Mc_SIG3D->Draw(
"colz");
1888 ANN_Mc_BKG3D->GetXaxis()->SetTitle(
"BKG:Mchirp_reconstructed");
1889 ANN_Mc_BKG3D->GetYaxis()->SetTitle(
"BKG:ANN_average");
1890 ANN_Mc_BKG3D->GetZaxis()->SetTitle(
"count");
1891 ANN_Mc_BKG3D->Draw(
"colz");
1895 TString ANN_Mc_rootname3D(name);
1896 char ANN_Mc_cname23D[1024];
1897 char ANN_Mc_crootname23D[1024];
1898 ANN_Mc_name3D.ReplaceAll(
".root",
".png");
1899 sprintf(ANN_Mc_cname23D,
"average_png/nSig%i_nBg%i_3DMc_ANNav_Plots_%s",nSig,nBg,ANN_Mc_name3D.Data());
1900 sprintf(ANN_Mc_crootname23D,
"average_png/nSig%i_nBg%i_3DMc_ANNav_Plots_%s",nSig,nBg,ANN_Mc_rootname3D.Data());
1901 ANN_Mc_c3D->SaveAs(ANN_Mc_cname23D);
1902 ANN_Mc_c3D->Print(ANN_Mc_crootname23D);
1906 ANN_cc_SIG3D->GetXaxis()->SetTitle(
"SIG:cc");
1907 ANN_cc_SIG3D->GetYaxis()->SetTitle(
"SIG:ANN_average");
1908 ANN_cc_SIG3D->GetZaxis()->SetTitle(
"count");
1909 ANN_cc_SIG3D->Draw(
"colz");
1911 ANN_cc_BKG3D->GetXaxis()->SetTitle(
"BKG:cc");
1912 ANN_cc_BKG3D->GetYaxis()->SetTitle(
"BKG:ANN_average");
1913 ANN_cc_BKG3D->GetZaxis()->SetTitle(
"count");
1914 ANN_cc_BKG3D->Draw(
"colz");
1918 TString ANN_cc_crootname3D(name);
1919 char ANN_cc_cname23D[1024];
1920 char ANN_cc_crootname23D[1024];
1921 ANN_cc_cname3D.ReplaceAll(
".root",
".png");
1922 sprintf(ANN_cc_cname23D,
"average_png/nSig%i_nBg%i_3DANNav_cc_Plots_%s",nSig,nBg,ANN_cc_cname3D.Data());
1923 sprintf(ANN_cc_crootname23D,
"average_png/nSig%i_nBg%i_3DANNav_cc_Plots_%s",nSig,nBg,ANN_cc_crootname3D.Data());
1924 ANN_cc_c3D->SaveAs(ANN_cc_cname23D);
1925 ANN_cc_c3D->Print(ANN_cc_crootname23D);
1928 Mc_inj_g->GetXaxis()->SetTitle(
"Mchirp_injected");
1929 Mc_inj_g->GetYaxis()->SetTitle(
"ANN_average");
1930 Mc_inj_g->GetZaxis()->SetTitle(
"count");
1931 Mc_inj_g->Draw(
"colz");
1933 Mc_inj_gMc->GetXaxis()->SetTitle(
"Mchirp_injected");
1934 Mc_inj_gMc->GetYaxis()->SetTitle(
"Mchirp_reconstructed");
1935 Mc_inj_gMc->GetZaxis()->SetTitle(
"count");
1936 Mc_inj_gMc->Draw(
"colz");
1940 TString Mc_inj_crootname(name);
1941 char Mc_inj_cname2[1024];
1942 char Mc_inj_crootname2[1024];
1943 Mc_inj_cname.ReplaceAll(
".root",
".png");
1944 sprintf(Mc_inj_cname2,
"average_png/nSig%i_nBg%i_Mc_inj_Plots_%s",nSig,nBg,Mc_inj_cname.Data());
1945 sprintf(Mc_inj_crootname2,
"average_png/nSig%i_nBg%i_Mc_inj_Plots_%s",nSig,nBg,Mc_inj_crootname.Data());
1946 Mc_inj_c->SaveAs(Mc_inj_cname2);
1947 Mc_inj_c->Print(Mc_inj_crootname2);
1950 TCanvas*
c=
new TCanvas(
"Plots",
"Plots",0,0,1200,700);
1953 TMultiGraph* mg1=
new TMultiGraph();
1954 mg1->SetTitle(
"Av_Mc");
1955 if(gB[0]->GetN()!=0) mg1->Add(gB[0]);
1956 if(gS[0]->GetN()!=0) mg1->Add(gS[0]);
1958 mg1->GetHistogram()->GetXaxis()->SetTitle(
"Mchirp");
1959 mg1->GetHistogram()->GetYaxis()->SetTitle(
"Average on ANN ouputs");
1961 TMultiGraph* mg2=
new TMultiGraph();
1962 mg2->SetTitle(
"Av_Mc");
1963 if(gS[0]->GetN()!=0) mg2->Add(gS[0]);
1964 if(gB[0]->GetN()!=0) mg2->Add(gB[0]);
1966 mg2->GetHistogram()->GetXaxis()->SetTitle(
"Mchirp");
1967 mg2->GetHistogram()->GetYaxis()->SetTitle(
"Average on ANN ouputs");
1969 cout<<
" name "<<name<<endl;
1973 char Cname2root[1024];
1974 Cname.ReplaceAll(
".root",
".png");
1975 sprintf(Cname2,
"average_png/nSig%i_nBg%i_Mc_Plots_%s",nSig,nBg,Cname.Data());
1976 sprintf(Cname2root,
"average_png/nSig%i_nBg%i_Mc_Plots_%s",nSig,nBg,Cnameroot.Data());
1977 cout<<
"Cname2 "<<Cname2<<endl;
1979 c->Print(Cname2root);
1980 cout<<
" gS[0]->GetN() "<<gS[0]->GetN()<<endl;
1982 cout<<
" nSig "<<nSig<<
" nBg "<<nBg<<
" aa1 "<<aa1<<endl;
1989 name.ReplaceAll(
"outfile/",
"");
1990 name.ReplaceAll(
"average_file/",
"");
1991 TFile* fTEST =TFile::Open(ifile.Data());
1992 TTree* NNTree2=(TTree*)fTEST->Get(
"Parameters");
2000 NNTree2->SetBranchAddress(
"Mchirp",&Mc);
2001 NNTree2->SetBranchAddress(
"Average",&av);
2002 NNTree2->SetBranchAddress(
"cc",&cc);
2003 NNTree2->SetBranchAddress(
"rho",&rho);
2004 NNTree2->SetBranchAddress(
"Mchirp_injected",&Mc_inj);
2005 NNTree2->SetBranchAddress(
"#TestSig",&nSi);
2006 NNTree2->GetEntry(0);
2008 cout<<
"nSig: "<<nSig<<
" nSi: "<<nSi<<endl;
2009 int const nBg=NNTree2->GetEntries()-nSig;
2010 int const nTot=NNTree2->GetEntries();
2012 int nBgSur[3][n_points];
2013 int nSigSur[3][n_points];
2014 double zax[3][n_points];
2016 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.;}
2031 double deltaANNth=0.;
2032 double deltaRHOth=0.;
2038 TCanvas* SNR_c=
new TCanvas(
"SIG-BKG_reduction",
"SIG-BKG_reduction",0,0,1200,700);
2044 SNR3Dcc0->SetDirectory(0);
2045 SNR3Dcc0->SetStats(0);
2046 SNR3Dcc1->SetDirectory(0);
2047 SNR3Dcc1->SetStats(0);
2048 SNR3Dcc2->SetDirectory(0);
2049 SNR3Dcc2->SetStats(0);
2051 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;}
2052 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;}
2054 cout<<
"fino def cose"<<endl;
2089 for (
int u=0; u<nTot; u++){
2090 NNTree2->GetEntry(u);
2091 for (
int y=0;
y<3;
y++){
2097 if(u<nSig) nSigSur[
y][j+N_ANNth*
i]=nSigSur[
y][j+N_ANNth*
i]+1;
2098 else nBgSur[
y][j+N_ANNth*
i]=nBgSur[
y][j+N_ANNth*
i]+1;
2113 nBgSur0=nBgSur[0][0];
2115 nSigSur0=nSigSur[0][0];
2116 if(nBgSur0==0){nBgSur0=nBg;}
2117 if(nSigSur0==0){nSigSur0=nSig;}
2119 cout<<
"dopo ciclo"<<
" nSigSur0 "<<nSigSur0<<
" nBgSur0 "<<nBgSur0<<endl;
2123 if(nSigSur[u][
i+
j*N_ANNth]==0) {
2124 if (nSigSur[u][
i+
j*N_ANNth]==0 && nBgSur[u][
i+
j*N_ANNth]==0) zax[u][
i+
j*
N_ANNth]=-1;
2130 num=(double)nBgSur[u][
i+
j*N_ANNth]/nBgSur0;
2131 den=(double)nSigSur0/nSigSur[u][
i+
j*N_ANNth];
2132 zax[u][
i+
j*
N_ANNth]=(double)num/den; count_zax=count_zax+1;
2133 cout<<(double)(nBgSur[u][
i+
j*N_ANNth]/nBgSur0)*(nSigSur0/nSigSur[u][
i+
j*
N_ANNth])<<endl;
2141 SNR3Dcc0->Fill(pANNth[
i]+ deltaANNth/2.,pRHOth[
j]+ deltaRHOth/2.,zax[0][
i+
j*N_ANNth]);
2142 SNR3Dcc1->Fill(pANNth[
i]+ deltaANNth/2.,pRHOth[
j]+ deltaRHOth/2.,zax[1][
i+
j*N_ANNth]);
2143 SNR3Dcc2->Fill(pANNth[
i]+ deltaANNth/2.,pRHOth[
j]+ deltaRHOth/2.,zax[2][
i+
j*N_ANNth]);
2146 for(
int yy=0;
yy<3;
yy++) {
2147 cout<<
" pCCth "<<pCCth[
yy]<<endl;
2148 for (
int ii=N_ANNth-1; ii>-1; ii--) {
2149 cout<<
" pANNth[i] "<<pANNth[ii]<<endl;
2150 for (
int jj=N_RHOth-1; jj>-1;jj--){
2151 cout<<
" pRHOth[jj] "<<pRHOth[jj]<<endl;
2152 cout<<
" nBgSur[yy][ii+N_ANNth*jj] "<<nBgSur[
yy][ii+N_ANNth*jj]<<endl;
2153 cout<<
" nSigSur[yy][ii+N_ANNth*jj] "<<nSigSur[
yy][ii+N_ANNth*jj]<<endl;
2154 cout<<
" zax[0][i+j*N_ANNth]"<<zax[
yy][ii+jj*
N_ANNth]<<endl;
2155 cout<<
" (double)(nBgSur[u][i+j*N_ANNth]/nBgSur0)"<<(double)nBgSur[
yy][ii+jj*N_ANNth]/nBgSur0<<endl;
2160 cout<<
"coutn_zax "<<count_zax<<endl;
2162 SNR3Dcc0->GetXaxis()->SetTitle(
"ANN_average_thresholds");
2163 SNR3Dcc0->GetYaxis()->SetTitle(
"RHO_thresholds");
2164 SNR3Dcc0->GetZaxis()->SetTitle(
"normBKG/normSIG");
2165 SNR3Dcc0->Draw(
"colz");
2168 SNR3Dcc1->GetXaxis()->SetTitle(
"ANN_average_thresholds");
2169 SNR3Dcc1->GetYaxis()->SetTitle(
"RHO_thresholds");
2170 SNR3Dcc1->GetZaxis()->SetTitle(
"normBKG/normSIG");
2171 SNR3Dcc1->Draw(
"colz");
2174 SNR3Dcc2->GetXaxis()->SetTitle(
"ANN_average_thresholds");
2175 SNR3Dcc2->GetYaxis()->SetTitle(
"RHO_thresholds");
2176 SNR3Dcc2->GetZaxis()->SetTitle(
"normBKG/normSIG");
2177 SNR3Dcc2->Draw(
"colz");
2182 char SNR_c_nroot[1024];
2183 SNR_n.ReplaceAll(
".root",
".png");
2184 sprintf(SNR_c_n,
"SNR_plots/nSig%i_nBg%i_invSNR_Plots_%s",nSig,nBg,SNR_n.Data());
2185 sprintf(SNR_c_nroot,
"SNR_plots/nSig%i_nBg%i_invSNR_Plots_%s",nSig,nBg,SNR_nroot.Data());
2186 SNR_c->SaveAs(SNR_c_n);
2187 SNR_c->Print(SNR_c_nroot);
2195 name.ReplaceAll(
"outfile/",
"");
2196 name.ReplaceAll(
"average_file/",
"");
2197 TFile* fTEST =TFile::Open(ifile.Data());
2198 TTree* NNTree2=(TTree*)fTEST->Get(
"Parameters");
2207 NNTree2->SetBranchAddress(
"Center_of_Gravity",&CoG);
2208 NNTree2->SetBranchAddress(
"Mchirp",&Mc);
2209 NNTree2->SetBranchAddress(
"Average",&av);
2210 NNTree2->SetBranchAddress(
"cc",&cc);
2211 NNTree2->SetBranchAddress(
"rho",&rho);
2212 NNTree2->SetBranchAddress(
"Mchirp_injected",&Mc_inj);
2213 NNTree2->SetBranchAddress(
"#TestSig",&nSi);
2214 NNTree2->GetEntry(0);
2216 cout<<
"nSig: "<<nSig<<
" nSi: "<<nSi<<endl;
2217 int const nTot=NNTree2->GetEntries();
2218 int const nBg=nTot-nSig;
2220 TCanvas* CoG_c=
new TCanvas(
"SIG-BKG_reduction",
"SIG-BKG_reduction",0,0,1200,700);
2228 CoG1Sig->SetDirectory(0);
2229 CoG1Sig->SetStats(0);
2230 CoG0Sig->SetDirectory(0);
2231 CoG0Sig->SetStats(0);
2232 CoG1Bg->SetDirectory(0);
2233 CoG1Bg->SetStats(0);
2234 CoG0Bg->SetDirectory(0);
2235 CoG0Bg->SetStats(0);
2237 for (
int n=0;
n<nTot;
n++){
2238 NNTree2->GetEntry(
n);
2240 if(CoG==0) {CoG0Sig->Fill(av);}
2241 else {CoG1Sig->Fill(av);}
2244 if(CoG==0) {CoG0Bg->Fill(av);}
2245 else {CoG1Bg->Fill(av);}
2247 cout<<
" CoG "<<CoG<<endl;
2250 imp->SetDirectory(0);
2257 for(
int i=0;
i<4;
i++) max[
i]=0;
2259 max[0]=CoG1Sig->GetMaximum();
2260 max[1]=CoG0Sig->GetMaximum();
2261 max[2]=CoG1Bg->GetMaximum();
2262 max[3]=CoG0Bg->GetMaximum();
2265 for(
int i=0;
i<4;
i++)
if(max_n<max[
i]) max_n=max[
i] ;
2268 imp->SetLineColor(10);
2270 imp->GetXaxis()->SetTitle(
"ANN");
2271 imp->GetYaxis()->SetTitle(
"Count");
2274 CoG1Sig->SetFillStyle(3018);
2275 CoG0Sig->SetFillStyle(3018);
2276 CoG0Bg->SetFillStyle(3004);
2277 CoG1Bg->SetFillStyle(3004);
2278 CoG1Sig->SetFillColor(2);
2279 CoG0Sig->SetFillColor(6);
2280 CoG0Bg->SetFillColor(4);
2281 CoG1Bg->SetFillColor(9);
2282 CoG1Sig->SetLineColor(2);
2283 CoG0Sig->SetLineColor(6);
2284 CoG0Bg->SetLineColor(4);
2285 CoG1Bg->SetLineColor(9);
2289 CoG1Sig->Draw(
"same");
2290 CoG0Sig->Draw(
"same");
2291 CoG0Bg->Draw(
"same");
2292 CoG1Bg->Draw(
"same");
2297 char CoG_c_nroot[1024];
2298 CoG_n.ReplaceAll(
".root",
".png");
2299 sprintf(CoG_c_n,
"CoG_plots/nSig%i_nBg%i_invSNR_Plots_%s",nSig,nBg,CoG_n.Data());
2300 sprintf(CoG_c_nroot,
"CoG_plots/nSig%i_nBg%i_invSNR_Plots_%s",nSig,nBg,CoG_nroot.Data());
2301 CoG_c->SaveAs(CoG_c_n);
2302 CoG_c->Print(CoG_c_nroot);
2309 name.ReplaceAll(
"outfile/",
"");
2310 name.ReplaceAll(
"average_file/",
"");
2311 TFile* fTEST =TFile::Open(ifile.Data());
2312 TTree* NNTree2=(TTree*)fTEST->Get(
"Parameters");
2321 NNTree2->SetBranchAddress(
"Center_of_Gravity",&CoG);
2322 NNTree2->SetBranchAddress(
"Mchirp",&Mc);
2323 NNTree2->SetBranchAddress(
"Average",&av);
2324 NNTree2->SetBranchAddress(
"cc",&cc);
2325 NNTree2->SetBranchAddress(
"rho",&rho);
2326 NNTree2->SetBranchAddress(
"Mchirp_injected",&Mc_inj);
2327 NNTree2->SetBranchAddress(
"#TestSig",&nSi);
2328 NNTree2->GetEntry(0);
2330 cout<<
"nSig: "<<nSig<<
" nSi: "<<nSi<<endl;
2331 int const nTot=NNTree2->GetEntries();
2332 int const nBg=nTot-nSig;
2351 for(
int i=0;
i<7;
i++){
2368 for(
int i=0;
i<7;
i++){
2374 double delta_rho=0.;
2395 double delta_yasym=0.;
2398 cout<<
" delta_yasym "<<delta_yasym<<endl;
2402 cout<<
" yasym[i] "<<yasym[
i]<<
" i "<<
i<<endl;
2411 double delta_logk=0.;
2415 min_logk=log10(
min_k);
2416 max_logk=log10(
max_k);
2417 delta_logk=(log10(
max_k)-log10(
min_k))/npoints;
2423 th_k[
i]=pow(10,min_logk+
i*delta_logk);
2424 cout<<
" th_k[i] "<<th_k[
i]<<
" th_Mc[i] "<<th_Mc[
i]<<endl;
2430 for(
int n=0;
n<nTot;
n++){
2431 NNTree2->GetEntry(
n);
2432 if(cc<0.5)
continue;
2433 if(
n<nSig) countS=countS+1;
2434 else countB=countB+1;
2435 for(
int i=0;
i<7;
i++){
2436 if(Mc>Mccuts[
i]&&av>ANNcuts[
i]) {
2438 if(rho>th_rho[
j]&&
n<nSig) TA_rho[
i][
j]=TA_rho[
i][
j]+1;
2439 if(rho>th_rho[
j]&&(
n>nSig||
n==nSig)) FA_rho[
i][
j]=FA_rho[
i][
j]+1;
2446 for(
int i=0;
i<7;
i++){
2448 if(
i==6) cout<<
"TA_rho[i][j] "<<TA_rho[
i][
j]<<
" countS "<<countS<<
" FA_rho[i][j] "<<FA_rho[
i][
j]<<
" countB "<<countB<<endl;
2449 FA_rho[
i][
j]=(double)FA_rho[
i][
j]/countB;
2450 TA_rho[
i][
j]=(double)TA_rho[
i][
j]/countS;
2451 if(FA_rho[
i][
j]==0) FA_rho[
i][
j]=0.00001;
2452 if(
i==6) cout<<
"TA_rho[i][j] "<<TA_rho[
i][
j]<<
" FA_rho[i][j] "<<FA_rho[
i][
j]<<endl;
2458 for (
int n=0;
n<nTot;
n++){
2459 NNTree2->GetEntry(
n);
2463 if(Mc>th_Mc[
j]&&
i==0)TA_Mc[0][
j]=TA_Mc[0][
j]+1;
2464 if(Mc>th_Mc[
j]&&av>yasym[
i]) TA_Mc[i+1][
j]=TA_Mc[i+1][
j]+1;
2465 if(av>((th_k[
j]/(Mc-
x_asym))+yasym[i]))TA_ANNMc[
i][
j]=TA_Mc[i+1][
j]+1;
2474 if(Mc>th_Mc[
j]&&
i==0)FA_Mc[0][
j]=FA_Mc[0][
j]+1;
2475 if(Mc>th_Mc[
j]&&av>yasym[
i]) FA_Mc[i+1][
j]=FA_Mc[i+1][
j]+1;
2476 if(av>(th_k[
j]/(Mc-
x_asym)+yasym[i]))FA_ANNMc[
i][
j]=FA_Mc[i+1][
j]+1;
2485 TA_Mc[0][
j]=TA_Mc[0][
j]/nSig;
2486 FA_Mc[0][
j]=FA_Mc[0][
j]/nBg;
2488 TA_Mc[
i+1][
j]=(double)TA_Mc[
i+1][
j]/nSig;
2489 FA_Mc[
i+1][
j]=(double)FA_Mc[
i+1][
j]/nBg;
2490 TA_ANNMc[
i][
j]=(double)TA_ANNMc[
i][
j]/nSig;
2491 FA_ANNMc[
i][
j]=(double)FA_ANNMc[
i][
j]/nBg;
2495 Mc_g[0]=
new TGraph(npoints,FA_Mc[0],TA_Mc[0]);
2496 TGraph* g0=
new TGraph();
2497 g0->SetPoint(0.00001,1,0);
2498 for (
int i=0;
i<7;
i++){
2499 rho_g[
i]=
new TGraph(npoints,FA_rho[
i],TA_rho[i]);
2501 TCanvas* canrho=
new TCanvas(
"Efficiency_vs_FalseAlarm",
"Efficiency_vs_Alarm",0,0,1200,700);
2503 TLegend *legrho =
new TLegend(.75, .2, .99, .4);
2504 TMultiGraph* mg0=
new TMultiGraph();
2505 if(g0->GetN()!=0) mg0->Add(g0);
2506 g0->SetMarkerColor(0);
2508 mg0->SetTitle(
"Comparison;FalseAlarms;Efficiency");
2509 for (
int i=0;
i<7;
i++){
2510 rho_g[
i]->SetLineColor(2+
i);
2511 rho_g[
i]->SetMarkerColor(2+
i);
2512 rho_g[
i]->SetMarkerStyle(
i+20);
2514 rho_g[
i]->SetMarkerSize(0.5);
2516 char defANNMc_rho[1024];
2517 sprintf(defANNMc_rho,
"Mc_%1.2f & ANNcut_%1.2f",Mccuts[
i],ANNcuts[i]);
2518 if(rho_g[i]->GetN()!=0) legrho->AddEntry(rho_g[i],defANNMc_rho,
"pl");
2519 if(rho_g[i]->GetN()!=0) mg0->Add(rho_g[i]);
2526 rhoCname.ReplaceAll(
".root",
".png");
2527 char rhoCname2[1024];
2528 char rhoCname2r[1024];
2529 sprintf(rhoCname2,
"Cuts_caROC/TAvsFA_changingRHO%s",rhoCname.Data());
2530 sprintf(rhoCname2r,
"Cuts_caROC/TAvsFA_changingRHO%s",rhoCnamer.Data());
2531 canrho->SaveAs(rhoCname2);
2532 canrho->Print(rhoCname2r);
2535 for(
int j=0;
j<
npoints;
j++) cout<<
" th_Mc[j] "<<th_Mc[
j]<<
" j "<<
j<<
" TA_Mc[0][j] "<<TA_Mc[0][
j]<<
" FA_Mc[0][j] "<<FA_Mc[0][
j]<<endl;
2539 Mc_g[
i+1]=
new TGraph(npoints,FA_Mc[
i+1],TA_Mc[
i+1]);
2540 ANNMc_g[
i]=
new TGraph(npoints,FA_ANNMc[
i],TA_ANNMc[i]);
2543 TCanvas* can=
new TCanvas(
"Efficiency_vs_FalseAlarm",
"Efficiency_vs_Alarm",0,0,1200,700);
2545 TLegend *leg =
new TLegend(.75, .4, .99, .65);
2547 TMultiGraph* mg1=
new TMultiGraph();
2548 mg1->SetTitle(
"Comparison;FalseAlarms;Efficiency");
2549 Mc_g[0]->SetLineColor(3);
2550 Mc_g[0]->SetMarkerStyle(1);
2552 Mc_g[
i+1]->SetLineColor(4);
2554 Mc_g[
i+1]->SetMarkerSize(0.5);
2555 Mc_g[
i+1]->SetMarkerStyle(
i+20);
2556 Mc_g[
i+1]->SetMarkerColor(4);
2557 ANNMc_g[
i]->SetLineColor(2);
2558 ANNMc_g[
i]->SetMarkerColor(2);
2559 ANNMc_g[
i]->SetMarkerStyle(
i+20);
2561 ANNMc_g[
i]->SetMarkerSize(0.5);
2563 char defANNMc[1024];
2564 sprintf(defMc,
"Mc & ANNcut_%1.2f",yasym[
i]);
2565 sprintf(defANNMc,
"Hyperbola_cut,y_asymtoto_%1.2f",
"yasym[i]");
2566 if(Mc_g[i+1]->GetN()!=0) leg->AddEntry(Mc_g[i+1],defMc,
"pl");
2567 if(Mc_g[i+1]->GetN()!=0) mg1->Add(Mc_g[i+1]);
2568 if(ANNMc_g[i]->GetN()!=0) leg->AddEntry(ANNMc_g[i],defANNMc,
"pl");
2569 if(ANNMc_g[i]->GetN()!=0) mg1->Add(ANNMc_g[i]);
2572 if(Mc_g[0]->GetN()!=0) mg1->Add(Mc_g[0]);
2573 if(Mc_g[0]->GetN()!=0) leg->AddEntry(Mc_g[0],
"Mc, no ANNcut",
"pl");
2580 Cname.ReplaceAll(
".root",
".png");
2583 sprintf(Cname2,
"Cuts_caROC/TAvsFA_%s",Cname.Data());
2584 sprintf(Cname2r,
"Cuts_caROC/TAvsFA_%s",Cnamer.Data());
2585 can->SaveAs(Cname2);
2586 can->Print(Cname2r);
Float_t * rho
biased null statistics
void CoG_plots(TString ifile)
wavearray< double > a(hp.size())
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 CutMcANN(TString ifile)
cout<< "SNR "<< xsnr<< endl;wavearray< double > f
void Annth(TString ifile, int &FAth_n, int &FDth_n, double &thresFA)
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
void PlotsAv_cc(TString ifile)
Float_t * netcc
effective correlated SNR
void graph(TString ifile)
void Mcth(TString ifile, int &McFAth_n, int &McFDth_n, double &McthresFA)
sprintf(tfres,"(1/%g)x(%g) (sec)x(Hz)", 2 *df, df)
void PlotsAv_Mc(TString ifile)
void SNR_plots(TString ifile)
Float_t * chirp
range to source: [0/1]-rec/inj
void JoinCutANN_Mchirp_ROCcurves_rho2(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)