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 void Fisher_1(
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 nFs,
int nFb,
int Fs=0,
int Fb=0,
int TS=0,
int TB=0,
int s=0,
int b=0,
int uf=1,
int ni=0){
47 if (NN_FILE.CompareTo(
"")){
50 if (NN_FILE2.CompareTo(
"")){
53 if (NN_FILE3.CompareTo(
"")){
56 if (NN_FILE4.CompareTo(
"")){
59 if (NN_FILE5.CompareTo(
"")){
62 if (NN_FILE6.CompareTo(
"")){
65 if (NN_FILE7.CompareTo(
"")){
68 if (NN_FILE8.CompareTo(
"")){
76 sprintf(NNi2[0],
"%s",NN_FILE.Data());
77 if(nNN>1)
sprintf(NNi2[1],
"%s",NN_FILE2.Data());
78 if(nNN>2)
sprintf(NNi2[2],
"%s",NN_FILE3.Data());
79 if(nNN>3)
sprintf(NNi2[3],
"%s",NN_FILE4.Data());
80 if(nNN>4)
sprintf(NNi2[4],
"%s",NN_FILE5.Data());
81 if(nNN>5)
sprintf(NNi2[5],
"%s",NN_FILE6.Data());
82 if(nNN>6)
sprintf(NNi2[6],
"%s",NN_FILE7.Data());
83 if(nNN>7)
sprintf(NNi2[7],
"%s",NN_FILE8.Data());
84 for (
int u=0;u<nNN;u++){
90 if((NNi2[u][p+1]==
'N')&&(NNi2[u][p+2]==
'\/')) {
93 while (NNi2[u][hh]!=
'\0'){NNi[u][hh-p-3]=NNi2[u][hh];hh=hh+1;}
103 sprintf(Filei2,
"%s",TEST_FILE.Data());
105 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]==
'\/')) {
107 while (Filei2[hh]!=
'\0') {Filei[hh-q-7]=Filei2[hh];hh=hh+1;
109 for (
int h0=hh-q-7;h0<1024;h0++) Filei[h0]=
'\0';
115 cout<<Filei<<
" original String: "<<Filei2<<endl;
120 if(nNN>1) NNi0[1]=NNi[1];
121 if(nNN>2) NNi0[2]=NNi[2];
122 if(nNN>3) NNi0[3]=NNi[3];
123 if(nNN>4) NNi0[4]=NNi[4];
124 if(nNN>5) NNi0[5]=NNi[5];
125 if(nNN>6) NNi0[6]=NNi[6];
126 if(nNN>7) NNi0[7]=NNi[7];
130 for (
int u=0;u<nNN;u++){
131 NNi0[u].ReplaceAll(
".root",
"");
133 Filei0.ReplaceAll(
".root",
"");
136 TMultiLayerPerceptron* mlp[nNN];
142 for (
int u=0;u<nNN;u++){
143 fnet[u]=TFile::Open(NNi2[u]);
145 cout<<
"dopo file"<<endl;
146 mlp[u]=(TMultiLayerPerceptron*)fnet[u]->
Get(
"TMultiLayerPerceptron");
148 cout<<
"dopo TMLP"<<endl;
149 if(mlp[u]==NULL) {cout <<
"Error getting mlp" << endl;
exit(1);}
150 infot[u]=(TTree*)fnet[u]->
Get(
"info");
151 infot[u]->SetBranchAddress(
"Rand_start_Sig",&NNs[u]);
152 infot[u]->SetBranchAddress(
"Rand_start_Bg",&NNb[u]);
153 infot[u]->SetBranchAddress(
"#trainSig",&NNnTS[u]);
154 infot[u]->SetBranchAddress(
"#trainBg",&NNnTB[u]);
155 infot[u]->GetEntry(0);
156 if(NNb[u]<min_NNb) min_NNb=NNb[u];
157 cout<<
"n "<<u<<
" b "<<NNb[u]<<
" min_NNb "<<min_NNb<<endl;
159 cout<<
"da Tree"<<endl;
160 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;
162 if (uf!=0&&ni==0&&(b<min_NNb)&&(TS!=0||
TB!=0)){ b=min_NNb;cout<<
" change in b value to have BKG events: "<<b<<endl;}
164 cout<<
"Def. tree e mlp"<<endl;
165 TFile* fTEST =TFile::Open(TEST_FILE.Data());
166 TTree* NNTree=(TTree*)fTEST->Get(
"nnTree");
167 int entries=NNTree->GetEntries();
168 cout<<
"entries: "<<entries<<endl;
178 NNTree->SetBranchAddress(
"#Entries_type",&entriesTot);
179 NNTree->SetBranchAddress(
"Matrix_dim",&ndim);
180 NNTree->SetBranchAddress(
"#inputs",&ninp);
181 NNTree->SetBranchAddress(
"amplitude_mode",&y);
184 sig_entries=entriesTot;
185 NNTree->GetEntry(entries-1);
186 bg_entries=entriesTot;
191 cout<<
"NDIM "<<NDIM<<endl;
192 cout<<
"nINP"<<nINP<<endl;
193 cout<<
"sig e "<<sig_entries<<endl;
194 cout<<
"bg e "<<bg_entries<<endl;
196 if (sig_entries>bg_entries) minevents=bg_entries;
197 else minevents=sig_entries;
199 if(b==0) b=sig_entries;
205 cout<<
"Error: Bg index<sig_entries"<<endl;
208 if((TS>sig_entries||
TB>bg_entries)&&(TS==
TB)) {TS=minevents-
s;
TB=minevents-b+sig_entries;}
209 if((TS>sig_entries||
TB>bg_entries)&&(TS!=
TB)) {TS=sig_entries-
s;
TB=bg_entries-b+sig_entries;}
213 sprintf(NOMEtot,
"%s",NOMEtot_S.Data());
214 cout<<
"nome: "<<NOMEtot<<endl;
219 NNTree->SetBranchAddress(
"Files_name",&FILE_NAME);
222 NNTree->GetEntry(entries-1);
224 cout<<
"fine ifdef RHO_CC"<<endl;
226 TChain sigTree(
"waveburst");
227 sigTree.Add(SIG_FILE.Data());
230 cout <<
"sig entries2 : " << sig_entries2 << endl;
232 TChain bgTree(
"waveburst");
233 bgTree.Add(BG_FILE.Data());
236 cout <<
"bg entries2 : " << bg_entries2 << endl;
238 cout<<
"b: "<<b<<endl;
239 cout<<
"s: "<<
s<<endl;
243 for (
int jj=0; jj<nINP;jj++) x[jj]=0.;
244 char ilabel[nINP][16];
247 for(
int i=0;
i<nINP;
i++) {
249 NNTree->SetBranchAddress(ilabel[i], &x[i]);
253 sprintf(ofile,
"average_file/%s.root",NOMEtot);
254 TFile*
f =
new TFile(ofile,
"RECREATE");
255 TTree* NNTree2=
new TTree(
"Parameters",
"Parameters");
256 NNTree2->SetDirectory(f);
259 for(
int y=0; y<nNN; y++) out[y]=0.;
264 NNTree2->Branch(
"Average",&average,
"Average/D");
265 NNTree2->Branch(
"StandardDevaition",&std,
"StandardDeviation/D");
266 NNTree2->Branch(
"cc",&NNcc,
"cc/D");
267 NNTree2->Branch(
"Mchirp",&Mc,
"Mchirp/D");
268 NNTree2->Branch(
"rho",&NNrho,
"rho/D");
269 for(
int u=0;u<nNN;u++){
275 sprintf(NNoutl2,
"NNout%i/D",u);
277 sprintf(NNnamel2,
"NNname%i/C",u);
278 NNTree2->Branch(NNoutl,&out[u],NNoutl2);
279 NNTree2->Branch(NNnamel,&NNi[u],NNnamel2);}
281 NNTree2->Branch(
"TestFile",&Testf,
"TestFile/C");
282 sprintf(Testf,
"%s",TEST_FILE.Data());
284 NNTree2->Branch(
"#TestSig",&nTestS,
"#TestSig/I");
285 cout<<
"nTestS: "<<nTestS<<
" TS: "<<TS<<endl;
286 cout<<
"dopo def tree"<<endl;
290 for(
int n=
s;
n<
s+TS;
n++) {
292 for(
int u=0;u<nNN;u++){
293 if (uf!=0&&
n>=NNs[u]&&
n<(NNs[u]+NNnTS[u])) countNN=countNN+1;
296 if(countNN==1&&ni==0) scount=scount+1;
297 if(countNN<2&&ni!=0) scount=scount+1;
298 if(countNN>1){cout<<
"Error: training non independent";
exit(0);}
303 cout<<
"s test "<<
s<<
" s+TS "<<
s+TS<<
" b "<<b<<
" b+ TB "<<b+
TB<<
" nTestS "<<nTestS<<endl;
307 for (
int i=0;
i<nINP;
i++) params[
i]=0.;
312 for(
int n=
s;
n<
s+TS;
n++) {
316 for(
int u=0;u<nNN;u++){
317 if (uf!=0&&
n>=NNs[u]&&
n<(NNs[u]+NNnTS[u])) { indNN=u;countNN=countNN+1;}
319 if (countNN>1){cout<<
"Error: training non independent";
exit(0);}
320 if(nNN==1){cout<<
"out==Averege:only 1NN is considered"<<endl;}
321 if(ni==0&&countNN==0)
continue;
324 NNcc=(double)signal.
netcc[1];
325 NNrho=(
double)signal.
rho[0];
327 for (
int i=0;
i<nINP;
i++){
330 for (
int u=0;u<nNN;u++) {
331 double output=mlp[u]->Evaluate(0,params);
335 for (
int u=0;u<nNN;u++){
336 if((u!=indNN&&ni==0)||ni!=0) {average=out[u]+average;std+=out[u]*out[u];}
339 if(nNN!=1&&ni==0) {average=average/(nNN-countNN);
if((nNN-1-countNN)!=0)std=pow((std/(nNN-1-countNN)-average*average),0.5);
else std=pow((std/(nNN-countNN)-average*average),0.5);}
340 if(nNN!=1&&ni!=0) {average=average/(nNN);
if((nNN-1)!=0)std=pow((std/(nNN-1)-average*average),0.5);
else std=pow((std/nNN-average*average),0.5);}
341 cout<<
"average: "<<average<<endl;
343 if (average<0.6) TD=TD+1;
354 cout<<
"riempito sig"<<endl;
356 cout<<
"b "<<b<<
" TB "<<
TB<<endl;
363 cout<<
" prima ciclo fro bg"<<endl;
365 for(
int n=b;
n<b+
TB;
n++) {
370 for(
int u=0;u<nNN;u++){
371 cout<<
" uf "<<uf<<
" n "<<
n<<
" u "<<u<<
" NN b[u] "<<NNb[u]<<
" (primo non preso) NNb[u]+NNnTB[u]"<<NNb[u]+NNnTB[u]<<endl;
372 if (uf!=0&&
n>=NNb[u]&&
n<(NNb[u]+NNnTB[u])) { indNN=u;countNN=countNN+1;
376 if (countNN>1){cout<<
"Error: training non independent";
exit(0);}
377 if(nNN==1){cout<<
"out==Averege:only 1NN is considered"<<endl;}
378 if(ni==0&&countNN==0){
379 cout<<
"countNN"<<countNN<<endl;
383 cout<<
"n: "<<
n<<
"Bg index"<<(
n-sig_entries)<<endl;
385 NNcc=(double)background.
netcc[1];
386 NNrho=(
double)background.
rho[0];
388 for (
int i=0;
i<nINP;
i++){
393 for(
int u=0;u<nNN;u++) {
394 double output=mlp[u]->Evaluate(0,params);
398 for (
int u=0;u<nNN;u++){
399 if((u!=indNN&&ni==0)||ni!=0) { average=out[u]+average;std=out[u]*out[u];}
401 if(nNN!=1&&ni==0) {cout<<average<<endl;average=average/(nNN-countNN);
403 cout<<
"ni==0"<<average<<endl;
if((nNN-1-countNN)!=0)std=pow((std/(nNN-1-countNN)-average*average),0.5);
else std=pow((std/(nNN-countNN)-average*average),0.5);}
406 if(nNN!=1&&ni!=0) {cout<<average<<endl;average=average/(nNN);
if((nNN-1)!=0)std=pow((std/(nNN-1)-average*average),0.5);
else std=pow((std/nNN-average*average),0.5); cout<<
"ni!=0"<<average<<endl;}
407 cout<<
"average: "<<average<<
" nNN-1-countNN "<<nNN-1-countNN<<endl;
408 if(average>0.6) FA=FA+1;
423 cout<<
"riempito bg"<<endl;
429 cout<<
"chiuso file"<<endl;
435 cout<<
"dopo richiamo funzione"<<endl;
442 cout<<
" S_eff "<<S_eff<<
" B_eff "<<B_eff<<endl;
443 cout<<
" FA>0.6 "<<FA<<
" TD<0.6 "<<TD<<
" FA/tot_BG "<<FA/B_eff<<
" TD/tot_S "<<TD/S_eff<<endl;
453 name.ReplaceAll(
"average_file/",
"");
454 TFile* fTEST =TFile::Open(ifile.Data());
455 TTree* NNTree2=(TTree*)fTEST->Get(
"Parameters");
459 NNTree2->SetBranchAddress(
"Average",&av);
460 NNTree2->SetBranchAddress(
"cc",&cc);
461 NNTree2->SetBranchAddress(
"#TestSig",&nSi);
462 NNTree2->GetEntry(0);
477 if (nFs+Fs>nSi){ Fs=0;
if(nFs>nSi) nFs=nSi; cout<<
" change: Fs "<<Fs<<
" nFs "<<nFs<<endl;}
479 if (Fb<nSi) {Fb=nSi+Fb; cout<<
" change: Fb "<<Fb<<endl;}
481 for(
int n=Fs;
n<Fs+nFs;
n++){
482 NNTree2->GetEntry(
n);
493 int const TOTent=NNTree2->GetEntries();
494 int const nBg=NNTree2->GetEntries()-nSi;
495 cout<<
"nSi "<<nSi<<
" nBg "<<nBg<<
" entries "<<TOTent<<endl;
497 if (nFb+Fb>TOTent){ Fb=nSi;
if(nFs>nBg) nFb=nBg; cout<<
" change: Fb "<<Fb<<
" nFb "<<nFb<<endl;}
499 for(
int n=Fb;
n<Fb+nFb;
n++){
500 NNTree2->GetEntry(
n);
519 a_b=qB_c-nFb*(mB_c*mB_c);
520 d_b=qB_o-nFb*(mB_o*mB_o);
521 b_b=sB_co-nFb*(mB_c*mB_o);
523 cout<<
"a_b "<<a_b<<endl;
524 cout<<
"d_b "<<d_b<<endl;
525 cout<<
"a_s "<<a_s<<endl;
526 cout<<
"d_s "<<d_s<<endl;
527 a_s=qS_c-nFs*(mS_c*mS_c);
528 d_s=qS_o-nFs*(mS_o*mS_o);
529 b_s=sS_co-nFs*(mS_c*mS_o);
548 cout<<
"ca standard deviation cc bg "<<pow(a_b/nFb,0.5)<<
" ca standard deviation out bg "<<pow(d_b/nFb,0.5)<<
" det "<<det<<
" media cc bg "<<mB_c<<
" media out bg "<<mB_o<<endl;
549 cout<<
"ca standard deviation cc sig "<<pow(a_s/nFs,0.5)<<
" ca standard deviation out sig "<<pow(d_s/nFs,0.5)<<
" det "<<det<<
" media cc sig "<<mS_c<<
" media out sig "<<mS_o<<endl;
550 if(det==0){cout<<
"Problem: det==0"<<endl;
exit(0);}
560 cout<<
" a_i "<<a_i<<
" d_i "<<d_i<<
" b_i "<<b_i<<
" dm_c "<<dm_c<<
" dm_o "<<dm_o<<endl;
564 w_c=a_i*dm_c+b_i*dm_o;
565 w_o=b_i*dm_c+d_i*dm_o;
568 TGraph *ms=
new TGraph();
569 TGraph *mb=
new TGraph();
570 TGraph *pg=
new TGraph();
571 TGraph *
g=
new TGraph();
572 TGraph *g0=
new TGraph();
573 TGraph *
g1=
new TGraph();
576 for(
int n=Fs;
n<Fs+nFs;
n++){
577 NNTree2->GetEntry(
n);
579 cout<<
" sig"<<
n<<
" "<<w_c*cc+w_o*av<<endl;
580 g0->SetPoint(count,cc,av);
584 cout<<
"count sig "<<count<<endl;
590 for(
int n=Fb;
n<Fb+nFb;
n++){
591 NNTree2->GetEntry(
n);
593 cout<<
" bg"<<
n<<
" "<<w_c*cc+w_o*av<<endl;
594 g1->SetPoint(count,cc,av);
597 double mb0=w_c*(mB_c)+w_o*(mB_o);
600 double ms0=w_c*(mS_c)+w_o*(mS_o);
603 w0=w_c*(mS_c+mB_c)+w_o*(mS_o+mB_o);
604 cout<<
" mS_c+mB_c "<<mS_c+mB_c<<
" mS_o+mB_o "<<mS_o+mB_o<<endl;
606 cout<<
" count bg "<<count<<endl;
617 x_thres=pow(w0*w0/(1+(w_c*w_c/(w_o*w_o))),0.5);
618 y_thres=-w_c/w_o*x_thres;
619 pg->SetPoint(0,x_thres,y_thres);
620 TF1 retta_ms(
"retta_p",
"[1]*x+[0]",-0.5,1.);
621 TF1 retta_mb(
"retta",
"[1]*x+[0]",-0.5,1.);
622 TF1 retta_p(
"retta_p",
"[1]*x+[0]",-0.5,1.);
623 TF1 retta(
"retta",
"[1]*x+[0]",-0.5,1.);
624 retta.SetParameter(0,0.);
627 retta.SetParameter(1,c_ang);
628 double c_ang_p=-1./c_ang;
629 retta_p.SetParameter(1,c_ang_p);
631 q_p=(mS_o+mB_o)/2.-c_ang_p*(mS_c+mB_c)/2.;
633 retta_p.SetParameter(0,q_p);
634 retta_ms.SetParameter(1,c_ang_p);
637 q_ms=mS_o-c_ang_p*mS_c;
638 retta_ms.SetParameter(0,q_ms);
639 retta_mb.SetParameter(1,c_ang_p);
642 q_mb=mB_o-c_ang_p*mB_c;
643 retta_mb.SetParameter(0,q_mb);
644 cout<<
"q_mb "<<q_mb<<
" q_ms "<<q_ms<<
" mS_o "<<mS_o<<
" mS_c"<<mS_c<<
" mB_o "<<mB_o<<
" mB_c"<<mB_c<<endl;
645 cout<<
" wc "<<w_c<<
" w_o "<<w_o<<
" coef ang "<<c_ang<<
" x_thres "<<x_thres<<
" y_thres "<<y_thres<<
" w0 "<<w0<<
" q_p "<<q_p<<
" c_ang_p"<<c_ang_p<<endl;
646 TCanvas *canv=
new TCanvas(
"reg_wErr_woErr_media",
"reg_wErr_woErr_media",0,0,600,400);
647 g1->SetMarkerStyle(6);
648 g1->SetMarkerColor(4);
649 g0->SetMarkerStyle(7);
650 g0->SetMarkerColor(2);
651 g->SetPoint(0,1,1.3);
652 g->SetPoint(1,-0.3,-0.3);
653 g->SetMarkerColor(10);
657 pg->SetMarkerStyle(29);
658 pg->SetMarkerColor(1);
659 retta_ms.SetLineColor(3);
660 retta_mb.SetLineColor(3);
661 retta_p.SetLineColor(6);
662 retta_ms.Draw(
"same");
663 retta_mb.Draw(
"same");
664 retta_p.Draw(
"same");
665 retta.SetLineColor(1);
669 char nomecroot[1024];
670 sprintf(nomec,
"Fisher_png/%s_.png",name.Data());
671 sprintf(nomecroot,
"Fisher_png/%s_.root",name.Data());
673 canv->SaveAs(nomecroot);
678 NOMEtot.ReplaceAll(
"average_file/",
"");
679 NOMEtot.ReplaceAll(
".root",
"");
681 sprintf(namefF,
"Fisher_file/%s_Fisher.root",NOMEtot.Data());
682 cout<<
" namefF "<<namefF<<
" NOMEtot "<<NOMEtot.Data()<<endl;
683 TFile* Fishf =
new TFile(namefF,
"RECREATE");
684 TTree* TreeFis=
new TTree(
"Fisher_Discriminant",
"Fisher_Discriminant");
685 TreeFis->SetDirectory(Fishf);
688 TreeFis->Branch(
"Fish_coef_cc",&wc,
"Fish_coef_cc/D");
689 TreeFis->Branch(
"Fish_coef_ANNout",&wo,
"Fish_coef_ANNout/D");
690 TreeFis->Branch(
"nFs",&nFs,
"nFs/I");
691 TreeFis->Branch(
"nFb",&nFb,
"nFb/I");
692 TreeFis->Branch(
"Fb_start",&Fb,
"Fb_start/I");
693 TreeFis->Branch(
"Fs_start",&Fs,
"Fs_start/I");
695 sprintf(nomeif,
"%s",ifile.Data());
696 TreeFis->Branch(
"File_name",&nomeif,
"File_name/C");
701 cout<<
" wc "<<wc<<
" wo "<<wo<<endl;
702 cout<<
" entries "<<TreeFis->GetEntries()<<endl;
712 name.ReplaceAll(
"average_file/",
"Fisher_file/");
713 TFile* fTEST =TFile::Open(ifile.Data());
714 TTree* NNTree2=(TTree*)fTEST->Get(
"Parameters");
724 namefF.ReplaceAll(
".root",
"_Fisher.root");
725 TFile* fF =TFile::Open(namefF.Data());
726 TTree* FTree= (TTree*)fF->Get(
"Fisher_Discriminant");
727 FTree->SetBranchAddress(
"Fs_start",&Fs);
728 FTree->SetBranchAddress(
"Fb_start",&Fb);
729 FTree->SetBranchAddress(
"nFs",&nFs);
730 FTree->SetBranchAddress(
"nFb",&nFb);
731 FTree->SetBranchAddress(
"Fish_coef_cc",&w_c);
732 FTree->SetBranchAddress(
"Fish_coef_ANNout",&w_o);
736 FTree->Branch(
"w_i",&w_i,
"w_i/D");
737 FTree->Branch(
"index",&ind,
"index/I");
740 name.ReplaceAll(
"Fisher_file/",
"");
746 NNTree2->SetBranchAddress(
"Average",&av);
747 NNTree2->SetBranchAddress(
"cc",&cc);
748 NNTree2->SetBranchAddress(
"rho",&rho);
749 NNTree2->SetBranchAddress(
"#TestSig",&nSi);
750 NNTree2->GetEntry(0);
753 cout<<
"nSig: "<<nSig<<
" nSi: "<<nSi<<endl;
754 cout<<
" BG: "<<NNTree2->GetEntries()-nSi<<endl;
755 int nBgi=NNTree2->GetEntries()-nSi;
756 double minw_i=10000000;
759 for(
int u=0;u<nSi;u++ ){
760 if (u>=Fs&&u<(Fs+nFs))
continue;
762 NNTree2->GetEntry(u);
763 cout<<
" u "<<u<<endl;
766 if(w_i<minw_i)minw_i=w_i;
767 if(w_i>maxw_i)maxw_i=w_i;
769 int const nSigF=FTree->GetEntries();
770 cout<<
" nSigF "<<nSigF<<endl;
771 for(
int u=nSi;u<nSi+nBgi;u++ ){
772 if (u>=Fb&&u<(Fb+nFb))
continue;
774 NNTree2->GetEntry(u);
775 cout<<
" u "<<u<<endl;
778 if(w_i<minw_i)minw_i=w_i;
779 if(w_i>maxw_i)maxw_i=w_i;
782 cout<<
"F Entries "<<FTree->GetEntries()<<endl;
785 deltaw=(maxw_i-minw_i)/50.;
786 TH1D *hbg=
new TH1D(
"Hbg",
"projection[0]", 50, minw_i-deltaw, maxw_i+ deltaw);
787 TH1D *hsig=
new TH1D(
"Hsig",
"projection[0]", 50, minw_i-deltaw, maxw_i+deltaw);
788 hsig->SetDirectory(0);
789 hbg->SetDirectory(0);
793 for(
int u=0; u<FTree->GetEntries()-1;u++){
795 cout<<
" u "<<u<<
" ind "<<ind<<
" w_i "<<w_i<<
" nSigF-1 "<<nSigF-1<<endl;
796 if(u<nSigF-1) hsig->Fill(w_i);
802 TCanvas *c_histo=
new TCanvas(
"Histogram_Fisher",
"Histogram_Fisher", 0,0,900,600);
803 hbg->SetLineColor(kBlue);
804 hbg->SetFillStyle(3008); hbg->SetFillColor(kBlue);
805 hsig->SetLineColor(kRed);
806 hsig->SetFillStyle(3003); hsig->SetFillColor(kRed);
813 TLegend *hlegend =
new TLegend(.75, .80, .95, .95);
814 hlegend->AddEntry(hbg,
"Background");
815 hlegend->AddEntry(hsig,
"Signal");
818 char namechroot[2048];
820 namch.ReplaceAll(
".root",
".png");
821 sprintf(namech,
"Fisher_png/Histog_%s",namch.Data());
822 sprintf(namechroot,
"Fisher_png/Histog_%s",name.Data());
823 c_histo->SaveAs(namech);
824 c_histo->SaveAs(namechroot);
1421 name.ReplaceAll(
"outfile/",
"");
1422 name.ReplaceAll(
"average_file/",
"");
1423 TFile* fTEST =TFile::Open(ifile.Data());
1424 TTree* NNTree2=(TTree*)fTEST->Get(
"Parameters");
1432 NNTree2->SetBranchAddress(
"Average",&av);
1433 NNTree2->SetBranchAddress(
"cc",&cc);
1434 NNTree2->SetBranchAddress(
"rho",&rho);
1435 NNTree2->SetBranchAddress(
"#TestSig",&nSi);
1436 NNTree2->GetEntry(0);
1438 cout<<
"nSig: "<<nSig<<
" nSi: "<<nSi<<endl;
1439 int const nBg=NNTree2->GetEntries()-nSig;
1440 cout<<
"nBg: "<<nBg<<
" Entries: "<<NNTree2->GetEntries()<<endl;
1447 for (
int n = 0;
n <NNTree2->GetEntries();
n++){
1448 NNTree2->GetEntry(
n);
1450 gS[0]->SetPoint(
n,cc,av);
1451 cout<<
"Sig_graph1: x="<<cc<<
" y: "<<av<<endl;
1454 gB[0]->SetPoint(
n-nSig,cc,av);
1455 cout<<
"Bg_graph1: x="<<cc<<
" y: "<<av<<endl;
1472 gS[0]->SetMarkerColor(2);
1473 gB[0]->SetMarkerColor(4);
1474 gS[0]->SetMarkerStyle(6);
1475 gB[0]->SetMarkerStyle(7);
1477 TCanvas*
c=
new TCanvas(
"Plots",
"Plots",0,0,1200,700);
1480 TMultiGraph* mg1=
new TMultiGraph();
1481 mg1->SetTitle(
"Av_cc");
1482 if(gB[0]->GetN()!=0) mg1->Add(gB[0]);
1483 if(gS[0]->GetN()!=0) mg1->Add(gS[0]);
1486 TMultiGraph* mg2=
new TMultiGraph();
1487 mg2->SetTitle(
"Av_cc");
1488 if(gS[0]->GetN()!=0) mg2->Add(gS[0]);
1489 if(gB[0]->GetN()!=0) mg2->Add(gB[0]);
1492 cout<<
" name "<<name<<endl;
1496 char Cname2root[1024];
1497 Cname.ReplaceAll(
".root",
".png");
1498 sprintf(Cname2,
"average_png/out_Plots_%s",Cname.Data());
1499 sprintf(Cname2root,
"average_png/out_Plots_%s",Cnameroot.Data());
1501 c->Print(Cname2root);
1539 name.ReplaceAll(
"outfile/",
"");
1540 name.ReplaceAll(
"average_file/",
"");
1541 TFile* fTEST =TFile::Open(ifile.Data());
1542 TTree* NNTree2=(TTree*)fTEST->Get(
"Parameters");
1551 NNTree2->SetBranchAddress(
"Mchirp",&Mc);
1552 NNTree2->SetBranchAddress(
"Average",&av);
1553 NNTree2->SetBranchAddress(
"cc",&cc);
1554 NNTree2->SetBranchAddress(
"rho",&rho);
1555 NNTree2->SetBranchAddress(
"#TestSig",&nSi);
1556 NNTree2->GetEntry(0);
1558 cout<<
"nSig: "<<nSig<<
" nSi: "<<nSi<<endl;
1559 int const nBg=NNTree2->GetEntries()-nSig;
1566 for (
int n = 0;
n <NNTree2->GetEntries();
n++){
1567 NNTree2->GetEntry(
n);
1569 gS[0]->SetPoint(
n,Mc,av);
1570 cout<<
"Sig_graph1: x="<<cc<<
" y: "<<av<<endl;
1573 gB[0]->SetPoint(
n-nSig,Mc,av);
1574 cout<<
"Bg_graph1: x="<<cc<<
" y: "<<av<<endl;
1587 gS[0]->SetMarkerColor(2);
1588 gB[0]->SetMarkerColor(4);
1589 gS[0]->SetMarkerStyle(6);
1590 gB[0]->SetMarkerStyle(7);
1592 TCanvas*
c=
new TCanvas(
"Plots",
"Plots",0,0,1200,700);
1595 TMultiGraph* mg1=
new TMultiGraph();
1596 mg1->SetTitle(
"Av_Mc");
1597 if(gB[0]->GetN()!=0) mg1->Add(gB[0]);
1598 if(gS[0]->GetN()!=0) mg1->Add(gS[0]);
1601 TMultiGraph* mg2=
new TMultiGraph();
1602 mg2->SetTitle(
"Av_Mc");
1603 if(gS[0]->GetN()!=0) mg2->Add(gS[0]);
1604 if(gB[0]->GetN()!=0) mg2->Add(gB[0]);
1607 cout<<
" name "<<name<<endl;
1611 char Cname2root[1024];
1612 Cname.ReplaceAll(
".root",
".png");
1613 sprintf(Cname2,
"average_png/Mc_Plots_%s",Cname.Data());
1614 sprintf(Cname2root,
"average_png/Mc_Plots_%s",Cnameroot.Data());
1616 c->Print(Cname2root);
Float_t * rho
biased null statistics
static double g(double e)
wavearray< double > a(hp.size())
void graph_Fish(TString ifile)
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 PlotsAv_cc(TString ifile)
cout<< "Injected signals: "<< mdc.GetEntries()<< endl;cout<< "Injected signals in histogram factor_events_inj: "<< NEVTS<< endl;float myifar, ecor, m1, m2, netcc[3], neted, penalty;float rho[2];float chirp[6];float range[2];float frequency[2];float iSNR[3], sSNR[3];sim.SetBranchAddress("mass", mass);sim.SetBranchAddress("factor",&factor);sim.SetBranchAddress("range", range);sim.SetBranchAddress("chirp", chirp);sim.SetBranchAddress("rho", rho);sim.SetBranchAddress("netcc", netcc);sim.SetBranchAddress("neted",&neted);sim.SetBranchAddress("ifar",&myifar);sim.SetBranchAddress("ecor",&ecor);sim.SetBranchAddress("penalty",&penalty);sim.SetBranchAddress("time", mytime);sim.SetBranchAddress("iSNR", iSNR);sim.SetBranchAddress("sSNR", sSNR);sim.SetBranchAddress("spin", spin);sim.SetBranchAddress("frequency", frequency);float **volume=new float *[NBINS_mass1];float **volume_first_shell=new float *[NBINS_mass1];float **radius=new float *[NBINS_mass1];float **error_volume=new float *[NBINS_mass1];float **error_volume_first_shell=new float *[NBINS_mass1];float **error_radius=new float *[NBINS_mass1];for(int i=0;i< NBINS_mass1;i++){volume[i]=new float[NBINS_mass2];volume_first_shell[i]=new float[NBINS_mass2];radius[i]=new float[NBINS_mass2];error_volume[i]=new float[NBINS_mass2];error_volume_first_shell[i]=new float[NBINS_mass2];error_radius[i]=new float[NBINS_mass2];for(int j=0;j< NBINS_mass2;j++){volume[i][j]=0.;volume_first_shell[i][j]=0.;radius[i][j]=0.;error_volume[i][j]=0.;error_volume_first_shell[i][j]=0.;error_radius[i][j]=0.;}}float **spin_mtot_volume=new float *[NBINS_MTOT+1];float **spin_mtot_radius=new float *[NBINS_MTOT+1];float **error_spin_mtot_volume=new float *[NBINS_MTOT+1];float **error_spin_mtot_radius=new float *[NBINS_MTOT+1];for(int i=0;i< NBINS_MTOT+1;i++){spin_mtot_volume[i]=new float[NBINS_SPIN+1];spin_mtot_radius[i]=new float[NBINS_SPIN+1];error_spin_mtot_volume[i]=new float[NBINS_SPIN+1];error_spin_mtot_radius[i]=new float[NBINS_SPIN+1];for(int j=0;j< NBINS_SPIN+1;j++){spin_mtot_volume[i][j]=0.;error_spin_mtot_volume[i][j]=0.;spin_mtot_radius[i][j]=0.;error_spin_mtot_radius[i][j]=0.;}}char fname[1024];sprintf(fname,"%s/recovered_signals.txt", netdir);ofstream fev;fev.open(fname, std::ofstream::out);sprintf(line,"#GPS@L1 FAR[Hz] eFAR[Hz] Pval ""ePval factor rho frequency iSNR sSNR \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 Fisher_ex(TString ifile, int nFs, int nFb, int Fs, int Fb)
void Fisher_1(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 nFs, int nFb, int Fs=0, int Fb=0, int TS=0, int TB=0, int s=0, int b=0, int uf=1, int ni=0)
void PlotsAv_Mc(TString ifile)
sprintf(tfres,"(1/%g)x(%g) (sec)x(Hz)", 2 *df, df)
for(int i=0;i< 101;++i) Cos2[2][i]=0
Float_t * chirp
range to source: [0/1]-rec/inj