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