3 #pragma GCC system_header
10 #include "TObjArray.h"
11 #include "TObjString.h"
12 #include "TPaletteAxis.h"
13 #include "TMultiLayerPerceptron.h"
14 #include "TMLPAnalyzer.h"
47 #define minANN_av -0.2
54 #define ANNth_min -0.5
55 #define RHOth_max 10.0
58 #define x_asym 0.00009999999999999999999999999999
60 #define min_yasym -0.1
94 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){
97 if (uf==0&&av_on_nNN!=0) cout<<
"all events were not used for the training procedure"<<endl;
98 if(uf==0) {ni=1; consider_all=1; av_on_nNN=0;}
109 if (NN_FILE.CompareTo(
"")){
112 if (NN_FILE2.CompareTo(
"")){
115 if (NN_FILE3.CompareTo(
"")){
118 if (NN_FILE4.CompareTo(
"")){
121 if (NN_FILE5.CompareTo(
"")){
124 if (NN_FILE6.CompareTo(
"")){
127 if (NN_FILE7.CompareTo(
"")){
130 if (NN_FILE8.CompareTo(
"")){
137 char NNi2[nNN][1024];
138 sprintf(NNi2[0],
"%s",NN_FILE.Data());
139 if(nNN>1)
sprintf(NNi2[1],
"%s",NN_FILE2.Data());
140 if(nNN>2)
sprintf(NNi2[2],
"%s",NN_FILE3.Data());
141 if(nNN>3)
sprintf(NNi2[3],
"%s",NN_FILE4.Data());
142 if(nNN>4)
sprintf(NNi2[4],
"%s",NN_FILE5.Data());
143 if(nNN>5)
sprintf(NNi2[5],
"%s",NN_FILE6.Data());
144 if(nNN>6)
sprintf(NNi2[6],
"%s",NN_FILE7.Data());
145 if(nNN>7)
sprintf(NNi2[7],
"%s",NN_FILE8.Data());
147 if(nNN==1) {av_on_nNN=1; consider_all=0; ni=0;}
149 for (
int u=0;u<nNN;u++){
152 if (NNi2[u][p]==
'N'){
153 if((NNi2[u][p+1]==
'N')&&(NNi2[u][p+2]==
'\/')) {
155 while (NNi2[u][hh]!=
'\0'){NNi[u][hh-p-3]=NNi2[u][hh];hh=hh+1;}
167 sprintf(Filei2,
"%s",TEST_FILE.Data());
169 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]==
'\/')) {
171 while (Filei2[hh]!=
'\0') {Filei[hh-q-7]=Filei2[hh];hh=hh+1;
173 for (
int h0=hh-q-7;h0<1024;h0++) Filei[h0]=
'\0';
179 cout<<Filei<<
" original String: "<<Filei2<<endl;
184 if(nNN>1) NNi0[1]=NNi[1];
185 if(nNN>2) NNi0[2]=NNi[2];
186 if(nNN>3) NNi0[3]=NNi[3];
187 if(nNN>4) NNi0[4]=NNi[4];
188 if(nNN>5) NNi0[5]=NNi[5];
189 if(nNN>6) NNi0[6]=NNi[6];
190 if(nNN>7) NNi0[7]=NNi[7];
195 for (
int u=0;u<nNN;u++){
196 NNi0[u].ReplaceAll(
".root",
"");
198 Filei0.ReplaceAll(
".root",
"");
202 TMultiLayerPerceptron* mlp[nNN];
208 for (
int yy=0;
yy<nNN;
yy++){TotBg[
yy]=0;FA0[
yy]=0;FD0[
yy]=0;}
222 for (
int u=0;u<nNN;u++){
223 fnet[u]=TFile::Open(NNi2[u]);
224 mlp[u]=(TMultiLayerPerceptron*)fnet[u]->
Get(
"TMultiLayerPerceptron");
226 cout<<
"dopo TMLP"<<endl;
227 if(mlp[u]==NULL) {cout <<
"Error getting mlp" << endl;
exit(1);}
228 infot[u]=(TTree*)fnet[u]->
Get(
"info");
230 infot[u]->SetBranchAddress(
"Rand_start_Sig",&NNs[u]);
231 infot[u]->SetBranchAddress(
"Rand_start_Bg",&NNb[u]);
232 infot[u]->SetBranchAddress(
"#trainSig",&NNnTS[u]);
233 infot[u]->SetBranchAddress(
"#trainBg",&NNnTB[u]);
234 infot[u]->GetEntry(0);
235 cout<<
"n "<<u<<
" b "<<NNb[u]<<
" min_NNb "<<min_NNb<<endl;
237 if(NNs[u]<min_NNs) min_NNs=NNs[u];
238 if(NNb[u]<min_NNb) min_NNb=NNb[u];
239 if(NNs[u]>max_NNs) max_NNs=NNs[u];
240 if(NNb[u]>max_NNb) max_NNb=NNb[u];
241 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;
252 cout<<
" min_NNb "<<min_NNb<<
" b "<<b<<endl;
253 cout<<
"Def. tree e mlp"<<endl;
256 TFile* fTEST =TFile::Open(TEST_FILE.Data());
257 cout<<
"Def. tree e mlp"<<endl;
258 TTree* NNTree=(TTree*)fTEST->Get(
"nnTree");
259 cout<<
"Def. tree e mlp"<<endl;
260 int entries=NNTree->GetEntries();
263 cout<<
"entries: "<<entries<<endl;
264 cout<<
" NNTree->GetEntries() "<<NNTree->GetEntries()<<endl;
274 NNTree->SetBranchAddress(
"#Entries_type",&entriesTot);
275 NNTree->SetBranchAddress(
"Matrix_dim",&ndim);
276 NNTree->SetBranchAddress(
"#inputs",&ninp);
277 NNTree->SetBranchAddress(
"amplitude_mode",&y);
280 sig_entries=entriesTot;
281 NNTree->GetEntry(entries-1);
282 bg_entries=entriesTot;
283 cout<<
"sig "<<sig_entries<<
" bg "<<bg_entries<<endl;
286 cout<<
"NDIM: "<<NDIM<<endl;
287 cout<<
"nINP: "<<nINP<<endl;
288 cout<<
"sig e: "<<sig_entries<<endl;
289 cout<<
"bg e: "<<bg_entries<<endl;
293 if (sig_entries>bg_entries) minevents=bg_entries;
294 else minevents=sig_entries;
301 cout<<
"TS "<<TS<<
" TB "<<
TB<<
" minevents "<<minevents<<endl;
306 cout<<
"Error: Bg index<sig_entries: new set of b parameter-> b="<<b<<
" instead of b="<<a<<endl;
312 cout<<
"Error: Sig index>sig_entries: new set of s parameter-> s="<<b<<
" instead of s="<<a<<endl;
314 if((TS>sig_entries-
s||
TB>(bg_entries-(b-sig_entries)))&&(TS==
TB)) {TS=minevents-
s;
TB=minevents-(b-sig_entries);
317 cout<<
"Error:S>sig_entries or TB>bg_entries, to maintain ugual number of analysed events TS=TB="<<
TB<<endl;
319 if((TS>sig_entries-
s||
TB>bg_entries-(b-sig_entries))&&(TS!=
TB)) {
320 if(TS>sig_entries) TS=sig_entries-
s;
321 if (
TB>bg_entries)
TB=bg_entries-(b-sig_entries);
322 cout<<
"Error:S>sig_entries or TB>bg_entries, new TS and TB values are thus define-> TS="<<TS<<
" TB="<<
TB<<endl;
327 sprintf(NOMEtot,
"%s",NOMEtot_S.Data());
328 cout<<
"output name: "<<NOMEtot<<endl;
334 NNTree->SetBranchAddress(
"Files_name",&FILE_NAME);
337 NNTree->GetEntry(entries-1);
339 cout<<
"fine ifdef RHO_CC"<<endl;
342 TChain sigTree(
"waveburst");
343 sigTree.Add(SIG_FILE.Data());
346 cout <<
"sig entries2 : " << sig_entries2 << endl;
348 TChain bgTree(
"waveburst");
349 bgTree.Add(BG_FILE.Data());
352 cout <<
"bg entries2 : " << bg_entries2 << endl;
354 cout<<
"b: "<<b<<endl;
355 cout<<
"s: "<<
s<<endl;
359 for (
int jj=0; jj<nINP;jj++) x[jj]=0.;
360 char ilabel[nINP][16];
363 for(
int i=0;
i<nINP;
i++) {
365 NNTree->SetBranchAddress(ilabel[i], &x[i]);
369 sprintf(ofile,
"average_file/%s.root",NOMEtot);
370 TFile*
f =
new TFile(ofile,
"RECREATE");
371 TTree* NNTree2=
new TTree(
"Parameters",
"Parameters");
372 NNTree2->SetDirectory(f);
377 for(
int y=0; y<nNN; y++) out[y]=0.;
389 NNTree2->Branch(
"Center_of_Gravity",&CoG,
"Center_of_Gravity/I");
390 NNTree2->Branch(
"Average",&average,
"Average/D");
391 NNTree2->Branch(
"StandardDevaition",&std,
"StandardDeviation/D");
392 NNTree2->Branch(
"cc",&NNcc,
"cc/D");
393 NNTree2->Branch(
"Mchirp",&Mc,
"Mchirp/D");
394 NNTree2->Branch(
"Mchirp_injected",&Mc_inj,
"Mchirp_injected/D");
395 NNTree2->Branch(
"rho",&NNrho,
"rho/D");
396 NNTree2->Branch(
"index",&index_ev,
"index/I");
399 NNTree2->Branch(
"Test_file",&TestFile,
"Test_file/C");
401 for(
int u=0;u<nNN;u++){
407 sprintf(NNoutl2,
"NNout%i/D",u);
409 sprintf(NNnamel2,
"NNname%i/C",u);
410 NNTree2->Branch(NNoutl,&out[u],NNoutl2);
411 NNTree2->Branch(NNnamel,&NNi[u],NNnamel2);
415 NNTree2->Branch(
"TestFile",&Testf,
"TestFile/C");
416 sprintf(Testf,
"%s",TEST_FILE.Data());
425 for(
int n=
s;
n<sig_entries;
n++) {
427 for(
int u=0;u<nNN;u++){
428 if (uf!=0&&
n>NNs[u]&&
n<(NNs[u]+NNnTS[u])) countNN=countNN+1;
434 if(countNN==0&&av_on_nNN!=0) scount=scount+1;
437 if(countNN==1&&consider_all==0&&av_on_nNN==0) scount=scount+1;
438 if(countNN<2&&consider_all!=0) scount=scount+1;
439 if(countNN>1){cout<<
"Error: training non independent"<<
n<<endl;
exit(0);}
440 cout<<
"n "<<
n<<
"; countNN "<<countNN<<
"; scount "<< scount<<
"; consider_all "<<consider_all<<
"; av_on_nNN "<<av_on_nNN<<endl;
441 if(scount==TS)
break;}
445 cout<<
" nTestS "<< nTestS<<
" TS "<<TS<<endl;
460 for(
int n=b;
n<sig_entries+bg_entries;
n++) {
462 for(
int u=0;u<nNN;u++){
463 if (uf!=0&&
n>NNb[u]&&
n<(NNb[u]+NNnTB[u])) countNN=countNN+1;
465 if(countNN==0&&av_on_nNN!=0) bcount=bcount+1;
467 if(countNN==1&&consider_all==0&&av_on_nNN==0) bcount=bcount+1;
468 if(countNN<2&&consider_all!=0) bcount=bcount+1;
469 if(countNN>1){cout<<
"Error: training non independent"<<
n<<endl;
exit(0);}
470 if(bcount==
TB)
break;
475 if(uf!=0) nTestS=nTestS-1;
476 if(uf!=0) nTestB=nTestB-1;
479 cout<<
"TS "<<TS<<
" TB "<<
TB<<
" nTestS "<<nTestS<<
" nTestB "<<nTestB<<endl;
481 if(nTestB>nTestS) {nTestB=nTestS;
TB=nTestS; TS=nTestS;}
482 else {nTestS=nTestB;
TB=nTestB; TS=nTestB;}
485 if(nTestS<TS) TS= nTestS;
489 NNTree2->Branch(
"#TestSig",&TS,
"#TestSig/I");
491 cout<<
"nTestS: "<<nTestS<<
" TS: "<<TS<<endl;
492 cout<<
"dopo def tree"<<endl;
493 cout<<
"s test "<<
s<<
" s+TS "<<
s+TS<<
" b "<<b<<
" b+ TB "<<b+
TB<<
" nTestS "<<nTestS<<
" TB "<<
TB<<
" nTestB "<<nTestB<<endl;
496 for (
int i=0;
i<nINP;
i++) params[
i]=0.;
502 TString txt_originaldata(NOMEtot_S);
503 txt_originaldata.ReplaceAll(
".root",
"_originalData.txt");
505 char txt_originaldata_c[1024];
506 sprintf(txt_originaldata_c,
"txt_files/%s.txt",txt_originaldata.Data());
507 ofstream od_txt(txt_originaldata_c);
511 for(
int n=
s;
n<sig_entries;
n++) {
519 for(
int u=0;u<nNN;u++){
520 if (uf!=0&&
n>=NNs[u]&&
n<(NNs[u]+NNnTS[u])) { indNN=u;countNN=countNN+1;}
522 if (countNN>1){cout<<
"Error: training non independent";
exit(0);}
523 if(nNN==1){cout<<
"out==Averege:only 1NN is considered"<<endl;}
524 if(consider_all==0&&av_on_nNN==0&&countNN==0)
continue;
525 if(consider_all==0&&av_on_nNN!=0&&countNN!=0) {sigskip=sigskip+1;
continue; }
531 NNcc=(double)signal.
netcc[0];
532 NNrho=(
double)signal.
rho[1];
534 Mc_inj=(
double)signal.
chirp[0];
536 sprintf(TestFile,
"%s",TEST_FILE.Data());
542 for (
int i=0;
i<nINP;
i++){
549 ti_0+=(double)x[
i]*ti_i;
550 fi_0+=(double)x[
i]*fi_i;
551 sprintf(line_od2,
"%s %1.5f",line_od2, x[
i]);
553 sprintf(line_od2,
"%s \n",line_od2);
555 if (ti_0<fi_0) CoG=1;
560 for (
int u=0;u<nNN;u++) {
562 double output=mlp[u]->Evaluate(0,params);
572 for (
int u=0;u<nNN;u++){
573 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;}
576 average=average/(c_nNN0);
577 if((c_nNN0)!=1)std=pow((std/(nNN-1-countNN)-average*average),0.5);
581 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);
584 if (average<0.6) FD=FD+1;
589 cout<<
" cc "<<NNcc<<
" NNrho "<<NNrho<<
" Mc_inj "<< Mc_inj<<endl;
594 cout<<txt_originaldata_c<<endl;
597 cout<<
" S_eff "<<S_eff<<
" s "<<
s<<
" b "<<b<<
" sigskip "<<sigskip<<endl;
603 for(
int n=b;
n<sig_entries+bg_entries;
n++) {
611 for(
int u=0;u<nNN;u++){
612 cout<<
" uf "<<uf<<
" n "<<
n<<
" u "<<u<<
" NN b[u] "<<NNb[u]<<
" NNb[u]+NNnTB[u]"<<NNb[u]+NNnTB[u]<<endl;
613 if (uf!=0&&
n>=NNb[u]&&
n<(NNb[u]+NNnTB[u])) { indNN=u;countNN=countNN+1; }
615 if (countNN>1){cout<<
"Error: training non independent";
exit(0);}
616 if(nNN==1){cout<<
"out==Averege:only 1NN is considered"<<endl;}
617 cout<<
"consider_all "<<consider_all<<
" av_on_nNN "<<av_on_nNN<<
" countNN "<<countNN<<
" indNN "<<indNN<<endl;
618 if(consider_all==0&&av_on_nNN==0&&countNN==0)
continue;
619 if(consider_all==0&&av_on_nNN!=0&&countNN!=0) { cout<<
" n skipped "<<
n<<endl; bgskip=bgskip+1;
continue;}
621 cout<<
"BKG->n: "<<
n<<
"Bg index"<<(
n-sig_entries)<<endl;
624 NNcc=(double)background.
netcc[0];
626 NNrho=(
double)background.
rho[1];
628 Mc_inj=(
double)background.
chirp[0];
633 sprintf(TestFile,
"%s",TEST_FILE.Data());
635 for (
int i=0;
i<nINP;
i++){
641 ti_0+=(double)x[
i]*ti_i;
642 fi_0+=(double)x[
i]*fi_i;
645 if (ti_0<fi_0) CoG=1;
648 for(
int u=0;u<nNN;u++) {
649 double output=mlp[u]->Evaluate(0,params);
656 for (
int u=0;u<nNN;u++){
657 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;}}
661 average=average/(c_nNN0);
662 if((c_nNN0)!=1)std=pow((std/(nNN-1-countNN)-average*average),0.5);
665 if(nnsu==6) cont_su=cont_su+1;
666 if(nnsu>4) cont_su5=cont_su5+1;
667 if(nnsu>3) cont_su4=cont_su4+1;
668 if(nnsu>2) cont_su3=cont_su3+1;
674 if(average>0.6) FA=FA+1;
685 cout<<
"B_eff "<<B_eff<<
" TB "<<
TB<<endl;
695 for (
int yy=0;
yy<nNN;
yy++){
698 if(TotBg[
yy]!=0){freq_c[
yy]=(double)FA0[
yy]/TotBg[
yy];
701 if(freq_c[
yy]!=0) {meanf=freq_c[
yy]+meanf;cont=cont+1;
704 dev=freq_c[
yy]*freq_c[
yy]+dev;
707 if(cont==0) cout<<
"Error cont==0"<<endl;
708 if(cont!=0) meanf=meanf/cont;
710 for (
int yy=0;
yy<nNN;
yy++){
713 if(freq_c[
yy]!=0)dev+=(freq_c[
yy]-meanf)*(freq_c[
yy]-meanf);
715 double McFAdes=FAdes;
716 int FAth_n=FAdes*B_eff;
717 int McFAth_n=FAdes*B_eff;
718 cout<<
"FAth_n "<<FAth_n<<
" FAdes*B_eff "<<FAdes*B_eff<<endl;
731 if(cont!=0) dev=pow(dev/(cont-1),0.5);
732 cout<<
"meanf "<<meanf<<
" dev "<<dev<<endl;
733 cout<<
" FA average "<<FA<<endl;
734 cout<<
" cont_su "<<cont_su<<
" cont_su5 "<<cont_su5<<
" cont_su4 "<<cont_su4<<
" cont_su3 "<<cont_su3<<endl;
736 cout<<
" S_eff "<<S_eff<<
" B_eff "<<B_eff<<
" s "<<
s<<
" b "<<b<<
" bgskip "<<bgskip<<
" sigskip "<<sigskip<<endl;
737 cout<<
" FA0[1] "<<FA0[1]<<
" TotBg[1] "<<TotBg[1]<<endl;
738 cout<<
" FD0[1] "<<FD0[1]<<
" TotBg[1] "<<TotBg[1]<<endl;
740 double FDdes=(double)FDth_n/S_eff;
741 double McFDdes=(double)McFDth_n/S_eff;
742 FAdes=(double)FAth_n/B_eff;
743 McFAdes=(double)McFAth_n/B_eff;
744 cout<<
"FAth_n "<<FAth_n<<
" FAdes: "<<FAdes<<
" ANN_av_FDdes "<<FDdes<<
" ANN_av_FDth_n "<<FDth_n<<
" ANN_av_thresFA "<<thresFA<<endl;
745 cout<<
"McFAth_n "<<McFAth_n<<
" McFAdes: "<<McFAdes<<
" Mc_FDdes "<<McFDdes<<
" McFDth_n "<<McFDth_n<<
" McthresFA "<<McthresFA<<endl;
750 name.ReplaceAll(
"average_file/",
"");
751 TFile* fTEST =TFile::Open(ifile.Data());
752 TTree* NNTree2=(TTree*)fTEST->Get(
"Parameters");
757 NNTree2->SetBranchAddress(
"Average",&av);
758 NNTree2->SetBranchAddress(
"cc",&cc);
759 NNTree2->SetBranchAddress(
"rho",&rho);
760 NNTree2->SetBranchAddress(
"#TestSig",&nSi);
761 NNTree2->GetEntry(0);
763 cout<<
"nSig: "<<nSig<<
" nSi: "<<nSi<<endl;
764 cout<<
" BG: "<<NNTree2->GetEntries()-nSi<<endl;
766 cout<<
"dentro funzione dopodef"<<endl;
768 double* rhoSig[ncurve];
769 for (
int i=0;
i<ncurve;
i++) rhoSig[
i]=
new double[nSig];
770 cout<<
"dopo def rhoSig"<<endl;
774 int const nBg=NNTree2->GetEntries()-nSig;
775 for (
int i=0;
i<ncurve;
i++) {
777 for (
int j=0;
j<nSig;
j++) rhoSig[
i][
j]=0.;
779 cout<<
"dopo def rhoSig"<<endl;
780 double* rhoBg[ncurve];
781 for (
int i=0;
i<ncurve;
i++) rhoBg[
i]=
new double[nBg];
784 for (
int i=0;
i<ncurve;
i++) {
786 for (
int j=0;
j<nBg;
j++) rhoBg[
i][
j]=0.;
788 cout<<
"dopo def rhoBg"<<endl;
790 for (
int i=0;
i<
nCC;
i++) ccTh[
i]=0.;
792 for (
int i=0;
i<
nANN;
i++) NNTh[
i]=0.;
798 cout<<NNTree2->GetEntries()<<endl;
799 for(
int n=0;
n<NNTree2->GetEntries();
n++){
801 NNTree2->GetEntry(
n);
802 cout<<
"rho "<<rho<<
" cc "<<cc<<
" av "<<av<<endl;
805 if(cc<ccTh[
i])
continue;
807 if(
j==0) NNTh[
j]=-1000.;
813 if(av<NNTh[
j])
continue;
817 NBg[i*nANN+
j]= NBg[i*nANN+
j]+1;
818 while(rhoBg[i*nANN+j][ni]!=0)ni=ni+1;
819 rhoBg[i*nANN+
j][ni]=
rho;
824 NSig[i*nANN+
j]= NSig[i*nANN+
j]+1;
825 while(rhoSig[i*nANN+j][ni]!=0)ni=ni+1;
826 rhoSig[i*nANN+
j][ni]=
rho;
834 cout<<
"dopo riempimento variabili"<<endl;
836 for (
int i=0;
i<ncurve;
i++) indexS[
i]=
new int[nSig];
839 for (
int y=0;
y<ncurve;
y++) {
852 TMath::Sort(nSig,rhoSig[
y],indexS[y],
false);
854 for (
int k=0;
k<nSig;
k++) {
859 int ij=indexS[
y][
k-1];
861 if(rhoSig[y][ii]!=0) {
864 if(rhoSig[y][ii]!=rhoSig[y][ij]) gS[
y]->SetPoint(igS_p++,rhoSig[y][ii],yy);
865 cout<<
"igS"<<igS<<
" x "<<rhoSig[
y][ii]<<
" y: "<<yy<<endl;
870 if(rhoSig[y][ii]!=0){
872 gS[
y]->SetPoint(0,rhoSig[y][ii],yy);
883 for (
int i=0;
i<ncurve;
i++) indexB[
i]=
new int[nBg];
886 for (
int y=0;
y<ncurve;
y++) {
890 TMath::Sort(nBg,rhoBg[
y],indexB[y],
false);
892 for (
int k=0;
k<nBg;
k++) {
896 int ij=indexB[
y][
k-1];
898 if(rhoBg[y][ii]!=0) {
901 if(rhoBg[y][ii]!=rhoBg[y][ij]) gB[
y]->SetPoint(igB_p++,rhoBg[y][ii],yy);
907 if(rhoBg[y][ii]!=0) {
909 gB[
y]->SetPoint(0,rhoBg[y][ii],yy);
916 cout<<
"dopo inserimento puntiB"<<endl;
919 TCanvas* cS=
new TCanvas(
"Efficiency_vs_rho",
"Efficiency_vs_rho",0,0,1200,700);
923 TMultiGraph* mg1=
new TMultiGraph();
925 gS[0]->SetMarkerColor(2);
926 gS[0]->SetLineColor(2);
927 mg1->SetTitle(
"cc=0.5;rho;#Events");
928 if(gS[0]->GetN()!=0) mg1->Add(gS[0]);
931 gS[
h]->SetMarkerColor(3);
932 gS[
h]->SetLineColor(3);
934 if(gS[
h]->GetN()!=0) mg1->Add(gS[
h]);
940 TMultiGraph* mg2=
new TMultiGraph();
942 gS[
nANN]->SetMarkerColor(2);
943 gS[
nANN]->SetLineColor(2);
944 mg2->SetTitle(
"cc=0.55;rho;#Events");
945 if(gS[nANN]->GetN()!=0) mg2->Add(gS[nANN]);
947 gS[nANN+
h]->SetMarkerColor(3);
948 gS[nANN+
h]->SetLineColor(3);
950 if(gS[nANN+
h]->GetN()!=0) mg2->Add(gS[nANN+
h]);
956 TMultiGraph* mg3=
new TMultiGraph();
958 gS[nANN*2]->SetMarkerColor(2);
959 gS[nANN*2]->SetLineColor(2);
960 mg3->SetTitle(
"cc=0.6;rho;#Events");
961 if(gS[nANN*2]->GetN()!=0) mg3->Add(gS[nANN*2]);
963 gS[2*nANN+
h]->SetMarkerColor(3);
964 gS[2*nANN+
h]->SetLineColor(3);
966 if(gS[2*nANN+
h]->GetN()!=0) mg3->Add(gS[2*nANN+
h]);
972 TMultiGraph* mg4=
new TMultiGraph();
974 gS[nANN*3]->SetMarkerColor(2);
975 gS[nANN*3]->SetLineColor(2);
976 mg4->SetTitle(
"cc=0.65;rho;#Events");
977 if(gS[nANN*3]->GetN()!=0) mg4->Add(gS[nANN*3]);
980 gS[3*nANN+
h]->SetMarkerColor(3);
981 gS[3*nANN+
h]->SetLineColor(3);
983 if(gS[3*nANN+
h]->GetN()!=0) mg4->Add(gS[3*nANN+
h]);
987 cout<<
"nuovo canv"<<endl;
988 TCanvas* cB=
new TCanvas(
"Number_vs_rho",
"Number_vs_rho",0,0,1200,700);
990 cB->cd(1)->SetLogy();
991 TMultiGraph* mg1B=
new TMultiGraph();
993 gB[0]->SetMarkerColor(2);
994 gB[0]->SetLineColor(2);
995 mg1B->SetTitle(
"cc=0.5;rho;#Events");
996 if(gB[0]->GetN()!=0) mg1B->Add(gB[0]);
998 gB[
h]->SetMarkerColor(3);
999 gB[
h]->SetLineColor(3);
1001 if(gB[
h]->GetN()!=0) mg1B->Add(gB[
h]);
1005 cB->cd(2)->SetLogy();
1006 TMultiGraph* mg2B=
new TMultiGraph();
1008 gB[
nANN]->SetMarkerColor(2);
1009 gB[
nANN]->SetLineColor(2);
1010 mg2B->SetTitle(
"cc=0.55;rho;#Events");
1011 if(gB[nANN]->GetN()!=0) mg2B->Add(gB[nANN]);
1013 gB[nANN+
h]->SetMarkerColor(3);
1014 gB[nANN+
h]->SetLineColor(3);
1016 if(gB[nANN+
h]->GetN()!=0) mg2B->Add(gB[nANN+
h]);
1020 cB->cd(3)->SetLogy();
1021 TMultiGraph* mg3B=
new TMultiGraph();
1023 gB[2*
nANN]->SetMarkerColor(2);
1024 gB[2*
nANN]->SetLineColor(2);
1025 mg3B->SetTitle(
"cc=0.6;rho;#Events");
1026 if(gB[2*nANN]->GetN()!=0) mg3B->Add(gB[2*nANN]);
1028 gB[2*nANN+
h]->SetMarkerColor(3);
1029 gB[2*nANN+
h]->SetLineColor(3);
1031 if(gB[2*nANN+
h]->GetN()!=0) mg3B->Add(gB[2*nANN+
h]);
1035 cB->cd(4)->SetLogy();
1036 TMultiGraph* mg4B=
new TMultiGraph();
1038 gB[3*
nANN]->SetMarkerColor(2);
1039 gB[3*
nANN]->SetLineColor(2);
1040 mg4B->SetTitle(
"cc=0.65;rho;#Events");
1041 if(gB[3*nANN]->GetN()!=0) mg4B->Add(gB[3*nANN]);
1043 gB[3*nANN+
h]->SetMarkerColor(3);
1044 gB[3*nANN+
h]->SetLineColor(3);
1046 if(gB[3*nANN+
h]->GetN()!=0) mg4B->Add(gB[3*nANN+
h]);
1058 char CnameS2root[1024];
1059 char CnameB2root[1024];
1060 CnameS.ReplaceAll(
".root",
".png");
1061 CnameB.ReplaceAll(
".root",
".png");
1062 sprintf(CnameS2,
"logN_rho_av/logN_rho_S_dANN%1.2f_%s",
deltaANN,CnameS.Data());
1063 sprintf(CnameB2,
"logN_rho_av/logN_rho_B_dANN%1.2f_%s",
deltaANN,CnameB.Data());
1064 sprintf(CnameS2root,
"logN_rho_av/logN_rho_S_dANN%1.2f_%s",
deltaANN,CnameSroot.Data());
1065 sprintf(CnameB2root,
"logN_rho_av/logN_rho_B_dANN%1.2f_%s",
deltaANN,CnameBroot.Data());
1066 cS->SaveAs(CnameS2);
1067 cB->SaveAs(CnameB2);
1068 cS->Print(CnameS2root);
1069 cB->Print(CnameB2root);
1077 name.ReplaceAll(
"average_file/",
"");
1078 TFile* fTEST =TFile::Open(ifile.Data());
1079 TTree* NNTree2=(TTree*)fTEST->Get(
"Parameters");
1084 NNTree2->SetBranchAddress(
"Average",&av);
1085 NNTree2->SetBranchAddress(
"cc",&cc);
1086 NNTree2->SetBranchAddress(
"rho",&rho);
1087 NNTree2->SetBranchAddress(
"#TestSig",&nSi);
1088 NNTree2->GetEntry(0);
1090 cout<<
"nSig: "<<nSig<<
" nSi: "<<nSi<<endl;
1094 double* ANNSig[ncurve2];
1095 for (
int i=0;
i<ncurve2;
i++) ANNSig[
i]=
new double[nSig];
1099 int const nBg=NNTree2->GetEntries()-nSig;
1100 for (
int i=0;
i<ncurve2;
i++) {
1102 for (
int j=0;
j<nSig;
j++) ANNSig[
i][
j]=0.;
1104 double* ANNBg[ncurve2];
1105 for (
int i=0;
i<ncurve2;
i++) ANNBg[
i]=
new double[nBg];
1109 for (
int i=0;
i<ncurve2;
i++) {
1111 for (
int j=0;
j<nBg;
j++) ANNBg[
i][
j]=0.;
1114 for (
int i=0;
i<
nCC;
i++) ccTh[
i]=0.;
1116 for (
int i=0;
i<
nRHO;
i++) rhoTh[
i]=0.;
1123 for(
int n=0;
n<NNTree2->GetEntries();
n++){
1124 NNTree2->GetEntry(
n);
1125 cout<<
"rho "<<rho<<
" cc "<<cc<<
" av "<<av<<endl;
1129 if(cc<ccTh[
i])
continue;
1133 if(rho<rhoTh[
j])
continue;
1136 NBg[i*nRHO+
j]= NBg[i*nRHO+
j]+1;
1137 if(i*nRHO+j==0) cout<<
" NBg[i*nRHO+j] "<<NBg[i*nRHO+
j]<<endl;
1138 while(ANNBg[i*nRHO+j][ni]!=0)ni=ni+1;
1139 ANNBg[i*nRHO+
j][ni]=av;
1144 NSig[i*nRHO+
j]= NSig[i*nRHO+
j]+1;
1145 if(i*nRHO+j==0) cout<<
" NSig[i*nRHO+j] "<<NSig[i*nRHO+
j]<<endl;
1146 while(ANNSig[i*nRHO+j][ni]!=0)ni=ni+1;
1147 ANNSig[i*nRHO+
j][ni]=av;
1153 int* indexS[ncurve2];
1154 for (
int i=0;
i<ncurve2;
i++) indexS[
i]=
new int[nSig];
1156 TGraph * gS[ncurve2];
1157 for (
int y=0;
y<ncurve2;
y++) {
1161 TMath::Sort(nSig,ANNSig[
y],indexS[y],
false);
1162 for (
int k=0;
k<nSig;
k++) {
1163 int ii=indexS[
y][
k];
1167 int ij=indexS[
y][
k-1];
1169 if(ANNSig[y][ii]!=0) {
1172 if(ANNSig[y][ii]!=ANNSig[y][ij]) gS[
y]->SetPoint(igS_p++,ANNSig[y][ii],yy);
1179 if(ANNSig[y][ii]!=0){
1181 gS[
y]->SetPoint(0,ANNSig[y][ii],yy);
1192 int* indexB[ncurve2];
1193 for (
int i=0;
i<ncurve2;
i++) indexB[
i]=
new int[nBg];
1195 TGraph * gB[ncurve2];
1196 for (
int y=0;
y<ncurve2;
y++) {
1200 TMath::Sort(nBg,ANNBg[
y],indexB[y],
false);
1202 for (
int k=0;
k<nBg;
k++) {
1203 int ii=indexB[
y][
k];
1204 int ik=indexB[
y][
k-1];
1207 int ij=indexB[
y][
k-1];
1209 if(ANNBg[y][ii]!=0) {
1211 if(y==0 && yy==FAth_n+1) {thresFA=ANNBg[
y][ii];}
1212 if (y==0 && yy<FAth_n+1)
if(ANNBg[y][ii]==ANNBg[y][ik]){FAth_n=FAth_n-1;}
1213 if(y==0) cout<<
"yy "<<yy<<
" y "<<y<<
" FAth_n "<<FAth_n<<
" thresFA "<<thresFA<<
" ANNBg[y][ii] "<<ANNBg[
y][ii]<<endl;
1215 if(ANNBg[y][ii]!=ANNBg[y][ij]) gB[
y]->SetPoint(igB_p++,ANNBg[y][ii],yy);
1221 if(ANNBg[y][ii]!=0) {
1223 gB[
y]->SetPoint(0,ANNBg[y][ii],yy);
1234 for(
int ni=1;ni<nSig;ni++){
1235 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;
1237 if (ANNSig[0][indexS[0][ni]]<=thresFA) FDth_n=FDth_n+1;
1242 TCanvas* cS=
new TCanvas(
"Efficiency_vs_ANN",
"Efficiency_vs_ANN",0,0,1200,700);
1246 TMultiGraph* mg1=
new TMultiGraph();
1247 mg1->SetTitle(
"cc: no_cut;ANN;#Events");
1249 gS[
h]->SetLineColor(4);
1250 if(gS[
h]->GetN()!=0) mg1->Add(gS[
h]);
1255 TMultiGraph* mg2=
new TMultiGraph();
1256 mg2->SetTitle(
"cc=0.55;ANN;#Events");
1258 gS[nRHO+
h]->SetLineColor(4);
1259 if(gS[nRHO+
h]->GetN()!=0) mg2->Add(gS[nRHO+
h]);
1265 TMultiGraph* mg3=
new TMultiGraph();
1266 mg3->SetTitle(
"cc=0.6;ANN;#Events");
1268 gS[2*nRHO+
h]->SetLineColor(4);
1269 if(gS[2*nRHO+
h]->GetN()!=0) mg3->Add(gS[2*nRHO+
h]);
1274 TMultiGraph* mg4=
new TMultiGraph();
1275 mg4->SetTitle(
"cc=0.65;ANN;#Events");
1277 gS[3*nRHO+
h]->SetLineColor(4);
1278 if(gS[3*nRHO+
h]->GetN()!=0) mg4->Add(gS[3*nRHO+
h]);
1282 TCanvas* cB=
new TCanvas(
"Number_vs_ANN",
"Number_vs_ANN",0,0,1200,700);
1284 cB->cd(1)->SetLogy();
1285 TMultiGraph* mg1B=
new TMultiGraph();
1286 mg1B->SetTitle(
"cc: no_cut;ANN;#Events");
1288 gB[
h]->SetLineColor(4);
1289 if(gB[
h]->GetN()!=0) mg1B->Add(gB[
h]);
1292 cB->cd(2)->SetLogy();
1293 TMultiGraph* mg2B=
new TMultiGraph();
1294 mg2B->SetTitle(
"cc=0.55;ANN;#Events");
1296 gB[nRHO+
h]->SetLineColor(4);
1297 if(gB[nRHO+
h]->GetN()!=0) mg2B->Add(gB[nRHO+
h]);
1300 cB->cd(3)->SetLogy();
1301 TMultiGraph* mg3B=
new TMultiGraph();
1302 mg3B->SetTitle(
"cc=0.6;ANN;#Events");
1304 gB[2*nRHO+
h]->SetLineColor(4);
1305 if(gB[2*nRHO+
h]->GetN()!=0) mg3B->Add(gB[2*nRHO+
h]);
1308 cB->cd(4)->SetLogy();
1309 TMultiGraph* mg4B=
new TMultiGraph();
1310 mg4B->SetTitle(
"cc=0.65;ANN;#Events");
1312 gB[3*nRHO+
h]->SetLineColor(4);
1313 if(gB[3*nRHO+
h]->GetN()!=0) mg4B->Add(gB[3*nRHO+
h]);
1325 char CnameS2root[1024];
1326 char CnameB2root[1024];
1327 CnameS.ReplaceAll(
".root",
".png");
1328 CnameB.ReplaceAll(
".root",
".png");
1329 sprintf(CnameS2,
"ANNthres_av/N_ANN_S_%s",CnameS.Data());
1330 sprintf(CnameB2,
"ANNthres_av/N_ANN_B_%s",CnameB.Data());
1331 sprintf(CnameS2root,
"ANNthres_av/N_ANN_S_%s",CnameSroot.Data());
1332 sprintf(CnameB2root,
"ANNthres_av/N_ANN_B_%s",CnameBroot.Data());
1333 cS->SaveAs(CnameS2);
1334 cB->SaveAs(CnameB2);
1335 cS->Print(CnameS2root);
1336 cB->Print(CnameB2root);
1347 name.ReplaceAll(
"outfile/",
"");
1348 name.ReplaceAll(
"average_file/",
"");
1349 TFile* fTEST =TFile::Open(ifile.Data());
1350 TTree* NNTree2=(TTree*)fTEST->Get(
"Parameters");
1360 NNTree2->SetBranchAddress(
"Mchirp",&Mc);
1361 NNTree2->SetBranchAddress(
"Average",&av);
1362 NNTree2->SetBranchAddress(
"cc",&cc);
1363 NNTree2->SetBranchAddress(
"rho",&rho);
1364 NNTree2->SetBranchAddress(
"Mchirp_injected",&Mc_inj);
1365 NNTree2->SetBranchAddress(
"#TestSig",&nSi);
1366 NNTree2->GetEntry(0);
1368 cout<<
"nSig: "<<nSig<<
" nSi: "<<nSi<<endl;
1371 double* McSig[ncurve2];
1372 for (
int i=0;
i<ncurve2;
i++) McSig[
i]=
new double[nSig];
1376 int const nBg=NNTree2->GetEntries()-nSig;
1377 for (
int i=0;
i<ncurve2;
i++) {
1379 for (
int j=0;
j<nSig;
j++) McSig[
i][
j]=0.;
1381 double* McBg[ncurve2];
1382 for (
int i=0;
i<ncurve2;
i++) McBg[
i]=
new double[nBg];
1386 for (
int i=0;
i<ncurve2;
i++) {
1388 for (
int j=0;
j<nBg;
j++) McBg[
i][
j]=0.;
1391 for (
int i=0;
i<
nCC;
i++) ccTh[
i]=0.;
1393 for (
int i=0;
i<
nRHO;
i++) rhoTh[
i]=0.;
1399 for(
int n=0;
n<NNTree2->GetEntries();
n++){
1400 NNTree2->GetEntry(
n);
1401 cout<<
"rho "<<rho<<
" cc "<<cc<<
" av "<<av<<endl;
1405 if(cc<ccTh[
i])
continue;
1409 if(rho<rhoTh[
j])
continue;
1412 NBg[i*nRHO+
j]= NBg[i*nRHO+
j]+1;
1413 if(i*nRHO+j==0) cout<<
" NBg[i*nRHO+j] "<<NBg[i*nRHO+
j]<<endl;
1414 while(McBg[i*nRHO+j][ni]!=0)ni=ni+1;
1415 McBg[i*nRHO+
j][ni]=Mc;
1420 NSig[i*nRHO+
j]= NSig[i*nRHO+
j]+1;
1421 if(i*nRHO+j==0) cout<<
" NSig[i*nRHO+j] "<<NSig[i*nRHO+
j]<<endl;
1422 while(McSig[i*nRHO+j][ni]!=0)ni=ni+1;
1423 McSig[i*nRHO+
j][ni]=Mc;
1430 int* indexS[ncurve2];
1431 for (
int i=0;
i<ncurve2;
i++) indexS[
i]=
new int[nSig];
1433 TGraph * gS[ncurve2];
1434 for (
int y=0;
y<ncurve2;
y++) {
1438 TMath::Sort(nSig,McSig[
y],indexS[y],
false);
1439 for (
int k=0;
k<nSig;
k++) {
1440 int ii=indexS[
y][
k];
1444 int ij=indexS[
y][
k-1];
1446 if(McSig[y][ii]!=0) {
1449 if(McSig[y][ii]!=McSig[y][ij]) gS[
y]->SetPoint(igS_p++,McSig[y][ii],yy);
1456 if(McSig[y][ii]!=0){
1458 gS[
y]->SetPoint(0,McSig[y][ii],yy);
1468 int* indexB[ncurve2];
1469 for (
int i=0;
i<ncurve2;
i++) indexB[
i]=
new int[nBg];
1471 TGraph * gB[ncurve2];
1472 for (
int y=0;
y<ncurve2;
y++) {
1476 TMath::Sort(nBg,McBg[
y],indexB[y],
false);
1478 for (
int k=0;
k<nBg;
k++) {
1479 int ii=indexB[
y][
k];
1480 int ik=indexB[
y][
k-1];
1483 int ij=indexB[
y][
k-1];
1485 if(McBg[y][ii]!=0) {
1487 if(y==0 && yy==McFAth_n+1) {McthresFA=McBg[
y][ii];
1489 if (y==0 && yy<McFAth_n+1) { cout<<
"dentro primo if"<<endl;
1491 if(McBg[y][ii]>McBg[y][ik]){McFAth_n=McFAth_n;cout<<
"maggiore ii "<<
" diff"<<(McBg[
y][ii]-McBg[
y][ik])<<endl;}
1492 if(McBg[y][ii]<McBg[y][ik]){McFAth_n=McFAth_n;cout<<
"minore ii"<<endl;}
1493 if(McBg[y][ii]==McBg[y][ik]){McFAth_n=McFAth_n-1;cout<<
"uguale"<<endl;}
1496 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;
1498 if(McBg[y][ii]!=McBg[y][ij]) gB[
y]->SetPoint(igB_p++,McBg[y][ii],yy);
1504 if(McBg[y][ii]!=0) {
1506 gB[
y]->SetPoint(0,McBg[y][ii],yy);
1515 for(
int ni=1;ni<nSig;ni++){
1516 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;
1518 if (McSig[0][indexS[0][ni]]<=McthresFA) McFDth_n=McFDth_n+1;
1522 TCanvas* cS=
new TCanvas(
"Efficiency_vs_Mchirp",
"Efficiency_vs_Mchirp",0,0,1200,700);
1526 TMultiGraph* mg1=
new TMultiGraph();
1527 mg1->SetTitle(
"cc: no_cut;Mchirp;#Events");
1529 gS[
h]->SetLineColor(4);
1530 if(gS[
h]->GetN()!=0) mg1->Add(gS[
h]);
1535 TMultiGraph* mg2=
new TMultiGraph();
1536 mg2->SetTitle(
"cc=0.55;Mchirp;#Events");
1538 gS[nRHO+
h]->SetLineColor(4);
1539 if(gS[nRHO+
h]->GetN()!=0) mg2->Add(gS[nRHO+
h]);
1545 TMultiGraph* mg3=
new TMultiGraph();
1546 mg3->SetTitle(
"cc=0.6;Mchirp;#Events");
1548 gS[2*nRHO+
h]->SetLineColor(4);
1549 if(gS[2*nRHO+
h]->GetN()!=0) mg3->Add(gS[2*nRHO+
h]);
1554 TMultiGraph* mg4=
new TMultiGraph();
1555 mg4->SetTitle(
"cc=0.65;Mchirp;#Events");
1557 gS[3*nRHO+
h]->SetLineColor(4);
1558 if(gS[3*nRHO+
h]->GetN()!=0) mg4->Add(gS[3*nRHO+
h]);
1562 TCanvas* cB=
new TCanvas(
"Number_vs_Mchirp",
"Number_vs_Mchirp",0,0,1200,700);
1564 cB->cd(1)->SetLogy();
1565 TMultiGraph* mg1B=
new TMultiGraph();
1566 mg1B->SetTitle(
"cc: no_cut;Mchirp;#Events");
1568 gB[
h]->SetLineColor(4);
1569 if(gB[
h]->GetN()!=0) mg1B->Add(gB[
h]);
1572 cB->cd(2)->SetLogy();
1573 TMultiGraph* mg2B=
new TMultiGraph();
1574 mg2B->SetTitle(
"cc=0.55;Mchirp;#Events");
1576 gB[nRHO+
h]->SetLineColor(4);
1577 if(gB[nRHO+
h]->GetN()!=0) mg2B->Add(gB[nRHO+
h]);
1580 cB->cd(3)->SetLogy();
1581 TMultiGraph* mg3B=
new TMultiGraph();
1582 mg3B->SetTitle(
"cc=0.6;Mchirp;#Events");
1584 gB[2*nRHO+
h]->SetLineColor(4);
1585 if(gB[2*nRHO+
h]->GetN()!=0) mg3B->Add(gB[2*nRHO+
h]);
1588 cB->cd(4)->SetLogy();
1589 TMultiGraph* mg4B=
new TMultiGraph();
1590 mg4B->SetTitle(
"cc=0.6;Mchirp;#Events");
1592 gB[3*nRHO+
h]->SetLineColor(4);
1593 if(gB[3*nRHO+
h]->GetN()!=0) mg4B->Add(gB[3*nRHO+
h]);
1604 char CnameS2root[1024];
1605 char CnameB2root[1024];
1606 CnameS.ReplaceAll(
".root",
".png");
1607 CnameB.ReplaceAll(
".root",
".png");
1608 sprintf(CnameS2,
"Mcthres/N_Mc_S_%s",CnameS.Data());
1609 sprintf(CnameB2,
"Mcthres/N_Mc_B_%s",CnameB.Data());
1610 sprintf(CnameS2root,
"Mcthres/N_Mc_S_%s",CnameSroot.Data());
1611 sprintf(CnameB2root,
"Mcthres/N_Mc_B_%s",CnameBroot.Data());
1612 cS->SaveAs(CnameS2);
1613 cB->SaveAs(CnameB2);
1614 cS->Print(CnameS2root);
1615 cB->Print(CnameB2root);
1622 name.ReplaceAll(
"outfile/",
"");
1623 name.ReplaceAll(
"average_file/",
"");
1624 TFile* fTEST =TFile::Open(ifile.Data());
1625 TTree* NNTree2=(TTree*)fTEST->Get(
"Parameters");
1633 NNTree2->SetBranchAddress(
"Average",&av);
1634 NNTree2->SetBranchAddress(
"cc",&cc);
1635 NNTree2->SetBranchAddress(
"rho",&rho);
1636 NNTree2->SetBranchAddress(
"#TestSig",&nSi);
1637 NNTree2->GetEntry(0);
1639 cout<<
"nSig: "<<nSig<<
" nSi: "<<nSi<<endl;
1640 int const nBg=NNTree2->GetEntries()-nSig;
1641 cout<<
"nBg: "<<nBg<<
" Entries: "<<NNTree2->GetEntries()<<endl;
1648 for (
int n = 0;
n <NNTree2->GetEntries();
n++){
1649 NNTree2->GetEntry(
n);
1651 gS[0]->SetPoint(
n,cc,av);
1652 cout<<
"Sig_graph1: x="<<cc<<
" y: "<<av<<endl;
1655 gB[0]->SetPoint(
n-nSig,cc,av);
1656 cout<<
"Bg_graph1: x="<<cc<<
" y: "<<av<<endl;
1677 gS[0]->SetMarkerColor(2);
1678 gB[0]->SetMarkerColor(4);
1679 gS[0]->SetMarkerStyle(6);
1680 gB[0]->SetMarkerStyle(7);
1682 TCanvas*
c=
new TCanvas(
"Plots",
"Plots",0,0,1200,700);
1685 TMultiGraph* mg1=
new TMultiGraph();
1686 mg1->SetTitle(
"Av_cc");
1687 if(gB[0]->GetN()!=0) mg1->Add(gB[0]);
1688 if(gS[0]->GetN()!=0) mg1->Add(gS[0]);
1690 mg1->GetHistogram()->GetXaxis()->SetTitle(
"cc");
1691 mg1->GetHistogram()->GetYaxis()->SetTitle(
"Average on ANN ouputs");
1694 TMultiGraph* mg2=
new TMultiGraph();
1695 mg2->SetTitle(
"Av_cc");
1696 if(gS[0]->GetN()!=0) mg2->Add(gS[0]);
1697 if(gB[0]->GetN()!=0) mg2->Add(gB[0]);
1699 mg2->GetHistogram()->GetXaxis()->SetTitle(
"cc");
1700 mg2->GetHistogram()->GetYaxis()->SetTitle(
"Average on ANN ouputs");
1702 cout<<
" name "<<name<<endl;
1706 char Cname2root[1024];
1707 Cname.ReplaceAll(
".root",
".png");
1708 sprintf(Cname2,
"average_png/out_Plots_%s",Cname.Data());
1709 sprintf(Cname2root,
"average_png/out_Plots_%s",Cnameroot.Data());
1711 c->Print(Cname2root);
1749 name.ReplaceAll(
"outfile/",
"");
1750 name.ReplaceAll(
"average_file/",
"");
1751 TFile* fTEST =TFile::Open(ifile.Data());
1752 TTree* NNTree2=(TTree*)fTEST->Get(
"Parameters");
1762 NNTree2->SetBranchAddress(
"Mchirp",&Mc);
1763 NNTree2->SetBranchAddress(
"Average",&av);
1764 NNTree2->SetBranchAddress(
"cc",&cc);
1765 NNTree2->SetBranchAddress(
"rho",&rho);
1766 NNTree2->SetBranchAddress(
"Mchirp_injected",&Mc_inj);
1767 NNTree2->SetBranchAddress(
"#TestSig",&nSi);
1768 NNTree2->GetEntry(0);
1770 cout<<
"nSig: "<<nSig<<
" nSi: "<<nSi<<endl;
1772 int const nBg=NNTree2->GetEntries()-nSig;
1780 TCanvas* ANN_Mc_c3D=
new TCanvas(
"ANN_average_vs_Mc_reconstructed",
"ANN_average_vs_Mc_reconstructed",0,0,1200,700);
1781 ANN_Mc_c3D->Divide(1,2);
1785 ANN_Mc_BKG3D->SetDirectory(0);
1786 ANN_Mc_BKG3D->SetStats(0);
1787 ANN_Mc_SIG3D->SetDirectory(0);
1788 ANN_Mc_SIG3D->SetStats(0);
1790 TCanvas* ANN_cc_c3D=
new TCanvas(
"ANN_average_vs_cc",
"ANN_average_vs_cc",0,0,1200,700);
1791 ANN_cc_c3D->Divide(1,2);
1794 ANN_cc_SIG3D->SetDirectory(0);
1795 ANN_cc_SIG3D->SetStats(0);
1796 ANN_cc_BKG3D->SetDirectory(0);
1797 ANN_cc_BKG3D->SetStats(0);
1802 TCanvas* Mc_inj_c=
new TCanvas(
"ANN_vs_Mc_injected",
"ANN_vs_Mc_injected",0,0,1200,700);
1803 Mc_inj_c->Divide(1,2);
1807 Mc_inj_gMc->SetDirectory(0);
1808 Mc_inj_gMc->SetStats(0);
1809 Mc_inj_g->SetDirectory(0);
1810 Mc_inj_g->SetStats(0);
1811 double deltaMc_inj=0;
1813 double deltaANN_av_M=0;
1820 txt_name0.ReplaceAll(
".root",
".txt");
1821 char txt_name[1024];
1822 sprintf(txt_name,
"txt_files/%s",txt_name0.Data());
1823 ofstream file_txt_out(txt_name);
1829 for (
int n = 0;
n <NNTree2->GetEntries();
n++){
1830 NNTree2->GetEntry(
n);
1832 if(
n<nSig&&
n!=nSig) {
1833 Mc_inj_gMc->Fill(Mc_inj,Mc);
1834 Mc_inj_g->Fill(Mc_inj,av);
1835 gS[0]->SetPoint(
n,Mc,av);
1836 cout<<
" n "<<
n<<
" Mc "<<Mc<<
" av "<<av<<
" M_inj "<<Mc_inj<<endl;
1837 cout<<
"Sig_graph1: x="<<cc<<
" y: "<<av<<endl;
1839 ANN_Mc_SIG3D->Fill(Mc,av);
1840 ANN_cc_SIG3D->Fill(cc,av);
1841 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);
1843 cout<<
" n "<<
n<<
" nSig "<<nSig<<endl;
1847 gB[0]->SetPoint(
n-nSig,Mc,av);
1848 ANN_Mc_BKG3D->Fill(Mc,av);
1849 ANN_cc_BKG3D->Fill(cc,av);
1851 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);
1859 gS[0]->SetMarkerColor(2);
1860 gB[0]->SetMarkerColor(4);
1861 gS[0]->SetMarkerStyle(6);
1862 gB[0]->SetMarkerStyle(7);
1865 ANN_Mc_SIG3D->GetXaxis()->SetTitle(
"SIG:Mchirp_reconstructed");
1866 ANN_Mc_SIG3D->GetYaxis()->SetTitle(
"SIG:ANN_average");
1867 ANN_Mc_SIG3D->GetZaxis()->SetTitle(
"count");
1868 ANN_Mc_SIG3D->Draw(
"colz");
1870 ANN_Mc_BKG3D->GetXaxis()->SetTitle(
"BKG:Mchirp_reconstructed");
1871 ANN_Mc_BKG3D->GetYaxis()->SetTitle(
"BKG:ANN_average");
1872 ANN_Mc_BKG3D->GetZaxis()->SetTitle(
"count");
1873 ANN_Mc_BKG3D->Draw(
"colz");
1877 TString ANN_Mc_rootname3D(name);
1878 char ANN_Mc_cname23D[1024];
1879 char ANN_Mc_crootname23D[1024];
1880 ANN_Mc_name3D.ReplaceAll(
".root",
".png");
1881 sprintf(ANN_Mc_cname23D,
"average_png/nSig%i_nBg%i_3DMc_ANNav_Plots_%s",nSig,nBg,ANN_Mc_name3D.Data());
1882 sprintf(ANN_Mc_crootname23D,
"average_png/nSig%i_nBg%i_3DMc_ANNav_Plots_%s",nSig,nBg,ANN_Mc_rootname3D.Data());
1883 ANN_Mc_c3D->SaveAs(ANN_Mc_cname23D);
1884 ANN_Mc_c3D->Print(ANN_Mc_crootname23D);
1888 ANN_cc_SIG3D->GetXaxis()->SetTitle(
"SIG:cc");
1889 ANN_cc_SIG3D->GetYaxis()->SetTitle(
"SIG:ANN_average");
1890 ANN_cc_SIG3D->GetZaxis()->SetTitle(
"count");
1891 ANN_cc_SIG3D->Draw(
"colz");
1893 ANN_cc_BKG3D->GetXaxis()->SetTitle(
"BKG:cc");
1894 ANN_cc_BKG3D->GetYaxis()->SetTitle(
"BKG:ANN_average");
1895 ANN_cc_BKG3D->GetZaxis()->SetTitle(
"count");
1896 ANN_cc_BKG3D->Draw(
"colz");
1900 TString ANN_cc_crootname3D(name);
1901 char ANN_cc_cname23D[1024];
1902 char ANN_cc_crootname23D[1024];
1903 ANN_cc_cname3D.ReplaceAll(
".root",
".png");
1904 sprintf(ANN_cc_cname23D,
"average_png/nSig%i_nBg%i_3DANNav_cc_Plots_%s",nSig,nBg,ANN_cc_cname3D.Data());
1905 sprintf(ANN_cc_crootname23D,
"average_png/nSig%i_nBg%i_3DANNav_cc_Plots_%s",nSig,nBg,ANN_cc_crootname3D.Data());
1906 ANN_cc_c3D->SaveAs(ANN_cc_cname23D);
1907 ANN_cc_c3D->Print(ANN_cc_crootname23D);
1910 Mc_inj_g->GetXaxis()->SetTitle(
"Mchirp_injected");
1911 Mc_inj_g->GetYaxis()->SetTitle(
"ANN_average");
1912 Mc_inj_g->GetZaxis()->SetTitle(
"count");
1913 Mc_inj_g->Draw(
"colz");
1915 Mc_inj_gMc->GetXaxis()->SetTitle(
"Mchirp_injected");
1916 Mc_inj_gMc->GetYaxis()->SetTitle(
"Mchirp_reconstructed");
1917 Mc_inj_gMc->GetZaxis()->SetTitle(
"count");
1918 Mc_inj_gMc->Draw(
"colz");
1922 TString Mc_inj_crootname(name);
1923 char Mc_inj_cname2[1024];
1924 char Mc_inj_crootname2[1024];
1925 Mc_inj_cname.ReplaceAll(
".root",
".png");
1926 sprintf(Mc_inj_cname2,
"average_png/nSig%i_nBg%i_Mc_inj_Plots_%s",nSig,nBg,Mc_inj_cname.Data());
1927 sprintf(Mc_inj_crootname2,
"average_png/nSig%i_nBg%i_Mc_inj_Plots_%s",nSig,nBg,Mc_inj_crootname.Data());
1928 Mc_inj_c->SaveAs(Mc_inj_cname2);
1929 Mc_inj_c->Print(Mc_inj_crootname2);
1932 TCanvas*
c=
new TCanvas(
"Plots",
"Plots",0,0,1200,700);
1935 TMultiGraph* mg1=
new TMultiGraph();
1936 mg1->SetTitle(
"Av_Mc");
1937 if(gB[0]->GetN()!=0) mg1->Add(gB[0]);
1938 if(gS[0]->GetN()!=0) mg1->Add(gS[0]);
1940 mg1->GetHistogram()->GetXaxis()->SetTitle(
"Mchirp");
1941 mg1->GetHistogram()->GetYaxis()->SetTitle(
"Average on ANN ouputs");
1943 TMultiGraph* mg2=
new TMultiGraph();
1944 mg2->SetTitle(
"Av_Mc");
1945 if(gS[0]->GetN()!=0) mg2->Add(gS[0]);
1946 if(gB[0]->GetN()!=0) mg2->Add(gB[0]);
1948 mg2->GetHistogram()->GetXaxis()->SetTitle(
"Mchirp");
1949 mg2->GetHistogram()->GetYaxis()->SetTitle(
"Average on ANN ouputs");
1951 cout<<
" name "<<name<<endl;
1955 char Cname2root[1024];
1956 Cname.ReplaceAll(
".root",
".png");
1957 sprintf(Cname2,
"average_png/nSig%i_nBg%i_Mc_Plots_%s",nSig,nBg,Cname.Data());
1958 sprintf(Cname2root,
"average_png/nSig%i_nBg%i_Mc_Plots_%s",nSig,nBg,Cnameroot.Data());
1959 cout<<
"Cname2 "<<Cname2<<endl;
1961 c->Print(Cname2root);
1962 cout<<
" gS[0]->GetN() "<<gS[0]->GetN()<<endl;
1964 cout<<
" nSig "<<nSig<<
" nBg "<<nBg<<
" aa1 "<<aa1<<endl;
1971 name.ReplaceAll(
"outfile/",
"");
1972 name.ReplaceAll(
"average_file/",
"");
1973 TFile* fTEST =TFile::Open(ifile.Data());
1974 TTree* NNTree2=(TTree*)fTEST->Get(
"Parameters");
1982 NNTree2->SetBranchAddress(
"Mchirp",&Mc);
1983 NNTree2->SetBranchAddress(
"Average",&av);
1984 NNTree2->SetBranchAddress(
"cc",&cc);
1985 NNTree2->SetBranchAddress(
"rho",&rho);
1986 NNTree2->SetBranchAddress(
"Mchirp_injected",&Mc_inj);
1987 NNTree2->SetBranchAddress(
"#TestSig",&nSi);
1988 NNTree2->GetEntry(0);
1990 cout<<
"nSig: "<<nSig<<
" nSi: "<<nSi<<endl;
1991 int const nBg=NNTree2->GetEntries()-nSig;
1992 int const nTot=NNTree2->GetEntries();
1994 int nBgSur[3][n_points];
1995 int nSigSur[3][n_points];
1996 double zax[3][n_points];
1998 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.;}
2013 double deltaANNth=0.;
2014 double deltaRHOth=0.;
2020 TCanvas* SNR_c=
new TCanvas(
"SIG-BKG_reduction",
"SIG-BKG_reduction",0,0,1200,700);
2026 SNR3Dcc0->SetDirectory(0);
2027 SNR3Dcc0->SetStats(0);
2028 SNR3Dcc1->SetDirectory(0);
2029 SNR3Dcc1->SetStats(0);
2030 SNR3Dcc2->SetDirectory(0);
2031 SNR3Dcc2->SetStats(0);
2033 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;}
2034 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;}
2036 cout<<
"fino def cose"<<endl;
2071 for (
int u=0; u<nTot; u++){
2072 NNTree2->GetEntry(u);
2073 for (
int y=0;
y<3;
y++){
2079 if(u<nSig) nSigSur[
y][j+N_ANNth*
i]=nSigSur[
y][j+N_ANNth*
i]+1;
2080 else nBgSur[
y][j+N_ANNth*
i]=nBgSur[
y][j+N_ANNth*
i]+1;
2095 nBgSur0=nBgSur[0][0];
2097 nSigSur0=nSigSur[0][0];
2098 if(nBgSur0==0){nBgSur0=nBg;}
2099 if(nSigSur0==0){nSigSur0=nSig;}
2101 cout<<
"dopo ciclo"<<
" nSigSur0 "<<nSigSur0<<
" nBgSur0 "<<nBgSur0<<endl;
2105 if(nSigSur[u][
i+
j*N_ANNth]==0) {
2106 if (nSigSur[u][
i+
j*N_ANNth]==0 && nBgSur[u][
i+
j*N_ANNth]==0) zax[u][
i+
j*
N_ANNth]=-1;
2112 num=(double)nBgSur[u][
i+
j*N_ANNth]/nBgSur0;
2113 den=(double)nSigSur0/nSigSur[u][
i+
j*N_ANNth];
2114 zax[u][
i+
j*
N_ANNth]=(double)num/den; count_zax=count_zax+1;
2115 cout<<(double)(nBgSur[u][
i+
j*N_ANNth]/nBgSur0)*(nSigSur0/nSigSur[u][
i+
j*
N_ANNth])<<endl;
2123 SNR3Dcc0->Fill(pANNth[
i]+ deltaANNth/2.,pRHOth[
j]+ deltaRHOth/2.,zax[0][
i+
j*N_ANNth]);
2124 SNR3Dcc1->Fill(pANNth[
i]+ deltaANNth/2.,pRHOth[
j]+ deltaRHOth/2.,zax[1][
i+
j*N_ANNth]);
2125 SNR3Dcc2->Fill(pANNth[
i]+ deltaANNth/2.,pRHOth[
j]+ deltaRHOth/2.,zax[2][
i+
j*N_ANNth]);
2128 for(
int yy=0;
yy<3;
yy++) {
2129 cout<<
" pCCth "<<pCCth[
yy]<<endl;
2130 for (
int ii=N_ANNth-1; ii>-1; ii--) {
2131 cout<<
" pANNth[i] "<<pANNth[ii]<<endl;
2132 for (
int jj=N_RHOth-1; jj>-1;jj--){
2133 cout<<
" pRHOth[jj] "<<pRHOth[jj]<<endl;
2134 cout<<
" nBgSur[yy][ii+N_ANNth*jj] "<<nBgSur[
yy][ii+N_ANNth*jj]<<endl;
2135 cout<<
" nSigSur[yy][ii+N_ANNth*jj] "<<nSigSur[
yy][ii+N_ANNth*jj]<<endl;
2136 cout<<
" zax[0][i+j*N_ANNth]"<<zax[
yy][ii+jj*
N_ANNth]<<endl;
2137 cout<<
" (double)(nBgSur[u][i+j*N_ANNth]/nBgSur0)"<<(double)nBgSur[
yy][ii+jj*N_ANNth]/nBgSur0<<endl;
2142 cout<<
"coutn_zax "<<count_zax<<endl;
2144 SNR3Dcc0->GetXaxis()->SetTitle(
"ANN_average_thresholds");
2145 SNR3Dcc0->GetYaxis()->SetTitle(
"RHO_thresholds");
2146 SNR3Dcc0->GetZaxis()->SetTitle(
"normBKG/normSIG");
2147 SNR3Dcc0->Draw(
"colz");
2150 SNR3Dcc1->GetXaxis()->SetTitle(
"ANN_average_thresholds");
2151 SNR3Dcc1->GetYaxis()->SetTitle(
"RHO_thresholds");
2152 SNR3Dcc1->GetZaxis()->SetTitle(
"normBKG/normSIG");
2153 SNR3Dcc1->Draw(
"colz");
2156 SNR3Dcc2->GetXaxis()->SetTitle(
"ANN_average_thresholds");
2157 SNR3Dcc2->GetYaxis()->SetTitle(
"RHO_thresholds");
2158 SNR3Dcc2->GetZaxis()->SetTitle(
"normBKG/normSIG");
2159 SNR3Dcc2->Draw(
"colz");
2164 char SNR_c_nroot[1024];
2165 SNR_n.ReplaceAll(
".root",
".png");
2166 sprintf(SNR_c_n,
"SNR_plots/nSig%i_nBg%i_invSNR_Plots_%s",nSig,nBg,SNR_n.Data());
2167 sprintf(SNR_c_nroot,
"SNR_plots/nSig%i_nBg%i_invSNR_Plots_%s",nSig,nBg,SNR_nroot.Data());
2168 SNR_c->SaveAs(SNR_c_n);
2169 SNR_c->Print(SNR_c_nroot);
2177 name.ReplaceAll(
"outfile/",
"");
2178 name.ReplaceAll(
"average_file/",
"");
2179 TFile* fTEST =TFile::Open(ifile.Data());
2180 TTree* NNTree2=(TTree*)fTEST->Get(
"Parameters");
2189 NNTree2->SetBranchAddress(
"Center_of_Gravity",&CoG);
2190 NNTree2->SetBranchAddress(
"Mchirp",&Mc);
2191 NNTree2->SetBranchAddress(
"Average",&av);
2192 NNTree2->SetBranchAddress(
"cc",&cc);
2193 NNTree2->SetBranchAddress(
"rho",&rho);
2194 NNTree2->SetBranchAddress(
"Mchirp_injected",&Mc_inj);
2195 NNTree2->SetBranchAddress(
"#TestSig",&nSi);
2196 NNTree2->GetEntry(0);
2198 cout<<
"nSig: "<<nSig<<
" nSi: "<<nSi<<endl;
2199 int const nTot=NNTree2->GetEntries();
2200 int const nBg=nTot-nSig;
2202 TCanvas* CoG_c=
new TCanvas(
"SIG-BKG_reduction",
"SIG-BKG_reduction",0,0,1200,700);
2210 CoG1Sig->SetDirectory(0);
2211 CoG1Sig->SetStats(0);
2212 CoG0Sig->SetDirectory(0);
2213 CoG0Sig->SetStats(0);
2214 CoG1Bg->SetDirectory(0);
2215 CoG1Bg->SetStats(0);
2216 CoG0Bg->SetDirectory(0);
2217 CoG0Bg->SetStats(0);
2219 for (
int n=0;
n<nTot;
n++){
2220 NNTree2->GetEntry(
n);
2222 if(CoG==0) {CoG0Sig->Fill(av);}
2223 else {CoG1Sig->Fill(av);}
2226 if(CoG==0) {CoG0Bg->Fill(av);}
2227 else {CoG1Bg->Fill(av);}
2229 cout<<
" CoG "<<CoG<<endl;
2232 imp->SetDirectory(0);
2239 for(
int i=0;
i<4;
i++) max[
i]=0;
2241 max[0]=CoG1Sig->GetMaximum();
2242 max[1]=CoG0Sig->GetMaximum();
2243 max[2]=CoG1Bg->GetMaximum();
2244 max[3]=CoG0Bg->GetMaximum();
2247 for(
int i=0;
i<4;
i++)
if(max_n<max[
i]) max_n=max[
i] ;
2250 imp->SetLineColor(10);
2252 imp->GetXaxis()->SetTitle(
"ANN");
2253 imp->GetYaxis()->SetTitle(
"Count");
2256 CoG1Sig->SetFillStyle(3018);
2257 CoG0Sig->SetFillStyle(3018);
2258 CoG0Bg->SetFillStyle(3004);
2259 CoG1Bg->SetFillStyle(3004);
2260 CoG1Sig->SetFillColor(2);
2261 CoG0Sig->SetFillColor(6);
2262 CoG0Bg->SetFillColor(4);
2263 CoG1Bg->SetFillColor(9);
2264 CoG1Sig->SetLineColor(2);
2265 CoG0Sig->SetLineColor(6);
2266 CoG0Bg->SetLineColor(4);
2267 CoG1Bg->SetLineColor(9);
2271 CoG1Sig->Draw(
"same");
2272 CoG0Sig->Draw(
"same");
2273 CoG0Bg->Draw(
"same");
2274 CoG1Bg->Draw(
"same");
2279 char CoG_c_nroot[1024];
2280 CoG_n.ReplaceAll(
".root",
".png");
2281 sprintf(CoG_c_n,
"CoG_plots/nSig%i_nBg%i_invSNR_Plots_%s",nSig,nBg,CoG_n.Data());
2282 sprintf(CoG_c_nroot,
"CoG_plots/nSig%i_nBg%i_invSNR_Plots_%s",nSig,nBg,CoG_nroot.Data());
2283 CoG_c->SaveAs(CoG_c_n);
2284 CoG_c->Print(CoG_c_nroot);
2291 name.ReplaceAll(
"outfile/",
"");
2292 name.ReplaceAll(
"average_file/",
"");
2293 TFile* fTEST =TFile::Open(ifile.Data());
2294 TTree* NNTree2=(TTree*)fTEST->Get(
"Parameters");
2303 NNTree2->SetBranchAddress(
"Center_of_Gravity",&CoG);
2304 NNTree2->SetBranchAddress(
"Mchirp",&Mc);
2305 NNTree2->SetBranchAddress(
"Average",&av);
2306 NNTree2->SetBranchAddress(
"cc",&cc);
2307 NNTree2->SetBranchAddress(
"rho",&rho);
2308 NNTree2->SetBranchAddress(
"Mchirp_injected",&Mc_inj);
2309 NNTree2->SetBranchAddress(
"#TestSig",&nSi);
2310 NNTree2->GetEntry(0);
2312 cout<<
"nSig: "<<nSig<<
" nSi: "<<nSi<<endl;
2313 int const nTot=NNTree2->GetEntries();
2314 int const nBg=nTot-nSig;
2333 for(
int i=0;
i<7;
i++){
2350 for(
int i=0;
i<7;
i++){
2356 double delta_rho=0.;
2377 double delta_yasym=0.;
2380 cout<<
" delta_yasym "<<delta_yasym<<endl;
2384 cout<<
" yasym[i] "<<yasym[
i]<<
" i "<<
i<<endl;
2393 double delta_logk=0.;
2397 min_logk=log10(
min_k);
2398 max_logk=log10(
max_k);
2399 delta_logk=(log10(
max_k)-log10(
min_k))/npoints;
2405 th_k[
i]=pow(10,min_logk+
i*delta_logk);
2406 cout<<
" th_k[i] "<<th_k[
i]<<
" th_Mc[i] "<<th_Mc[
i]<<endl;
2412 for(
int n=0;
n<nTot;
n++){
2413 NNTree2->GetEntry(
n);
2414 if(cc<0.5)
continue;
2415 if(
n<nSig) countS=countS+1;
2416 else countB=countB+1;
2417 for(
int i=0;
i<7;
i++){
2418 if(Mc>Mccuts[
i]&&av>ANNcuts[
i]) {
2420 if(rho>th_rho[
j]&&
n<nSig) TA_rho[
i][
j]=TA_rho[
i][
j]+1;
2421 if(rho>th_rho[
j]&&(
n>nSig||
n==nSig)) FA_rho[
i][
j]=FA_rho[
i][
j]+1;
2428 for(
int i=0;
i<7;
i++){
2430 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;
2431 FA_rho[
i][
j]=(double)FA_rho[
i][
j]/countB;
2432 TA_rho[
i][
j]=(double)TA_rho[
i][
j]/countS;
2433 if(FA_rho[
i][
j]==0) FA_rho[
i][
j]=0.00001;
2434 if(
i==6) cout<<
"TA_rho[i][j] "<<TA_rho[
i][
j]<<
" FA_rho[i][j] "<<FA_rho[
i][
j]<<endl;
2440 for (
int n=0;
n<nTot;
n++){
2441 NNTree2->GetEntry(
n);
2445 if(Mc>th_Mc[
j]&&
i==0)TA_Mc[0][
j]=TA_Mc[0][
j]+1;
2446 if(Mc>th_Mc[
j]&&av>yasym[
i]) TA_Mc[i+1][
j]=TA_Mc[i+1][
j]+1;
2447 if(av>((th_k[
j]/(Mc-
x_asym))+yasym[i]))TA_ANNMc[
i][
j]=TA_Mc[i+1][
j]+1;
2456 if(Mc>th_Mc[
j]&&
i==0)FA_Mc[0][
j]=FA_Mc[0][
j]+1;
2457 if(Mc>th_Mc[
j]&&av>yasym[
i]) FA_Mc[i+1][
j]=FA_Mc[i+1][
j]+1;
2458 if(av>(th_k[
j]/(Mc-
x_asym)+yasym[i]))FA_ANNMc[
i][
j]=FA_Mc[i+1][
j]+1;
2467 TA_Mc[0][
j]=TA_Mc[0][
j]/nSig;
2468 FA_Mc[0][
j]=FA_Mc[0][
j]/nBg;
2470 TA_Mc[
i+1][
j]=(double)TA_Mc[
i+1][
j]/nSig;
2471 FA_Mc[
i+1][
j]=(double)FA_Mc[
i+1][
j]/nBg;
2472 TA_ANNMc[
i][
j]=(double)TA_ANNMc[
i][
j]/nSig;
2473 FA_ANNMc[
i][
j]=(double)FA_ANNMc[
i][
j]/nBg;
2477 Mc_g[0]=
new TGraph(npoints,FA_Mc[0],TA_Mc[0]);
2478 TGraph* g0=
new TGraph();
2479 g0->SetPoint(0.00001,1,0);
2480 for (
int i=0;
i<7;
i++){
2481 rho_g[
i]=
new TGraph(npoints,FA_rho[
i],TA_rho[i]);
2483 TCanvas* canrho=
new TCanvas(
"Efficiency_vs_FalseAlarm",
"Efficiency_vs_Alarm",0,0,1200,700);
2485 TLegend *legrho =
new TLegend(.75, .2, .99, .4);
2486 TMultiGraph* mg0=
new TMultiGraph();
2487 if(g0->GetN()!=0) mg0->Add(g0);
2488 g0->SetMarkerColor(0);
2490 mg0->SetTitle(
"Comparison;FalseAlarms;Efficiency");
2491 for (
int i=0;
i<7;
i++){
2492 rho_g[
i]->SetLineColor(2+
i);
2493 rho_g[
i]->SetMarkerColor(2+
i);
2494 rho_g[
i]->SetMarkerStyle(
i+20);
2496 rho_g[
i]->SetMarkerSize(0.5);
2498 char defANNMc_rho[1024];
2499 sprintf(defANNMc_rho,
"Mc_%1.2f & ANNcut_%1.2f",Mccuts[
i],ANNcuts[i]);
2500 if(rho_g[i]->GetN()!=0) legrho->AddEntry(rho_g[i],defANNMc_rho,
"pl");
2501 if(rho_g[i]->GetN()!=0) mg0->Add(rho_g[i]);
2508 rhoCname.ReplaceAll(
".root",
".png");
2509 char rhoCname2[1024];
2510 char rhoCname2r[1024];
2511 sprintf(rhoCname2,
"Cuts_caROC/TAvsFA_changingRHO%s",rhoCname.Data());
2512 sprintf(rhoCname2r,
"Cuts_caROC/TAvsFA_changingRHO%s",rhoCnamer.Data());
2513 canrho->SaveAs(rhoCname2);
2514 canrho->Print(rhoCname2r);
2517 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;
2521 Mc_g[
i+1]=
new TGraph(npoints,FA_Mc[
i+1],TA_Mc[
i+1]);
2522 ANNMc_g[
i]=
new TGraph(npoints,FA_ANNMc[
i],TA_ANNMc[i]);
2525 TCanvas* can=
new TCanvas(
"Efficiency_vs_FalseAlarm",
"Efficiency_vs_Alarm",0,0,1200,700);
2527 TLegend *
leg =
new TLegend(.75, .4, .99, .65);
2529 TMultiGraph* mg1=
new TMultiGraph();
2530 mg1->SetTitle(
"Comparison;FalseAlarms;Efficiency");
2531 Mc_g[0]->SetLineColor(3);
2532 Mc_g[0]->SetMarkerStyle(1);
2534 Mc_g[
i+1]->SetLineColor(4);
2536 Mc_g[
i+1]->SetMarkerSize(0.5);
2537 Mc_g[
i+1]->SetMarkerStyle(
i+20);
2538 Mc_g[
i+1]->SetMarkerColor(4);
2539 ANNMc_g[
i]->SetLineColor(2);
2540 ANNMc_g[
i]->SetMarkerColor(2);
2541 ANNMc_g[
i]->SetMarkerStyle(
i+20);
2543 ANNMc_g[
i]->SetMarkerSize(0.5);
2545 char defANNMc[1024];
2546 sprintf(defMc,
"Mc & ANNcut_%1.2f",yasym[
i]);
2547 sprintf(defANNMc,
"Hyperbola_cut,y_asymtoto_%1.2f",
"yasym[i]");
2548 if(Mc_g[i+1]->GetN()!=0) leg->AddEntry(Mc_g[i+1],defMc,
"pl");
2549 if(Mc_g[i+1]->GetN()!=0) mg1->Add(Mc_g[i+1]);
2550 if(ANNMc_g[i]->GetN()!=0) leg->AddEntry(ANNMc_g[i],defANNMc,
"pl");
2551 if(ANNMc_g[i]->GetN()!=0) mg1->Add(ANNMc_g[i]);
2554 if(Mc_g[0]->GetN()!=0) mg1->Add(Mc_g[0]);
2555 if(Mc_g[0]->GetN()!=0) leg->AddEntry(Mc_g[0],
"Mc, no ANNcut",
"pl");
2562 Cname.ReplaceAll(
".root",
".png");
2565 sprintf(Cname2,
"Cuts_caROC/TAvsFA_%s",Cname.Data());
2566 sprintf(Cname2r,
"Cuts_caROC/TAvsFA_%s",Cnamer.Data());
2567 can->SaveAs(Cname2);
2568 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<< "\t layers : "<< nLAYERS<< "\t dF(hz) : "<< dF<< "\t dT(ms) : "<< dT *1000.<< endl;int itime=TIME_PIXEL_INDEX;int ifreq=FREQ_PIXEL_INDEX;int index=(levels+1)*itime+ifreq;double time=itime *dT;double freq=(ifreq >0)?ifreq *dF:dF/4;cout<< endl;cout<< "PIXEL TIME = "<< time<< " sec "<< endl;cout<< "PIXEL FREQ = "<< freq<< " Hz "<< endl;cout<< endl;wavearray< double > x
cout<<"Comparison bkg events above threshold: "<< entriesx<< endl;double *rhox=cnet.GetV1();comph=(TH1D *) gDirectory-> Get("hcomp")
void CutMcANN(TString ifile)
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 \n");fev<< line<< endl;ofstream *fev_single=new ofstream[nfactor];for(int l=1;l< nfactor+1;l++){sprintf(fname,"%s/recovered_signals_%d.txt", netdir, l);fev_single[l-1].open(fname, std::ofstream::out);fev_single[l-1]<< line<< endl;}double Vrho[RHO_NBINS], eVrho[RHO_NBINS], Rrho[RHO_NBINS], eRrho[RHO_NBINS], Trho[RHO_NBINS];for(int i=0;i< RHO_NBINS;i++){Vrho[i]=0.;eVrho[i]=0.;Rrho[i]=0.;eRrho[i]=0.;Trho[i]=RHO_MIN+i *RHO_BIN;}double dV, dV1, dV_spin_mtot, nevts, internal_volume;int nT;int countv=0;int cnt=0;int cnt2=0;int cntfreq=0;bool bcut=false;double liveTot=sim.GetMaximum("ifar");double BKG_LIVETIME_yr=liveTot/CYS;double BKG_LIVETIME_Myr=BKG_LIVETIME_yr/(1.e6);cout.precision(14);cout<< "Total live time ---> background
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)