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