Logo coherent WaveBurst  
Library Reference Guide
Logo
cwb_report_prod_2.C
Go to the documentation of this file.
1 /*
2 # Copyright (C) 2019 Gabriele Vedovato, Marco Drago
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 // post-production macro for the background report : used by the cwb_report command
20 
21 {
22  cout<<"cwb_report_prod_2.C starts..."<<endl;
23 
24  CWB::Toolbox::checkFile(gSystem->Getenv("CWB_ROOTLOGON_FILE"));
25  CWB::Toolbox::checkFile(gSystem->Getenv("CWB_PARAMETERS_FILE"));
26  CWB::Toolbox::checkFile(gSystem->Getenv("CWB_UPARAMETERS_FILE"));
27  CWB::Toolbox::checkFile(gSystem->Getenv("CWB_PPARAMETERS_FILE"));
28  CWB::Toolbox::checkFile(gSystem->Getenv("CWB_UPPARAMETERS_FILE"));
29  CWB::Toolbox::checkFile(gSystem->Getenv("CWB_EPPARAMETERS_FILE"));
30 
31 #ifndef _USE_ROOT6
32  // the CWB_CAT_NAME declared in CWB_EPPARAMETERS_FILE is not visible. why?
33  // the include is defined again
34  #undef GTOOLBOX_HH
35 #endif
36  #include "GToolbox.hh"
37  #include <map>
38 
39  gStyle->SetTitleOffset(1.4,"X");
40  //gStyle->SetTitleOffset(1.2,"Y");
41  gStyle->SetTitleOffset(2.0,"Y");
42  gStyle->SetLabelOffset(0.010,"X");
43  gStyle->SetLabelOffset(0.010,"Y");
44  gStyle->SetLabelFont(42,"X");
45  gStyle->SetLabelFont(42,"Y");
46  gStyle->SetTitleFont(42,"X");
47  gStyle->SetTitleFont(42,"Y");
48  gStyle->SetTitleSize(0.05,"X");
49  gStyle->SetTitleSize(0.04,"Y");
50  gStyle->SetLabelSize(0.06,"X");
51  gStyle->SetLabelSize(0.06,"Y");
52 
53  gStyle->SetTitleH(0.060);
54  gStyle->SetTitleW(0.95);
55  gStyle->SetTitleY(0.99);
56  gStyle->SetTitleFont(12,"D");
57  gStyle->SetTitleColor(kBlue,"D");
58  gStyle->SetTextFont(12);
59  gStyle->SetTitleFillColor(kWhite);
60  gStyle->SetLineColor(kWhite);
61  gStyle->SetNumberContours(256);
62  gStyle->SetCanvasColor(kWhite);
63  gStyle->SetStatBorderSize(1);
64  gStyle->SetOptStat(kFALSE);
65 
66  // remove the red box around canvas
67  gStyle->SetFrameBorderMode(0);
68  gROOT->ForceStyle();
69 
70  if(nIFO==1) { // Single Detector Mode
72  config.Import();
73  config.SetSingleDetectorMode();
74  config.Export();
75  }
76 
77  // initialize the ifo name (takes into account the non built-in detectors)
78  char IFO[NIFO_MAX][32];
79  for(int n=0;n<nIFO;n++) {
80  if(strlen(ifo[n])!=0) strcpy(IFO[n],ifo[n]);
81  else strcpy(IFO[n],detParms[n].name);
82  }
83 
84  // ----------------------------------------------------------
85  // canvas
86  // ----------------------------------------------------------
87  TCanvas *c1 = new TCanvas("c","C",0,0,600,600);
88  c1->SetBorderMode(0);
89  c1->SetFillColor(0);
90  c1->SetBorderSize(2);
91  c1->SetLogx(kFALSE);
92  c1->SetGridx();
93  c1->SetGridy();
94  c1->SetRightMargin(0.1517039);
95  c1->SetTopMargin(0.0772727);
96  c1->SetBottomMargin(0.103939);
97  gStyle->SetPalette(1,0);
98 
99  TChain wave("waveburst");
100  TChain live("liveTime");
101  wave.Add(net_file_name);
102  live.Add(liv_file_name);
103  netevent W(&wave,nIFO);
104 
105  // check vetoes
106  bool bcat2 = false;
107  bool bhveto = false;
108  bool bcat3 = false;
109 
110  for(int i=0;i<nVDQF;i++) if(VDQF[i].cat==CWB_CAT2) bcat2=true;
111  for(int i=0;i<nVDQF;i++) if(VDQF[i].cat==CWB_HVETO) bhveto=true;
112  for(int i=0;i<nVDQF;i++) if(VDQF[i].cat==CWB_CAT3) bcat3=true;
113 
114  for(int i=0;i<nVDQF;i++) {
115  if((VDQF[i].cat!=CWB_CAT2)&&(VDQF[i].cat!=CWB_HVETO)&&(VDQF[i].cat!=CWB_CAT3)) continue;
116  char veto_name[256];sprintf(veto_name,"%s_%s",CWB_CAT_NAME[VDQF[i].cat].Data(),VDQF[i].ifo);
117  if(!CWB::Toolbox::isLeafInTree(W.fChain,veto_name)) {
118  cout << "cwb_report_prod_2.C Error : Leaf " << veto_name
119  << " is not present in tree" << endl;
120  gSystem->Exit(1);
121  }
122  }
123 
124  // check if slag is presents in liv tree
125  TBranch* branch;
126  bool slagFound=false;
127  TIter next(wave.GetListOfBranches());
128  while ((branch=(TBranch*)next())) {
129  if (TString("slag").CompareTo(branch->GetName())==0) slagFound=true;
130  }
131  next.Reset();
132  if(!slagFound) {
133  cout << "cwb_report_prod_2.C : Error - wave tree do not contains slag leaf : "
134  << net_file_name << endl;
135  gSystem->Exit(1);
136  }
137 
138  bool saveVETO[100];
139  UChar_t VETO[100];
140  int countVETO[100];
141  TString nameVETO[100]; // name of vetoes
142 
143  // build XDQF structure used for internal's computations
144  int nXDQF=0;
146  for(int j=0;j<nVDQF;j++) {
147  if(VDQF[j].cat==CWB_CAT0) continue;
148  if(VDQF[j].cat==CWB_CAT1) continue;
149  bool bifo=false;
150  for(int i=0;i<nIFO;i++) if(TString(IFO[i]).CompareTo(VDQF[j].ifo)==0) bifo=true;
151  if(bifo) XDQF[nXDQF++]=VDQF[j];
152  }
153  for(int j=0;j<nXDQF;j++) {
154  cout << "XDQF[" << j << "] " << CWB_CAT_NAME[XDQF[j].cat] << "_" << XDQF[j].ifo << endl;
155  }
156 
157  for(int j=0;j<nXDQF;j++) {
158  char veto_name[256];
159  sprintf(veto_name,"%s_%s",CWB_CAT_NAME[XDQF[j].cat].Data(),XDQF[j].ifo);
160  nameVETO[j]=veto_name;
161  countVETO[j]=0;
162  W.fChain->SetBranchAddress(nameVETO[j].Data(),&VETO[j]);
163  }
164 
165  gSystem->Exec("date");
166 
167  double xcor, acor, rho, asnr, xCOR, xcor2, xcor3, vED;
168  int i,j,n,m,k;
169  bool save;
170  bool save_veto;
171 
172  size_t ntype = 0;
173  char fname[1024];
174  char _title[1024];
175  char ch1[256];
176  char ch3[256];
177 
188 
189  // create/init structures for FAR output statistic
190 
191  // find the min and max in the tree and set rho limits for far_rho.txt file
193  wave.SetEstimate(nsize);
194  wave.Draw(TString::Format("rho[%d]",pp_irho).Data(),"","goff");
195  double rho_min = TMath::MinElement(nsize, wave.GetV1());
196  double rho_max = TMath::MaxElement(nsize, wave.GetV1());
197 
198  float far_rho_min = TMath::Min(pp_rho_min,(double)TMath::Nint(rho_min-0.5));
199  float far_rho_max = TMath::Max(pp_rho_max,(double)TMath::Nint(rho_max+0.5));
200  float far_rho_wbin = 0.01;
201  int far_rho_bin = float(far_rho_max-far_rho_min)/far_rho_wbin;
202  double far_drho = double(far_rho_max-far_rho_min)/double(far_rho_bin);
203 
204  wavearray<double> Xfar(far_rho_bin);
205  wavearray<double> Yfar(far_rho_bin); Yfar = 0.;
206 
207 
208 // calculate live time
209 
210  float xlag;
211  Int_t xrun, rUn;
212  double xlive, sTARt, sTOp, gps;
213  double liveTot = 0.;
214  double liveZero = 0.;
215  double Live;
216 
217  wavearray<double> Trun(500000); Trun = 0.;
225 
226  cout << "Start CWB::Toolbox::getLiveTime : be patient, it takes a while ..." << endl;
227  liveTot=CWB::Toolbox::getLiveTime(nIFO,live,Trun,Wlag,Wslag,Tlag,Tdlag,cwb_lag_number,cwb_slag_number);
228 
229  // use std::map to make faster the search
230  std::map<std::pair<int,int>, int> lagslag;
231  for(j=0; j<Wlag[nIFO].size(); j++) {
232  lagslag[std::make_pair(int(Wslag[nIFO].data[j]),int(Wlag[nIFO].data[j]))] = j;
233  }
234 
235  Rlag = Tlag; Rlag = 0.;
236  Elag = Tlag; Elag = 0.;
237  Olag = Tlag; Olag = 0.;
238 
239  sprintf(fname,"%s/live.txt",netdir);
240  FILE* flive = fopen(fname,"w");
241  if(flive==NULL) {
242  cout << "cwb_report_prod_2.C Error : Error opening " << fname << endl;
243  gSystem->Exit(1);
244  }
245 
246  // get live time zero (when is not included into Tlag array)
247  if((cwb_lag_number!=0)&&(cwb_slag_number!=0)) {
248 #ifdef _USE_ROOT6
249  // with ROOT6 live crash, it is necessary to open live again, why?
250  TChain live1("liveTime");
251  live1.Add(liv_file_name);
252  liveZero=CWB::Toolbox::getZeroLiveTime(nIFO,live1);
253 #else
254  liveZero=CWB::Toolbox::getZeroLiveTime(nIFO,live);
255 #endif
256  fprintf(flive,"slag=%i\t lag=%i\t ",0,0);
257  for (int jj=0; jj<nIFO; jj++) fprintf(flive,"%s:slag=%5.2f\tlag=%5.2f\t",IFO[jj],0.,0.);
258  fprintf(flive,"live=%9.2f\n",liveZero);
259  printf("live time: zero lags = %10.1f \n",liveZero);
260  }
261  for(j=0; j<Wlag[nIFO].size(); j++){
262  fprintf(flive,"slag=%i\t lag=%i\t ",(int)Wslag[nIFO].data[j],(int)Wlag[nIFO].data[j]);
263  for (int jj=0; jj<nIFO; jj++) {
264  fprintf(flive,"%s:slag=%5.2f\tlag=%5.2f\t",IFO[jj],Wslag[jj].data[j],Wlag[jj].data[j]);
265  }
266  fprintf(flive,"live=%9.2f\n",Tlag.data[j]);
267  }
268  fprintf(flive,"nonzero lags live=%10.1f \n",liveTot);
269  fclose(flive);
270  printf("total live time: non-zero lags = %10.1f \n",liveTot);
271  cout << "End CWB::Toolbox::getLiveTime : ";cout.flush();gSystem->Exec("/bin/date");
272 
273  //int const nlag=Wlag[nIFO].size()+1;
274  int const nlag=Wlag[nIFO].size(); // FIX
275  int min_lag=kMaxInt;
276  int max_lag=0;
277  for(int i=0;i<nlag;i++) if(Wlag[nIFO][i]<min_lag) min_lag=Wlag[nIFO][i];
278  for(int i=0;i<nlag;i++) if(Wlag[nIFO][i]>max_lag) max_lag=Wlag[nIFO][i];
279  int* iy_lag = new int[max_lag+1]; // this array is used because the lag numbers in general are not contiguous
280  for(int i=0;i<=max_lag;i++) iy_lag[i]=-1;
281  for(int i=0;i<nlag;i++) iy_lag[int(Wlag[nIFO][i])-min_lag]=i;
282  double** y_lag = new double*[nlag]; //Ycut = 0.;
283  double** y_lag_veto = new double*[nlag]; //Ycut = 0.;
284  for(int i=0;i<nlag;i++) {
285  y_lag[i] = new double[pp_rho_bin];
286  y_lag_veto[i] = new double[pp_rho_bin];
287  }
288 // double y_lag[nlag][pp_rho_bin]; //Ycut = 0.;
289 // double y_lag_veto[nlag][pp_rho_bin]; //Ycut = 0.;
290  for (int i=0;i<nlag;i++) for (int j=0; j<pp_rho_bin; j++) {y_lag[i][j] = 0.;y_lag_veto[i][j] = 0.;}
291 
292 // histograms
293 
294  TH1F* xCor = new TH1F("xCor","",100,0.4,1.);
295  xCor->SetTitleOffset(1.3,"Y");
296  xCor->SetTitle("");
297  xCor->GetXaxis()->SetTitle("network correlation");
298  xCor->GetYaxis()->SetTitle("events");
299 
300  TH1F* dens = new TH1F("dens","",100,0.,3);
301  dens->SetTitleOffset(1.3,"Y");
302  dens->SetTitle("");
303  dens->GetXaxis()->SetTitle("-log10(cluster density)");
304  dens->GetYaxis()->SetTitle("events");
305 
306  TH1F* hpf = new TH1F("hpf","",100,0.,1.);
307  hpf->SetTitleOffset(1.3,"Y");
308  hpf->SetTitle("");
309  hpf->GetXaxis()->SetTitle("penalty factor");
310  hpf->GetYaxis()->SetTitle("events");
311 
312  TH1F* hvED = new TH1F("hvED","",200,0,2.);
313  hvED->SetTitleOffset(1.3,"Y");
314  hvED->SetTitle("");
315  hvED->GetXaxis()->SetTitle("hvED consistency");
316  hvED->GetYaxis()->SetTitle("events");
317 
318  TH1F* ecor = new TH1F("ecor","",200,0,10.);
319  ecor->SetTitleOffset(1.3,"Y");
320  ecor->SetTitle("");
321  ecor->GetXaxis()->SetTitle("correlated amplitude");
322  ecor->GetYaxis()->SetTitle("events");
323 
324  TH1F* ECOR = new TH1F("ECOR","",200,0,10.);
325  ECOR->SetTitleOffset(1.3,"Y");
326  ECOR->SetTitle("");
327  ECOR->GetXaxis()->SetTitle("#rho(ECOR))");
328  ECOR->GetYaxis()->SetTitle("events");
329 
330  TH1F* Like = new TH1F("Like","",100,1,4.);
331  Like->SetTitleOffset(1.3,"Y");
332  Like->SetTitle("");
333  Like->GetXaxis()->SetTitle("log10(likelihood)");
334  Like->GetYaxis()->SetTitle("events");
335 
336  TH1F* Mchirp = new TH1F("Mchirp","",100,0.,40.);
337  Mchirp->SetTitleOffset(1.3,"Y");
338  Mchirp->SetTitle("After pp cuts");
339  Mchirp->GetXaxis()->SetTitle("reconstructed chirp mass(M_{#odot})");
340  Mchirp->GetYaxis()->SetTitle("events");
341 
342  TH1F* McErr = new TH1F("McErr","",100,0.,1.);
343  McErr->SetTitleOffset(1.3,"Y");
344  McErr->SetTitle("After pp cuts");
345  McErr->GetXaxis()->SetTitle("pixels used in reconstruction/total");
346  McErr->GetYaxis()->SetTitle("events");
347 
348  TH1F* cutF = new TH1F("cutF","",24,60,2048.);//,300,2,6);
349  cutF->SetTitleOffset(1.2,"Y");
350  cutF->GetXaxis()->SetTitle("frequency, Hz");
351  //cutF->GetYaxis()->SetTitle("#rho");
352  cutF->SetStats(kFALSE);
353  cutF->SetFillColor(2);
354  //cutF->SetMarkerStyle(20);
355  //cutF->SetMarkerSize(0.6);
356  //cutF->SetMarkerColor(2);
357 
358  TH2F* rhocc = new TH2F("rhocc","",100,0.,1.,100,pp_rho_min,pp_rho_max);
359  rhocc->SetTitle("0 < cc < 1");
360  rhocc->SetTitleOffset(1.3,"Y");
361  rhocc->GetXaxis()->SetTitle("network correlation");
362  rhocc->GetYaxis()->SetTitle("#rho");
363  rhocc->SetStats(kFALSE);
364  rhocc->SetMarkerStyle(20);
365  rhocc->SetMarkerSize(0.5);
366  rhocc->SetMarkerColor(1);
367 
368  TH2F* ECOR_cc = new TH2F("ECOR_cc","",100,0.,1.,500,0,15.);
369  ECOR_cc->SetTitleOffset(1.3,"Y");
370  ECOR_cc->GetXaxis()->SetTitle("network correlation");
371  ECOR_cc->GetYaxis()->SetTitle("#rho(ECOR)");
372  ECOR_cc->SetStats(kFALSE);
373  ECOR_cc->SetMarkerStyle(20);
374  ECOR_cc->SetMarkerSize(0.5);
375  ECOR_cc->SetMarkerColor(1);
376 
377  TH2F* ecor_cc = new TH2F("ecor_cc","",100,0.,1.,500,0,15.);
378  ecor_cc->SetTitleOffset(1.3,"Y");
379  ecor_cc->GetXaxis()->SetTitle("network correlation");
380  ecor_cc->GetYaxis()->SetTitle("#rho(ecor)");
381  ecor_cc->SetStats(kFALSE);
382  ecor_cc->SetMarkerStyle(20);
383  ecor_cc->SetMarkerSize(0.5);
384  ecor_cc->SetMarkerColor(1);
385 
386  TH2F* rho_subnet = new TH2F("rho_subnet","",100,0.,1.,100,pp_rho_min,pp_rho_max);
387  rho_subnet->SetTitle("0 < subnet < 1");
388  rho_subnet->SetTitleOffset(1.3,"Y");
389  rho_subnet->GetXaxis()->SetTitle("subnet");
390  rho_subnet->GetYaxis()->SetTitle("#rho");
391  rho_subnet->SetMarkerStyle(20);
392  rho_subnet->SetMarkerColor(1);
393  rho_subnet->SetMarkerSize(0.5);
394  rho_subnet->SetStats(kFALSE);
395 
396  TH2F* rho_vED = new TH2F("rho_vED","",100,0.,1.,100,pp_rho_min,pp_rho_max);
397  rho_vED->SetTitle("0 < vED < 1");
398  rho_vED->SetTitleOffset(1.3,"Y");
399  rho_vED->GetXaxis()->SetTitle("vED");
400  rho_vED->GetYaxis()->SetTitle("#rho");
401  rho_vED->SetMarkerStyle(20);
402  rho_vED->SetMarkerColor(1);
403  rho_vED->SetMarkerSize(0.5);
404  rho_vED->SetStats(kFALSE);
405 
406  TH2F* rho_pf;
407  if(TString(analysis)=="1G") {
408  rho_pf = new TH2F("rho_pf","",100,0.,1.,100,pp_rho_min,pp_rho_max);
409  rho_pf->SetTitle("0 < penalty < 1");
410  rho_pf->GetXaxis()->SetTitle("penalty");
411  } else {
412  rho_pf = new TH2F("rho_pf","",100,-1.,2.,100,pp_rho_min,pp_rho_max);
413  rho_pf->SetTitle("chi2");
414  rho_pf->GetXaxis()->SetTitle("log10(chi2)");
415  }
416  rho_pf->SetTitleOffset(1.3,"Y");
417  rho_pf->GetYaxis()->SetTitle("#rho");
418  rho_pf->SetMarkerStyle(20);
419  rho_pf->SetMarkerColor(1);
420  rho_pf->SetMarkerSize(0.5);
421  rho_pf->SetStats(kFALSE);
422 
423  TH2F* pf_cc = new TH2F("pf_cc","",100,0.,1.,100,0,1.);
424  pf_cc->SetTitleOffset(1.3,"Y");
425  pf_cc->GetXaxis()->SetTitle("network correlation");
426  pf_cc->GetYaxis()->SetTitle("penalty");
427  pf_cc->SetMarkerStyle(20);
428  pf_cc->SetMarkerColor(1);
429  pf_cc->SetMarkerSize(0.8);
430  pf_cc->SetStats(kFALSE);
431 
432  TH2F* pf_vED = new TH2F("pf_vED","",100,0.,1.,100,0,1.);
433  pf_vED->SetTitleOffset(1.3,"Y");
434  pf_vED->GetXaxis()->SetTitle("vED consistency");
435  pf_vED->GetYaxis()->SetTitle("penalty");
436  pf_vED->SetMarkerStyle(20);
437  pf_vED->SetMarkerColor(1);
438  pf_vED->SetMarkerSize(0.8);
439  pf_vED->SetStats(kFALSE);
440 
441  TH2F* pf_ed = new TH2F("pf_ed","",100,0.,1.,100,0.,1.);
442  pf_ed->SetTitleOffset(1.3,"Y");
443  pf_ed->GetXaxis()->SetTitle("energy disbalance");
444  pf_ed->GetYaxis()->SetTitle("penalty");
445  pf_ed->SetMarkerStyle(20);
446  pf_ed->SetMarkerColor(1);
447  pf_ed->SetMarkerSize(0.8);
448  pf_ed->SetStats(kFALSE);
449 
450  TH2F* rho_L = new TH2F("rho_L","",500,0.,5.,500,0,5.);
451  rho_L->SetTitleOffset(1.3,"Y");
452  rho_L->GetYaxis()->SetTitle("log10(average SNR)");
453  rho_L->GetXaxis()->SetTitle("log10(2*#rho^2)");
454  rho_L->SetStats(kFALSE);
455  rho_L->SetMarkerStyle(20);
456  rho_L->SetMarkerSize(0.5);
457  rho_L->SetMarkerColor(1);
458 
459  TH2F* rho_mchirp = new TH2F("rho_mchirp","",200,0.,30.,100,pp_rho_min,pp_rho_max);
460  rho_mchirp->SetTitle("rho vs Mchirp(after pp cuts)");
461  rho_mchirp->SetTitleOffset(1.3,"Y");
462  rho_mchirp->GetXaxis()->SetTitle("Mchirp");
463  rho_mchirp->GetYaxis()->SetTitle("#rho");
464  rho_mchirp->SetMarkerStyle(20);
465  rho_mchirp->SetMarkerColor(1);
466  rho_mchirp->SetMarkerSize(0.5);
467  rho_mchirp->SetStats(kFALSE);
468 
469  //ONLINE
470  skymap sm_theta_phi(3);
471  for (int qq=0;qq<sm_theta_phi.size(); qq++) sm_theta_phi.set(qq,0);
472  skymap sm_ra_dec(3);
473  for (int qq=0;qq<sm_ra_dec.size(); qq++) sm_ra_dec.set(qq,0);
474 
475  sprintf(fname,"%s/time.txt",netdir);
476  ifstream in;
477  in.open(fname);
478  char lab[256];
479  in.getline(lab,256);
480  in >> sTARt >> sTOp;
481  in.close();
482 
483  double T_bgn = sTARt;
484  double T_end = sTOp;
485  T_bgn-=hours*3600;
486  T_end+=hours*3600;
487  int nBins = int((T_end-T_bgn)/hours/3600.);
488  sprintf(fname,"time (%d hours per bin)",int(hours));
489 
490  TH1F* hrho[2];
491  int hrho_col[2] = {1,3};
492  for(int j=0; j<2; j++) {
493  sprintf(ch1,"hrho%d",j);
494  hrho[j] = new TH1F(ch1,ch1,Xcut.size(),pp_rho_min,pp_rho_max);
495  hrho[j]->SetTitleOffset(1.3,"Y");
496  sprintf(_title,"#rho (bin width = %2.1f)",(pp_rho_max-pp_rho_min)/pp_rho_bin);
497  hrho[j]->GetXaxis()->SetTitle(_title);
498  hrho[j]->GetYaxis()->SetTitle("events");
499  hrho[j]->GetYaxis()->SetTitleOffset(2.0);
500  hrho[j]->GetYaxis()->CenterTitle(true);
501  hrho[j]->SetLineColor(hrho_col[j]);
502  hrho[j]->SetFillColor(hrho_col[j]);
503  hrho[j]->SetStats(kFALSE);
504  hrho[j]->SetMinimum(0.5);
505 
506  }
507  hrho[0]->SetTitle("full events (black), after pp cuts (green)");
508 
509  TH1F* hF[NIFO_MAX+1];
510  TH1F* hF2[NIFO_MAX+1];
511  for(int j=0; j<nIFO+1; j++){
512  sprintf(ch1,"hF%d",j);
513  hF[j] = new TH1F(ch1,ch1,nBins,T_bgn,T_end);
514  hF[j]->GetXaxis()->SetTitle(fname);
515  hF[j]->GetXaxis()->SetTitleSize(0.1);
516  hF[j]->GetXaxis()->SetLabelSize(0.1);
517  hF[j]->GetXaxis()->SetTitleOffset(0.9);
518  sprintf(ch1,"hF2%d",j);
519  hF2[j] = new TH1F(ch1,ch1,24,32,2048.);
520  hF2[j]->GetXaxis()->SetTitle("frequency, (80 Hz per bin)");
521  hF2[j]->GetXaxis()->SetTitleSize(0.1);
522  hF2[j]->GetXaxis()->SetLabelSize(0.1);
523  hF2[j]->GetXaxis()->SetTitleOffset(0.9);
524  if(j) {
525  sprintf(_title,"%s : fraction (%%)",IFO[j-1]);
526  hF[j]->GetYaxis()->SetTitle(_title);
527  hF2[j]->GetYaxis()->SetTitle(_title);
528  }
529  hF[j]->GetYaxis()->SetTitleSize(0.12);
530  hF[j]->GetYaxis()->SetLabelSize(0.1);
531  hF[j]->GetYaxis()->SetTitleOffset(0.4);
532  hF[j]->SetStats(kFALSE);
533  hF[j]->SetLineColor(1);
534  hF[j]->SetFillColor(1);
535  hF[j]->SetTitle("full events");
536  hF2[j]->GetYaxis()->SetTitleSize(0.12);
537  hF2[j]->GetYaxis()->SetLabelSize(0.1);
538  hF2[j]->GetYaxis()->SetTitleOffset(0.4);
539  hF2[j]->SetStats(kFALSE);
540  hF2[j]->SetLineColor(1);
541  hF2[j]->SetFillColor(1);
542  hF2[j]->SetTitle("full events");
543  }
544 
545  TH1F* hR[3];
546  int hR_col[3] = {2,1,3};
547  for(int j=0; j<3; j++){
548  sprintf(fname,"hR%d",j);
549  hR[j] = new TH1F(fname,"",nBins,T_bgn,T_end);
550  hR[j]->SetTitleOffset(1.3,"Y");
551  sprintf(fname,"time (%d hours per bin)",int(hours));
552  hR[j]->GetXaxis()->SetTitle(fname);
553  hR[j]->GetYaxis()->SetTitle("rate, Hz");
554  hR[j]->GetYaxis()->SetTitleOffset(2.0);
555  hR[j]->SetTitle("full events (black), after pp cuts (green)");
556  hR[j]->SetStats(kFALSE);
557  hR[j]->SetLineColor(hR_col[j]);
558  hR[j]->SetFillColor(hR_col[j]);
559  }
560 
561  // read events
562 
563  sprintf(fname,"%s/events.txt",netdir);
564  FILE* ftrig = fopen(fname,"w");
565  fprintf(ftrig,"# correlation threshold = %f \n",T_cor);
566  fprintf(ftrig,"# network rho threshold = %f\n",T_cut);
567  fprintf(ftrig,"# -/+ - not passed/passed final selection cuts\n");
568  fprintf(ftrig,"# 1 - effective correlated amplitude rho \n");
569  fprintf(ftrig,"# 2 - correlation coefficient 0/1 (1G/2G)\n");
570  fprintf(ftrig,"# 3 - correlation coefficient 2\n");
571  fprintf(ftrig,"# 4 - correlation coefficient 3\n");
572  fprintf(ftrig,"# 5 - correlated amplitude \n");
573  fprintf(ftrig,"# 6 - time shift \n");
574  fprintf(ftrig,"# 7 - time super shift \n"); //SLAG
575  fprintf(ftrig,"# 8 - likelihood \n");
576  fprintf(ftrig,"# 9 - penalty factor \n");
577  fprintf(ftrig,"# 10 - energy disbalance \n");
578  fprintf(ftrig,"# 11 - central frequency \n");
579  fprintf(ftrig,"# 12 - bandwidth \n");
580  fprintf(ftrig,"# 13 - duration \n");
581  fprintf(ftrig,"# 14 - number of pixels \n");
582  fprintf(ftrig,"# 15 - frequency resolution \n");
583  fprintf(ftrig,"# 16 - cwb run number \n");
584  i = 16;
585  for(int j=0; j<nIFO; j++) fprintf(ftrig,"# %2d - time for %s detector \n",++i,IFO[j]);
586  for(int j=0; j<nIFO; j++) fprintf(ftrig,"# %2d - sSNR for %s detector \n",++i,IFO[j]);
587  for(int j=0; j<nIFO; j++) fprintf(ftrig,"# %2d - hrss for %s detector \n",++i,IFO[j]);
588  fprintf(ftrig,"# %2d - PHI \n",++i);
589  fprintf(ftrig,"# %2d - THETA \n",++i);
590  fprintf(ftrig,"# %2d - PSI \n",++i);
591 
592  int ntrg = wave.GetEntries();
593  cout<<"total events: "<<ntrg<<endl;
594  printf("data start GPS: %15.5f \n",sTARt);
595  printf("data stop GPS: %15.5f \n",sTOp);
596  rUn = -1;
597 
598  if(bhveto||bcat3) {
599 // int vgtrg = W.fChain->GetEntries();
600 // if (vgtrg!=ntrg){cout<<"Warning: vgtree has "<<vgtrg<<" events!"<<endl;}
601 // cout << "events passing the " << vetocut << " veto: " << W.fChain->Draw("",vetocut,"goff")<<endl;
602  }
603 
604  wavearray<int> LAG_PASS(ntrg);LAG_PASS=0; //LAG_PASS ARRAY
605  wavearray<int> SAVE(ntrg);SAVE=0; //SAVE ARRAY
606  wavearray<int> Wsel(ntrg); //MULTI
607  for(int i=0;i<ntrg;i++) Wsel[i]=0; //MULTI
608 
609  cout << "cwb_report_prod_2.C : Start event loop ..." << endl;
610  for(int i=0; i<ntrg; i++) {
611 
612  W.GetEntry(i);
613  if(i%10000==0) cout << "cwb_report_prod_2.C : loop 1 - processed: " << i << "/" << ntrg << endl;
614 
615  save_veto=1;
616 
617  // apply veto cuts
618  bool bveto=false;
619  for(int j=0;j<nXDQF;j++) {
620  saveVETO[j]=1;
621  if((XDQF[j].cat==CWB_CAT2)&&(!VETO[j])) {countVETO[j]++;bveto=true;}
622  if((XDQF[j].cat==CWB_CAT3)&&(VETO[j])) {countVETO[j]++;saveVETO[j]=0;save_veto=0;}
623  if((XDQF[j].cat==CWB_HVETO)&&(VETO[j])) {countVETO[j]++;saveVETO[j]=0;save_veto=0;}
624  }
625  if(bveto) continue;
626 
627  double WLag = W.lag[nIFO];
628  double WSLag = W.slag[nIFO];
629 
630  if((cwb_lag_number==-1)&&(cwb_slag_number==-1)) {
631  if((WLag==0)&&(WSLag==0)) continue; // LAG=0 && SLAG=0
632  }
633  if((cwb_lag_number>=0)&&(cwb_slag_number==-1)) {
634  if(WLag!=cwb_lag_number) continue; // SINGLE LAG & ANY SLAG
635  if((WLag==0)&&(WSLag==0)) continue; // LAG=0 && SLAG=0
636  }
637  if((cwb_lag_number==-1)&&(cwb_slag_number>=0)) {
638  if(WSLag!=cwb_slag_number) continue; // ANY LAG & SINGLE SLAG
639  if((WLag==0)&&(WSLag==0)) continue; // LAG=0 && SLAG=0
640  }
641  if((cwb_lag_number>=0)&&(cwb_slag_number>=0)) {
642  if((WLag!=cwb_lag_number)||(WSLag!=cwb_slag_number)) continue; // SINGLE LAG & SINGLE SLAG
643  }
644  LAG_PASS[i]=1;
645 
646  hrho[0]->Fill(W.rho[pp_irho]); // rho distribution (no cuts)
647 
648  if(W.run != rUn) {
649  rUn = int(W.run+0.1);
650  hR[0]->Fill(float(W.gps[0]),Trun.data[rUn]);
651  }
652 
653  hR[1]->Fill(float(W.gps[0]));
654 
655  // frequencies user band cuts
656  bool bcut=false;
657  for(int j=0;j<nFCUT;j++) {
658  if((W.frequency[0]>lowFCUT[j])&&(W.frequency[0]<=highFCUT[j])) bcut=true;
659  }
660  if(bcut) continue;
661 
662  vED = W.neted[0]/W.ecor; // network disbalance
663  xcor = W.netcc[pp_inetcc]; // network correlation 0/1
664  xcor2 = W.netcc[2]; // network correlation 2
665  xcor3 = W.netcc[3]; // network correlation 3
666  rho = W.rho[pp_irho]; // effective SNR per detector
667  acor = sqrt(W.ecor/nIFO);
668 
669  save = true;
670  if (T_scc>0) {if(W.netcc[2] < T_scc) save = false;}
671  if (T_pen>0) {if(W.penalty < T_pen) save = false;}
672  if (T_vED>0) {if(vED > T_vED) save = false;}
673  if (T_cor>0) {if(xcor < T_cor) save = false;}
674  if (T_cut>0) {if(rho < T_cut) save = false;}
675  if (T_acor>0) {if(acor < T_acor) save = false;}
676  if (T_mchirp>0) {if(W.chirp[1] < T_mchirp) save = false;}
677  if (T_sphr>0) {if(W.chirp[3] < T_sphr) save = false;}
678  if (T_efrac>0) {if(W.chirp[5]*W.chirp[3] + log10(W.size[1])/10< T_efrac) save = false;}
679 
680  SAVE[i]=save;
681 
682  if(!save) continue;
683 
684  // write to file all events with (rho > T_out)
685  if(rho>T_out) {
686 
687  pf_cc->Fill(xcor,W.penalty);
688  if(W.frequency[0]>0 && W.duration[0]>0) dens->Fill(-log10(W.size[0]*0.5/W.duration[0]/W.frequency[0]));
689  pf_vED->Fill(vED,W.penalty);
690  pf_ed->Fill(vED,W.penalty);
691  hvED->Fill(fabs(vED));
692  hpf->Fill(W.penalty);
693 
694  if(save) fprintf(ftrig,"+");
695  else fprintf(ftrig,"-");
696  for(int j=0;j<nXDQF;j++) {
697  if((XDQF[j].cat==CWB_HVETO)&&(!saveVETO[j])) fprintf(ftrig,"%c",XDQF[j].ifo[0]);
698  }
699  fprintf(ftrig," -");
700  for(int j=0;j<nXDQF;j++) {
701  if((XDQF[j].cat==CWB_CAT3)&&(!saveVETO[j])) fprintf(ftrig,"%c",XDQF[j].ifo[0]);
702  }
703  fprintf(ftrig," ");
704 
705  int wslag=0; wslag=W.slag[nIFO];
706  fprintf(ftrig,"%5.4f %4.3f %4.3f %4.3f %5.2f %7.3f %7d %5.1e %4.3f %4.3f ",
707  rho,xcor,xcor2,xcor3,acor,W.lag[nIFO],wslag,W.likelihood,W.penalty,vED);
708  fprintf(ftrig,"%4.0f %4.0f %4.3f %3d %3.1d %5d ",
709  W.frequency[0],W.bandwidth[0],
710  W.duration[0],W.size[0],W.rate[0],int(W.run));
711 
712  for(j=0; j<nIFO; j++) fprintf(ftrig,"%14.4f ",W.time[j]);
713  for(j=0; j<nIFO; j++) fprintf(ftrig,"%5.1e ",W.sSNR[j]);
714  for(j=0; j<nIFO; j++) fprintf(ftrig,"%5.1e ",W.hrss[j]);
715  if(TMath::IsNaN(W.psi[0])) W.psi[0]=-1000; // fix psi value when is nan
716  fprintf(ftrig,"%4.2f %4.2f %4.2f ",W.phi[0], W.theta[0], W.psi[0]);
717  fprintf(ftrig,"\n");
718  }
719 
720  if(rho>T_out) {
721  int indx = lagslag[std::make_pair(int(W.slag[nIFO]),int(W.lag[nIFO]))];
722  Rlag.data[indx] += 1.;
723  }
724 
725  int rho_size=0;
726  double drho = (pp_rho_max-pp_rho_min)/pp_rho_bin;
727  for(j=0; j<Xcut.size(); j++) {
728  Xcut.data[j] = pp_rho_min+j*drho;
729  if(Xcut.data[j]>pp_rho_max) continue;
730  if(rho > Xcut.data[j]) {Ycut.data[j] += 1.;}
731  if(rho > Xcut.data[j] && save_veto==1) {Ycut_veto.data[j] += 1.;}
732  if(rho > Xcut.data[j]) {y_lag[iy_lag[int(W.lag[nIFO])-min_lag]][j] += 1.;}
733  if(rho > Xcut.data[j] && save_veto==1) {y_lag_veto[iy_lag[int(W.lag[nIFO])-min_lag]][j] += 1.;}
734  rho_size++;
735  }
736  Xcut.resize(rho_size);
737 
738  // fill high resolution array (drho=0.01) 'dump to far_rho.txt file' with not vetoed bkg events
739  if(save_veto) AddRho2FAR(rho, &Xfar, &Yfar, far_rho_min, far_drho);
740 
741  Wsel[i]=1; //MULTI
742 
743  } // End event loop
744 
745  delete [] iy_lag;
746  for(int i=0;i<nlag;i++) {
747  delete [] y_lag[i];
748  delete [] y_lag_veto[i];
749  }
750 
751  // WARNING !!! the main loop has been splitted to make faster the loop. I don't know why!!!
752  for(int i=0; i<ntrg; i++) {
753 
754  W.GetEntry(i);
755  if(i%10000==0) cout << "cwb_report_prod_2.C : loop 2 - processed: " << i << "/" << ntrg << endl;
756 
757  if (!LAG_PASS[i]) continue; // skip events if not pass lag/slag cuts
758 
759  //ONLINE
760  sm_theta_phi.add(sm_theta_phi.getSkyIndex(W.theta[0],W.phi[0]),1);
761  sm_ra_dec.add(sm_ra_dec.getSkyIndex(-(W.theta[2]-90.),W.phi[2]),1);
762 
763  xcor = W.netcc[pp_inetcc]; // network correlation
764  rho = W.rho[pp_irho]; // effective SNR per detector
765  vED = W.neted[0]/W.ecor; // energy disbalance
766 
767  // get dectector with max SNR
768  double mSNR = 0.;
769  int detId = 0;
770  for(j=0; j<nIFO; j++) {
771  if(W.snr[j]>mSNR) {detId=j+1; mSNR=W.snr[j];}
772  }
773 
774  // fill histograms with events which pass pp cuts
775 
776  rho_L->Fill(log10(2*rho*rho),log10(W.likelihood/nIFO));
777  xCor->Fill(xcor);
778  rhocc->Fill(xcor,rho);
779  ecor_cc->Fill(xcor,W.rho[0]);
780  ECOR_cc->Fill(xcor,W.rho[1]);
781  rho_subnet->Fill(W.netcc[2],rho);
782  rho_vED->Fill(vED,rho);
783  float chi2 = W.penalty>0 ? log10(W.penalty) : 0;
784  if(TString(analysis)=="1G") rho_pf->Fill(W.penalty,rho);
785  else rho_pf->Fill(chi2,rho);
786 
787  float Wgps=float(W.gps[0]);
788  float Wfreq=float(W.frequency[0]);
789 
790  hF[0]->Fill(Wgps);
791  hF[detId]->Fill(Wgps,100.);
792  hF2[0]->Fill(Wfreq);
793  hF2[detId]->Fill(Wfreq,100.);
794  cutF->Fill(Wfreq);
795 
796  ecor->Fill(sqrt(W.ecor/nIFO));
797  ECOR->Fill(sqrt(W.ECOR/nIFO));
798  Like->Fill(log10(W.likelihood));
799 
800  Mchirp->Fill(W.chirp[1]);
801  McErr->Fill(W.chirp[5]);
802  rho_mchirp->Fill(W.chirp[1],rho);
803 
804  if (!SAVE[i]) continue; // skip events if not pass pp cuts
805 
806  hR[2]->Fill(Wgps);
807  hrho[1]->Fill(rho);
808 
809  } // End event loop
810 
811  fclose(ftrig);
812 
813  for(int j=0;j<nXDQF;j++) {
814  cout << "Events vetoed by " << nameVETO[j].Data() << " - " << countVETO[j] << endl;
815  }
816 
817  sprintf(fname,"%s/lags.txt",netdir);
818  FILE* filelags = fopen(fname,"w");
819  for(j=0; j<Wlag[nIFO].size(); j++){
820  Elag.data[j] = sqrt(Rlag.data[j])/Tlag.data[j];
821  if(Wlag[nIFO].data[j]>0.) {
822  fprintf(filelags,"%6.3f %6.3f %d %d\n",
823  Wslag[nIFO].data[j],Wlag[nIFO].data[j],(int)Tlag.data[j],(int)Rlag.data[j]);
824  }
825  Rlag.data[j]/= Tlag.data[j];
826  }
827  fclose(filelags);
828 
829  if(pp_rho_vs_rate_no_multiplicity) cout << "start rate vs mutiplicity ..." << endl;
830  for(j=0; j<Xcut.size(); j++){
831  if(pp_rho_vs_rate_no_multiplicity) {
832  // rate correct taking into account the multiplicity
833  wavecomplex rate_multi=CWB::Toolbox::getRate(Xcut.data[j],Tgap,nIFO,wave,Wsel,Wlag,Wslag,Tlag); //MULTI
834  Ycut_multi.data[j] = rate_multi.real();
835  Yerr_multi.data[j] = rate_multi.imag();
836  }
837  Yerr.data[j] = sqrt(Ycut.data[j])/liveTot;
838  Ycut.data[j] = Ycut.data[j]/liveTot;
839  yERR.data[j] = sqrt(yCUT.data[j])/liveTot;
840  yCUT.data[j] = yCUT.data[j]/liveTot;
841  //veto
842  Yerr_veto.data[j] = sqrt(Ycut_veto.data[j])/liveTot;
844 #ifdef PERC_CAT3
845  Ycut_veto.data[j] /= PERC_CAT3;
846 #endif
847  }
848 
849  // write rho statistic distribution
850  ofstream out_far;
851  sprintf(fname,"%s/far_rho.txt",netdir);
852  out_far.open(fname,ios::out);
853  if(!out_far.good()) {cout << "Error Opening File " << fname << endl;exit(1);}
854  ofstream out_efar;
855  sprintf(fname,"%s/efar_rho.txt",netdir);
856  out_efar.open(fname,ios::out);
857  if(!out_efar.good()) {cout << "Error Opening File " << fname << endl;exit(1);}
858  for(int i=0;i<Xfar.size(); i++) if (Yfar[i]>0) {
859  double x = Xfar[i];
860  double ex = 0;
861  double y = Yfar[i]/liveTot;
862  double ey = sqrt(Yfar[i])/liveTot;
863  if(y>=1) out_far << x << "\t\t" << y << endl;
864  if(y<1) out_far << x << "\t\t" << y << endl;
865  //cout << i << " " << x << " " << y << " " << ex << " " << ey << endl;
866  if(y>=1) out_efar << x << "\t\t" << y << "\t\t" << ex << "\t" << ey << endl;
867  if(y<1) out_efar << x << "\t\t" << y << "\t" << ex << "\t" << ey << endl;
868  }
869  out_far.close();
870  out_efar.close();
871 
872  sprintf(fname,"%s/rate_threshold.txt",netdir);
873  FILE* frate = fopen(fname,"w");
874  for(j=0; j<Xcut.size(); j++){
875  fprintf(frate,"%3.2f %4.3e\n",Xcut.data[j],Ycut.data[j]);
876  }
877  fclose(frate);
878 
879  sprintf(fname,"%s/rate_threshold_veto.txt",netdir);
880  FILE* fratev = fopen(fname,"w");
881  for(j=0; j<Xcut.size(); j++){
882  fprintf(fratev,"%3.2f %4.3e\n",Xcut.data[j],Ycut_veto.data[j]);
883  }
884  fclose(fratev);
885 
886  //MULTI
887  sprintf(fname,"%s/rate_threshold_multi.txt",netdir);
888  FILE* fratem= fopen(fname,"w");
889  for(j=0; j<Xcut.size(); j++){
890  fprintf(fratem,"%3.2f %4.3e\n",Xcut.data[j],Ycut_multi.data[j]);
891  }
892  fclose(fratem);
893 
894  char output[256];
895  sprintf(fname,"%s/sigma.txt",netdir);
896  ofstream out_lf(fname,ios::out);
897  for(j=0; j<pp_rho_bin; j++){
898  int elag=0;
899  double mean=0;
900  double sigma=0;
901  double sum=0;
902  for (int k=1; k<nlag; k++) { // FIX
903  float rate=0.0;
904  if(Tlag[k]>0) rate=y_lag[k][j]/Tlag[k]; // FIX Tlag[j] -> Tlag[k]
905  mean+=rate;
906  sum+=rate*rate;
907  elag++;
908  }
909  if(elag>0) {
910  mean=mean/elag;
911  sigma= sqrt((sum-elag*mean*mean)/elag);
912  }
913  sprintf(output,"%3.2f %4.3e %4.3e\n",Xcut[j],Ycut[j],sigma);
914  out_lf << output;
915  }
916  cout << fname << endl;
917  out_lf.close();
918 
919  sprintf(fname,"%s/sigma_veto.txt",netdir);
920  ofstream out_veto(fname,ios::out);
921  for(j=0; j<pp_rho_bin; j++){
922  int elag=0;
923  double mean=0;
924  double sigma=0;
925  double sum=0;
926  for (int k=1; k<nlag-1; k++) { // FIX
927  float rate=0.0;
928  if(Tlag[k]>0) rate=y_lag_veto[k][j]/Tlag[k]; // FIX : Tlag[j] -> Tlag[k]
929  mean+=rate;
930  sum+=rate*rate;
931  elag++;
932  }
933  if(elag>0) {
934  mean=mean/elag;
935  sigma= sqrt((sum-elag*mean*mean)/elag);
936  }
937  sprintf(output,"%3.2f %4.3e %4.3e\n",Xcut[j],Ycut_veto[j],sigma);
938  out_veto << output;
939  }
940  cout << fname << endl;
941  out_veto.close();
942 
943  CWB::Toolbox::doPoissonPlot(nIFO, Wlag, Tlag, Rlag, netdir);
944 
945  c1->Clear();
946  pf_vED->Draw("colz");
947  sprintf(fname,"%s/penalty_vED.eps",netdir);
948  c1->Update(); c1->SaveAs(fname);
949 
950  c1->Clear();
951  rho_L->Draw("colz");
952  sprintf(fname,"%s/rho_L.eps",netdir);
953  c1->Update(); c1->SaveAs(fname);
954 
955  c1->Clear();
956  pf_ed->Draw("colz");
957  sprintf(fname,"%s/penalty_ed.eps",netdir);
958  c1->Update(); c1->SaveAs(fname);
959 
960  c1->Clear();
961  pf_cc->Draw("colz");
962  sprintf(fname,"%s/penalty_cc.eps",netdir);
963  c1->Update(); c1->SaveAs(fname);
964 
965  if(c1) delete c1;
966  c1 = new TCanvas("c","C",0,0,1400,400*nIFO);
967  c1->SetBorderMode(0);
968  c1->SetFillColor(0);
969  c1->SetBorderSize(2);
970  c1->SetGridx();
971  c1->SetGridy();
972  c1->SetBottomMargin(0.143939);
973  c1->SetRightMargin(0.1517039);
974  c1->SetTopMargin(0.0772727);
975 
976  c1->Clear();
977  c1->Divide(1,nIFO);
978  for(i=1; i<nIFO+1; i++) {
979  c1->cd(i);
980  c1->SetLogy(kFALSE);
981  hF[i]->Divide(hF[0]); hF[i]->SetMaximum(100.);
982  gStyle->SetOptStat(kFALSE);
983  gPad->SetBottomMargin(0.2);
984  hF[i]->Draw("HIST");
985  hF[i]->GetYaxis()->SetLabelSize(0.06);
986  hF[i]->GetXaxis()->SetTimeDisplay(1);
987  }
988  c1->Update();
989  sprintf(fname,"%s/fraction_time.eps",netdir);
990  c1->SaveAs(fname);
991 
992  c1->Clear();
993  c1->Divide(1,nIFO);
994  for(i=1; i<nIFO+1; i++) {
995  c1->cd(i);
996  c1->SetLogy(kFALSE);
997  hF2[i]->Divide(hF2[0]); hF2[i]->SetMaximum(100.);
998  gStyle->SetOptStat(kFALSE);
999  gPad->SetBottomMargin(0.2);
1000  hF2[i]->Draw("HIST");
1001  hF2[i]->GetYaxis()->SetLabelSize(0.06);
1002  }
1003  c1->Update();
1004  sprintf(fname,"%s/fraction_frequency.eps",netdir);
1005  c1->SaveAs(fname);
1006 
1007  c1->Clear();
1008  cutF->Draw("HIST");
1009  c1->Update();
1010  sprintf(fname,"%s/frequency.eps",netdir);
1011  c1->SaveAs(fname);
1012 
1013  if(c1) delete c1;
1014  c1 = new TCanvas("c","C",0,0,1400,1050);
1015  c1->SetBorderMode(0);
1016  c1->SetFillColor(0);
1017  c1->SetBorderSize(2);
1018  c1->SetGridx();
1019  c1->SetGridy();
1020  c1->SetBottomMargin(0.143939);
1021  //c1->SetRightMargin(0.1517039);
1022  c1->SetRightMargin(0.10);
1023  c1->SetLeftMargin(0.15);
1024  c1->SetTopMargin(0.0772727);
1025 
1026  c1->Clear();
1027  c1->SetLogy(kTRUE);
1028  hR[1]->Divide(hR[0]);
1029  hR[1]->Draw("HIST");
1030  hR[1]->SetMinimum(1.e-5);
1031  gStyle->SetOptStat(kFALSE);
1032  hR[1]->Draw("HIST");
1033  hR[1]->GetXaxis()->SetTimeDisplay(1);
1034  hR[1]->GetXaxis()->SetLabelSize(0.04);
1035  for(i=2; i<3; i++) { hR[i]->Divide(hR[0]); hR[i]->Draw("same"); }
1036  sprintf(fname,"%s/rate_time.eps",netdir);
1037  c1->Update(); c1->SaveAs(fname);
1038 
1039  c1->Clear();
1040  c1->SetLogy(kFALSE);
1041  TGraphErrors* gr2;
1042  gr2=new TGraphErrors(Wlag[nIFO].size(),Tdlag.data,Rlag.data,Olag.data,Elag.data);
1043  sprintf(_title,"after pp-cuts & rho > %3.2f",T_out);
1044  gr2->SetTitle(_title);
1045  gr2->SetLineColor(1);
1046  gr2->SetMarkerStyle(20);
1047  gr2->SetMarkerColor(1);
1048  gr2->SetMarkerSize(1);
1049  gr2->Draw("AP");
1050  gr2->GetHistogram()->SetXTitle("lag");
1051  gr2->GetHistogram()->SetYTitle("rate, Hz");
1052  gr2->GetHistogram()->GetXaxis()->SetNdivisions(508);
1053 
1054  sprintf(fname,"%s/rate_lag.eps",netdir);
1055  c1->Update(); c1->SaveAs(fname);
1056 
1057  c1->Clear();
1058  c1->SetLogy(kFALSE);
1059  for(int l=0;l<Wlag[nIFO].size();l++) Tlag.data[l]/=86400.;
1060  if(gr2) delete gr2;
1061  gr2=new TGraphErrors(Wlag[nIFO].size(),Tdlag.data,Tlag.data,Olag.data,Elag.data);
1062  gr2->SetTitle("live vs lag");
1063  gr2->SetLineColor(1);
1064  gr2->SetMarkerStyle(20);
1065  gr2->SetMarkerColor(1);
1066  gr2->SetMarkerSize(1);
1067  gr2->Draw("AP");
1068  gr2->GetHistogram()->GetXaxis()->SetNdivisions(508);
1069  gr2->GetHistogram()->SetXTitle("lag");
1070  gr2->GetHistogram()->SetYTitle("live, days");
1071 
1072 
1073  sprintf(fname,"%s/live_lag.eps",netdir);
1074  c1->Update(); c1->SaveAs(fname);
1075 
1076  #define YEAR (24.*3600.*365.)
1077 
1078  c1->Clear();
1079  c1->SetLogy(kTRUE);
1080  if(pp_rho_log) c1->SetLogx(kTRUE); else c1->SetLogx(kFALSE);
1081  wavearray<double> Ycut_year = Ycut;
1082  wavearray<double> Yerr_year = Yerr;
1083  Ycut_year *= YEAR;
1084  Yerr_year *= YEAR;
1085  TGraphErrors* gr1;
1086  gr1=new TGraphErrors(Xcut.size(),Xcut.data,Ycut_year.data,Xerr.data,Yerr_year.data);
1087  gr1->SetTitle("after pp-cuts");
1088  gr1->SetLineColor(1);
1089  gr1->SetMarkerStyle(20);
1090  gr1->SetMarkerColor(1);
1091  gr1->SetMarkerSize(1);
1092  gr1->SetMinimum(0.5/liveTot*YEAR);
1093  c1->SetLogy(kTRUE);
1094  gr1->Draw("AP");
1095  gr1->GetHistogram()->SetXTitle("#rho");
1096  gr1->GetHistogram()->SetYTitle("rate, 1/year");
1097 
1098  sprintf(fname,"%s/rate_threshold.eps",netdir);
1099  c1->Update(); c1->SaveAs(fname);
1100 
1101  if(bhveto||bcat3) {
1102  c1->Clear();
1103  c1->SetLogy(kTRUE);
1104  if(pp_rho_log) c1->SetLogx(kTRUE); else c1->SetLogx(kFALSE);
1105  wavearray<double> Ycut_veto_year = Ycut_veto;
1106  wavearray<double> Yerr_veto_year = Yerr_veto;
1107  Ycut_veto_year *= YEAR;
1108  Yerr_veto_year *= YEAR;
1109  TGraphErrors* gr1_veto;
1110  gr1_veto=new TGraphErrors(Xcut.size(),Xcut.data,Ycut_veto_year.data,Xerr.data,Yerr_veto_year.data);
1111  gr1_veto->SetTitle("after pp-cuts & vetoes");
1112  gr1_veto->SetLineColor(1);
1113  gr1_veto->SetMarkerStyle(20);
1114  gr1_veto->SetMarkerColor(1);
1115  gr1_veto->SetMarkerSize(1);
1116  gr1_veto->SetMinimum(0.5/liveTot*YEAR);
1117  c1->SetLogy(kTRUE);
1118  gr1_veto->Draw("AP");
1119  gr1_veto->GetHistogram()->SetXTitle("#rho");
1120  gr1_veto->GetHistogram()->SetYTitle("rate, 1/year");
1121 
1122  sprintf(fname,"%s/rate_threshold_veto.eps",netdir);
1123  c1->Update(); c1->SaveAs(fname);
1124 
1125  c1->Clear();
1126  if(pp_rho_log) c1->SetLogx(kTRUE); else c1->SetLogx(kFALSE);
1127  gr1->SetTitle("after pp-cuts (black), after pp-cuts & vetoes (red) ");
1128  gr1->Draw("AP");
1129  gr1_veto->SetLineColor(2);
1130  gr1_veto->SetMarkerColor(2);
1131  gr1_veto->Draw("P,same");
1132  sprintf(fname,"%s/rate_threshold_veto_compare.eps",netdir);
1133  c1->Update(); c1->SaveAs(fname);
1134  }
1135 
1136  //MULTI
1137  if(pp_rho_vs_rate_no_multiplicity) {
1138  c1->Clear();
1139  c1->SetLogy(kTRUE);
1140  if(pp_rho_log) c1->SetLogx(kTRUE); else c1->SetLogx(kFALSE);
1141  wavearray<double> Ycut_multi_year = Ycut_multi;
1142  wavearray<double> Yerr_multi_year = Yerr_multi;
1143  Ycut_multi_year *= YEAR;
1144  Yerr_multi_year *= YEAR;
1145  TGraphErrors* gr1_multi;
1146  gr1_multi=new TGraphErrors(Xcut.size(),Xcut.data,Ycut_multi_year.data,Xerr.data,Yerr_multi_year.data);
1147  gr1_multi->SetLineColor(1);
1148  gr1_multi->SetMarkerStyle(20);
1149  gr1_multi->SetMarkerColor(1);
1150  gr1_multi->SetMarkerSize(1);
1151  gr1_multi->SetMinimum(0.5/liveTot);
1152  c1->SetLogy(kTRUE);
1153  gr1_multi->Draw("AP");
1154  gr1_multi->GetHistogram()->SetXTitle("#rho");
1155  gr1_multi->GetHistogram()->SetYTitle("rate, Hz");
1156 
1157  sprintf(fname,"%s/rate_threshold_multi.eps",netdir);
1158  c1->Update(); c1->SaveAs(fname);
1159 
1160  c1->Clear();
1161  if(pp_rho_log) c1->SetLogx(kTRUE); else c1->SetLogx(kFALSE);
1162  gr1->Draw("AP");
1163  gr1->SetTitle("after pp-cuts (black), no-multiplicity (green) ");
1164  gr1_multi->SetLineColor(kGreen+2);
1165  gr1_multi->SetMarkerColor(kGreen+2);
1166  gr1_multi->Draw("P,same");
1167  sprintf(fname,"%s/rate_threshold_multi_compare.eps",netdir);
1168  c1->Update(); c1->SaveAs(fname);
1169  }
1170 
1171  c1->Clear();
1172  c1->SetLogy(kFALSE);
1173  dens->Draw("HIST");
1174  sprintf(fname,"%s/density.eps",netdir);
1175  c1->Update(); c1->SaveAs(fname);
1176 
1177  c1->Clear();
1178  c1->SetLogy(kTRUE);
1179  hpf->Draw("HIST");
1180  sprintf(fname,"%s/penalty.eps",netdir);
1181  c1->Update(); c1->SaveAs(fname);
1182 
1183  c1->Clear();
1184  c1->SetLogy(kTRUE);
1185  hvED->Draw("HIST");
1186  sprintf(fname,"%s/vED.eps",netdir);
1187  c1->Update(); c1->SaveAs(fname);
1188 
1189  gStyle->SetOptStat(kTRUE);
1190  c1->Clear();
1191  c1->SetLogy(kTRUE);
1192  xCor->Draw("HIST");
1193  sprintf(fname,"%s/netcor.eps",netdir);
1194  c1->Update(); c1->SaveAs(fname);
1195 
1196  c1->Clear();
1197  if(pp_rho_log) c1->SetLogx(kTRUE); else c1->SetLogx(kFALSE);
1198  ecor->Draw("HIST");
1199  sprintf(fname,"%s/ecor.eps",netdir);
1200  c1->Update();c1->SaveAs(fname);
1201 
1202  c1->Clear();
1203  hrho[0]->Draw("HIST");
1204  hrho[1]->Draw("same");
1205  sprintf(fname,"%s/rho.eps",netdir);
1206  c1->Update(); c1->SaveAs(fname);
1207 
1208 #ifdef WRITE_ASCII
1209  gROOT->LoadMacro(wat_dir+"/tools/cwb/postproduction/burst/h12ascii.C");
1210  sprintf(fname,"%s/rho.txt",netdir);
1211  h12ascii(hrho[0],fname);
1212  sprintf(fname,"%s/rho_veto.txt",netdir);
1213  h12ascii(hrho[1],fname);
1214 #endif
1215 
1216  c1->Clear();
1217  ECOR->Draw("HIST");
1218  sprintf(fname,"%s/ECOR.eps",netdir);
1219  c1->Update(); c1->SaveAs(fname);
1220 
1221  c1->Clear();
1222  Like->Draw("HIST");
1223  sprintf(fname,"%s/likelihood.eps",netdir);
1224  c1->Update(); c1->SaveAs(fname);
1225 
1226  c1->Clear();
1227  Mchirp->Draw("HIST");
1228  sprintf(fname,"%s/Mchirp.eps",netdir);
1229  c1->Update(); c1->SaveAs(fname);
1230 
1231  c1->Clear();
1232  c1->SetLogy(kFALSE);
1233  McErr->Draw("HIST");
1234  sprintf(fname,"%s/McErr.eps",netdir);
1235  c1->Update(); c1->SaveAs(fname);
1236 
1237  c1->Clear();
1238  c1->SetLogx(kFALSE);
1239  if(pp_rho_log) c1->SetLogy(kTRUE); else c1->SetLogy(kFALSE);
1240  rho_subnet->Draw("colz");
1241  sprintf(fname,"%s/rho_subnet.eps",netdir);
1242  c1->Update(); c1->SaveAs(fname);
1243 
1244  c1->Clear();
1245  c1->SetLogx(kFALSE);
1246  if(pp_rho_log) c1->SetLogy(kTRUE); else c1->SetLogy(kFALSE);
1247  rho_vED->Draw("colz");
1248  sprintf(fname,"%s/rho_vED.eps",netdir);
1249  c1->Update(); c1->SaveAs(fname);
1250 
1251  c1->Clear();
1252  c1->SetLogx(kFALSE);
1253  if(pp_rho_log) c1->SetLogy(kTRUE); else c1->SetLogy(kFALSE);
1254  rho_pf->Draw("colz");
1255  sprintf(fname,"%s/rho_pf.eps",netdir);
1256  c1->Update(); c1->SaveAs(fname);
1257 
1258  c1->Clear();
1259  c1->SetLogx(kFALSE);
1260  if(pp_rho_log) c1->SetLogy(kTRUE); else c1->SetLogy(kFALSE);
1261  rhocc->Draw("colz");
1262  sprintf(fname,"%s/rho_cc.eps",netdir);
1263  c1->Update(); c1->SaveAs(fname);
1264 
1265  c1->Clear();
1266  ECOR_cc->Draw("HIST");
1267  sprintf(fname,"%s/ECOR_cc.eps",netdir);
1268  c1->Update(); c1->SaveAs(fname);
1269 
1270  c1->Clear();
1271  ecor_cc->Draw("HIST");
1272  sprintf(fname,"%s/ecor_cc.eps",netdir);
1273  c1->Update(); c1->SaveAs(fname);
1274 
1275  c1->Clear();
1276  c1->SetLogx(kTRUE);
1277  if(pp_rho_log) c1->SetLogy(kTRUE); else c1->SetLogy(kFALSE);
1278  rho_mchirp->Draw("colz");
1279  sprintf(fname,"%s/rho_mchirp.eps",netdir);
1280  c1->Update(); c1->SaveAs(fname);
1281  c1->SetLogx(kFALSE);
1282 
1283  // WARNING: The following declarations must be creted with new otherwise in ROOT6 macro crash when exit !!!
1284 
1285  //ONLINE
1286  gskymap* gsm_theta_phi = new gskymap(sm_theta_phi);
1287  gsm_theta_phi->SetTitle("Latitude - Longitude");
1288  gsm_theta_phi->SetWorldMap();
1289  gsm_theta_phi->Draw();
1290  sprintf(fname,"%s/phi_vs_theta_online.eps",netdir);
1291  gsm_theta_phi->GetCanvas()->SaveAs(fname);
1292  delete gsm_theta_phi;
1293 
1294  gskymap* gsm_ra_dec = new gskymap(sm_ra_dec);
1295  gsm_ra_dec->SetTitle("right ascension - declination");
1296  //gsm_ra_dec->SetOptions("hammer","celestial");
1297  gsm_ra_dec->SetGalacticDisk();
1298  gsm_ra_dec->Draw();
1299  gsm_ra_dec->GetHistogram()->GetXaxis()->SetTitle("right ascension, degree");
1300  gsm_ra_dec->GetHistogram()->GetYaxis()->SetTitle("declination, degree");
1301  sprintf(fname,"%s/ra_vs_dec_online.eps",netdir);
1302  gsm_ra_dec->GetCanvas()->SaveAs(fname);
1303  delete gsm_ra_dec;
1304 
1305  gSystem->Exit(0);
1306 }
char IFO[NIFO_MAX][32]
TH2D * GetHistogram()
Definition: gskymap.hh:138
wavearray< double > Yfar(far_rho_bin)
double rho
wavearray< double > Ycut_veto(pp_rho_bin)
TH1F * McErr
TH1F * cutF
double T_pen
void Export(TString fname="")
Definition: config.cc:406
FILE * flive
TH2F * rho_L
TH1F * dens
wavearray< double > Yerr_veto(pp_rho_bin)
delete [] iy_lag
double Live
double T_bgn
TH2F * pf_cc
double far_drho
double sTARt
wavearray< double > Trun(500000)
par [0] name
wavearray< double > Yerr_multi(pp_rho_bin)
wavearray< double > yCUT(pp_rho_bin)
double T_sphr
TH1F * ecor
dqfile VDQF[100]
double xcor2
float far_rho_min
double rho_min
double imag() const
Definition: wavecomplex.hh:70
TString("c")
wavearray< double > Xfar(far_rho_bin)
int nBins
double sTOp
char ifo[32]
Definition: Toolbox.hh:84
fclose(flive)
double T_cor
TH1F * hpf
wavearray< double > Olag
static void doPoissonPlot(int nIFO, wavearray< double > *Wlag, wavearray< double > Tlag, wavearray< double > Rlag, TString odir)
Definition: Toolbox.cc:5193
float far_rho_wbin
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
void AddRho2FAR(double rho, wavearray< double > *Xfar, wavearray< double > *Yfar, double far_rho_min, double far_drho)
Definition: Toolfun.hh:970
int max_lag
size_t ntype
int cwb_lag_number
UChar_t VETO[100]
double hours
dqfile * XDQF
int min_lag
TH2F * ECOR_cc
TH2F * rhocc
i pp_inetcc
char ch3[256]
float xlag
wavearray< int > SAVE(ntrg)
void Draw(int dpaletteId=1, Option_t *option="colfz")
Definition: gskymap.cc:460
TString nameVETO[100]
Long_t size
static double getLiveTime(vector< waveSegment > &jobList, vector< waveSegment > &dqList)
Definition: Toolbox.cc:2094
cout<< "Start CWB::Toolbox::getLiveTime : be patient, it takes a while ..."<< endl;liveTot=CWB::Toolbox::getLiveTime(nIFO, live, Trun, Wlag, Wslag, Tlag, Tdlag, cwb_lag_number, cwb_slag_number);std::map< std::pair< int, int >, int > lagslag
static TString CWB_CAT_NAME[14]
Definition: GToolbox.hh:21
int nVDQF
wavearray< int > Wsel(ntrg)
void Import(TString umacro="")
Definition: config.cc:352
static bool checkFile(TString fName, bool question=false, TString message="")
Definition: Toolbox.cc:4670
TH1F * hR[3]
wavearray< double > yERR(pp_rho_bin)
char ifo[NIFO_MAX][8]
double Tgap
Definition: test_config1.C:23
static wavecomplex getRate(double rho, double Tgap, int nIFO, TChain &wav, wavearray< int > &Wsel, wavearray< double > *Wlag, wavearray< double > *Wslag, wavearray< double > Tlag)
Definition: Toolbox.cc:6193
wavearray< double > Xerr(pp_rho_bin)
double T_mchirp
TChain live("liveTime")
static double getZeroLiveTime(int nIFO, TChain &liv, int dummy=0)
Definition: Toolbox.cc:4889
char lab[256]
int m
TH1F * hF[NIFO_MAX+1]
#define nIFO
size_t getSkyIndex(double th, double ph)
param: theta param: phi
Definition: skymap.cc:720
CWB_CAT cat
Definition: Toolbox.hh:86
int n
wavearray< double > Yerr(pp_rho_bin)
virtual size_t size() const
Definition: wavearray.hh:145
double T_acor
int nXDQF
double vED
FILE * filelags
int cwb_slag_number
FILE * frate
wavearray< double > Rlag
ofstream out_lf(fname, ios::out)
wavearray< double > Ycut(pp_rho_bin)
bool bcat2
double real() const
Definition: wavecomplex.hh:69
wavearray< double > Xcut(pp_rho_bin)
fprintf(flive,"nonzero lags live=%10.1f \, liveTot)
double pp_rho_min
static bool isLeafInTree(TTree *itree, TString leaf)
Definition: Toolbox.cc:5466
double xcor3
TCanvas * c1
FILE * ftrig
ofstream out_efar
i() int(T_cor *100))
double rho_max
int far_rho_bin
char netdir[1024]
const int NIFO_MAX
Definition: wat.hh:22
wavearray< double > Tlag
bool pp_rho_log
TH1F * hF2[NIFO_MAX+1]
printf("total live time: non-zero lags = %10.1f \, liveTot)
int l
TCanvas * GetCanvas()
Definition: gskymap.hh:137
int nsize
#define YEAR
TIter next(wave.GetListOfBranches())
void SetGalacticDisk(double gpsGalacticDisk=0.0)
Definition: gskymap.hh:163
char fname[1024]
double acor
char output[256]
wavearray< int > LAG_PASS(ntrg)
TH2F * rho_pf
double liveTot
double xlive
int k
wavearray< double > Tdlag
TH2F * rho_mchirp
FILE * fratem
ofstream out_far
pp_rho_bin
double sigma
Definition: skymap.hh:63
TBranch * branch
int i
TH2F * pf_vED
double e
bool save_veto
double pp_rho_max
bool slagFound
char net_file_name[256]
double T_end
TGraphErrors * gr2
void SetTitle(TString title)
Definition: gskymap.hh:152
char liv_file_name[256]
TH1F * ECOR
TH2F * pf_ed
double liveZero
FILE * fratev
double gps
bool saveVETO[100]
wavearray< double > Ycut_multi(pp_rho_bin)
ifstream in
void SetWorldMap(bool drawWorldMap=true)
Definition: gskymap.hh:154
Int_t rUn
float far_rho_max
double fabs(const Complex &x)
Definition: numpy.cc:55
double highFCUT[100]
TH1F * hvED
TH1F * Mchirp
bool bhveto
strcpy(RunLabel, RUN_LABEL)
netevent W & wave
double xCOR
skymap sm_theta_phi(3)
sprintf(fname,"%s/live.txt", netdir)
double T_cut
double T_efrac
void set(size_t i, double a)
param: sky index param: value to set
Definition: skymap.hh:122
double asnr
wavearray< double > Wlag[NIFO_MAX+1]
int countVETO[100]
DataType_t * data
Definition: wavearray.hh:319
TH2F * rho_subnet
int const nlag
wavearray< double > Elag
int cat
TH2F * ecor_cc
double T_out
double T_scc
bool save
Int_t GetEntries()
Definition: netevent.cc:403
double T_vED
TString config
detectorParams detParms[4]
size_t size()
Definition: skymap.hh:136
void add(size_t i, double a)
param: sky index param: value to add
Definition: skymap.hh:130
virtual void resize(unsigned int)
Definition: wavearray.cc:463
wavearray< double > y
Definition: Test10.C:31
Int_t xrun
int j
TH1F * Like
i drho pp_irho
int hR_col[3]
double lowFCUT[100]
void SetSingleDetectorMode()
Definition: config.cc:1352
double xcor
char _title[1024]
exit(0)
TH1F * xCor
char ch1[256]
bool bcat3
wavearray< double > Wslag[NIFO_MAX+1]
TH2F * rho_vED