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 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){
65 if (NN_FILE.CompareTo(
"")){
68 if (NN_FILE2.CompareTo(
"")){
71 if (NN_FILE3.CompareTo(
"")){
74 if (NN_FILE4.CompareTo(
"")){
77 if (NN_FILE5.CompareTo(
"")){
80 if (NN_FILE6.CompareTo(
"")){
83 if (NN_FILE7.CompareTo(
"")){
86 if (NN_FILE8.CompareTo(
"")){
94 sprintf(NNi2[0],
"%s",NN_FILE.Data());
95 if(nNN>1)
sprintf(NNi2[1],
"%s",NN_FILE2.Data());
96 if(nNN>2)
sprintf(NNi2[2],
"%s",NN_FILE3.Data());
97 if(nNN>3)
sprintf(NNi2[3],
"%s",NN_FILE4.Data());
98 if(nNN>4)
sprintf(NNi2[4],
"%s",NN_FILE5.Data());
99 if(nNN>5)
sprintf(NNi2[5],
"%s",NN_FILE6.Data());
100 if(nNN>6)
sprintf(NNi2[6],
"%s",NN_FILE7.Data());
101 if(nNN>7)
sprintf(NNi2[7],
"%s",NN_FILE8.Data());
102 for (
int u=0;u<nNN;u++){
106 if (NNi2[u][p]==
'N'){
108 if((NNi2[u][p+1]==
'N')&&(NNi2[u][p+2]==
'\/')) {
111 while (NNi2[u][hh]!=
'\0'){NNi[u][hh-p-3]=NNi2[u][
hh];hh=hh+1;}
121 sprintf(Filei2,
"%s",TEST_FILE.Data());
123 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]==
'\/')) {
125 while (Filei2[hh]!=
'\0') {Filei[hh-q-7]=Filei2[
hh];hh=hh+1;
127 for (
int h0=hh-q-7;h0<1024;h0++) Filei[h0]=
'\0';
133 cout<<Filei<<
" original String: "<<Filei2<<endl;
138 if(nNN>1) NNi0[1]=NNi[1];
139 if(nNN>2) NNi0[2]=NNi[2];
140 if(nNN>3) NNi0[3]=NNi[3];
141 if(nNN>4) NNi0[4]=NNi[4];
142 if(nNN>5) NNi0[5]=NNi[5];
143 if(nNN>6) NNi0[6]=NNi[6];
144 if(nNN>7) NNi0[7]=NNi[7];
148 for (
int u=0;u<nNN;u++){
149 NNi0[u].ReplaceAll(
".root",
"");
151 Filei0.ReplaceAll(
".root",
"");
154 TMultiLayerPerceptron* mlp[nNN];
160 for (
int u=0;u<nNN;u++){
161 fnet[u]=TFile::Open(NNi2[u]);
163 cout<<
"dopo file"<<endl;
164 mlp[u]=(TMultiLayerPerceptron*)fnet[u]->Get(
"TMultiLayerPerceptron");
166 cout<<
"dopo TMLP"<<endl;
167 if(mlp[u]==NULL) {cout <<
"Error getting mlp" << endl;
exit(1);}
168 infot[u]=(TTree*)fnet[u]->Get(
"info");
169 infot[u]->SetBranchAddress(
"Rand_start_Sig",&NNs[u]);
170 infot[u]->SetBranchAddress(
"Rand_start_Bg",&NNb[u]);
171 infot[u]->SetBranchAddress(
"#trainSig",&NNnTS[u]);
172 infot[u]->SetBranchAddress(
"#trainBg",&NNnTB[u]);
173 infot[u]->GetEntry(0);
174 if(NNb[u]<min_NNb) min_NNb=NNb[u];
175 cout<<
"n "<<u<<
" b "<<NNb[u]<<
" min_NNb "<<min_NNb<<endl;
177 cout<<
"da Tree"<<endl;
178 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;
180 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;}
182 cout<<
"Def. tree e mlp"<<endl;
183 TFile* fTEST =TFile::Open(TEST_FILE.Data());
184 TTree* NNTree=(TTree*)fTEST->Get(
"nnTree");
185 int entries=NNTree->GetEntries();
186 cout<<
"entries: "<<entries<<endl;
196 NNTree->SetBranchAddress(
"#Entries_type",&entriesTot);
197 NNTree->SetBranchAddress(
"Matrix_dim",&ndim);
198 NNTree->SetBranchAddress(
"#inputs",&ninp);
199 NNTree->SetBranchAddress(
"amplitude_mode",&y);
202 sig_entries=entriesTot;
203 NNTree->GetEntry(entries-1);
204 bg_entries=entriesTot;
209 cout<<
"NDIM "<<NDIM<<endl;
210 cout<<
"nINP"<<nINP<<endl;
211 cout<<
"sig e "<<sig_entries<<endl;
212 cout<<
"bg e "<<bg_entries<<endl;
214 if (sig_entries>bg_entries) minevents=bg_entries;
215 else minevents=sig_entries;
217 if(b==0) b=sig_entries;
223 cout<<
"Error: Bg index<sig_entries"<<endl;
226 if((TS>sig_entries||
TB>bg_entries)&&(TS==
TB)) {TS=minevents-
s;
TB=minevents-b+sig_entries;}
227 if((TS>sig_entries||
TB>bg_entries)&&(TS!=
TB)) {TS=sig_entries-
s;
TB=bg_entries-b+sig_entries;}
231 sprintf(NOMEtot,
"%s",NOMEtot_S.Data());
232 cout<<
"nome: "<<NOMEtot<<endl;
237 NNTree->SetBranchAddress(
"Files_name",&FILE_NAME);
240 NNTree->GetEntry(entries-1);
242 cout<<
"fine ifdef RHO_CC"<<endl;
244 TChain sigTree(
"waveburst");
245 sigTree.Add(SIG_FILE.Data());
248 cout <<
"sig entries2 : " << sig_entries2 << endl;
250 TChain bgTree(
"waveburst");
251 bgTree.Add(BG_FILE.Data());
254 cout <<
"bg entries2 : " << bg_entries2 << endl;
256 cout<<
"b: "<<b<<endl;
257 cout<<
"s: "<<
s<<endl;
261 for (
int jj=0; jj<nINP;jj++) x[jj]=0.;
262 char ilabel[nINP][16];
265 for(
int i=0;
i<nINP;
i++) {
267 NNTree->SetBranchAddress(ilabel[i], &x[i]);
271 sprintf(ofile,
"average_file/%s.root",NOMEtot);
272 TFile*
f =
new TFile(ofile,
"RECREATE");
273 TTree* NNTree2=
new TTree(
"Parameters",
"Parameters");
274 NNTree2->SetDirectory(f);
277 for(
int y=0; y<nNN; y++) out[y]=0.;
282 NNTree2->Branch(
"Average",&average,
"Average/D");
283 NNTree2->Branch(
"StandardDevaition",&std,
"StandardDeviation/D");
284 NNTree2->Branch(
"cc",&NNcc,
"cc/D");
285 NNTree2->Branch(
"Mchirp",&Mc,
"Mchirp/D");
286 NNTree2->Branch(
"rho",&NNrho,
"rho/D");
287 for(
int u=0;u<nNN;u++){
293 sprintf(NNoutl2,
"NNout%i/D",u);
295 sprintf(NNnamel2,
"NNname%i/C",u);
296 NNTree2->Branch(NNoutl,&out[u],NNoutl2);
297 NNTree2->Branch(NNnamel,&NNi[u],NNnamel2);}
299 NNTree2->Branch(
"TestFile",&Testf,
"TestFile/C");
300 sprintf(Testf,
"%s",TEST_FILE.Data());
302 NNTree2->Branch(
"#TestSig",&nTestS,
"#TestSig/I");
303 cout<<
"nTestS: "<<nTestS<<
" TS: "<<TS<<endl;
304 cout<<
"dopo def tree"<<endl;
308 for(
int n=
s;
n<
s+TS;
n++) {
310 for(
int u=0;u<nNN;u++){
311 if (uf!=0&&
n>=NNs[u]&&
n<(NNs[u]+NNnTS[u])) countNN=countNN+1;
314 if(countNN==1&&ni==0) scount=scount+1;
315 if(countNN<2&&ni!=0) scount=scount+1;
316 if(countNN>1){cout<<
"Error: training non independent";
exit(0);}
321 cout<<
"s test "<<
s<<
" s+TS "<<
s+TS<<
" b "<<b<<
" b+ TB "<<b+
TB<<
" nTestS "<<nTestS<<endl;
325 for (
int i=0;
i<nINP;
i++) params[
i]=0.;
330 for(
int n=
s;
n<
s+TS;
n++) {
334 for(
int u=0;u<nNN;u++){
335 if (uf!=0&&
n>=NNs[u]&&
n<(NNs[u]+NNnTS[u])) { indNN=u;countNN=countNN+1;}
337 if (countNN>1){cout<<
"Error: training non independent";
exit(0);}
338 if(nNN==1){cout<<
"out==Averege:only 1NN is considered"<<endl;}
339 if(ni==0&&countNN==0)
continue;
342 NNcc=(double)signal.
netcc[1];
343 NNrho=(
double)signal.
rho[0];
345 for (
int i=0;
i<nINP;
i++){
348 for (
int u=0;u<nNN;u++) {
349 double output=mlp[u]->Evaluate(0,params);
353 for (
int u=0;u<nNN;u++){
354 if((u!=indNN&&ni==0)||ni!=0) {average=out[u]+average;std+=out[u]*out[u];}
357 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);}
358 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);}
359 cout<<
"average: "<<average<<endl;
361 if (average<0.6) TD=TD+1;
372 cout<<
"riempito sig"<<endl;
374 cout<<
"b "<<b<<
" TB "<<
TB<<endl;
381 cout<<
" prima ciclo fro bg"<<endl;
383 for(
int n=b;
n<b+
TB;
n++) {
388 for(
int u=0;u<nNN;u++){
389 cout<<
" uf "<<uf<<
" n "<<
n<<
" u "<<u<<
" NN b[u] "<<NNb[u]<<
" (primo non preso) NNb[u]+NNnTB[u]"<<NNb[u]+NNnTB[u]<<endl;
390 if (uf!=0&&
n>=NNb[u]&&
n<(NNb[u]+NNnTB[u])) { indNN=u;countNN=countNN+1;
394 if (countNN>1){cout<<
"Error: training non independent";
exit(0);}
395 if(nNN==1){cout<<
"out==Averege:only 1NN is considered"<<endl;}
396 if(ni==0&&countNN==0){
397 cout<<
"countNN"<<countNN<<endl;
401 cout<<
"n: "<<
n<<
"Bg index"<<(
n-sig_entries)<<endl;
403 NNcc=(double)background.
netcc[1];
404 NNrho=(
double)background.
rho[0];
406 for (
int i=0;
i<nINP;
i++){
411 for(
int u=0;u<nNN;u++) {
412 double output=mlp[u]->Evaluate(0,params);
416 for (
int u=0;u<nNN;u++){
417 if((u!=indNN&&ni==0)||ni!=0) { average=out[u]+average;std=out[u]*out[u];}
419 if(nNN!=1&&ni==0) {cout<<average<<endl;average=average/(nNN-countNN);
421 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);}
424 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;}
425 cout<<
"average: "<<average<<
" nNN-1-countNN "<<nNN-1-countNN<<endl;
426 if(average>0.6) FA=FA+1;
441 cout<<
"riempito bg"<<endl;
447 cout<<
"chiuso file"<<endl;
453 cout<<
"dopo richiamo funzione"<<endl;
460 cout<<
" S_eff "<<S_eff<<
" B_eff "<<B_eff<<endl;
461 cout<<
" FA>0.6 "<<FA<<
" TD<0.6 "<<TD<<
" FA/tot_BG "<<FA/B_eff<<
" TD/tot_S "<<TD/S_eff<<endl;
471 name.ReplaceAll(
"average_file/",
"");
472 TFile* fTEST =TFile::Open(ifile.Data());
473 TTree* NNTree2=(TTree*)fTEST->Get(
"Parameters");
477 NNTree2->SetBranchAddress(
"Average",&av);
478 NNTree2->SetBranchAddress(
"cc",&cc);
479 NNTree2->SetBranchAddress(
"#TestSig",&nSi);
480 NNTree2->GetEntry(0);
495 if (nFs+Fs>nSi){ Fs=0;
if(nFs>nSi) nFs=nSi; cout<<
" change: Fs "<<Fs<<
" nFs "<<nFs<<endl;}
497 if (Fb<nSi) {Fb=nSi+Fb; cout<<
" change: Fb "<<Fb<<endl;}
499 for(
int n=Fs;
n<Fs+nFs;
n++){
500 NNTree2->GetEntry(
n);
511 int const TOTent=NNTree2->GetEntries();
512 int const nBg=NNTree2->GetEntries()-nSi;
513 cout<<
"nSi "<<nSi<<
" nBg "<<nBg<<
" entries "<<TOTent<<endl;
515 if (nFb+Fb>TOTent){ Fb=nSi;
if(nFs>nBg) nFb=nBg; cout<<
" change: Fb "<<Fb<<
" nFb "<<nFb<<endl;}
517 for(
int n=Fb;
n<Fb+nFb;
n++){
518 NNTree2->GetEntry(
n);
537 a_b=qB_c-nFb*(mB_c*mB_c);
538 d_b=qB_o-nFb*(mB_o*mB_o);
539 b_b=sB_co-nFb*(mB_c*mB_o);
541 cout<<
"a_b "<<a_b<<endl;
542 cout<<
"d_b "<<d_b<<endl;
543 cout<<
"a_s "<<a_s<<endl;
544 cout<<
"d_s "<<d_s<<endl;
545 a_s=qS_c-nFs*(mS_c*mS_c);
546 d_s=qS_o-nFs*(mS_o*mS_o);
547 b_s=sS_co-nFs*(mS_c*mS_o);
566 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;
567 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;
568 if(det==0){cout<<
"Problem: det==0"<<endl;
exit(0);}
578 cout<<
" a_i "<<a_i<<
" d_i "<<d_i<<
" b_i "<<b_i<<
" dm_c "<<dm_c<<
" dm_o "<<dm_o<<endl;
582 w_c=a_i*dm_c+b_i*dm_o;
583 w_o=b_i*dm_c+d_i*dm_o;
586 TGraph *ms=
new TGraph();
587 TGraph *mb=
new TGraph();
588 TGraph *pg=
new TGraph();
589 TGraph *
g=
new TGraph();
590 TGraph *g0=
new TGraph();
591 TGraph *
g1=
new TGraph();
594 for(
int n=Fs;
n<Fs+nFs;
n++){
595 NNTree2->GetEntry(
n);
597 cout<<
" sig"<<
n<<
" "<<w_c*cc+w_o*av<<endl;
598 g0->SetPoint(count,cc,av);
602 cout<<
"count sig "<<count<<endl;
608 for(
int n=Fb;
n<Fb+nFb;
n++){
609 NNTree2->GetEntry(
n);
611 cout<<
" bg"<<
n<<
" "<<w_c*cc+w_o*av<<endl;
612 g1->SetPoint(count,cc,av);
615 double mb0=w_c*(mB_c)+w_o*(mB_o);
618 double ms0=w_c*(mS_c)+w_o*(mS_o);
621 w0=w_c*(mS_c+mB_c)+w_o*(mS_o+mB_o);
622 cout<<
" mS_c+mB_c "<<mS_c+mB_c<<
" mS_o+mB_o "<<mS_o+mB_o<<endl;
624 cout<<
" count bg "<<count<<endl;
635 x_thres=pow(w0*w0/(1+(w_c*w_c/(w_o*w_o))),0.5);
636 y_thres=-w_c/w_o*x_thres;
637 pg->SetPoint(0,x_thres,y_thres);
638 TF1 retta_ms(
"retta_p",
"[1]*x+[0]",-0.5,1.);
639 TF1 retta_mb(
"retta",
"[1]*x+[0]",-0.5,1.);
640 TF1 retta_p(
"retta_p",
"[1]*x+[0]",-0.5,1.);
641 TF1 retta(
"retta",
"[1]*x+[0]",-0.5,1.);
642 retta.SetParameter(0,0.);
645 retta.SetParameter(1,c_ang);
646 double c_ang_p=-1./c_ang;
647 retta_p.SetParameter(1,c_ang_p);
649 q_p=(mS_o+mB_o)/2.-c_ang_p*(mS_c+mB_c)/2.;
651 retta_p.SetParameter(0,q_p);
652 retta_ms.SetParameter(1,c_ang_p);
655 q_ms=mS_o-c_ang_p*mS_c;
656 retta_ms.SetParameter(0,q_ms);
657 retta_mb.SetParameter(1,c_ang_p);
660 q_mb=mB_o-c_ang_p*mB_c;
661 retta_mb.SetParameter(0,q_mb);
662 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;
663 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;
664 TCanvas *canv=
new TCanvas(
"reg_wErr_woErr_media",
"reg_wErr_woErr_media",0,0,600,400);
665 g1->SetMarkerStyle(6);
666 g1->SetMarkerColor(4);
667 g0->SetMarkerStyle(7);
668 g0->SetMarkerColor(2);
669 g->SetPoint(0,1,1.3);
670 g->SetPoint(1,-0.3,-0.3);
671 g->SetMarkerColor(10);
675 pg->SetMarkerStyle(29);
676 pg->SetMarkerColor(1);
677 retta_ms.SetLineColor(3);
678 retta_mb.SetLineColor(3);
679 retta_p.SetLineColor(6);
680 retta_ms.Draw(
"same");
681 retta_mb.Draw(
"same");
682 retta_p.Draw(
"same");
683 retta.SetLineColor(1);
687 char nomecroot[1024];
688 sprintf(nomec,
"Fisher_png/%s_.png",name.Data());
689 sprintf(nomecroot,
"Fisher_png/%s_.root",name.Data());
691 canv->SaveAs(nomecroot);
696 NOMEtot.ReplaceAll(
"average_file/",
"");
697 NOMEtot.ReplaceAll(
".root",
"");
699 sprintf(namefF,
"Fisher_file/%s_Fisher.root",NOMEtot.Data());
700 cout<<
" namefF "<<namefF<<
" NOMEtot "<<NOMEtot.Data()<<endl;
701 TFile* Fishf =
new TFile(namefF,
"RECREATE");
702 TTree* TreeFis=
new TTree(
"Fisher_Discriminant",
"Fisher_Discriminant");
703 TreeFis->SetDirectory(Fishf);
706 TreeFis->Branch(
"Fish_coef_cc",&wc,
"Fish_coef_cc/D");
707 TreeFis->Branch(
"Fish_coef_ANNout",&wo,
"Fish_coef_ANNout/D");
708 TreeFis->Branch(
"nFs",&nFs,
"nFs/I");
709 TreeFis->Branch(
"nFb",&nFb,
"nFb/I");
710 TreeFis->Branch(
"Fb_start",&Fb,
"Fb_start/I");
711 TreeFis->Branch(
"Fs_start",&Fs,
"Fs_start/I");
713 sprintf(nomeif,
"%s",ifile.Data());
714 TreeFis->Branch(
"File_name",&nomeif,
"File_name/C");
719 cout<<
" wc "<<wc<<
" wo "<<wo<<endl;
720 cout<<
" entries "<<TreeFis->GetEntries()<<endl;
730 name.ReplaceAll(
"average_file/",
"Fisher_file/");
731 TFile* fTEST =TFile::Open(ifile.Data());
732 TTree* NNTree2=(TTree*)fTEST->Get(
"Parameters");
742 namefF.ReplaceAll(
".root",
"_Fisher.root");
743 TFile* fF =TFile::Open(namefF.Data());
744 TTree* FTree= (TTree*)fF->Get(
"Fisher_Discriminant");
745 FTree->SetBranchAddress(
"Fs_start",&Fs);
746 FTree->SetBranchAddress(
"Fb_start",&Fb);
747 FTree->SetBranchAddress(
"nFs",&nFs);
748 FTree->SetBranchAddress(
"nFb",&nFb);
749 FTree->SetBranchAddress(
"Fish_coef_cc",&w_c);
750 FTree->SetBranchAddress(
"Fish_coef_ANNout",&w_o);
754 FTree->Branch(
"w_i",&w_i,
"w_i/D");
755 FTree->Branch(
"index",&ind,
"index/I");
758 name.ReplaceAll(
"Fisher_file/",
"");
764 NNTree2->SetBranchAddress(
"Average",&av);
765 NNTree2->SetBranchAddress(
"cc",&cc);
766 NNTree2->SetBranchAddress(
"rho",&rho);
767 NNTree2->SetBranchAddress(
"#TestSig",&nSi);
768 NNTree2->GetEntry(0);
771 cout<<
"nSig: "<<nSig<<
" nSi: "<<nSi<<endl;
772 cout<<
" BG: "<<NNTree2->GetEntries()-nSi<<endl;
773 int nBgi=NNTree2->GetEntries()-nSi;
774 double minw_i=10000000;
777 for(
int u=0;u<nSi;u++ ){
778 if (u>=Fs&&u<(Fs+nFs))
continue;
780 NNTree2->GetEntry(u);
781 cout<<
" u "<<u<<endl;
784 if(w_i<minw_i)minw_i=w_i;
785 if(w_i>maxw_i)maxw_i=w_i;
787 int const nSigF=FTree->GetEntries();
788 cout<<
" nSigF "<<nSigF<<endl;
789 for(
int u=nSi;u<nSi+nBgi;u++ ){
790 if (u>=Fb&&u<(Fb+nFb))
continue;
792 NNTree2->GetEntry(u);
793 cout<<
" u "<<u<<endl;
796 if(w_i<minw_i)minw_i=w_i;
797 if(w_i>maxw_i)maxw_i=w_i;
800 cout<<
"F Entries "<<FTree->GetEntries()<<endl;
803 deltaw=(maxw_i-minw_i)/50.;
804 TH1D *hbg=
new TH1D(
"Hbg",
"projection[0]", 50, minw_i-deltaw, maxw_i+ deltaw);
805 TH1D *hsig=
new TH1D(
"Hsig",
"projection[0]", 50, minw_i-deltaw, maxw_i+deltaw);
806 hsig->SetDirectory(0);
807 hbg->SetDirectory(0);
811 for(
int u=0; u<FTree->GetEntries()-1;u++){
813 cout<<
" u "<<u<<
" ind "<<ind<<
" w_i "<<w_i<<
" nSigF-1 "<<nSigF-1<<endl;
814 if(u<nSigF-1) hsig->Fill(w_i);
820 TCanvas *c_histo=
new TCanvas(
"Histogram_Fisher",
"Histogram_Fisher", 0,0,900,600);
821 hbg->SetLineColor(kBlue);
822 hbg->SetFillStyle(3008); hbg->SetFillColor(kBlue);
823 hsig->SetLineColor(kRed);
824 hsig->SetFillStyle(3003); hsig->SetFillColor(kRed);
831 TLegend *hlegend =
new TLegend(.75, .80, .95, .95);
832 hlegend->AddEntry(hbg,
"Background");
833 hlegend->AddEntry(hsig,
"Signal");
836 char namechroot[2048];
838 namch.ReplaceAll(
".root",
".png");
839 sprintf(namech,
"Fisher_png/Histog_%s",namch.Data());
840 sprintf(namechroot,
"Fisher_png/Histog_%s",name.Data());
841 c_histo->SaveAs(namech);
842 c_histo->SaveAs(namechroot);
1439 name.ReplaceAll(
"outfile/",
"");
1440 name.ReplaceAll(
"average_file/",
"");
1441 TFile* fTEST =TFile::Open(ifile.Data());
1442 TTree* NNTree2=(TTree*)fTEST->Get(
"Parameters");
1450 NNTree2->SetBranchAddress(
"Average",&av);
1451 NNTree2->SetBranchAddress(
"cc",&cc);
1452 NNTree2->SetBranchAddress(
"rho",&rho);
1453 NNTree2->SetBranchAddress(
"#TestSig",&nSi);
1454 NNTree2->GetEntry(0);
1456 cout<<
"nSig: "<<nSig<<
" nSi: "<<nSi<<endl;
1457 int const nBg=NNTree2->GetEntries()-nSig;
1458 cout<<
"nBg: "<<nBg<<
" Entries: "<<NNTree2->GetEntries()<<endl;
1465 for (
int n = 0;
n <NNTree2->GetEntries();
n++){
1466 NNTree2->GetEntry(
n);
1468 gS[0]->SetPoint(
n,cc,av);
1469 cout<<
"Sig_graph1: x="<<cc<<
" y: "<<av<<endl;
1472 gB[0]->SetPoint(
n-nSig,cc,av);
1473 cout<<
"Bg_graph1: x="<<cc<<
" y: "<<av<<endl;
1490 gS[0]->SetMarkerColor(2);
1491 gB[0]->SetMarkerColor(4);
1492 gS[0]->SetMarkerStyle(6);
1493 gB[0]->SetMarkerStyle(7);
1495 TCanvas*
c=
new TCanvas(
"Plots",
"Plots",0,0,1200,700);
1498 TMultiGraph* mg1=
new TMultiGraph();
1499 mg1->SetTitle(
"Av_cc");
1500 if(gB[0]->GetN()!=0) mg1->Add(gB[0]);
1501 if(gS[0]->GetN()!=0) mg1->Add(gS[0]);
1504 TMultiGraph* mg2=
new TMultiGraph();
1505 mg2->SetTitle(
"Av_cc");
1506 if(gS[0]->GetN()!=0) mg2->Add(gS[0]);
1507 if(gB[0]->GetN()!=0) mg2->Add(gB[0]);
1510 cout<<
" name "<<name<<endl;
1514 char Cname2root[1024];
1515 Cname.ReplaceAll(
".root",
".png");
1516 sprintf(Cname2,
"average_png/out_Plots_%s",Cname.Data());
1517 sprintf(Cname2root,
"average_png/out_Plots_%s",Cnameroot.Data());
1519 c->Print(Cname2root);
1557 name.ReplaceAll(
"outfile/",
"");
1558 name.ReplaceAll(
"average_file/",
"");
1559 TFile* fTEST =TFile::Open(ifile.Data());
1560 TTree* NNTree2=(TTree*)fTEST->Get(
"Parameters");
1569 NNTree2->SetBranchAddress(
"Mchirp",&Mc);
1570 NNTree2->SetBranchAddress(
"Average",&av);
1571 NNTree2->SetBranchAddress(
"cc",&cc);
1572 NNTree2->SetBranchAddress(
"rho",&rho);
1573 NNTree2->SetBranchAddress(
"#TestSig",&nSi);
1574 NNTree2->GetEntry(0);
1576 cout<<
"nSig: "<<nSig<<
" nSi: "<<nSi<<endl;
1577 int const nBg=NNTree2->GetEntries()-nSig;
1584 for (
int n = 0;
n <NNTree2->GetEntries();
n++){
1585 NNTree2->GetEntry(
n);
1587 gS[0]->SetPoint(
n,Mc,av);
1588 cout<<
"Sig_graph1: x="<<cc<<
" y: "<<av<<endl;
1591 gB[0]->SetPoint(
n-nSig,Mc,av);
1592 cout<<
"Bg_graph1: x="<<cc<<
" y: "<<av<<endl;
1605 gS[0]->SetMarkerColor(2);
1606 gB[0]->SetMarkerColor(4);
1607 gS[0]->SetMarkerStyle(6);
1608 gB[0]->SetMarkerStyle(7);
1610 TCanvas*
c=
new TCanvas(
"Plots",
"Plots",0,0,1200,700);
1613 TMultiGraph* mg1=
new TMultiGraph();
1614 mg1->SetTitle(
"Av_Mc");
1615 if(gB[0]->GetN()!=0) mg1->Add(gB[0]);
1616 if(gS[0]->GetN()!=0) mg1->Add(gS[0]);
1619 TMultiGraph* mg2=
new TMultiGraph();
1620 mg2->SetTitle(
"Av_Mc");
1621 if(gS[0]->GetN()!=0) mg2->Add(gS[0]);
1622 if(gB[0]->GetN()!=0) mg2->Add(gB[0]);
1625 cout<<
" name "<<name<<endl;
1629 char Cname2root[1024];
1630 Cname.ReplaceAll(
".root",
".png");
1631 sprintf(Cname2,
"average_png/Mc_Plots_%s",Cname.Data());
1632 sprintf(Cname2root,
"average_png/Mc_Plots_%s",Cnameroot.Data());
1634 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<< "\ 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
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 \");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
pointers to detectors
Float_t * chirp
range to source: [0/1]-rec/inj