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"
44 sprintf(NNi2,
"%s",NN_FILE.Data());
49 if((NNi2[p+1]==
'N')&&(NNi2[p+2]==
'\/')) {
52 while (NNi2[hh]!=
'\0'){NNi[hh-p-3]=NNi2[hh];hh=hh+1;}
62 sprintf(NNi2bis,
"%s",NN_FILEbis.Data());
63 while (NNi2bis[pbis]){
65 if (NNi2bis[pbis]==
'N'){
67 if((NNi2bis[pbis+1]==
'N')&&(NNi2bis[pbis+2]==
'\/')) {
70 while (NNi2bis[hh]!=
'\0'){NNibis[hh-p-3]=NNi2bis[hh];hh=hh+1;}
81 sprintf(Filei2,
"%s",TEST_FILE.Data());
84 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]==
'\/')) {
87 while (Filei2[hh]!=
'\0') {Filei[hh-p-7]=Filei2[hh];hh=hh+1;
90 for (
int h0=hh-p-7;h0<1024;h0++) Filei[h0]=
'\0';
96 cout<<NNibis<<
" original String: "<<NNi2bis<<endl;
97 cout<<NNi<<
" original String: "<<NNi2<<endl;
98 cout<<Filei<<
" original String: "<<Filei2<<endl;
105 NNi0bis.ReplaceAll(
".root",
"");
106 NNi0.ReplaceAll(
".root",
"");
107 Filei0.ReplaceAll(
".root",
"");
110 TFile* fnet =TFile::Open(NN_FILE.Data());
111 TMultiLayerPerceptron *mlp = (TMultiLayerPerceptron*)fnet->Get(
"TMultiLayerPerceptron");
112 if(mlp==NULL) {cout <<
"Error getting mlp" << endl;
exit(1);}
113 TTree* infot=(TTree*)fnet->Get(
"info");
118 infot->SetBranchAddress(
"Rand_start_Sig",&NNs);
119 infot->SetBranchAddress(
"Rand_start_Bg",&NNb);
120 infot->SetBranchAddress(
"#trainSig",&NNnTS);
121 infot->SetBranchAddress(
"#trainBg",&NNnTB);
124 TFile* fnetbis =TFile::Open(NN_FILEbis.Data());
125 TMultiLayerPerceptron *mlpbis = (TMultiLayerPerceptron*)fnetbis->Get(
"TMultiLayerPerceptron");
126 if(mlpbis==NULL) {cout <<
"Error getting mlp" << endl;
exit(1);}
127 TTree* infotbis=(TTree*)fnetbis->Get(
"info");
132 infotbis->SetBranchAddress(
"Rand_start_Sig",&NNsbis);
133 infotbis->SetBranchAddress(
"Rand_start_Bg",&NNbbis);
134 infotbis->SetBranchAddress(
"#trainSig",&NNnTSbis);
135 infotbis->SetBranchAddress(
"#trainBg",&NNnTBbis);
136 infotbis->GetEntry(0);
138 TFile* fTEST =TFile::Open(TEST_FILE.Data());
139 TTree* NNTree=(TTree*)fTEST->Get(
"nnTree");
140 int entries=NNTree->GetEntries();
141 cout<<
"entries: "<<entries<<endl;
151 NNTree->SetBranchAddress(
"#Entries_type",&entriesTot);
152 NNTree->SetBranchAddress(
"Matrix_dim",&ndim);
153 NNTree->SetBranchAddress(
"#inputs",&ninp);
154 NNTree->SetBranchAddress(
"amplitude_mode",&y);
157 sig_entries=entriesTot;
158 NNTree->GetEntry(entries-1);
159 bg_entries=entriesTot;
164 cout<<
"NDIM "<<NDIM<<endl;
165 cout<<
"nINP"<<nINP<<endl;
166 cout<<
"sig e "<<sig_entries<<endl;
167 cout<<
"bg e "<<bg_entries<<endl;
169 if (sig_entries>bg_entries) minevents=bg_entries;
170 else minevents=sig_entries;
172 if(b==0) b=sig_entries;
178 cout<<
"Error: Bg index<sig_entries"<<endl;
181 if((TS>sig_entries||
TB>bg_entries)&&(TS==
TB)) {TS=minevents-
s;
TB=minevents-b+sig_entries;}
182 if((TS>sig_entries||
TB>bg_entries)&&(TS!=
TB)) {TS=sig_entries-
s;
TB=bg_entries-b+sig_entries;}
186 sprintf(NOMEtot2,
"N1_%s_N2_%s_F_%s_TS%i_TB%i_st%i_bt%i_uf%i",NNi0.Data(),NNi0bis.Data(),Filei0.Data(),TS,
TB,
s,b,uf);
188 NOMEtot_S.ReplaceAll(
"nnTree",
"");
189 NOMEtot_S.ReplaceAll(
"s0",
"");
190 NOMEtot_S.ReplaceAll(
"b70000",
"");
191 NOMEtot_S.ReplaceAll(
"ROC",
"");
192 NOMEtot_S.ReplaceAll(
"approx",
"ap");
193 NOMEtot_S.ReplaceAll(
"mlpNetwork",
"");
194 NOMEtot_S.ReplaceAll(
"structure",
"str");
195 NOMEtot_S.ReplaceAll(
"epochs",
"ep");
196 NOMEtot_S.ReplaceAll(
"colored",
"rec");
197 NOMEtot_S.ReplaceAll(
"__",
"_");
201 sprintf(NOMEtot,
"%s",NOMEtot_S.Data());
202 cout<<
"nome: "<<NOMEtot<<endl;
203 char Nometot2[1024]=
"comp_orig_dt_a_21marzo_50000";
207 NNTree->SetBranchAddress(
"Files_name",&FILE_NAME);
210 NNTree->GetEntry(entries-1);
212 cout<<
"fine ifdef RHO_CC"<<endl;
214 TChain sigTree(
"waveburst");
215 sigTree.Add(SIG_FILE.Data());
218 cout <<
"sig entries2 : " << sig_entries2 << endl;
220 TChain bgTree(
"waveburst");
221 bgTree.Add(BG_FILE.Data());
224 cout <<
"bg entries2 : " << bg_entries2 << endl;
226 cout<<
"b: "<<b<<endl;
227 cout<<
"s: "<<s<<endl;
231 for (
int jj=0; jj<nINP;jj++) x[jj]=0.;
232 char ilabel[nINP][16];
235 for(
int i=0;
i<nINP;
i++) {
237 NNTree->SetBranchAddress(ilabel[i], &x[i]);
241 sprintf(ofile,
"outfile_2NN/%s.root",Nometot2);
243 TFile*
f =
new TFile(ofile,
"RECREATE");
244 TTree* NNTree2=
new TTree(
"Parameters",
"Parameters");
245 NNTree2->SetDirectory(f);
250 NNTree2->Branch(
"ANNout",&out,
"ANNout/D");
251 NNTree2->Branch(
"ANN2out",&outbis,
"ANN2out/D");
252 NNTree2->Branch(
"cc",&NNcc,
"cc/D");
253 NNTree2->Branch(
"rho",&NNrho,
"rho/D");
254 char NNfilenamebis[1024];
255 NNTree2->Branch(
"NN2name",&NNfilenamebis,
"NN2name/C");
256 sprintf(NNfilenamebis,
"%s",NN_FILEbis.Data());
257 char NNfilename[1024];
258 NNTree2->Branch(
"NNname",&NNfilename,
"NNname/C");
259 sprintf(NNfilename,
"%s",NN_FILE.Data());
261 NNTree2->Branch(
"TestFile",&Testf,
"TestFile/C");
262 sprintf(Testf,
"%s",TEST_FILE.Data());
264 NNTree2->Branch(
"#TestSig",&nTestS,
"#TestSig/I");
265 cout<<
"nTestS: "<<nTestS<<
" TS: "<<TS<<endl;
266 cout<<
"dopo def tree"<<endl;
282 for(
int n=s;
n<s+TS;
n++) {
283 if (uf!=0&&
n>=NNs&&
n<=(NNs+NNnTS))
continue;
289 for (
int i=0;
i<nINP;
i++) params[
i]=0.;
291 for(
int n=s;
n<s+TS;
n++) {
292 if (uf!=0&&
n>=NNs&&
n<=(NNs+NNnTS))
continue;
295 NNcc=(double)signal.
netcc[1];
296 NNrho=(
double)signal.
rho[0];
297 for (
int i=0;
i<nINP;
i++){
301 double output=mlp->Evaluate(0,params);
302 double outputbis=mlpbis->Evaluate(0,params);
307 if (outbis<0.5 || out<0.5) sig_05=sig_05+1;
309 cout<<
"rho: "<<signal.
rho[0]<<
" cc "<<signal.
netcc[1]<<
" out: "<<out<<
" outbis "<<outbis<<endl;
313 cout<<
"riempito sig"<<endl;
316 for(
int n=b;
n<b+
TB;
n++) {
317 if (uf!=0&&(
n>=NNb&&
n<=(NNb+NNnTB) ||
n>=NNbbis&&
n<=(NNbbis+NNnTBbis)))
continue;
319 cout<<
"n: "<<
n<<
"Bg index"<<(
n-sig_entries)<<endl;
321 NNcc=(double)background.
netcc[1];
322 NNrho=(
double)background.
rho[0];
323 for (
int i=0;
i<nINP;
i++){
328 double output=mlp->Evaluate(0,params);
330 double outputbis=mlpbis->Evaluate(0,params);
335 if(outbis>0.5 && out>0.5) bg_05=bg_05+1;
338 cout<<
"rho: "<<background.
rho[0]<<
" cc "<<background.
netcc[1]<<
" out: "<<out<<endl;
341 cout<<
"riempito bg"<<endl;
347 cout<<
"chiuso file"<<endl;
352 cout<<
"dopo richiamo funzione"<<endl;
355 cout<<
" Sig with out<06: "<<sig_05<<endl;
356 cout<<
" Bg with double threshold "<<bg_05<<endl;
361 name.ReplaceAll(
"outfile/",
"");
362 TFile* fTEST =TFile::Open(ifile.Data());
363 TTree* NNTree2=(TTree*)fTEST->Get(
"Parameters");
368 NNTree2->SetBranchAddress(
"ANNout",&out);
369 NNTree2->SetBranchAddress(
"cc",&cc);
370 NNTree2->SetBranchAddress(
"rho",&rho);
371 NNTree2->SetBranchAddress(
"#TestSig",&nSi);
372 NNTree2->GetEntry(0);
374 cout<<
"nSig: "<<nSig<<
" nSi: "<<nSi<<endl;
376 cout<<
"dentro funzione dopodef"<<endl;
378 double* rhoSig[ncurve];
379 for (
int i=0;
i<ncurve;
i++) rhoSig[
i]=
new double[nSig];
380 cout<<
"dopo def rhoSig"<<endl;
384 int const nBg=NNTree2->GetEntries()-nSig;
385 for (
int i=0;
i<ncurve;
i++) {
387 for (
int j=0;
j<nSig;
j++) rhoSig[
i][
j]=0.;
389 cout<<
"dopo def rhoSig"<<endl;
390 double* rhoBg[ncurve];
391 for (
int i=0;
i<ncurve;
i++) rhoBg[
i]=
new double[nBg];
394 for (
int i=0;
i<ncurve;
i++) {
396 for (
int j=0;
j<nBg;
j++) rhoBg[
i][
j]=0.;
398 cout<<
"dopo def rhoBg"<<endl;
400 for (
int i=0;
i<
nCC;
i++) ccTh[
i]=0.;
402 for (
int i=0;
i<
nANN;
i++) NNTh[
i]=0.;
408 cout<<NNTree2->GetEntries()<<endl;
409 for(
int n=0;
n<NNTree2->GetEntries();
n++){
411 NNTree2->GetEntry(
n);
412 cout<<
"rho "<<rho<<
" cc "<<cc<<
" out "<<out<<endl;
415 if(cc<ccTh[
i])
continue;
417 if(
j==0) NNTh[
j]=-1000.;
423 if(out<NNTh[
j])
continue;
426 NBg[i*nANN+
j]= NBg[i*nANN+
j]+1;
427 while(rhoBg[i*nANN+j][ni]!=0)ni=ni+1;
428 rhoBg[i*nANN+
j][ni]=
rho;
433 NSig[i*nANN+
j]= NSig[i*nANN+
j]+1;
434 while(rhoSig[i*nANN+j][ni]!=0)ni=ni+1;
435 rhoSig[i*nANN+
j][ni]=
rho;
443 cout<<
"dopo riempimento variabili"<<endl;
445 for (
int i=0;
i<ncurve;
i++) indexS[
i]=
new int[nSig];
448 for (
int y=0;
y<ncurve;
y++) {
461 TMath::Sort(nSig,rhoSig[
y],indexS[y],
false);
463 for (
int k=0;
k<nSig;
k++) {
468 int ij=indexS[
y][
k-1];
470 if(rhoSig[y][ii]!=0) {
473 if(rhoSig[y][ii]!=rhoSig[y][ij]) gS[
y]->SetPoint(igS_p++,rhoSig[y][ii],yy);
474 cout<<
"igS"<<igS<<
" x "<<rhoSig[
y][ii]<<
" y: "<<yy<<endl;
479 if(rhoSig[y][ii]!=0){
481 gS[
y]->SetPoint(0,rhoSig[y][ii],yy);
492 for (
int i=0;
i<ncurve;
i++) indexB[
i]=
new int[nBg];
495 for (
int y=0;
y<ncurve;
y++) {
499 TMath::Sort(nBg,rhoBg[
y],indexB[y],
false);
501 for (
int k=0;
k<nBg;
k++) {
505 int ij=indexB[
y][
k-1];
507 if(rhoBg[y][ii]!=0) {
510 if(rhoBg[y][ii]!=rhoBg[y][ij]) gB[
y]->SetPoint(igB_p++,rhoBg[y][ii],yy);
516 if(rhoBg[y][ii]!=0) {
518 gB[
y]->SetPoint(0,rhoBg[y][ii],yy);
525 cout<<
"dopo inserimento puntiB"<<endl;
528 TCanvas* cS=
new TCanvas(
"Efficiency_vs_rho",
"Efficiency_vs_rho",0,0,1200,700);
530 cS->cd(1)->SetLogy();
531 TMultiGraph* mg1=
new TMultiGraph();
533 gS[0]->SetMarkerColor(2);
534 gS[0]->SetLineColor(2);
535 mg1->SetTitle(
"cc=0.5;rho;#Events");
536 if(gS[0]->GetN()!=0) mg1->Add(gS[0]);
539 gS[
h]->SetMarkerColor(3);
540 gS[
h]->SetLineColor(3);
542 if(gS[
h]->GetN()!=0) mg1->Add(gS[
h]);
546 cS->cd(2)->SetLogy();
547 TMultiGraph* mg2=
new TMultiGraph();
549 gS[
nANN]->SetMarkerColor(2);
550 gS[
nANN]->SetLineColor(2);
551 mg2->SetTitle(
"cc=0.55;rho;#Events");
552 if(gS[nANN]->GetN()!=0) mg2->Add(gS[nANN]);
554 gS[nANN+
h]->SetMarkerColor(3);
555 gS[nANN+
h]->SetLineColor(3);
557 if(gS[nANN+
h]->GetN()!=0) mg2->Add(gS[nANN+
h]);
561 cS->cd(3)->SetLogy();
562 TMultiGraph* mg3=
new TMultiGraph();
564 gS[nANN*2]->SetMarkerColor(2);
565 gS[nANN*2]->SetLineColor(2);
566 mg3->SetTitle(
"cc=0.6;rho;#Events");
567 if(gS[nANN*2]->GetN()!=0) mg3->Add(gS[nANN*2]);
569 gS[2*nANN+
h]->SetMarkerColor(3);
570 gS[2*nANN+
h]->SetLineColor(3);
572 if(gS[2*nANN+
h]->GetN()!=0) mg3->Add(gS[2*nANN+
h]);
576 cS->cd(4)->SetLogy();
577 TMultiGraph* mg4=
new TMultiGraph();
579 gS[nANN*3]->SetMarkerColor(2);
580 gS[nANN*3]->SetLineColor(2);
581 mg4->SetTitle(
"cc=0.65;rho;#Events");
582 if(gS[nANN*3]->GetN()!=0) mg4->Add(gS[nANN*3]);
585 gS[3*nANN+
h]->SetMarkerColor(3);
586 gS[3*nANN+
h]->SetLineColor(3);
588 if(gS[3*nANN+
h]->GetN()!=0) mg4->Add(gS[3*nANN+
h]);
592 cout<<
"nuovo canv"<<endl;
593 TCanvas* cB=
new TCanvas(
"Number_vs_rho",
"Number_vs_rho",0,0,1200,700);
595 cB->cd(1)->SetLogy();
596 TMultiGraph* mg1B=
new TMultiGraph();
598 gB[0]->SetMarkerColor(2);
599 gB[0]->SetLineColor(2);
600 mg1B->SetTitle(
"cc=0.5;rho;#Events");
601 if(gB[0]->GetN()!=0) mg1B->Add(gB[0]);
603 gB[
h]->SetMarkerColor(3);
604 gB[
h]->SetLineColor(3);
606 if(gB[
h]->GetN()!=0) mg1B->Add(gB[
h]);
610 cB->cd(2)->SetLogy();
611 TMultiGraph* mg2B=
new TMultiGraph();
613 gB[
nANN]->SetMarkerColor(2);
614 gB[
nANN]->SetLineColor(2);
615 mg2B->SetTitle(
"cc=0.55;rho;#Events");
616 if(gB[nANN]->GetN()!=0) mg2B->Add(gB[nANN]);
618 gB[nANN+
h]->SetMarkerColor(3);
619 gB[nANN+
h]->SetLineColor(3);
621 if(gB[nANN+
h]->GetN()!=0) mg2B->Add(gB[nANN+
h]);
625 cB->cd(3)->SetLogy();
626 TMultiGraph* mg3B=
new TMultiGraph();
628 gB[2*
nANN]->SetMarkerColor(2);
629 gB[2*
nANN]->SetLineColor(2);
630 mg3B->SetTitle(
"cc=0.6;rho;#Events");
631 if(gB[2*nANN]->GetN()!=0) mg3B->Add(gB[2*nANN]);
633 gB[2*nANN+
h]->SetMarkerColor(3);
634 gB[2*nANN+
h]->SetLineColor(3);
636 if(gB[2*nANN+
h]->GetN()!=0) mg3B->Add(gB[2*nANN+
h]);
640 cB->cd(4)->SetLogy();
641 TMultiGraph* mg4B=
new TMultiGraph();
643 gB[3*
nANN]->SetMarkerColor(2);
644 gB[3*
nANN]->SetLineColor(2);
645 mg4B->SetTitle(
"cc=0.65;rho;#Events");
646 if(gB[3*nANN]->GetN()!=0) mg4B->Add(gB[3*nANN]);
648 gB[3*nANN+
h]->SetMarkerColor(3);
649 gB[3*nANN+
h]->SetLineColor(3);
651 if(gB[3*nANN+
h]->GetN()!=0) mg4B->Add(gB[3*nANN+
h]);
663 char CnameS2root[1024];
664 char CnameB2root[1024];
665 CnameS.ReplaceAll(
".root",
".png");
666 CnameB.ReplaceAll(
".root",
".png");
667 sprintf(CnameS2,
"logN_rho/logN_rho_S_dANN%1.2f_%s",
deltaANN,CnameS.Data());
668 sprintf(CnameB2,
"logN_rho/logN_rho_B_dANN%1.2f_%s",
deltaANN,CnameB.Data());
669 sprintf(CnameS2root,
"logN_rho/logN_rho_S_dANN%1.2f_%s",
deltaANN,CnameSroot.Data());
670 sprintf(CnameB2root,
"logN_rho/logN_rho_B_dANN%1.2f_%s",
deltaANN,CnameBroot.Data());
673 cS->Print(CnameS2root);
674 cB->Print(CnameB2root);
682 name.ReplaceAll(
"outfile/",
"");
683 TFile* fTEST =TFile::Open(ifile.Data());
684 TTree* NNTree2=(TTree*)fTEST->Get(
"Parameters");
689 NNTree2->SetBranchAddress(
"ANNout",&out);
690 NNTree2->SetBranchAddress(
"cc",&cc);
691 NNTree2->SetBranchAddress(
"rho",&rho);
692 NNTree2->SetBranchAddress(
"#TestSig",&nSi);
693 NNTree2->GetEntry(0);
699 double* ANNSig[ncurve2];
700 for (
int i=0;
i<ncurve2;
i++) ANNSig[
i]=
new double[nSig];
704 int const nBg=NNTree2->GetEntries()-nSig;
705 for (
int i=0;
i<ncurve2;
i++) {
707 for (
int j=0;
j<nSig;
j++) ANNSig[
i][
j]=0.;
709 double* ANNBg[ncurve2];
710 for (
int i=0;
i<ncurve2;
i++) ANNBg[
i]=
new double[nBg];
714 for (
int i=0;
i<ncurve2;
i++) {
716 for (
int j=0;
j<nBg;
j++) ANNBg[
i][
j]=0.;
719 for (
int i=0;
i<
nCC;
i++) ccTh[
i]=0.;
721 for (
int i=0;
i<
nRHO;
i++) rhoTh[
i]=0.;
728 for(
int n=0;
n<NNTree2->GetEntries();
n++){
729 NNTree2->GetEntry(
n);
730 cout<<
"rho "<<rho<<
" cc "<<cc<<
" out "<<out<<endl;
733 if(cc<ccTh[
i])
continue;
736 if(rho<rhoTh[
j])
continue;
739 NBg[i*nRHO+
j]= NBg[i*nRHO+
j]+1;
740 while(ANNBg[i*nRHO+j][ni]!=0)ni=ni+1;
741 ANNBg[i*nRHO+
j][ni]=
out;
745 NSig[i*nRHO+
j]= NSig[i*nRHO+
j]+1;
746 while(ANNSig[i*nRHO+j][ni]!=0)ni=ni+1;
747 ANNSig[i*nRHO+
j][ni]=
out;
754 int* indexS[ncurve2];
755 for (
int i=0;
i<ncurve2;
i++) indexS[
i]=
new int[nSig];
757 TGraph * gS[ncurve2];
758 for (
int y=0;
y<ncurve2;
y++) {
762 TMath::Sort(nSig,ANNSig[
y],indexS[y],
false);
763 for (
int k=0;
k<nSig;
k++) {
768 int ij=indexS[
y][
k-1];
770 if(ANNSig[y][ii]!=0) {
773 if(ANNSig[y][ii]!=ANNSig[y][ij]) gS[
y]->SetPoint(igS_p++,ANNSig[y][ii],yy);
780 if(ANNSig[y][ii]!=0){
782 gS[
y]->SetPoint(0,ANNSig[y][ii],yy);
793 int* indexB[ncurve2];
794 for (
int i=0;
i<ncurve2;
i++) indexB[
i]=
new int[nBg];
796 TGraph * gB[ncurve2];
797 for (
int y=0;
y<ncurve2;
y++) {
801 TMath::Sort(nBg,ANNBg[
y],indexB[y],
false);
803 for (
int k=0;
k<nBg;
k++) {
807 int ij=indexB[
y][
k-1];
809 if(ANNBg[y][ii]!=0) {
812 if(ANNBg[y][ii]!=ANNBg[y][ij]) gB[
y]->SetPoint(igB_p++,ANNBg[y][ii],yy);
818 if(ANNBg[y][ii]!=0) {
820 gB[
y]->SetPoint(0,ANNBg[y][ii],yy);
829 TCanvas* cS=
new TCanvas(
"Efficiency_vs_ANN",
"Efficiency_vs_ANN",0,0,1200,700);
833 TMultiGraph* mg1=
new TMultiGraph();
834 mg1->SetTitle(
"cc=0.5;ANN;#Events");
836 gS[
h]->SetLineColor(4);
837 if(gS[
h]->GetN()!=0) mg1->Add(gS[
h]);
842 TMultiGraph* mg2=
new TMultiGraph();
843 mg2->SetTitle(
"cc=0.55;ANN;#Events");
845 gS[nRHO+
h]->SetLineColor(4);
846 if(gS[nRHO+
h]->GetN()!=0) mg2->Add(gS[nRHO+
h]);
852 TMultiGraph* mg3=
new TMultiGraph();
853 mg3->SetTitle(
"cc=0.6;ANN;#Events");
855 gS[2*nRHO+
h]->SetLineColor(4);
856 if(gS[2*nRHO+
h]->GetN()!=0) mg3->Add(gS[2*nRHO+
h]);
861 TMultiGraph* mg4=
new TMultiGraph();
862 mg4->SetTitle(
"cc=0.65;ANN;#Events");
864 gS[3*nRHO+
h]->SetLineColor(4);
865 if(gS[3*nRHO+
h]->GetN()!=0) mg4->Add(gS[3*nRHO+
h]);
869 TCanvas* cB=
new TCanvas(
"Number_vs_ANN",
"Number_vs_ANN",0,0,1200,700);
871 cB->cd(1)->SetLogy();
872 TMultiGraph* mg1B=
new TMultiGraph();
873 mg1B->SetTitle(
"cc=0.5;ANN;#Events");
875 gB[
h]->SetLineColor(4);
876 if(gB[
h]->GetN()!=0) mg1B->Add(gB[
h]);
879 cB->cd(2)->SetLogy();
880 TMultiGraph* mg2B=
new TMultiGraph();
881 mg2B->SetTitle(
"cc=0.55;ANN;#Events");
883 gB[nRHO+
h]->SetLineColor(4);
884 if(gB[nRHO+
h]->GetN()!=0) mg2B->Add(gB[nRHO+
h]);
887 cB->cd(3)->SetLogy();
888 TMultiGraph* mg3B=
new TMultiGraph();
889 mg3B->SetTitle(
"cc=0.6;ANN;#Events");
891 gB[2*nRHO+
h]->SetLineColor(4);
892 if(gB[2*nRHO+
h]->GetN()!=0) mg3B->Add(gB[2*nRHO+
h]);
895 cB->cd(4)->SetLogy();
896 TMultiGraph* mg4B=
new TMultiGraph();
897 mg4B->SetTitle(
"cc=0.6;ANN;#Events");
899 gB[3*nRHO+
h]->SetLineColor(4);
900 if(gB[3*nRHO+
h]->GetN()!=0) mg4B->Add(gB[3*nRHO+
h]);
912 char CnameS2root[1024];
913 char CnameB2root[1024];
914 CnameS.ReplaceAll(
".root",
".png");
915 CnameB.ReplaceAll(
".root",
".png");
916 sprintf(CnameS2,
"ANNthres/N_ANN_S_%s",CnameS.Data());
917 sprintf(CnameB2,
"ANNthres/N_ANN_B_%s",CnameB.Data());
918 sprintf(CnameS2root,
"ANNthres/N_ANN_S_%s",CnameSroot.Data());
919 sprintf(CnameB2root,
"ANNthres/N_ANN_B_%s",CnameBroot.Data());
922 cS->Print(CnameS2root);
923 cB->Print(CnameB2root);
935 name.ReplaceAll(
"outfile/",
"");
936 name.ReplaceAll(
"outfile_2NN/",
"");
937 TFile* fTEST =TFile::Open(ifile.Data());
938 TTree* NNTree2=(TTree*)fTEST->Get(
"Parameters");
944 NNTree2->SetBranchAddress(
"ANNout",&out);
945 NNTree2->SetBranchAddress(
"ANN2out",&outbis);
946 NNTree2->SetBranchAddress(
"cc",&cc);
947 NNTree2->SetBranchAddress(
"rho",&rho);
948 NNTree2->SetBranchAddress(
"#TestSig",&nSi);
949 NNTree2->GetEntry(0);
951 cout<<
"nSig: "<<nSig<<
" nSi: "<<nSi<<endl;
952 int const nBg=NNTree2->GetEntries()-nSig;
959 for (
int n = 0;
n <NNTree2->GetEntries();
n++){
960 NNTree2->GetEntry(
n);
962 gS[0]->SetPoint(
n,outbis,out);
963 cout<<
"Sig_graph1: x="<<outbis<<
" y: "<<out<<endl;
966 gB[0]->SetPoint(
n-nSig,outbis,out);
967 cout<<
"Bg_graph1: x="<<outbis<<
" y: "<<out<<endl;
984 gS[0]->SetMarkerColor(2);
985 gB[0]->SetMarkerColor(4);
986 gS[0]->SetMarkerStyle(6);
987 gB[0]->SetMarkerStyle(7);
989 TCanvas*
c=
new TCanvas(
"Plots",
"Plots",0,0,1200,700);
992 TMultiGraph* mg1=
new TMultiGraph();
993 mg1->SetTitle(
"out1_out2");
994 if(gB[0]->GetN()!=0) mg1->Add(gB[0]);
995 if(gS[0]->GetN()!=0) mg1->Add(gS[0]);
998 TMultiGraph* mg2=
new TMultiGraph();
999 mg2->SetTitle(
"out1_out2");
1000 if(gS[0]->GetN()!=0) mg2->Add(gS[0]);
1001 if(gB[0]->GetN()!=0) mg2->Add(gB[0]);
1004 cout<<
" name "<<name<<endl;
1008 char Cname2root[1024];
1009 Cname.ReplaceAll(
".root",
".png");
1010 sprintf(Cname2,
"CC_RHO_ANN_Plots_2NN/out_Plots_%s",Cname.Data());
1011 sprintf(Cname2root,
"CC_RHO_ANN_Plots_2NN/out_Plots_%s",Cnameroot.Data());
1013 c->Print(Cname2root);
Float_t * rho
biased null statistics
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<< "Injected signals: "<< mdc.GetEntries()<< endl;cout<< "Injected signals in histogram factor_events_inj: "<< NEVTS<< endl;float myifar, ecor, m1, m2, netcc[3], neted, penalty;float rho[2];float chirp[6];float range[2];float frequency[2];float iSNR[3], sSNR[3];sim.SetBranchAddress("mass", mass);sim.SetBranchAddress("factor",&factor);sim.SetBranchAddress("range", range);sim.SetBranchAddress("chirp", chirp);sim.SetBranchAddress("rho", rho);sim.SetBranchAddress("netcc", netcc);sim.SetBranchAddress("neted",&neted);sim.SetBranchAddress("ifar",&myifar);sim.SetBranchAddress("ecor",&ecor);sim.SetBranchAddress("penalty",&penalty);sim.SetBranchAddress("time", mytime);sim.SetBranchAddress("iSNR", iSNR);sim.SetBranchAddress("sSNR", sSNR);sim.SetBranchAddress("spin", spin);sim.SetBranchAddress("frequency", frequency);float **volume=new float *[NBINS_mass1];float **volume_first_shell=new float *[NBINS_mass1];float **radius=new float *[NBINS_mass1];float **error_volume=new float *[NBINS_mass1];float **error_volume_first_shell=new float *[NBINS_mass1];float **error_radius=new float *[NBINS_mass1];for(int i=0;i< NBINS_mass1;i++){volume[i]=new float[NBINS_mass2];volume_first_shell[i]=new float[NBINS_mass2];radius[i]=new float[NBINS_mass2];error_volume[i]=new float[NBINS_mass2];error_volume_first_shell[i]=new float[NBINS_mass2];error_radius[i]=new float[NBINS_mass2];for(int j=0;j< NBINS_mass2;j++){volume[i][j]=0.;volume_first_shell[i][j]=0.;radius[i][j]=0.;error_volume[i][j]=0.;error_volume_first_shell[i][j]=0.;error_radius[i][j]=0.;}}float **spin_mtot_volume=new float *[NBINS_MTOT+1];float **spin_mtot_radius=new float *[NBINS_MTOT+1];float **error_spin_mtot_volume=new float *[NBINS_MTOT+1];float **error_spin_mtot_radius=new float *[NBINS_MTOT+1];for(int i=0;i< NBINS_MTOT+1;i++){spin_mtot_volume[i]=new float[NBINS_SPIN+1];spin_mtot_radius[i]=new float[NBINS_SPIN+1];error_spin_mtot_volume[i]=new float[NBINS_SPIN+1];error_spin_mtot_radius[i]=new float[NBINS_SPIN+1];for(int j=0;j< NBINS_SPIN+1;j++){spin_mtot_volume[i][j]=0.;error_spin_mtot_volume[i][j]=0.;spin_mtot_radius[i][j]=0.;error_spin_mtot_radius[i][j]=0.;}}char fname[1024];sprintf(fname,"%s/recovered_signals.txt", netdir);ofstream fev;fev.open(fname, std::ofstream::out);sprintf(line,"#GPS@L1 FAR[Hz] eFAR[Hz] Pval ""ePval factor rho frequency iSNR sSNR \n");fev<< line<< endl;ofstream *fev_single=new ofstream[nfactor];for(int l=1;l< nfactor+1;l++){sprintf(fname,"%s/recovered_signals_%d.txt", netdir, l);fev_single[l-1].open(fname, std::ofstream::out);fev_single[l-1]<< line<< endl;}double Vrho[RHO_NBINS], eVrho[RHO_NBINS], Rrho[RHO_NBINS], eRrho[RHO_NBINS], Trho[RHO_NBINS];for(int i=0;i< RHO_NBINS;i++){Vrho[i]=0.;eVrho[i]=0.;Rrho[i]=0.;eRrho[i]=0.;Trho[i]=RHO_MIN+i *RHO_BIN;}double dV, dV1, dV_spin_mtot, nevts, internal_volume;int nT;int countv=0;int cnt=0;int cnt2=0;int cntfreq=0;bool bcut=false;double liveTot=sim.GetMaximum("ifar");double BKG_LIVETIME_yr=liveTot/CYS;double BKG_LIVETIME_Myr=BKG_LIVETIME_yr/(1.e6);cout.precision(14);cout<< "Total live time ---> background
Float_t * netcc
effective correlated SNR
void graph(TString ifile)
sprintf(tfres,"(1/%g)x(%g) (sec)x(Hz)", 2 *df, df)
void Annth(TString ifile)
void Plots(TString ifile)
void Test_rho_cc_out1_out2(TString NN_FILE, TString NN_FILEbis, TString TEST_FILE, int TS=0, int TB=0, int s=0, int b=0, int uf=0)