Logo coherent WaveBurst  
Library Reference Guide
Logo
Test_rho_cc_out1_out2.C
Go to the documentation of this file.
1 /*
2 # Copyright (C) 2019 Serena Vinciguerra
3 #
4 # This program is free software: you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation, either version 3 of the License, or
7 # (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <https://www.gnu.org/licenses/>.
16 */
17 
18 
19 #define XIFO 4
20 
21 #pragma GCC system_header
22 
23 #include "cwb.hh"
24 #include "config.hh"
25 #include "network.hh"
26 #include "wavearray.hh"
27 #include "TString.h"
28 #include "TObjArray.h"
29 #include "TObjString.h"
30 #include "TPaletteAxis.h"
31 #include "TMultiLayerPerceptron.h"
32 #include "TMLPAnalyzer.h"
33 #include "TRandom.h"
34 #include "TComplex.h"
35 #include "TMath.h"
36 #include "mdc.hh"
37 #include "watplot.hh"
38 #include <vector>
39 
40 
41 //#define nINP 64
42 #define nIFO 3
43 #define nRHO 3
44 #define nANN 10
45 #define deltaANN 0.1
46 #define nCC 4
47 #define NPIX 20
48 #define RHOth 5.5
49 #define nth 10
50 #define rhomin 6
51 #define ccmin 0.6
52 using namespace std;
53 void graph(TString ifile);
54 void Annth(TString ifile);
55 void Plots(TString ifile);
56 //void Test0(TString NN_FILE,TString TEST_FILE,TString ofile, int TS=0, int TB=0, int s=0, int b=0, int uf=0){
57 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){
58 
59  int p=0;
60  char NNi[1024];
61  char NNi2[1024];
62  sprintf(NNi2,"%s",NN_FILE.Data());
63  while (NNi2[p]){
64  //cout<<NNi2[p]<<endl;
65  if (NNi2[p]=='N'){
66 // cout<<p<<endl;
67  if((NNi2[p+1]=='N')&&(NNi2[p+2]=='\/')) {
68 // cout<<" dentro if"<<endl;
69  int hh=p+3;
70  while (NNi2[hh]!='\0'){NNi[hh-p-3]=NNi2[hh];hh=hh+1;}
71  break;
72  }
73  }
74  p=p+1;
75  }
76 
77  int pbis=0;
78  char NNibis[1024];
79  char NNi2bis[1024];
80  sprintf(NNi2bis,"%s",NN_FILEbis.Data());
81  while (NNi2bis[pbis]){
82  //cout<<NNi2[p]<<endl;
83  if (NNi2bis[pbis]=='N'){
84 // cout<<p<<endl;
85  if((NNi2bis[pbis+1]=='N')&&(NNi2bis[pbis+2]=='\/')) {
86 // cout<<" dentro if"<<endl;
87  int hh=pbis+3;
88  while (NNi2bis[hh]!='\0'){NNibis[hh-p-3]=NNi2bis[hh];hh=hh+1;}
89  break;
90  }
91  }
92  pbis=pbis+1;
93  }
94 
95  int q=0;
96  char Filei[1024];
97 // for (int i=0;i<1024;i++)Filei[i]='';
98  char Filei2[1024];
99  sprintf(Filei2,"%s",TEST_FILE.Data());
100  while (Filei2[q]){
101 // cout<<Filei2[q]<<endl;
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]=='\/')) {
103  int hh=q+7;
104  //while (Filei2[hh]!='\0') {Filei[hh-p-8]=Filei2[hh];hh=hh+1;cout<<Filei2[hh]<<endl;}
105  while (Filei2[hh]!='\0') {Filei[hh-p-7]=Filei2[hh];hh=hh+1;
106  //cout<<Filei2[hh]<<endl;
107  }
108  for (int h0=hh-p-7;h0<1024;h0++) Filei[h0]='\0';
109  break;
110  }
111  q=q+1;
112  }
113 
114  cout<<NNibis<<" original String: "<<NNi2bis<<endl;
115  cout<<NNi<<" original String: "<<NNi2<<endl;
116  cout<<Filei<<" original String: "<<Filei2<<endl;
117 
118 
119  TString NNi0bis(NNibis);
120  TString NNi0(NNi);
121  TString Filei0(Filei);
122 
123  NNi0bis.ReplaceAll(".root","");
124  NNi0.ReplaceAll(".root","");
125  Filei0.ReplaceAll(".root","");
126 
127 
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");
132  int NNs;
133  int NNb;
134  int NNnTS;
135  int NNnTB;
136  infot->SetBranchAddress("Rand_start_Sig",&NNs);
137  infot->SetBranchAddress("Rand_start_Bg",&NNb);
138  infot->SetBranchAddress("#trainSig",&NNnTS);
139  infot->SetBranchAddress("#trainBg",&NNnTB);
140  infot->GetEntry(0);
141 
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");
146  int NNsbis;
147  int NNbbis;
148  int NNnTSbis;
149  int NNnTBbis;
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);
155 
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;
160 
161 //estraggo le info che servono anche al tree di def dell'mlp
162  int ndim;
163  int ninp;
164  int y;
165  int entriesTot;
166  int bg_entries;
167  int sig_entries;
168 
169  NNTree->SetBranchAddress("#Entries_type",&entriesTot);
170  NNTree->SetBranchAddress("Matrix_dim",&ndim);
171  NNTree->SetBranchAddress("#inputs",&ninp);
172  NNTree->SetBranchAddress("amplitude_mode",&y);
173 
174  NNTree->GetEntry(0);
175  sig_entries=entriesTot;
176  NNTree->GetEntry(entries-1);
177  bg_entries=entriesTot;
178 
179  int const NDIM=ndim;
180  int const nINP=ninp;
181 
182  cout<<"NDIM "<<NDIM<<endl;
183  cout<<"nINP"<<nINP<<endl;
184  cout<<"sig e "<<sig_entries<<endl;
185  cout<<"bg e "<<bg_entries<<endl;
186  int minevents=0;
187  if (sig_entries>bg_entries) minevents=bg_entries;
188  else minevents=sig_entries;
189 
190  if(b==0) b=sig_entries;
191  if(TB==0 && TS==0){
192  TS=minevents;
193  TB=minevents;
194  }
195  if (b<sig_entries){
196  cout<<"Error: Bg index<sig_entries"<<endl;
197  exit(0);
198  }
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;}
201 
202 
203  char NOMEtot2[1024];
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);
205  TString NOMEtot_S(NOMEtot2);
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("__","_");
216 
217  char NOMEtot[1024];
218  //sprintf(NOMEtot,"NN1_%s_NN2_%s_FILE_%s_TS%i_TB%i_st%i_bt%i_uf%i",NNi0.Data(),NNi0bis.Data(),Filei0.Data(),TS,TB,s,b,uf);
219  sprintf(NOMEtot,"%s",NOMEtot_S.Data());
220  cout<<"nome: "<<NOMEtot<<endl;
221  char Nometot2[1024]="comp_orig_dt_a_21marzo_50000";
222  TString SIG_FILE;
223  TString BG_FILE;
224  char FILE_NAME[516];
225  NNTree->SetBranchAddress("Files_name",&FILE_NAME);
226  NNTree->GetEntry(0);
227  SIG_FILE=FILE_NAME;
228  NNTree->GetEntry(entries-1);
229  BG_FILE=FILE_NAME;
230  cout<<"fine ifdef RHO_CC"<<endl;
231 
232  TChain sigTree("waveburst");//cerca il Tree "waveburst nei file
233  sigTree.Add(SIG_FILE.Data());//determina i file
234  netevent signal(&sigTree,nIFO);
235  int sig_entries2 = signal.GetEntries();
236  cout << "sig entries2 : " << sig_entries2 << endl;
237 
238  TChain bgTree("waveburst");
239  bgTree.Add(BG_FILE.Data());
240  netevent background(&bgTree,nIFO);
241  int bg_entries2 = background.GetEntries();
242  cout << "bg entries2 : " << bg_entries2 << endl;
243 
244  cout<<"b: "<<b<<endl;
245  cout<<"s: "<<s<<endl;
246 
247  // add leaf
248  Float_t x[nINP];
249  for (int jj=0; jj<nINP;jj++) x[jj]=0.;
250  char ilabel[nINP][16];
251 
252  //costruzione una foglia per ogni input
253  for(int i=0;i<nINP;i++) {
254  sprintf(ilabel[i],"x%i",i+1);
255  NNTree->SetBranchAddress(ilabel[i], &x[i]);
256  }
257 
258 char ofile[1024];
259 sprintf(ofile,"outfile_2NN/%s.root",Nometot2);
260 //TFile*f=new TFile(ofile.Data(),"RECREATE");
261 TFile*f =new TFile(ofile,"RECREATE");
262  TTree* NNTree2=new TTree("Parameters","Parameters");
263 NNTree2->SetDirectory(f);
264  double out=0.;
265  double outbis=0.;
266  double NNcc=0.;
267  double NNrho=0.;
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());
278  char Testf[1024];
279  NNTree2->Branch("TestFile",&Testf,"TestFile/C");
280  sprintf(Testf,"%s",TEST_FILE.Data());
281  int nTestS;
282  NNTree2->Branch("#TestSig",&nTestS,"#TestSig/I");
283  cout<<"nTestS: "<<nTestS<<" TS: "<<TS<<endl;
284  cout<<"dopo def tree"<<endl;
285 /* TChain TreeS("waveburst");//cerca il Tree "waveburst nei file
286  TreeS.Add(TEST_FILE.Data());//determina i file
287  netevent entryS(&TreeS,nIFO);
288  int entriesTot=0;
289  entriesTot = entryS.GetEntries();
290  cout << "Sig entries : " << entriesTot << endl;
291  std::vector<double>* frameS = new vector<double>;
292  entryS.fChain->SetBranchAddress("nnframe", &frameS);//fa esattamente come ha fatto per le altre variabili nella macro netevent.cc
293 
294 
295  //cout<<"cc"<<(double)entryS.netcc[1]<<endl;
296 */ //cout<<"rho"<<(double)entryS.rho[0]<<endl;
297 int scount=0;
298  if(uf==0) nTestS=TS;
299  else {
300 for(int n=s;n<s+TS;n++) {
301  if (uf!=0&&n>=NNs&&n<=(NNs+NNnTS)) continue;
302  scount=scount+1;
303  }
304 }
305  double params[nINP];
306  int sig_05=0;
307  for (int i=0; i<nINP; i++) params[i]=0.;
308  //for(int n=0;n<entryS.GetEntries();n++) {
309  for(int n=s;n<s+TS;n++) {
310  if (uf!=0&&n>=NNs&&n<=(NNs+NNnTS)) continue;
311  NNTree->GetEntry(n);
312  signal.GetEntry(n);
313  NNcc=(double)signal.netcc[1];
314  NNrho=(double)signal.rho[0];
315  for (int i=0; i<nINP; i++){
316  //x[i]=(*frameS)[i];
317  params[i]=x[i];
318  }
319  double output=mlp->Evaluate(0,params);
320  double outputbis=mlpbis->Evaluate(0,params);
321  outbis=outputbis;
322  out=output;
323  //if (outbis<0.5) sig_05=sig_05+1;
324  //if (outbis>0.5&&outbis<0.6) if(out<0.1) sig_05=sig_05+1;
325  if (outbis<0.5 || out<0.5) sig_05=sig_05+1;
326  //if (outbis<0.6) sig_05=sig_05+1;
327  cout<<"rho: "<<signal.rho[0]<<" cc "<<signal.netcc[1]<<" out: "<<out<<" outbis "<<outbis<<endl;
328  NNTree2->Fill();
329  }
330 
331 cout<<"riempito sig"<<endl;
332 int bg_05=0;
333  //for(int n=sig_entries+b;n<sig_entries+b+TB;n++) {
334  for(int n=b;n<b+TB;n++) {
335  if (uf!=0&&(n>=NNb&&n<=(NNb+NNnTB) || n>=NNbbis&&n<=(NNbbis+NNnTBbis))) continue;
336  NNTree->GetEntry(n);
337  cout<<"n: "<<n<<"Bg index"<<(n-sig_entries)<<endl;
338  background.GetEntry(n-sig_entries);
339  NNcc=(double)background.netcc[1];
340  NNrho=(double)background.rho[0];
341  for (int i=0; i<nINP; i++){
342  //x[i]=(*frameS)[i];
343  params[i]=x[i];
344  }
345 
346  double output=mlp->Evaluate(0,params);
347  out=output;
348  double outputbis=mlpbis->Evaluate(0,params);
349  outbis=outputbis;
350 // if(outbis>0.6) bg_05=bg_05+1;
351 // if(outbis<=0.6&&outbis>0.5) if(out>0.1)bg_05=bg_05+1;
352 
353  if(outbis>0.5 && out>0.5) bg_05=bg_05+1;
354  //if(outbis>0.6) bg_05=bg_05+1;
355 
356  cout<<"rho: "<<background.rho[0]<<" cc "<<background.netcc[1]<<" out: "<<out<<endl;
357  NNTree2->Fill();
358  }
359 cout<<"riempito bg"<<endl;
360 //TFile*f0 =new TFile(ofile,"RECREATE");
361 //NNTree2->SetDirectory(f0);
362 NNTree2->Write();
363 f->Close();
364 //f0->Close();
365 cout<<"chiuso file"<<endl;
366 
367 //graph(ofile.Data());
368 //graph(ofile);
369 cout<<ofile<<endl;
370 cout<<"dopo richiamo funzione"<<endl;
371 //Annth(ofile);
372 Plots(ofile);
373 cout<<" Sig with out<06: "<<sig_05<<endl;
374 cout<<" Bg with double threshold "<<bg_05<<endl;
375 }
376 
378  TString name(ifile);
379  name.ReplaceAll("outfile/","");
380  TFile* fTEST =TFile::Open(ifile.Data());
381  TTree* NNTree2=(TTree*)fTEST->Get("Parameters");
382  double out;
383  double cc;
384  double rho;
385  int nSi;
386  NNTree2->SetBranchAddress("ANNout",&out);
387  NNTree2->SetBranchAddress("cc",&cc);
388  NNTree2->SetBranchAddress("rho",&rho);
389  NNTree2->SetBranchAddress("#TestSig",&nSi);
390  NNTree2->GetEntry(0);
391  int const nSig=nSi;
392  cout<<"nSig: "<<nSig<<" nSi: "<<nSi<<endl;
393  int const ncurve=nANN*nCC;
394  cout<<"dentro funzione dopodef"<<endl;
395 //LOG(NBg)vs RHO------------------------------------------
396  double* rhoSig[ncurve];
397  for (int i=0;i<ncurve;i++) rhoSig[i]=new double[nSig];
398  cout<<"dopo def rhoSig"<<endl;
399  //double rhoSig[20][10];
400  int NSig[ncurve];
401 // int nBg=0;
402  int const nBg=NNTree2->GetEntries()-nSig;
403  for (int i=0;i<ncurve;i++) {
404  NSig[i]=0;
405  for (int j=0;j<nSig;j++) rhoSig[i][j]=0.;
406  }
407  cout<<"dopo def rhoSig"<<endl;
408  double* rhoBg[ncurve];
409  for (int i=0;i<ncurve;i++) rhoBg[i]=new double[nBg];
410  //double rhoBg[20][10];
411  int NBg[ncurve];
412  for (int i=0;i<ncurve;i++) {
413  NBg[i]=0;
414  for (int j=0;j<nBg;j++) rhoBg[i][j]=0.;
415  }
416  cout<<"dopo def rhoBg"<<endl;
417  double ccTh[nCC];
418  for (int i=0;i<nCC;i++) ccTh[i]=0.;
419  double NNTh[nANN];
420  for (int i=0;i<nANN;i++) NNTh[i]=0.;
421  double deltacc=0.;
422 // double deltaANN=0.;
423  deltacc=0.2/nCC;
424  //deltaANN=0.6/(nANN-1);
425 
426  cout<<NNTree2->GetEntries()<<endl;
427  for(int n=0;n<NNTree2->GetEntries();n++){
428  cout<<n<<endl;
429  NNTree2->GetEntry(n);
430  cout<<"rho "<<rho<<" cc "<<cc<<" out "<<out<<endl;
431  for(int i=0; i<nCC;i++){
432  ccTh[i]=0.5+i*deltacc;
433  if(cc<ccTh[i]) continue;
434  for(int j=0; j<nANN;j++){
435  if(j==0) NNTh[j]=-1000.;
436  //else NNTh[j]=0.5+(j-1)*deltaANN;
437  //else NNTh[j]=0.1+(j-1)*deltaANN;
438  else NNTh[j]=0.+(j)*deltaANN;
439  //else NNTh[j]=0.+(j-1)*deltaANN/1000.;
440  //else NNTh[j]=1.;
441  if(out<NNTh[j]) continue;
442  int ni=0;
443  if(n>nSig) {
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;
447  // cout<<"rho: "<<rho<<" colonna "<<i*nANN+j<<" riga "<<ni<<endl;
448 // cout<<" soglia_cc "<<ccTh[i]<<" soglia_ANN "<<NNTh[j]<<endl;
449  }
450  else {
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;
454  // cout<<"rho: "<<rho<<" colonna "<<i*nANN+j<<" riga "<<ni<<endl;
455 // cout<<" soglia_cc "<<ccTh[i]<<" soglia_ANN "<<NNTh[j]<<endl;
456  }
457  // }
458  }
459  }
460  }
461  cout<<"dopo riempimento variabili"<<endl;
462  int* indexS[ncurve];
463  for (int i=0;i<ncurve;i++) indexS[i]=new int[nSig];
464 
465  TGraph * gS[ncurve];
466  for (int y=0;y<ncurve;y++) {
467  int igS=0;
468  int igS_p=0;
469  /* int indexS[nSig];
470  double rhoS[nSig];
471  for(int i=0;i<nSig;i++) {
472  rhoS[i]=0.;
473  indexS[i]=0;
474  }*/
475  // ig=1;
476  // for(int i=0;i<nSig;i++) rhoS[i]=rhoSig[y][i];
477  gS[y]=new TGraph();
478 // gS[y]->SetMarkerStyle(7);
479  TMath::Sort(nSig,rhoSig[y],indexS[y],false);
480 // cout<<"dopo Sort "<<y<<endl;
481  for (int k=0;k<nSig;k++) {
482  int ii=indexS[y][k];
483  int yy=0;
484  if (k>0){
485 // cout<<"k "<<k<<endl;
486  int ij=indexS[y][k-1];
487  //if(rhoSig[y][ii]!=0&&rhoSig[y][ii]!=rhoSig[y][ij]) {
488  if(rhoSig[y][ii]!=0) {
489  yy=NSig[y]-igS;
490  //gS[y]->SetPoint(igS,rhoSig[y][ii],yy);
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;
493  igS=igS+1;
494  }
495  }
496  else {
497  if(rhoSig[y][ii]!=0){
498  yy=NSig[y]-igS;
499  gS[y]->SetPoint(0,rhoSig[y][ii],yy);
500  igS=igS+1;
501 // cout<<" x "<<rhoSig[y][ii]<<" y: "<<yy<<endl;
502  }
503 
504  }
505  }
506  }
507  // cout<<"dopo inserimento puntiiS"<<endl;
508 // cout<<ncurve<<endl;
509  int* indexB[ncurve];
510  for (int i=0;i<ncurve;i++) indexB[i]=new int[nBg];
511 
512  TGraph * gB[ncurve];
513  for (int y=0;y<ncurve;y++) {
514  int igB=0;
515  int igB_p=0;
516  gB[y]=new TGraph();
517  TMath::Sort(nBg,rhoBg[y],indexB[y],false);
518 // cout<<"dopo Sort "<<y<<endl;
519  for (int k=0;k<nBg;k++) {
520  int ii=indexB[y][k];
521  int yy=0;
522  if (k>0){
523  int ij=indexB[y][k-1];
524  //if(rhoBg[y][ii]!=0&&rhoBg[y][ii]!=rhoBg[y][ij]) {
525  if(rhoBg[y][ii]!=0) {
526  yy=NBg[y]-igB;
527  //gB[y]->SetPoint(igB,rhoBg[y][ii],yy);
528  if(rhoBg[y][ii]!=rhoBg[y][ij]) gB[y]->SetPoint(igB_p++,rhoBg[y][ii],yy);
529  igB=igB+1;
530 // cout<<"igB"<<igB<<" x "<<rhoBg[y][ii]<<" y: "<<yy<<endl;
531  }
532  }
533  else {
534  if(rhoBg[y][ii]!=0) {
535  yy=NBg[y]-igB;
536  gB[y]->SetPoint(0,rhoBg[y][ii],yy);
537  igB=igB+1;
538 // cout<<"igB"<<igB<<" x "<<rhoBg[y][ii]<<" y: "<<yy<<endl;
539  }
540  }
541  }
542  }
543  cout<<"dopo inserimento puntiB"<<endl;
544  //gB[1]->SetMarkerStyle(7);
545  //gB[1]->SetPoint(1,1,2);
546  TCanvas* cS=new TCanvas("Efficiency_vs_rho","Efficiency_vs_rho",0,0,1200,700);
547  cS->Divide(2,2);
548  cS->cd(1)->SetLogy();
549  TMultiGraph* mg1=new TMultiGraph();
550 // gS[0]->SetMarkerStyle(7);
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]);
555 // gS[0]->Draw("apl");
556  for (int h=1;h<nANN;h++){
557  gS[h]->SetMarkerColor(3);
558  gS[h]->SetLineColor(3);
559 // gS[h]->SetMarkerStyle(h+1);
560  if(gS[h]->GetN()!=0) mg1->Add(gS[h]);
561  // gS[h]->Draw("apl,same");
562  }
563  mg1->Draw("apl");
564  cS->cd(2)->SetLogy();
565  TMultiGraph* mg2=new TMultiGraph();
566 // gS[nANN]->SetMarkerStyle(7);
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]);
571  for (int h=1;h<nANN;h++){
572  gS[nANN+h]->SetMarkerColor(3);
573  gS[nANN+h]->SetLineColor(3);
574 // gS[nANN+h]->SetMarkerStyle(h+1);
575  if(gS[nANN+h]->GetN()!=0) mg2->Add(gS[nANN+h]);
576  // gS[nANN+h]->Draw("apl,same");
577  }
578  mg2->Draw("apl");
579  cS->cd(3)->SetLogy();
580  TMultiGraph* mg3=new TMultiGraph();
581 // gS[nANN*2]->SetMarkerStyle(7);
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]);
586  for (int h=1;h<nANN;h++){
587  gS[2*nANN+h]->SetMarkerColor(3);
588  gS[2*nANN+h]->SetLineColor(3);
589 // gS[2*nANN+h]->SetMarkerStyle(h+1);
590  if(gS[2*nANN+h]->GetN()!=0) mg3->Add(gS[2*nANN+h]);
591  // gS[2*nANN+h]->Draw("apl,same");
592  }
593  mg3->Draw("apl");
594  cS->cd(4)->SetLogy();
595  TMultiGraph* mg4=new TMultiGraph();
596 // gS[nANN*3]->SetMarkerStyle(7);
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]);
601  // gS[nANN*3]->Draw("apl");
602  for (int h=1;h<nANN;h++){
603  gS[3*nANN+h]->SetMarkerColor(3);
604  gS[3*nANN+h]->SetLineColor(3);
605 // gS[3*nANN+h]->SetMarkerStyle(h+1);
606  if(gS[3*nANN+h]->GetN()!=0) mg4->Add(gS[3*nANN+h]);
607  // gS[3*nANN+h]->Draw("apl,same");
608  }
609  mg4->Draw("apl");
610  cout<<"nuovo canv"<<endl;
611  TCanvas* cB=new TCanvas("Number_vs_rho","Number_vs_rho",0,0,1200,700);
612  cB->Divide(2,2);
613  cB->cd(1)->SetLogy();
614  TMultiGraph* mg1B=new TMultiGraph();
615 // gB[0]->SetMarkerStyle(7);
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]);
620  for (int h=1;h<nANN;h++){
621  gB[h]->SetMarkerColor(3);
622  gB[h]->SetLineColor(3);
623  // gB[h]>SetMarkerStyle(h+1);
624  if(gB[h]->GetN()!=0) mg1B->Add(gB[h]);
625  //gB[h]->Draw("apl,same");
626  }
627  mg1B->Draw("apl");
628  cB->cd(2)->SetLogy();
629  TMultiGraph* mg2B=new TMultiGraph();
630  //gB[nANN]->SetMarkerStyle(7);
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]);
635  for (int h=1;h<nANN;h++){
636  gB[nANN+h]->SetMarkerColor(3);
637  gB[nANN+h]->SetLineColor(3);
638  //gB[nANN+h]>SetMarkerStyle(h+1);
639  if(gB[nANN+h]->GetN()!=0) mg2B->Add(gB[nANN+h]);
640  //gB[h]->Draw("apl,same");
641  }
642  mg2B->Draw("apl");
643  cB->cd(3)->SetLogy();
644  TMultiGraph* mg3B=new TMultiGraph();
645 // gB[2*nANN]->SetMarkerStyle(7);
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]);
650  for (int h=1;h<nANN;h++){
651  gB[2*nANN+h]->SetMarkerColor(3);
652  gB[2*nANN+h]->SetLineColor(3);
653 // gB[2*nANN+h]>SetMarkerStyle(h+1);
654  if(gB[2*nANN+h]->GetN()!=0) mg3B->Add(gB[2*nANN+h]);
655  //gB[h]->Draw("apl,same");
656  }
657  mg3B->Draw("apl");
658  cB->cd(4)->SetLogy();
659  TMultiGraph* mg4B=new TMultiGraph();
660 // gB[3*nANN]->SetMarkerStyle(7);
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]);
665  for (int h=1;h<nANN;h++){
666  gB[3*nANN+h]->SetMarkerColor(3);
667  gB[3*nANN+h]->SetLineColor(3);
668 // gB[3*nANN+h]>SetMarkerStyle(h+1);
669  if(gB[3*nANN+h]->GetN()!=0) mg4B->Add(gB[3*nANN+h]);
670  //gB[h]->Draw("apl,same");
671  }
672  mg4B->Draw("apl");
673 
674 // cout<<"dopo Draw()"<<endl;
675  TString CnameS(name);
676  TString CnameB(name);
677  TString CnameSroot(name);
678  TString CnameBroot(name);
679  char CnameS2[1024];
680  char CnameB2[1024];
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());
689  cS->SaveAs(CnameS2);
690  cB->SaveAs(CnameB2);
691  cS->Print(CnameS2root);
692  cB->Print(CnameB2root);
693 // cout<<"fine"<<endl;
694 
695 }
696 
697 
699  TString name(ifile);
700  name.ReplaceAll("outfile/","");
701  TFile* fTEST =TFile::Open(ifile.Data());
702  TTree* NNTree2=(TTree*)fTEST->Get("Parameters");
703  double out;
704  double cc;
705  double rho;
706  int nSi;
707  NNTree2->SetBranchAddress("ANNout",&out);
708  NNTree2->SetBranchAddress("cc",&cc);
709  NNTree2->SetBranchAddress("rho",&rho);
710  NNTree2->SetBranchAddress("#TestSig",&nSi);
711  NNTree2->GetEntry(0);
712  int const nSig=nSi;
713 // cout<<"nSig: "<<nSig<<" nSi: "<<nSi<<endl;
714  int const ncurve2=nRHO*nCC;
715 
716 
717  double* ANNSig[ncurve2];
718  for (int i=0;i<ncurve2;i++) ANNSig[i]=new double[nSig];
719  //double rhoSig[20][10];
720  int NSig[ncurve2];
721 // int nBg=0;
722  int const nBg=NNTree2->GetEntries()-nSig;
723  for (int i=0;i<ncurve2;i++) {
724  NSig[i]=0;
725  for (int j=0;j<nSig;j++) ANNSig[i][j]=0.;
726  }
727  double* ANNBg[ncurve2];
728  for (int i=0;i<ncurve2;i++) ANNBg[i]=new double[nBg];
729 
730  //double rhoBg[20][10];
731  int NBg[ncurve2];
732  for (int i=0;i<ncurve2;i++) {
733  NBg[i]=0;
734  for (int j=0;j<nBg;j++) ANNBg[i][j]=0.;
735  }
736  double ccTh[nCC];
737  for (int i=0;i<nCC;i++) ccTh[i]=0.;
738  double rhoTh[nRHO];
739  for (int i=0;i<nRHO;i++) rhoTh[i]=0.;
740  double deltacc=0.;
741  double deltarho=0.;
742  deltacc=0.2/nCC;
743  deltarho=1./(nRHO);
744 
745 
746  for(int n=0;n<NNTree2->GetEntries();n++){
747  NNTree2->GetEntry(n);
748  cout<<"rho "<<rho<<" cc "<<cc<<" out "<<out<<endl;
749  for(int i=0; i<nCC;i++){
750  ccTh[i]=0.5+i*deltacc;
751  if(cc<ccTh[i]) continue;
752  for(int j=0; j<nRHO;j++){
753  rhoTh[j]=5+j*deltarho;
754  if(rho<rhoTh[j]) continue;
755  int ni=0;
756  if(n>nSig) {
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;
760  // cout<<" soglia_cc "<<ccTh[i]<<" soglia_RHO "<<rhoTh[j]<<endl;
761  }
762  else {
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;
766  // cout<<" soglia_cc "<<ccTh[i]<<" soglia_RHO "<<rhoTh[j]<<endl;
767  }
768  }
769  }
770  }
771 
772  int* indexS[ncurve2];
773  for (int i=0;i<ncurve2;i++) indexS[i]=new int[nSig];
774 
775  TGraph * gS[ncurve2];
776  for (int y=0;y<ncurve2;y++) {
777  int igS=0;
778  int igS_p=0;
779  gS[y]=new TGraph();
780  TMath::Sort(nSig,ANNSig[y],indexS[y],false);
781  for (int k=0;k<nSig;k++) {
782  int ii=indexS[y][k];
783  int yy=0;
784  if (k>0){
785  //cout<<"k "<<k<<endl;
786  int ij=indexS[y][k-1];
787  //if(ANNSig[y][ii]!=0&&ANNSig[y][ii]!=ANNSig[y][ij]) {
788  if(ANNSig[y][ii]!=0) {
789  yy=NSig[y]-igS;
790  //gS[y]->SetPoint(igS,ANNSig[y][ii],yy);
791  if(ANNSig[y][ii]!=ANNSig[y][ij]) gS[y]->SetPoint(igS_p++,ANNSig[y][ii],yy);
792  // cout<<"igS"<<igS<<" x "<<ANNSig[y][ii]<<" y: "<<yy<<endl;
793  igS=igS+1;
794 
795  }
796  }
797  else {
798  if(ANNSig[y][ii]!=0){
799  yy=NSig[y]-igS;
800  gS[y]->SetPoint(0,ANNSig[y][ii],yy);
801  igS=igS+1;
802  // cout<<" x "<<ANNSig[y][ii]<<" y: "<<yy<<endl;
803  }
804 
805  }
806  }
807  }
808 
809 
810 
811  int* indexB[ncurve2];
812  for (int i=0;i<ncurve2;i++) indexB[i]=new int[nBg];
813 
814  TGraph * gB[ncurve2];
815  for (int y=0;y<ncurve2;y++) {
816  int igB=0;
817  int igB_p=0;
818  gB[y]=new TGraph();
819  TMath::Sort(nBg,ANNBg[y],indexB[y],false);
820  // cout<<"dopo Sort "<<y<<endl;
821  for (int k=0;k<nBg;k++) {
822  int ii=indexB[y][k];
823  int yy=0;
824  if (k>0){
825  int ij=indexB[y][k-1];
826  //if(ANNBg[y][ii]!=0&&ANNBg[y][ii]!=ANNBg[y][ij]) {
827  if(ANNBg[y][ii]!=0) {
828  yy=NBg[y]-igB;
829  //gB[y]->SetPoint(igB,ANNBg[y][ii],yy);
830  if(ANNBg[y][ii]!=ANNBg[y][ij]) gB[y]->SetPoint(igB_p++,ANNBg[y][ii],yy);
831  igB=igB+1;
832  // cout<<"igB"<<igB<<" x "<<ANNBg[y][ii]<<" y: "<<yy<<endl;
833  }
834  }
835  else {
836  if(ANNBg[y][ii]!=0) {
837  yy=NBg[y]-igB;
838  gB[y]->SetPoint(0,ANNBg[y][ii],yy);
839  igB=igB+1;
840  // cout<<"igB"<<igB<<" x "<<ANNBg[y][ii]<<" y: "<<yy<<endl;
841  }
842  }
843  }
844  }
845 
846 
847  TCanvas* cS=new TCanvas("Efficiency_vs_ANN","Efficiency_vs_ANN",0,0,1200,700);
848  cS->Divide(2,2);
849  //cS->cd(1)->SetLogy();
850  cS->cd(1);
851  TMultiGraph* mg1=new TMultiGraph();
852  mg1->SetTitle("cc=0.5;ANN;#Events");
853  for (int h=0;h<nRHO;h++){
854  gS[h]->SetLineColor(4);
855  if(gS[h]->GetN()!=0) mg1->Add(gS[h]);
856  }
857  mg1->Draw("al");
858  cS->cd(2);
859  // cS->cd(2)->SetLogy();
860  TMultiGraph* mg2=new TMultiGraph();
861  mg2->SetTitle("cc=0.55;ANN;#Events");
862  for (int h=0;h<nRHO;h++){
863  gS[nRHO+h]->SetLineColor(4);
864  if(gS[nRHO+h]->GetN()!=0) mg2->Add(gS[nRHO+h]);
865  }
866  mg2->Draw("al");
867 
868  //cS->cd(3)->SetLogy();
869  cS->cd(3);
870  TMultiGraph* mg3=new TMultiGraph();
871  mg3->SetTitle("cc=0.6;ANN;#Events");
872  for (int h=0;h<nRHO;h++){
873  gS[2*nRHO+h]->SetLineColor(4);
874  if(gS[2*nRHO+h]->GetN()!=0) mg3->Add(gS[2*nRHO+h]);
875  }
876  mg3->Draw("al");
877  //cS->cd(4)->SetLogy();
878  cS->cd(4);
879  TMultiGraph* mg4=new TMultiGraph();
880  mg4->SetTitle("cc=0.65;ANN;#Events");
881  for (int h=0;h<nRHO;h++){
882  gS[3*nRHO+h]->SetLineColor(4);
883  if(gS[3*nRHO+h]->GetN()!=0) mg4->Add(gS[3*nRHO+h]);
884  }
885  mg4->Draw("al");
886 
887  TCanvas* cB=new TCanvas("Number_vs_ANN","Number_vs_ANN",0,0,1200,700);
888  cB->Divide(2,2);
889  cB->cd(1)->SetLogy();
890  TMultiGraph* mg1B=new TMultiGraph();
891  mg1B->SetTitle("cc=0.5;ANN;#Events");
892  for (int h=0;h<nRHO;h++){
893  gB[h]->SetLineColor(4);
894  if(gB[h]->GetN()!=0) mg1B->Add(gB[h]);
895  }
896  mg1B->Draw("al");
897  cB->cd(2)->SetLogy();
898  TMultiGraph* mg2B=new TMultiGraph();
899  mg2B->SetTitle("cc=0.55;ANN;#Events");
900  for (int h=0;h<nRHO;h++){
901  gB[nRHO+h]->SetLineColor(4);
902  if(gB[nRHO+h]->GetN()!=0) mg2B->Add(gB[nRHO+h]);
903  }
904  mg2B->Draw("al");
905  cB->cd(3)->SetLogy();
906  TMultiGraph* mg3B=new TMultiGraph();
907  mg3B->SetTitle("cc=0.6;ANN;#Events");
908  for (int h=0;h<nRHO;h++){
909  gB[2*nRHO+h]->SetLineColor(4);
910  if(gB[2*nRHO+h]->GetN()!=0) mg3B->Add(gB[2*nRHO+h]);
911  }
912  mg3B->Draw("al");
913  cB->cd(4)->SetLogy();
914  TMultiGraph* mg4B=new TMultiGraph();
915  mg4B->SetTitle("cc=0.6;ANN;#Events");
916  for (int h=0;h<nRHO;h++){
917  gB[3*nRHO+h]->SetLineColor(4);
918  if(gB[3*nRHO+h]->GetN()!=0) mg4B->Add(gB[3*nRHO+h]);
919  }
920  mg4B->Draw("al");
921 
922 
923  //cout<<"dopo Draw()"<<endl;
924  TString CnameS(name);
925  TString CnameB(name);
926  TString CnameSroot(name);
927  TString CnameBroot(name);
928  char CnameS2[1024];
929  char CnameB2[1024];
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());
938  cS->SaveAs(CnameS2);
939  cB->SaveAs(CnameB2);
940  cS->Print(CnameS2root);
941  cB->Print(CnameB2root);
942  //cout<<"fine"<<endl;
943 
944 //CARTELLA Annth
945 
946 
947 
948 }
949 
950 
952  TString name(ifile);
953  name.ReplaceAll("outfile/","");
954  name.ReplaceAll("outfile_2NN/","");
955  TFile* fTEST =TFile::Open(ifile.Data());
956  TTree* NNTree2=(TTree*)fTEST->Get("Parameters");
957  double outbis;
958  double out;
959  double cc;
960  double rho;
961  int nSi;
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);
968  int const nSig=nSi;
969  cout<<"nSig: "<<nSig<<" nSi: "<<nSi<<endl;
970  int const nBg=NNTree2->GetEntries()-nSig;
971 
972  TGraph * gS[3];
973  TGraph * gB[3];
974  gB[0]=new TGraph();
975  gS[0]=new TGraph();
976 // cout<<"nSig: "<<nSig<<endl;
977  for (int n = 0; n <NNTree2->GetEntries(); n++){
978  NNTree2->GetEntry(n);
979  if(n<nSig) {
980  gS[0]->SetPoint(n,outbis,out);
981  cout<<"Sig_graph1: x="<<outbis<<" y: "<<out<<endl;
982  }
983  else {
984  gB[0]->SetPoint(n-nSig,outbis,out);
985  cout<<"Bg_graph1: x="<<outbis<<" y: "<<out<<endl;
986  }
987  }
988 
989 
990  /*for (int a=0;a<nBg;a++){
991  if(aRHOB[a]>=RHOth){
992  for (int b=0;b<nth;b++){
993  if(aCCB[a]>=cc1th[b]){
994  for(int c=0;c<nth+1;c++){
995  if(aANNB[a]>=ANN1th[c]) Z[b*nth+c]=Z[b*nth+c]+1;
996  if(c=10) cout<<" ANN "<<ANN1th[c]<<" Zcount: "<<Z[b*nth+c]<<" aNNB "<<aANNB[a]<<" a "<<a<<" b "<<b<<endl;
997  }
998  }
999  }
1000  }
1001  }*/
1002  gS[0]->SetMarkerColor(2);
1003  gB[0]->SetMarkerColor(4);
1004  gS[0]->SetMarkerStyle(6);
1005  gB[0]->SetMarkerStyle(7);
1006 
1007  TCanvas* c=new TCanvas("Plots","Plots",0,0,1200,700);
1008  c->Divide(1,2);
1009  c->cd(1);
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]);
1014  mg1->Draw("ap");
1015  c->cd(2);
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]);
1020  mg2->Draw("ap");
1021 
1022  cout<<" name "<<name<<endl;
1023  TString Cname(name);
1024  TString Cnameroot(name);
1025  char Cname2[1024];
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());
1030  c->SaveAs(Cname2);
1031  c->Print(Cname2root);
1032 /*
1033  TCanvas* c2=new TCanvas("Plots_Bkg_on_Sig","Plots_Bkg_on_Sig",0,0,1200,700);
1034  c2->Divide(2,2);
1035  c2->cd(1);
1036  gS[0]->Draw("ap");
1037  gB[0]->Draw("p,same");
1038 
1039  c2->cd(2);
1040  gS[1]->Draw("ap");
1041  gB[1]->Draw("p,same");
1042  c2->cd(3);
1043  gS[2]->Draw("ap");
1044  gB[2]->Draw("p,same");
1045  c2->cd(4);
1046  TText* text2=new TText(0.37,0.0,"no cuts on ANN");
1047  hglitch->SetStats(0);
1048  hglitch->GetXaxis()->SetTitle("cc");
1049  hglitch->GetYaxis()->SetTitle("ANNoutput");
1050  hglitch->GetZaxis()->SetTitle("count");
1051  hglitch->Draw("colz");
1052  text2->Draw();
1053  gPad->SetLogz();
1054 
1055  TString Cname_2(name);
1056  TString Cname_2root(name);
1057  char Cname2_2[1024];
1058  char Cname2_2root[1024];
1059  Cname_2.ReplaceAll(".root",".png");
1060  sprintf(Cname2_2,"CC_RHO_ANN_Plots/CC_RHO_ANN_Plots_BoS_%s",Cname_2.Data());
1061  sprintf(Cname2_2root,"CC_RHO_ANN_Plots/CC_RHO_ANN_Plots_BoS_%s",Cname_2root.Data());
1062  c2->SaveAs(Cname2_2);
1063  c2->Print(Cname2_2root);
1064 
1065 //CARTELLA CCi_RHO_ANN_Plots */
1066 }
1067 
char ofile[1024]
double rho
Float_t * rho
biased null statistics
Definition: netevent.hh:112
par [0] name
int n
Definition: cwb_net.C:28
TString("c")
ofstream out
Definition: cwb_merge.C:214
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
Int_t GetEntry(Int_t)
Definition: netevent.cc:409
CWB::Toolbox TB
STL namespace.
int j
Definition: cwb_net.C:28
i drho i
wavearray< double > hh
Definition: Regression_H1.C:73
#define nIFO
cout<< "SNR "<< xsnr<< endl;wavearray< double > f
Definition: ComputeSNR.C:75
#define nCC
#define deltaANN
wavearray< double > h
Definition: Regression_H1.C:25
#define nANN
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
char output[256]
int k
Float_t * netcc
effective correlated SNR
Definition: netevent.hh:113
void graph(TString ifile)
TFile * ifile
wavearray< double > yy
Definition: TestFrame5.C:12
s s
Definition: cwb_net.C:155
#define nRHO
#define deltarho
sprintf(tfres,"(1/%g)x(%g) (sec)x(Hz)", 2 *df, df)
void Annth(TString ifile)
Int_t GetEntries()
Definition: netevent.cc:403
wavearray< double > y
Definition: Test10.C:31
#define deltacc
void Plots(TString ifile)
exit(0)
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)