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" 62 sprintf(NNi2,
"%s",NN_FILE.Data());
67 if((NNi2[p+1]==
'N')&&(NNi2[p+2]==
'\/')) {
70 while (NNi2[hh]!=
'\0'){NNi[hh-p-3]=NNi2[
hh];hh=hh+1;}
80 sprintf(NNi2bis,
"%s",NN_FILEbis.Data());
81 while (NNi2bis[pbis]){
83 if (NNi2bis[pbis]==
'N'){
85 if((NNi2bis[pbis+1]==
'N')&&(NNi2bis[pbis+2]==
'\/')) {
88 while (NNi2bis[hh]!=
'\0'){NNibis[hh-p-3]=NNi2bis[
hh];hh=hh+1;}
99 sprintf(Filei2,
"%s",TEST_FILE.Data());
102 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]==
'\/')) {
105 while (Filei2[hh]!=
'\0') {Filei[hh-p-7]=Filei2[
hh];hh=hh+1;
108 for (
int h0=hh-p-7;h0<1024;h0++) Filei[h0]=
'\0';
114 cout<<NNibis<<
" original String: "<<NNi2bis<<endl;
115 cout<<NNi<<
" original String: "<<NNi2<<endl;
116 cout<<Filei<<
" original String: "<<Filei2<<endl;
123 NNi0bis.ReplaceAll(
".root",
"");
124 NNi0.ReplaceAll(
".root",
"");
125 Filei0.ReplaceAll(
".root",
"");
128 TFile* fnet =TFile::Open(NN_FILE.Data());
129 TMultiLayerPerceptron *mlp = (TMultiLayerPerceptron*)fnet->Get(
"TMultiLayerPerceptron");
130 if(mlp==NULL) {cout <<
"Error getting mlp" << endl;
exit(1);}
131 TTree* infot=(TTree*)fnet->Get(
"info");
136 infot->SetBranchAddress(
"Rand_start_Sig",&NNs);
137 infot->SetBranchAddress(
"Rand_start_Bg",&NNb);
138 infot->SetBranchAddress(
"#trainSig",&NNnTS);
139 infot->SetBranchAddress(
"#trainBg",&NNnTB);
142 TFile* fnetbis =TFile::Open(NN_FILEbis.Data());
143 TMultiLayerPerceptron *mlpbis = (TMultiLayerPerceptron*)fnetbis->Get(
"TMultiLayerPerceptron");
144 if(mlpbis==NULL) {cout <<
"Error getting mlp" << endl;
exit(1);}
145 TTree* infotbis=(TTree*)fnetbis->Get(
"info");
150 infotbis->SetBranchAddress(
"Rand_start_Sig",&NNsbis);
151 infotbis->SetBranchAddress(
"Rand_start_Bg",&NNbbis);
152 infotbis->SetBranchAddress(
"#trainSig",&NNnTSbis);
153 infotbis->SetBranchAddress(
"#trainBg",&NNnTBbis);
154 infotbis->GetEntry(0);
156 TFile* fTEST =TFile::Open(TEST_FILE.Data());
157 TTree* NNTree=(TTree*)fTEST->Get(
"nnTree");
158 int entries=NNTree->GetEntries();
159 cout<<
"entries: "<<entries<<endl;
169 NNTree->SetBranchAddress(
"#Entries_type",&entriesTot);
170 NNTree->SetBranchAddress(
"Matrix_dim",&ndim);
171 NNTree->SetBranchAddress(
"#inputs",&ninp);
172 NNTree->SetBranchAddress(
"amplitude_mode",&y);
175 sig_entries=entriesTot;
176 NNTree->GetEntry(entries-1);
177 bg_entries=entriesTot;
182 cout<<
"NDIM "<<NDIM<<endl;
183 cout<<
"nINP"<<nINP<<endl;
184 cout<<
"sig e "<<sig_entries<<endl;
185 cout<<
"bg e "<<bg_entries<<endl;
187 if (sig_entries>bg_entries) minevents=bg_entries;
188 else minevents=sig_entries;
190 if(b==0) b=sig_entries;
196 cout<<
"Error: Bg index<sig_entries"<<endl;
199 if((TS>sig_entries||
TB>bg_entries)&&(TS==
TB)) {TS=minevents-
s;
TB=minevents-b+sig_entries;}
200 if((TS>sig_entries||
TB>bg_entries)&&(TS!=
TB)) {TS=sig_entries-
s;
TB=bg_entries-b+sig_entries;}
204 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);
206 NOMEtot_S.ReplaceAll(
"nnTree",
"");
207 NOMEtot_S.ReplaceAll(
"s0",
"");
208 NOMEtot_S.ReplaceAll(
"b70000",
"");
209 NOMEtot_S.ReplaceAll(
"ROC",
"");
210 NOMEtot_S.ReplaceAll(
"approx",
"ap");
211 NOMEtot_S.ReplaceAll(
"mlpNetwork",
"");
212 NOMEtot_S.ReplaceAll(
"structure",
"str");
213 NOMEtot_S.ReplaceAll(
"epochs",
"ep");
214 NOMEtot_S.ReplaceAll(
"colored",
"rec");
215 NOMEtot_S.ReplaceAll(
"__",
"_");
219 sprintf(NOMEtot,
"%s",NOMEtot_S.Data());
220 cout<<
"nome: "<<NOMEtot<<endl;
221 char Nometot2[1024]=
"comp_orig_dt_a_21marzo_50000";
225 NNTree->SetBranchAddress(
"Files_name",&FILE_NAME);
228 NNTree->GetEntry(entries-1);
230 cout<<
"fine ifdef RHO_CC"<<endl;
232 TChain sigTree(
"waveburst");
233 sigTree.Add(SIG_FILE.Data());
236 cout <<
"sig entries2 : " << sig_entries2 << endl;
238 TChain bgTree(
"waveburst");
239 bgTree.Add(BG_FILE.Data());
242 cout <<
"bg entries2 : " << bg_entries2 << endl;
244 cout<<
"b: "<<b<<endl;
245 cout<<
"s: "<<s<<endl;
249 for (
int jj=0; jj<nINP;jj++) x[jj]=0.;
250 char ilabel[nINP][16];
253 for(
int i=0;
i<nINP;
i++) {
255 NNTree->SetBranchAddress(ilabel[i], &x[i]);
259 sprintf(ofile,
"outfile_2NN/%s.root",Nometot2);
261 TFile*
f =
new TFile(ofile,
"RECREATE");
262 TTree* NNTree2=
new TTree(
"Parameters",
"Parameters");
263 NNTree2->SetDirectory(f);
268 NNTree2->Branch(
"ANNout",&out,
"ANNout/D");
269 NNTree2->Branch(
"ANN2out",&outbis,
"ANN2out/D");
270 NNTree2->Branch(
"cc",&NNcc,
"cc/D");
271 NNTree2->Branch(
"rho",&NNrho,
"rho/D");
272 char NNfilenamebis[1024];
273 NNTree2->Branch(
"NN2name",&NNfilenamebis,
"NN2name/C");
274 sprintf(NNfilenamebis,
"%s",NN_FILEbis.Data());
275 char NNfilename[1024];
276 NNTree2->Branch(
"NNname",&NNfilename,
"NNname/C");
277 sprintf(NNfilename,
"%s",NN_FILE.Data());
279 NNTree2->Branch(
"TestFile",&Testf,
"TestFile/C");
280 sprintf(Testf,
"%s",TEST_FILE.Data());
282 NNTree2->Branch(
"#TestSig",&nTestS,
"#TestSig/I");
283 cout<<
"nTestS: "<<nTestS<<
" TS: "<<TS<<endl;
284 cout<<
"dopo def tree"<<endl;
300 for(
int n=s;
n<s+TS;
n++) {
301 if (uf!=0&&
n>=NNs&&
n<=(NNs+NNnTS))
continue;
307 for (
int i=0;
i<nINP;
i++) params[
i]=0.;
309 for(
int n=s;
n<s+TS;
n++) {
310 if (uf!=0&&
n>=NNs&&
n<=(NNs+NNnTS))
continue;
313 NNcc=(double)signal.
netcc[1];
314 NNrho=(
double)signal.
rho[0];
315 for (
int i=0;
i<nINP;
i++){
319 double output=mlp->Evaluate(0,params);
320 double outputbis=mlpbis->Evaluate(0,params);
325 if (outbis<0.5 || out<0.5) sig_05=sig_05+1;
327 cout<<
"rho: "<<signal.
rho[0]<<
" cc "<<signal.
netcc[1]<<
" out: "<<out<<
" outbis "<<outbis<<endl;
331 cout<<
"riempito sig"<<endl;
334 for(
int n=b;
n<b+
TB;
n++) {
335 if (uf!=0&&(
n>=NNb&&
n<=(NNb+NNnTB) ||
n>=NNbbis&&
n<=(NNbbis+NNnTBbis)))
continue;
337 cout<<
"n: "<<
n<<
"Bg index"<<(
n-sig_entries)<<endl;
339 NNcc=(double)background.
netcc[1];
340 NNrho=(
double)background.
rho[0];
341 for (
int i=0;
i<nINP;
i++){
346 double output=mlp->Evaluate(0,params);
348 double outputbis=mlpbis->Evaluate(0,params);
353 if(outbis>0.5 && out>0.5) bg_05=bg_05+1;
356 cout<<
"rho: "<<background.
rho[0]<<
" cc "<<background.
netcc[1]<<
" out: "<<out<<endl;
359 cout<<
"riempito bg"<<endl;
365 cout<<
"chiuso file"<<endl;
370 cout<<
"dopo richiamo funzione"<<endl;
373 cout<<
" Sig with out<06: "<<sig_05<<endl;
374 cout<<
" Bg with double threshold "<<bg_05<<endl;
379 name.ReplaceAll(
"outfile/",
"");
380 TFile* fTEST =TFile::Open(ifile.Data());
381 TTree* NNTree2=(TTree*)fTEST->Get(
"Parameters");
386 NNTree2->SetBranchAddress(
"ANNout",&out);
387 NNTree2->SetBranchAddress(
"cc",&cc);
388 NNTree2->SetBranchAddress(
"rho",&rho);
389 NNTree2->SetBranchAddress(
"#TestSig",&nSi);
390 NNTree2->GetEntry(0);
392 cout<<
"nSig: "<<nSig<<
" nSi: "<<nSi<<endl;
394 cout<<
"dentro funzione dopodef"<<endl;
396 double* rhoSig[ncurve];
397 for (
int i=0;
i<ncurve;
i++) rhoSig[
i]=
new double[nSig];
398 cout<<
"dopo def rhoSig"<<endl;
402 int const nBg=NNTree2->GetEntries()-nSig;
403 for (
int i=0;
i<ncurve;
i++) {
405 for (
int j=0;
j<nSig;
j++) rhoSig[
i][
j]=0.;
407 cout<<
"dopo def rhoSig"<<endl;
408 double* rhoBg[ncurve];
409 for (
int i=0;
i<ncurve;
i++) rhoBg[
i]=
new double[nBg];
412 for (
int i=0;
i<ncurve;
i++) {
414 for (
int j=0;
j<nBg;
j++) rhoBg[
i][
j]=0.;
416 cout<<
"dopo def rhoBg"<<endl;
418 for (
int i=0;
i<
nCC;
i++) ccTh[
i]=0.;
420 for (
int i=0;
i<
nANN;
i++) NNTh[
i]=0.;
426 cout<<NNTree2->GetEntries()<<endl;
427 for(
int n=0;
n<NNTree2->GetEntries();
n++){
429 NNTree2->GetEntry(
n);
430 cout<<
"rho "<<rho<<
" cc "<<cc<<
" out "<<out<<endl;
433 if(cc<ccTh[
i])
continue;
435 if(
j==0) NNTh[
j]=-1000.;
441 if(out<NNTh[
j])
continue;
444 NBg[i*nANN+
j]= NBg[i*nANN+
j]+1;
445 while(rhoBg[i*nANN+j][ni]!=0)ni=ni+1;
446 rhoBg[i*nANN+
j][ni]=
rho;
451 NSig[i*nANN+
j]= NSig[i*nANN+
j]+1;
452 while(rhoSig[i*nANN+j][ni]!=0)ni=ni+1;
453 rhoSig[i*nANN+
j][ni]=
rho;
461 cout<<
"dopo riempimento variabili"<<endl;
463 for (
int i=0;
i<ncurve;
i++) indexS[
i]=
new int[nSig];
466 for (
int y=0;
y<ncurve;
y++) {
479 TMath::Sort(nSig,rhoSig[
y],indexS[y],
false);
481 for (
int k=0;
k<nSig;
k++) {
486 int ij=indexS[
y][
k-1];
488 if(rhoSig[y][ii]!=0) {
491 if(rhoSig[y][ii]!=rhoSig[y][ij]) gS[
y]->SetPoint(igS_p++,rhoSig[y][ii],yy);
492 cout<<
"igS"<<igS<<
" x "<<rhoSig[
y][ii]<<
" y: "<<yy<<endl;
497 if(rhoSig[y][ii]!=0){
499 gS[
y]->SetPoint(0,rhoSig[y][ii],yy);
510 for (
int i=0;
i<ncurve;
i++) indexB[
i]=
new int[nBg];
513 for (
int y=0;
y<ncurve;
y++) {
517 TMath::Sort(nBg,rhoBg[
y],indexB[y],
false);
519 for (
int k=0;
k<nBg;
k++) {
523 int ij=indexB[
y][
k-1];
525 if(rhoBg[y][ii]!=0) {
528 if(rhoBg[y][ii]!=rhoBg[y][ij]) gB[
y]->SetPoint(igB_p++,rhoBg[y][ii],yy);
534 if(rhoBg[y][ii]!=0) {
536 gB[
y]->SetPoint(0,rhoBg[y][ii],yy);
543 cout<<
"dopo inserimento puntiB"<<endl;
546 TCanvas* cS=
new TCanvas(
"Efficiency_vs_rho",
"Efficiency_vs_rho",0,0,1200,700);
548 cS->cd(1)->SetLogy();
549 TMultiGraph* mg1=
new TMultiGraph();
551 gS[0]->SetMarkerColor(2);
552 gS[0]->SetLineColor(2);
553 mg1->SetTitle(
"cc=0.5;rho;#Events");
554 if(gS[0]->GetN()!=0) mg1->Add(gS[0]);
557 gS[
h]->SetMarkerColor(3);
558 gS[
h]->SetLineColor(3);
560 if(gS[
h]->GetN()!=0) mg1->Add(gS[
h]);
564 cS->cd(2)->SetLogy();
565 TMultiGraph* mg2=
new TMultiGraph();
567 gS[
nANN]->SetMarkerColor(2);
568 gS[
nANN]->SetLineColor(2);
569 mg2->SetTitle(
"cc=0.55;rho;#Events");
570 if(gS[nANN]->GetN()!=0) mg2->Add(gS[nANN]);
572 gS[nANN+
h]->SetMarkerColor(3);
573 gS[nANN+
h]->SetLineColor(3);
575 if(gS[nANN+
h]->GetN()!=0) mg2->Add(gS[nANN+
h]);
579 cS->cd(3)->SetLogy();
580 TMultiGraph* mg3=
new TMultiGraph();
582 gS[nANN*2]->SetMarkerColor(2);
583 gS[nANN*2]->SetLineColor(2);
584 mg3->SetTitle(
"cc=0.6;rho;#Events");
585 if(gS[nANN*2]->GetN()!=0) mg3->Add(gS[nANN*2]);
587 gS[2*nANN+
h]->SetMarkerColor(3);
588 gS[2*nANN+
h]->SetLineColor(3);
590 if(gS[2*nANN+
h]->GetN()!=0) mg3->Add(gS[2*nANN+
h]);
594 cS->cd(4)->SetLogy();
595 TMultiGraph* mg4=
new TMultiGraph();
597 gS[nANN*3]->SetMarkerColor(2);
598 gS[nANN*3]->SetLineColor(2);
599 mg4->SetTitle(
"cc=0.65;rho;#Events");
600 if(gS[nANN*3]->GetN()!=0) mg4->Add(gS[nANN*3]);
603 gS[3*nANN+
h]->SetMarkerColor(3);
604 gS[3*nANN+
h]->SetLineColor(3);
606 if(gS[3*nANN+
h]->GetN()!=0) mg4->Add(gS[3*nANN+
h]);
610 cout<<
"nuovo canv"<<endl;
611 TCanvas* cB=
new TCanvas(
"Number_vs_rho",
"Number_vs_rho",0,0,1200,700);
613 cB->cd(1)->SetLogy();
614 TMultiGraph* mg1B=
new TMultiGraph();
616 gB[0]->SetMarkerColor(2);
617 gB[0]->SetLineColor(2);
618 mg1B->SetTitle(
"cc=0.5;rho;#Events");
619 if(gB[0]->GetN()!=0) mg1B->Add(gB[0]);
621 gB[
h]->SetMarkerColor(3);
622 gB[
h]->SetLineColor(3);
624 if(gB[
h]->GetN()!=0) mg1B->Add(gB[
h]);
628 cB->cd(2)->SetLogy();
629 TMultiGraph* mg2B=
new TMultiGraph();
631 gB[
nANN]->SetMarkerColor(2);
632 gB[
nANN]->SetLineColor(2);
633 mg2B->SetTitle(
"cc=0.55;rho;#Events");
634 if(gB[nANN]->GetN()!=0) mg2B->Add(gB[nANN]);
636 gB[nANN+
h]->SetMarkerColor(3);
637 gB[nANN+
h]->SetLineColor(3);
639 if(gB[nANN+
h]->GetN()!=0) mg2B->Add(gB[nANN+
h]);
643 cB->cd(3)->SetLogy();
644 TMultiGraph* mg3B=
new TMultiGraph();
646 gB[2*
nANN]->SetMarkerColor(2);
647 gB[2*
nANN]->SetLineColor(2);
648 mg3B->SetTitle(
"cc=0.6;rho;#Events");
649 if(gB[2*nANN]->GetN()!=0) mg3B->Add(gB[2*nANN]);
651 gB[2*nANN+
h]->SetMarkerColor(3);
652 gB[2*nANN+
h]->SetLineColor(3);
654 if(gB[2*nANN+
h]->GetN()!=0) mg3B->Add(gB[2*nANN+
h]);
658 cB->cd(4)->SetLogy();
659 TMultiGraph* mg4B=
new TMultiGraph();
661 gB[3*
nANN]->SetMarkerColor(2);
662 gB[3*
nANN]->SetLineColor(2);
663 mg4B->SetTitle(
"cc=0.65;rho;#Events");
664 if(gB[3*nANN]->GetN()!=0) mg4B->Add(gB[3*nANN]);
666 gB[3*nANN+
h]->SetMarkerColor(3);
667 gB[3*nANN+
h]->SetLineColor(3);
669 if(gB[3*nANN+
h]->GetN()!=0) mg4B->Add(gB[3*nANN+
h]);
681 char CnameS2root[1024];
682 char CnameB2root[1024];
683 CnameS.ReplaceAll(
".root",
".png");
684 CnameB.ReplaceAll(
".root",
".png");
685 sprintf(CnameS2,
"logN_rho/logN_rho_S_dANN%1.2f_%s",
deltaANN,CnameS.Data());
686 sprintf(CnameB2,
"logN_rho/logN_rho_B_dANN%1.2f_%s",
deltaANN,CnameB.Data());
687 sprintf(CnameS2root,
"logN_rho/logN_rho_S_dANN%1.2f_%s",
deltaANN,CnameSroot.Data());
688 sprintf(CnameB2root,
"logN_rho/logN_rho_B_dANN%1.2f_%s",
deltaANN,CnameBroot.Data());
691 cS->Print(CnameS2root);
692 cB->Print(CnameB2root);
700 name.ReplaceAll(
"outfile/",
"");
701 TFile* fTEST =TFile::Open(ifile.Data());
702 TTree* NNTree2=(TTree*)fTEST->Get(
"Parameters");
707 NNTree2->SetBranchAddress(
"ANNout",&out);
708 NNTree2->SetBranchAddress(
"cc",&cc);
709 NNTree2->SetBranchAddress(
"rho",&rho);
710 NNTree2->SetBranchAddress(
"#TestSig",&nSi);
711 NNTree2->GetEntry(0);
717 double* ANNSig[ncurve2];
718 for (
int i=0;
i<ncurve2;
i++) ANNSig[
i]=
new double[nSig];
722 int const nBg=NNTree2->GetEntries()-nSig;
723 for (
int i=0;
i<ncurve2;
i++) {
725 for (
int j=0;
j<nSig;
j++) ANNSig[
i][
j]=0.;
727 double* ANNBg[ncurve2];
728 for (
int i=0;
i<ncurve2;
i++) ANNBg[
i]=
new double[nBg];
732 for (
int i=0;
i<ncurve2;
i++) {
734 for (
int j=0;
j<nBg;
j++) ANNBg[
i][
j]=0.;
737 for (
int i=0;
i<
nCC;
i++) ccTh[
i]=0.;
739 for (
int i=0;
i<
nRHO;
i++) rhoTh[
i]=0.;
746 for(
int n=0;
n<NNTree2->GetEntries();
n++){
747 NNTree2->GetEntry(
n);
748 cout<<
"rho "<<rho<<
" cc "<<cc<<
" out "<<out<<endl;
751 if(cc<ccTh[
i])
continue;
754 if(rho<rhoTh[
j])
continue;
757 NBg[i*nRHO+
j]= NBg[i*nRHO+
j]+1;
758 while(ANNBg[i*nRHO+j][ni]!=0)ni=ni+1;
759 ANNBg[i*nRHO+
j][ni]=
out;
763 NSig[i*nRHO+
j]= NSig[i*nRHO+
j]+1;
764 while(ANNSig[i*nRHO+j][ni]!=0)ni=ni+1;
765 ANNSig[i*nRHO+
j][ni]=
out;
772 int* indexS[ncurve2];
773 for (
int i=0;
i<ncurve2;
i++) indexS[
i]=
new int[nSig];
775 TGraph * gS[ncurve2];
776 for (
int y=0;
y<ncurve2;
y++) {
780 TMath::Sort(nSig,ANNSig[
y],indexS[y],
false);
781 for (
int k=0;
k<nSig;
k++) {
786 int ij=indexS[
y][
k-1];
788 if(ANNSig[y][ii]!=0) {
791 if(ANNSig[y][ii]!=ANNSig[y][ij]) gS[
y]->SetPoint(igS_p++,ANNSig[y][ii],yy);
798 if(ANNSig[y][ii]!=0){
800 gS[
y]->SetPoint(0,ANNSig[y][ii],yy);
811 int* indexB[ncurve2];
812 for (
int i=0;
i<ncurve2;
i++) indexB[
i]=
new int[nBg];
814 TGraph * gB[ncurve2];
815 for (
int y=0;
y<ncurve2;
y++) {
819 TMath::Sort(nBg,ANNBg[
y],indexB[y],
false);
821 for (
int k=0;
k<nBg;
k++) {
825 int ij=indexB[
y][
k-1];
827 if(ANNBg[y][ii]!=0) {
830 if(ANNBg[y][ii]!=ANNBg[y][ij]) gB[
y]->SetPoint(igB_p++,ANNBg[y][ii],yy);
836 if(ANNBg[y][ii]!=0) {
838 gB[
y]->SetPoint(0,ANNBg[y][ii],yy);
847 TCanvas* cS=
new TCanvas(
"Efficiency_vs_ANN",
"Efficiency_vs_ANN",0,0,1200,700);
851 TMultiGraph* mg1=
new TMultiGraph();
852 mg1->SetTitle(
"cc=0.5;ANN;#Events");
854 gS[
h]->SetLineColor(4);
855 if(gS[
h]->GetN()!=0) mg1->Add(gS[
h]);
860 TMultiGraph* mg2=
new TMultiGraph();
861 mg2->SetTitle(
"cc=0.55;ANN;#Events");
863 gS[nRHO+
h]->SetLineColor(4);
864 if(gS[nRHO+
h]->GetN()!=0) mg2->Add(gS[nRHO+
h]);
870 TMultiGraph* mg3=
new TMultiGraph();
871 mg3->SetTitle(
"cc=0.6;ANN;#Events");
873 gS[2*nRHO+
h]->SetLineColor(4);
874 if(gS[2*nRHO+
h]->GetN()!=0) mg3->Add(gS[2*nRHO+
h]);
879 TMultiGraph* mg4=
new TMultiGraph();
880 mg4->SetTitle(
"cc=0.65;ANN;#Events");
882 gS[3*nRHO+
h]->SetLineColor(4);
883 if(gS[3*nRHO+
h]->GetN()!=0) mg4->Add(gS[3*nRHO+
h]);
887 TCanvas* cB=
new TCanvas(
"Number_vs_ANN",
"Number_vs_ANN",0,0,1200,700);
889 cB->cd(1)->SetLogy();
890 TMultiGraph* mg1B=
new TMultiGraph();
891 mg1B->SetTitle(
"cc=0.5;ANN;#Events");
893 gB[
h]->SetLineColor(4);
894 if(gB[
h]->GetN()!=0) mg1B->Add(gB[
h]);
897 cB->cd(2)->SetLogy();
898 TMultiGraph* mg2B=
new TMultiGraph();
899 mg2B->SetTitle(
"cc=0.55;ANN;#Events");
901 gB[nRHO+
h]->SetLineColor(4);
902 if(gB[nRHO+
h]->GetN()!=0) mg2B->Add(gB[nRHO+
h]);
905 cB->cd(3)->SetLogy();
906 TMultiGraph* mg3B=
new TMultiGraph();
907 mg3B->SetTitle(
"cc=0.6;ANN;#Events");
909 gB[2*nRHO+
h]->SetLineColor(4);
910 if(gB[2*nRHO+
h]->GetN()!=0) mg3B->Add(gB[2*nRHO+
h]);
913 cB->cd(4)->SetLogy();
914 TMultiGraph* mg4B=
new TMultiGraph();
915 mg4B->SetTitle(
"cc=0.6;ANN;#Events");
917 gB[3*nRHO+
h]->SetLineColor(4);
918 if(gB[3*nRHO+
h]->GetN()!=0) mg4B->Add(gB[3*nRHO+
h]);
930 char CnameS2root[1024];
931 char CnameB2root[1024];
932 CnameS.ReplaceAll(
".root",
".png");
933 CnameB.ReplaceAll(
".root",
".png");
934 sprintf(CnameS2,
"ANNthres/N_ANN_S_%s",CnameS.Data());
935 sprintf(CnameB2,
"ANNthres/N_ANN_B_%s",CnameB.Data());
936 sprintf(CnameS2root,
"ANNthres/N_ANN_S_%s",CnameSroot.Data());
937 sprintf(CnameB2root,
"ANNthres/N_ANN_B_%s",CnameBroot.Data());
940 cS->Print(CnameS2root);
941 cB->Print(CnameB2root);
953 name.ReplaceAll(
"outfile/",
"");
954 name.ReplaceAll(
"outfile_2NN/",
"");
955 TFile* fTEST =TFile::Open(ifile.Data());
956 TTree* NNTree2=(TTree*)fTEST->Get(
"Parameters");
962 NNTree2->SetBranchAddress(
"ANNout",&out);
963 NNTree2->SetBranchAddress(
"ANN2out",&outbis);
964 NNTree2->SetBranchAddress(
"cc",&cc);
965 NNTree2->SetBranchAddress(
"rho",&rho);
966 NNTree2->SetBranchAddress(
"#TestSig",&nSi);
967 NNTree2->GetEntry(0);
969 cout<<
"nSig: "<<nSig<<
" nSi: "<<nSi<<endl;
970 int const nBg=NNTree2->GetEntries()-nSig;
977 for (
int n = 0;
n <NNTree2->GetEntries();
n++){
978 NNTree2->GetEntry(
n);
980 gS[0]->SetPoint(
n,outbis,out);
981 cout<<
"Sig_graph1: x="<<outbis<<
" y: "<<out<<endl;
984 gB[0]->SetPoint(
n-nSig,outbis,out);
985 cout<<
"Bg_graph1: x="<<outbis<<
" y: "<<out<<endl;
1002 gS[0]->SetMarkerColor(2);
1003 gB[0]->SetMarkerColor(4);
1004 gS[0]->SetMarkerStyle(6);
1005 gB[0]->SetMarkerStyle(7);
1007 TCanvas*
c=
new TCanvas(
"Plots",
"Plots",0,0,1200,700);
1010 TMultiGraph* mg1=
new TMultiGraph();
1011 mg1->SetTitle(
"out1_out2");
1012 if(gB[0]->GetN()!=0) mg1->Add(gB[0]);
1013 if(gS[0]->GetN()!=0) mg1->Add(gS[0]);
1016 TMultiGraph* mg2=
new TMultiGraph();
1017 mg2->SetTitle(
"out1_out2");
1018 if(gS[0]->GetN()!=0) mg2->Add(gS[0]);
1019 if(gB[0]->GetN()!=0) mg2->Add(gB[0]);
1022 cout<<
" name "<<name<<endl;
1026 char Cname2root[1024];
1027 Cname.ReplaceAll(
".root",
".png");
1028 sprintf(Cname2,
"CC_RHO_ANN_Plots_2NN/out_Plots_%s",Cname.Data());
1029 sprintf(Cname2root,
"CC_RHO_ANN_Plots_2NN/out_Plots_%s",Cnameroot.Data());
1031 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<< "\ 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
cout<< "SNR "<< xsnr<< endl;wavearray< double > f
cout<< "Injected signals: "<< mdc.GetEntries()<< endl;cout<< "Injected signals in histogram factor_events_inj: "<< NEVTS<< endl;float myifar, ecor, m1, m2, netcc[3], neted, penalty;float rho[2];float chirp[6];float range[2];float frequency[2];float iSNR[3], sSNR[3];sim.SetBranchAddress("mass", mass);sim.SetBranchAddress("factor", &factor);sim.SetBranchAddress("range", range);sim.SetBranchAddress("chirp", chirp);sim.SetBranchAddress("rho", rho);sim.SetBranchAddress("netcc", netcc);sim.SetBranchAddress("neted", &neted);sim.SetBranchAddress("ifar", &myifar);sim.SetBranchAddress("ecor", &ecor);sim.SetBranchAddress("penalty", &penalty);sim.SetBranchAddress("time", mytime);sim.SetBranchAddress("iSNR", iSNR);sim.SetBranchAddress("sSNR", sSNR);sim.SetBranchAddress("spin", spin);sim.SetBranchAddress("frequency", frequency);float **volume=new float *[NBINS_mass1];float **volume_first_shell=new float *[NBINS_mass1];float **radius=new float *[NBINS_mass1];float **error_volume=new float *[NBINS_mass1];float **error_volume_first_shell=new float *[NBINS_mass1];float **error_radius=new float *[NBINS_mass1];for(int i=0;i< NBINS_mass1;i++) { volume[i]=new float[NBINS_mass2];volume_first_shell[i]=new float[NBINS_mass2];radius[i]=new float[NBINS_mass2];error_volume[i]=new float[NBINS_mass2];error_volume_first_shell[i]=new float[NBINS_mass2];error_radius[i]=new float[NBINS_mass2];for(int j=0;j< NBINS_mass2;j++) { volume[i][j]=0.;volume_first_shell[i][j]=0.;radius[i][j]=0.;error_volume[i][j]=0.;error_volume_first_shell[i][j]=0.;error_radius[i][j]=0.;} } float **spin_mtot_volume=new float *[NBINS_MTOT+1];float **spin_mtot_radius=new float *[NBINS_MTOT+1];float **error_spin_mtot_volume=new float *[NBINS_MTOT+1];float **error_spin_mtot_radius=new float *[NBINS_MTOT+1];for(int i=0;i< NBINS_MTOT+1;i++) { spin_mtot_volume[i]=new float[NBINS_SPIN+1];spin_mtot_radius[i]=new float[NBINS_SPIN+1];error_spin_mtot_volume[i]=new float[NBINS_SPIN+1];error_spin_mtot_radius[i]=new float[NBINS_SPIN+1];for(int j=0;j< NBINS_SPIN+1;j++) { spin_mtot_volume[i][j]=0.;error_spin_mtot_volume[i][j]=0.;spin_mtot_radius[i][j]=0.;error_spin_mtot_radius[i][j]=0.;} } char fname[1024];sprintf(fname, "%s/recovered_signals.txt", netdir);ofstream fev;fev.open(fname, std::ofstream::out);sprintf(line, "#GPS@L1 FAR[Hz] eFAR[Hz] Pval " "ePval factor rho frequency iSNR sSNR \");fev<< line<< endl;ofstream *fev_single=new ofstream[nfactor];for(int l=1;l< nfactor+1;l++) { sprintf(fname, "%s/recovered_signals_%d.txt", netdir, l);fev_single[l - 1].open(fname, std::ofstream::out);fev_single[l - 1]<< line<< endl;} double Vrho[RHO_NBINS], eVrho[RHO_NBINS], Rrho[RHO_NBINS], eRrho[RHO_NBINS], Trho[RHO_NBINS];for(int i=0;i< RHO_NBINS;i++) { Vrho[i]=0.;eVrho[i]=0.;Rrho[i]=0.;eRrho[i]=0.;Trho[i]=RHO_MIN+i *RHO_BIN;} double dV, dV1, dV_spin_mtot, nevts, internal_volume;int nT;int countv=0;int cnt=0;int cnt2=0;int cntfreq=0;bool bcut=false;double liveTot=sim.GetMaximum("ifar");double BKG_LIVETIME_yr=liveTot/CYS;double BKG_LIVETIME_Myr=BKG_LIVETIME_yr/(1.e6);cout.precision(14);cout<< "Total live time ---> background
Float_t * netcc
effective correlated SNR
void 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)