Logo Coherent WaveBurst  
Reference Guide
Logo
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Draw_FARvsRHO_ER8b_12Sep20Oct_C01_BKG_LF_rMRA_run1ato10a.C
Go to the documentation of this file.
1 
2 #define nFAR_MAX 32
3 
4 int nFAR;
14 
16 void PlotFAR(int nfar, TString far_plot_name, double rho_min=-1, double rho_max=-1);
17 
18 void
20 
21 
22  Style_t markers[32]= {20,21,22,23,29,29,21,22,20,21,22,23,29,20,21,22,
23  21,22,23,29,29,21,22,20,21,22,23,29,20,21,22,20 };
24 
25  Color_t colors[32] = { 8, 0, 2, 8,43, 7, 8, 4, 4, 2,43, 1, 3, 1, 6, 7,
26  6, 3, 2, 8,43, 7, 8, 4, 4, 2,43, 1, 3, 1, 6, 7 };
27 
28  for(int i=0;i<nFAR_MAX;i++) {
29  LINE_COLOR[i] = colors[i];
30  LINE_STYLE[i] = 1;
31  LINE_MARKER[i] = markers[i];
32  ZERO_LAG_TIME[i] = -1;
33  OBS_TIME[i] = 1;
34  }
35 
36  FAR_TITLE="";
37  FAR_PLOT_NAME="";
38 
39  //nFAR = 2;
40  //FAR_PATH[0]="chirp_low_bkg_high_bins.txt";
41  //FAR_PATH[1]="chirp_high_bkg_high_bins.txt";
42 
43  //FAR_PATH[0]="chirp_full_bkg_high_bins.txt";
44  //FAR_PATH[0]="chirp_full_bkg_high_bins_0d01.txt";
45  //FAR_PATH[0]="chirp_full_ext_bkg_high_bins_0d01.txt";
46 /*
47  nFAR = 3;
48  FAR_PATH[0]="unmodeled_full_ext_bkg_high_bins_0d01_M5.txt";
49  FAR_PATH[1]="constrained_full_ext_bkg_high_bins_0d01_M5.txt";
50  FAR_PATH[2]="chirp_full_ext_bkg_high_bins_0d01_M5.txt";
51 */
52 /*
53  nFAR = 3;
54  FAR_PATH[0]="unmodeled_full_ext_bkg_high_bins_0d01_C01_M1.txt";
55  FAR_PATH[1]="constrained_full_ext_bkg_high_bins_0d01_C01_M1.txt";
56  FAR_PATH[2]="chirp_full_ext_bkg_high_bins_0d01_C01_M1.txt";
57 */
58 
59 /*
60  #define MODE "inclusive"
61  nFAR = 6;
62  FAR_PATH[0]="FARvsRHO_ER8b_12Sep20Oct_C01_BKG_LF_rMRA_run1ato10a_unmodeled.txt";
63  FAR_PATH[1]="FARvsRHO_ER8b_12Sep20Oct_C01_BKG_LF_rMRA_run1ato10a_constrained.txt";
64  FAR_PATH[2]="FARvsRHO_ER8b_12Sep20Oct_C01_BKG_LF_rMRA_run1ato10a_chirp.txt";
65  FAR_PATH[3]="FARvsLowRHO_ER8b_12Sep20Oct_C01_BKG_LF_rMRA_run1ato10a_unmodeled.txt";
66  FAR_PATH[4]="FARvsLowRHO_ER8b_12Sep20Oct_C01_BKG_LF_rMRA_run1ato10a_constrained.txt";
67  FAR_PATH[5]="FARvsLowRHO_ER8b_12Sep20Oct_C01_BKG_LF_rMRA_run1ato10a_chirp.txt";
68 */
69 
70  #define MODE "exclusive"
71  nFAR = 6;
72  FAR_PATH[0]="FARvsRHO_ER8b_12Sep20Oct_C01_BKG_LF_rMRA_run1ato10a_eunmodeled.txt";
73  FAR_PATH[1]="FARvsRHO_ER8b_12Sep20Oct_C01_BKG_LF_rMRA_run1ato10a_econstrained.txt";
74  FAR_PATH[2]="FARvsRHO_ER8b_12Sep20Oct_C01_BKG_LF_rMRA_run1ato10a_chirp.txt";
75  FAR_PATH[3]="FARvsLowRHO_ER8b_12Sep20Oct_C01_BKG_LF_rMRA_run1ato10a_eunmodeled.txt";
76  FAR_PATH[4]="FARvsLowRHO_ER8b_12Sep20Oct_C01_BKG_LF_rMRA_run1ato10a_econstrained.txt";
77  FAR_PATH[5]="FARvsLowRHO_ER8b_12Sep20Oct_C01_BKG_LF_rMRA_run1ato10a_chirp.txt";
78 
79 
80  PlotFAR(nFAR, FAR_PLOT_NAME, -1, -1);
81 
82 }
83 
84 void PlotFAR(int nfar, TString far_plot_name, double rho_min, double rho_max) {
85 
86  // create plots
87  gStyle->SetFrameBorderMode(0); // remove the red box around canvas
88  gROOT->ForceStyle();
89 
90  gStyle->SetTitleFont(72);
91  gStyle->SetMarkerColor(50);
92  gStyle->SetLineColor(kWhite);
93  gStyle->SetTitleW(0.98);
94  gStyle->SetTitleH(0.05);
95  gStyle->SetTitleY(0.98);
96  gStyle->SetFillColor(kWhite);
97  gStyle->SetLineColor(kWhite);
98  gStyle->SetTitleFont(12,"D");
99 
100  TCanvas *canvas = new TCanvas("roc", "roc", 300,40, 800, 500);
101  canvas->Clear();
102  canvas->ToggleEventStatus();
103  canvas->SetLogy();
104  canvas->SetGridx();
105  canvas->SetGridy();
106  canvas->SetFillColor(kWhite);
107 
108  double far_min=1e10;
109  double rmin=1e20;
110  double rmax=0;
111  char fname[1024];
112  int nGR=0;
113  int line_style[3*nFAR_MAX];
114  int line_marker[3*nFAR_MAX];
115  int line_color[3*nFAR_MAX];
116  TString FAR_name[3*nFAR_MAX];
117  bool sigma_lines[3*nFAR_MAX];
118  TGraphErrors* gr[3*nFAR_MAX];
119  for(int n=0;n<nFAR;n++) {
120  cout << n << " OBS_TIME : " << OBS_TIME[n] << endl;
121  if(OBS_TIME[n]>0) if(far_min>1./OBS_TIME[n]) far_min=1./OBS_TIME[n];
122  vector<double> rho_far;
123  vector<double> far;
124  // read FAR
125  sprintf(fname,"%s",FAR_PATH[n].Data());
126  cout << "rate_threshold : " << fname << endl;
131  int far_size = readParameters(fname, RHO, eRHO, FAR, eFAR);
132  if(rmin<RHO[0]) rmin=RHO[0];
133  if(rmax>RHO[far_size-1]) rmax=RHO[far_size-1];
134  sigma_lines[nGR] = false;
135  line_style[nGR]=LINE_STYLE[n];
136  line_marker[nGR]=LINE_MARKER[n];
137  line_color[nGR]=LINE_COLOR[n];
138  FAR_name[nGR]=FAR_NAME[n];
139  gr[nGR++] = new TGraphErrors(far_size,RHO.data,FAR.data,eRHO.data,eFAR.data);
140  gr[nGR-1]->SetMarkerStyle(20);
141  gr[nGR-1]->SetMarkerSize(0.4);
142  if(n==0) gr[nGR-1]->SetMarkerColor(8);
143  if(n==1) gr[nGR-1]->SetMarkerColor(kBlack);
144  if(n==2) gr[nGR-1]->SetMarkerColor(kRed);
145  if(n==3) gr[nGR-1]->SetMarkerColor(8);
146  if(n==4) gr[nGR-1]->SetMarkerColor(kBlack);
147  if(n==5) gr[nGR-1]->SetMarkerColor(kRed);
148  gr[nGR-1]->SetName(TString::Format("gr%d",nGR-1));
149 
150  }
151 
152  // GW150914
153  RHO.data[0]=14.1*sqrt(2); FAR.data[0]=1./(1369200.00/(365*24*3600));
154  eRHO.data[0]=0; eFAR.data[0]=0;
155  gr[nGR] = new TGraphErrors(1,RHO.data,FAR.data,eRHO.data,eFAR.data);
156  gr[nGR]->SetMarkerColor(4);
157  gr[nGR]->SetMarkerStyle(22);
158  gr[nGR]->SetMarkerSize(2);
159  FAR_name[nGR]="GW150914";
160  nGR++;
161 
162 
163  TMultiGraph* mg = new TMultiGraph();
164  char gTitle[256];
165  if(FAR_TITLE!="") sprintf(gTitle,FAR_TITLE.Data());
166  else sprintf(gTitle,"FAR Comparison");
167 // PAPER
168 //sprintf(gTitle,"ER8b/O1 (C00) background of unmodeled/constrained/chirp data sets (Sep 12 - Oct 20)");
169 #if ( MODE == "inclusive")
170  sprintf(gTitle,"ER8b/O1 (C01) background of unmodeled/constrained/chirp data sets (Sep 12 - Oct 20)");
171 #endif
172 #if ( MODE == "exclusive")
173  sprintf(gTitle,"ER8b/O1 (C01) background of eunmodeled/econstrained/chirp data sets (Sep 12 - Oct 20)");
174 #endif
175  mg->SetName("mg");
176  mg->SetTitle(gTitle);
177  for(int n=0;n<nGR;n++) mg->Add(gr[n]);
178  //mg->Paint("APL");
179  mg->Paint("AP");
180 
181  mg->GetHistogram()->GetXaxis()->SetLabelSize(0.05);
182  mg->GetHistogram()->GetYaxis()->SetLabelSize(0.05);
183  mg->GetHistogram()->GetXaxis()->SetTitleSize(0.05);
184  mg->GetHistogram()->GetYaxis()->SetTitleSize(0.05);
185  mg->GetHistogram()->GetXaxis()->SetLabelFont(42);
186  mg->GetHistogram()->GetYaxis()->SetLabelFont(42);
187  mg->GetHistogram()->GetYaxis()->SetLabelOffset(0.01);
188  mg->GetHistogram()->GetYaxis()->SetTitleOffset(1.5);
189 // mg->GetHistogram()->SetMinimum(far_min/2.);
190 
191  if(rho_min>=0) rmin=rho_min*sqrt(2);
192  if(rho_max>=0) rmax=rho_max*sqrt(2);
193  rmax=16*sqrt(2);
194  mg->GetHistogram()->GetXaxis()->SetRangeUser(rmin,rmax);
195 
196  mg->GetXaxis()->SetTitle(gr[0]->GetXaxis()->GetTitle());
197  mg->GetXaxis()->SetLabelFont(42);
198  mg->GetYaxis()->SetLabelFont(42);
199  mg->GetXaxis()->SetTitleFont(42);
200  mg->GetYaxis()->SetTitleFont(42);
201  mg->GetXaxis()->SetTitleOffset(1.20);
202  mg->GetYaxis()->SetTitleOffset(1.20);
203  mg->GetXaxis()->SetTitleSize(0.04);
204  mg->GetYaxis()->SetTitleSize(0.04);
205  mg->GetXaxis()->CenterTitle(true); //PAPER
206  mg->GetYaxis()->CenterTitle(true); //PAPER
207  mg->GetXaxis()->SetTitle("Coherent Network SNR ( #eta_{c} )");
208  //mg->GetXaxis()->SetTitle("#eta_{c}");
209  mg->GetYaxis()->SetTitle("FAR ( yr^{-1} )");
210 
211  mg->Draw("ALP");
212 
213  // draw label GW150914
214  //TLatex *pS1 = new TLatex(RHO[0], FAR[0], "GW150914"); //PAPER
215  //TLatex *pS1 = new TLatex(18.30,2.14, "GW150914"); //PAPER
216  TLatex *pS1 = new TLatex(18.93,2.61, "GW150914"); //PAPER
217  pS1->SetTextFont(52);
218  pS1->SetTextSize(0.040); //PAPER
219  pS1->SetLineWidth(2);
220  pS1->SetTextColor(1);
221  pS1->Draw();
222 
223  TPad *pad = canvas->GetPad(0);;
224  pad->cd();
225  TFile *froot = new TFile("chirp_set_low_high_rho_paper.root", "RECREATE");
226  pad->Write("pad");
227  froot->Close();
228 
229  // draw the legend
230 
231  TLegend* leg;
232  //leg = new TLegend(0.65,0.24,0.87,0.40,NULL,"brNDC");
233  //leg = new TLegend(0.55,0.14,0.87,0.50,NULL,"brNDC");
234 // leg = new TLegend(0.55,0.14,0.87,0.40,NULL,"brNDC");
235 // leg = new TLegend(0.404,0.495,0.704,0.855,NULL,"brNDC"); // 3 sets
236 // leg = new TLegend(0.5791457,0.6751055,0.879397,0.8586498,NULL,"brNDC");
237  leg = new TLegend(0.3278894,0.6603376,0.6281407,0.8438819,NULL,"brNDC");
238 
239 
240  leg->SetBorderSize(1);
241  leg->SetTextAlign(22);
242  leg->SetTextFont(12);
243  leg->SetLineColor(1);
244  leg->SetLineStyle(1);
245  leg->SetLineWidth(1);
246  leg->SetFillColor(0);
247  leg->SetFillStyle(1001);
248  leg->SetTextSize(0.03);
249  leg->SetLineColor(kBlack);
250  leg->SetFillColor(kWhite);
251 
252 cout << nGR << endl;
253  for(int n=0;n<nGR;n++) {
254  if(n==3) continue;
255  if(n==4) continue;
256  if(n==5) continue;
257  char legLabel[256];
258 #if ( MODE == "inclusive")
259  if(n==0) strcpy(legLabel,"inclusive UnModeled");
260  if(n==1) strcpy(legLabel,"inclusive Constrained");
261 #endif
262 #if ( MODE == "exclusive")
263  if(n==0) strcpy(legLabel,"exclusive UnModeled");
264  if(n==1) strcpy(legLabel,"exclusive Constrained");
265 #endif
266  if(n==2) strcpy(legLabel,"Chirp");
267  if(n==6) strcpy(legLabel,"GW150914");
268  //sprintf(legLabel,"%s",FAR_name[n].Data());
269  leg->AddEntry(gr[n],legLabel,"lp");
270  }
271  leg->Draw();
272 
273  // save plot
274 #if ( MODE == "inclusive")
275  far_plot_name = "CompareFAR_Ext_UnModeled_Constrained_Chirp_run1ato10a_inclusive";
276 #endif
277 #if ( MODE == "exclusive")
278  far_plot_name = "CompareFAR_Ext_eUnModeled_eConstrained_Chirp_run1ato10a_exclusive";
279 #endif
280  if(far_plot_name!="") {
281  char gfileName[1024];
282  sprintf(gfileName,"%s.gif",far_plot_name.Data());
283  canvas->Print(gfileName);
284  TString pfileName=gfileName;
285  pfileName.ReplaceAll(".gif",".png");
286  char cmd[1024];
287  sprintf(cmd,"convert %s %s",gfileName,pfileName.Data());
288  cout << cmd << endl;
289  gSystem->Exec(cmd);
290  sprintf(cmd,"rm %s",gfileName);
291  cout << cmd << endl;
292  gSystem->Exec(cmd);
293 // gSystem->Exit(0);
294  }
295 
296  return;
297 }
298 
300 
301  double rho;
302  double erho;
303  double far;
304  double efar;
305 
306  double year = (24.*3600.*365.);
307 
308  RHO.resize(1000000);
309  eRHO.resize(1000000);
310  FAR.resize(1000000);
311  eFAR.resize(1000000);
312 
313  ifstream in;
314  in.open(fname.Data(),ios::in);
315  if (!in.good()) {cout << "Error Opening File : " << fname.Data() << endl;exit(1);}
316 
317  int n=0;
318  while (1) {
319  //in >> rho >> far >> erho >> efar;
320  in >> rho >> far;
321  if (!in.good()) break;
322 rho*=sqrt(2.);
323 if(rho>22.) continue;
324 far*=year;
325  RHO[n] = rho;
326  eRHO[n] = erho;
327  FAR[n] = far;
328 // eFAR[n] = efar;
329  eFAR[n] = 0;
330 
331  n++;
332  }
333  in.close();
334 
335  RHO.resize(n);
336  eRHO.resize(n);
337  FAR.resize(n);
338  eFAR.resize(n);
339 
340  return n;
341 }
342 
int readParameters(TString fname, wavearray< double > &RHO, wavearray< double > &eRHO, wavearray< double > &FAR, wavearray< double > &eFAR)
double rho
vector< double > FAR
Definition: cwb_mkfad.C:59
char cmd[1024]
vector< double > eRHO
Definition: cwb_mkfad.C:56
int n
Definition: cwb_net.C:10
double rho_min
TString("c")
TLegend * leg
Definition: compare_bkg.C:246
vector< double > RHO
Definition: cwb_mkfad.C:55
return wmap canvas
Color_t colors[16]
vector< double > eFAR
Definition: cwb_mkfad.C:60
i drho i
void PlotFAR(int nfar, TString far_plot_name, double rho_min=-1, double rho_max=-1)
TGraph * gr
double rho_max
char fname[1024]
TFile * froot
cout<<"Number of Entries: "<< num<< endl;double *slag1=new double[slag_entries];slag1=wave.GetV1();double *slag2=new double[slag_entries];slag2=wave.GetV2();char mytitle[256];double SlagMax=wave.GetMaximum("slag")+segLen/2.;double SlagMin=wave.GetMinimum("slag")-segLen/2.;int NSlag=TMath::FloorNint((SlagMax-SlagMin)/segLen);cout<< "SLAG MAX : "<< wave.GetMaximum("slag")<< " s SLAG MIN : "<< wave.GetMinimum("slag")<< " s #SLAGS : "<< NSlag-1<< endl;if(NSlag==1){cout<<"Just one slag....Skipping further execution!"<< endl;exit(0);}sprintf(mytitle,"FAR distribution over slags (post cat3 & rho>%f)", T_cut);TH2F *Slag=new TH2F("SLAG", mytitle, NSlag, SlagMin/86400., SlagMax/86400., NSlag, SlagMin/86400., SlagMax/86400.);Slag-> GetXaxis() -> SetTitle("slag[1] shift [day]")
Definition: slag.C:91
ifstream in
strcpy(RunLabel, RUN_LABEL)
sprintf(tfres,"(1/%g)x(%g) (sec)x(Hz)", 2 *df, df)
DataType_t * data
Definition: wavearray.hh:301
virtual void resize(unsigned int)
Definition: wavearray.cc:445
TMultiGraph * mg
exit(0)