Logo Coherent WaveBurst  
Reference Guide
Logo
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Draw_FARvsRHO_ER8b_12Sep20Oct_C0101_BKG_LF_rMRA_run1ato10a_LTDQ.C
Go to the documentation of this file.
1 
2 #define nFAR_MAX 32
3 
4 int nFAR;
14 
17 void PlotFAR(int nfar, TString far_plot_name, double rho_min=-1, double rho_max=-1);
18 
19 TString PLOT_PATH = "/home/vedovato/O1/ER8b_12Sep20Oct_C0101/ER8b_12Sep20Oct_C0101_BKG_LF_rMRA_run0a/report/dump/";
20 
21 TString FARvsLowRHO_PATH = "/home/vedovato/O1/ER8b_12Sep20Oct_C0101/ER8b_12Sep20Oct_C0101_BKG_LF_rMRA_run0a/report/dump/";
22 TString FARvsRHO_PATH = "/home/vedovato/O1/ER8b_12Sep20Oct_C0101/ER8b_12Sep20Oct_C0101_BKG_LF_rMRA_run1ato10a/report/dump/";
23 
24 void
26 
27 
28  Style_t markers[32]= {20,21,22,23,29,29,21,22,20,21,22,23,29,20,21,22,
29  21,22,23,29,29,21,22,20,21,22,23,29,20,21,22,20 };
30 
31  Color_t colors[32] = { 8, 0, 2, 8,43, 7, 8, 4, 4, 2,43, 1, 3, 1, 6, 7,
32  6, 3, 2, 8,43, 7, 8, 4, 4, 2,43, 1, 3, 1, 6, 7 };
33 
34  for(int i=0;i<nFAR_MAX;i++) {
35  LINE_COLOR[i] = colors[i];
36  LINE_STYLE[i] = 1;
37  LINE_MARKER[i] = markers[i];
38  ZERO_LAG_TIME[i] = -1;
39  OBS_TIME[i] = 1;
40  }
41 
42  FAR_TITLE="";
43  FAR_PLOT_NAME="";
44 
45 // ===========================================================================
46 // C01+C01+LTDQ
47 // ===========================================================================
48 
49  #define MODE "inclusive"
50  nFAR = 6;
51  FAR_PATH[0]=FARvsRHO_PATH+"FARvsRHO_ER8b_12Sep20Oct_C0101_BKG_LF_rMRA_run1ato10a_unmodeled_LTDQ.txt";
52  FAR_PATH[1]=FARvsRHO_PATH+"FARvsRHO_ER8b_12Sep20Oct_C0101_BKG_LF_rMRA_run1ato10a_constrained_LTDQ.txt";
53  FAR_PATH[2]=FARvsRHO_PATH+"FARvsRHO_ER8b_12Sep20Oct_C0101_BKG_LF_rMRA_run1ato10a_chirp_LTDQ.txt";
54  FAR_PATH[3]=FARvsLowRHO_PATH+"FARvsLowRHO_ER8b_12Sep20Oct_C0101_BKG_LF_rMRA_run1ato10a_unmodeled_LTDQ.txt";
55  FAR_PATH[4]=FARvsLowRHO_PATH+"FARvsLowRHO_ER8b_12Sep20Oct_C0101_BKG_LF_rMRA_run1ato10a_constrained_LTDQ.txt";
56  FAR_PATH[5]=FARvsLowRHO_PATH+"FARvsLowRHO_ER8b_12Sep20Oct_C0101_BKG_LF_rMRA_run1ato10a_chirp_LTDQ.txt";
57 
58 /*
59  #define MODE "exclusive"
60  nFAR = 6;
61  FAR_PATH[0]=FARvsRHO_PATH+"FARvsRHO_ER8b_12Sep20Oct_C0101_BKG_LF_rMRA_run1ato10a_eunmodeled_LTDQ.txt";
62  FAR_PATH[1]=FARvsRHO_PATH+"FARvsRHO_ER8b_12Sep20Oct_C0101_BKG_LF_rMRA_run1ato10a_econstrained_LTDQ.txt";
63  FAR_PATH[2]=FARvsRHO_PATH+"FARvsRHO_ER8b_12Sep20Oct_C0101_BKG_LF_rMRA_run1ato10a_chirp_LTDQ.txt";
64  FAR_PATH[3]=FARvsLowRHO_PATH+"FARvsLowRHO_ER8b_12Sep20Oct_C0101_BKG_LF_rMRA_run1ato10a_eunmodeled_LTDQ.txt";
65  FAR_PATH[4]=FARvsLowRHO_PATH+"FARvsLowRHO_ER8b_12Sep20Oct_C0101_BKG_LF_rMRA_run1ato10a_econstrained_LTDQ.txt";
66  FAR_PATH[5]=FARvsLowRHO_PATH+"FARvsLowRHO_ER8b_12Sep20Oct_C0101_BKG_LF_rMRA_run1ato10a_chirp_LTDQ.txt";
67 */
68 
69  PlotFAR(nFAR, FAR_PLOT_NAME, -1, -1);
70 
71 }
72 
73 void PlotFAR(int nfar, TString far_plot_name, double rho_min, double rho_max) {
74 
75  // create plots
76  gStyle->SetFrameBorderMode(0); // remove the red box around canvas
77  gROOT->ForceStyle();
78 
79  gStyle->SetTitleFont(72);
80  gStyle->SetMarkerColor(50);
81  gStyle->SetLineColor(kWhite);
82  gStyle->SetTitleW(0.98);
83  gStyle->SetTitleH(0.05);
84  gStyle->SetTitleY(0.98);
85  gStyle->SetFillColor(kWhite);
86  gStyle->SetLineColor(kWhite);
87  gStyle->SetTitleFont(12,"D");
88 
89  TCanvas *canvas = new TCanvas("roc", "roc", 300,40, 800, 500);
90  canvas->Clear();
91  canvas->ToggleEventStatus();
92  canvas->SetLogy();
93  canvas->SetGridx();
94  canvas->SetGridy();
95  canvas->SetFillColor(kWhite);
96 
97  double far_min=1e10;
98  double rmin=1e20;
99  double rmax=0;
100  char fname[1024];
101  int nGR=0;
102  int line_style[3*nFAR_MAX];
103  int line_marker[3*nFAR_MAX];
104  int line_color[3*nFAR_MAX];
105  TString FAR_name[3*nFAR_MAX];
106  bool sigma_lines[3*nFAR_MAX];
107  TGraphErrors* gr[3*nFAR_MAX];
108  for(int n=0;n<nFAR;n++) {
109  cout << n << " OBS_TIME : " << OBS_TIME[n] << endl;
110  if(OBS_TIME[n]>0) if(far_min>1./OBS_TIME[n]) far_min=1./OBS_TIME[n];
111  vector<double> rho_far;
112  vector<double> far;
113  // read FAR
114  sprintf(fname,"%s",FAR_PATH[n].Data());
115  cout << "rate_threshold : " << fname << endl;
120  int far_size = readParameters(fname, RHO, eRHO, FAR, eFAR);
121 #if ( MODE == "exclusive")
122  TString ofname = fname;
123  ofname.ReplaceAll(".txt","_comp_paper.txt");
124  writeParameters(ofname, RHO, FAR);
125 #endif
126  if(rmin<RHO[0]) rmin=RHO[0];
127  if(rmax>RHO[far_size-1]) rmax=RHO[far_size-1];
128  sigma_lines[nGR] = false;
129  line_style[nGR]=LINE_STYLE[n];
130  line_marker[nGR]=LINE_MARKER[n];
131  line_color[nGR]=LINE_COLOR[n];
132  FAR_name[nGR]=FAR_NAME[n];
133  gr[nGR++] = new TGraphErrors(far_size,RHO.data,FAR.data,eRHO.data,eFAR.data);
134  gr[nGR-1]->SetMarkerStyle(20);
135  gr[nGR-1]->SetMarkerSize(0.35);
136  if(n==0) gr[nGR-1]->SetMarkerColor(8);
137  if(n==1) gr[nGR-1]->SetMarkerColor(kBlack);
138  if(n==2) gr[nGR-1]->SetMarkerColor(kRed);
139  if(n==3) gr[nGR-1]->SetMarkerColor(8);
140  if(n==4) gr[nGR-1]->SetMarkerColor(kBlack);
141  if(n==5) gr[nGR-1]->SetMarkerColor(kRed);
142  gr[nGR-1]->SetName(TString::Format("gr%d",nGR-1));
143 
144  }
145 
146  // GW150914
147  RHO.data[0]=14.1*sqrt(2); FAR.data[0]=1./(1369200.00/(365*24*3600));
148  eRHO.data[0]=0; eFAR.data[0]=0;
149  gr[nGR] = new TGraphErrors(1,RHO.data,FAR.data,eRHO.data,eFAR.data);
150  gr[nGR]->SetMarkerColor(4);
151  gr[nGR]->SetMarkerStyle(22);
152  gr[nGR]->SetMarkerSize(2);
153  FAR_name[nGR]="GW150914";
154  nGR++;
155 
156 
157  TMultiGraph* mg = new TMultiGraph();
158  char gTitle[256];
159  if(FAR_TITLE!="") sprintf(gTitle,FAR_TITLE.Data());
160  else sprintf(gTitle,"FAR Comparison");
161 // PAPER
162 #if ( MODE == "inclusive")
163  sprintf(gTitle,"ER8b/O1 (C0101) background of unmodeled/constrained/chirp data sets (Sep 12 - Oct 20)");
164 #endif
165 #if ( MODE == "exclusive")
166  sprintf(gTitle,"ER8b/O1 (C0101) background of edge/bulk/chirp data sets (Sep 12 - Oct 20)");
167 #endif
168  sprintf(gTitle,"");
169  mg->SetName("mg");
170  mg->SetTitle(gTitle);
171  for(int n=0;n<nGR;n++) mg->Add(gr[n]);
172  //mg->Paint("APL");
173  mg->Paint("AL");
174 
175  mg->GetHistogram()->GetXaxis()->SetLabelSize(0.05);
176  mg->GetHistogram()->GetYaxis()->SetLabelSize(0.05);
177  mg->GetHistogram()->GetXaxis()->SetTitleSize(0.05);
178  mg->GetHistogram()->GetYaxis()->SetTitleSize(0.05);
179  mg->GetHistogram()->GetXaxis()->SetLabelFont(42);
180  mg->GetHistogram()->GetYaxis()->SetLabelFont(42);
181  mg->GetHistogram()->GetYaxis()->SetLabelOffset(0.01);
182  mg->GetHistogram()->GetYaxis()->SetTitleOffset(1.5);
183 // mg->GetHistogram()->SetMinimum(far_min/2.);
184 
185  if(rho_min>=0) rmin=rho_min*sqrt(2);
186  if(rho_max>=0) rmax=rho_max*sqrt(2);
187  rmax=16*sqrt(2);
188  mg->GetHistogram()->GetXaxis()->SetRangeUser(rmin,rmax);
189 
190  mg->GetXaxis()->SetTitle(gr[0]->GetXaxis()->GetTitle());
191  mg->GetXaxis()->SetLabelFont(42);
192  mg->GetYaxis()->SetLabelFont(42);
193  mg->GetXaxis()->SetTitleFont(42);
194  mg->GetYaxis()->SetTitleFont(42);
195  mg->GetXaxis()->SetTitleOffset(1.20);
196  mg->GetYaxis()->SetTitleOffset(1.20);
197  mg->GetXaxis()->SetTitleSize(0.04);
198  mg->GetYaxis()->SetTitleSize(0.04);
199  mg->GetXaxis()->CenterTitle(true); //PAPER
200  mg->GetYaxis()->CenterTitle(true); //PAPER
201  mg->GetXaxis()->SetTitle("Coherent Network SNR ( #eta_{c} )");
202  //mg->GetXaxis()->SetTitle("#eta_{c}");
203  mg->GetYaxis()->SetTitle("FAR ( yr^{-1} )");
204 
205  mg->Draw("ALP");
206 
207  // draw label GW150914
208  //TLatex *pS1 = new TLatex(RHO[0], FAR[0], "GW150914"); //PAPER
209  //TLatex *pS1 = new TLatex(18.30,2.14, "GW150914"); //PAPER
210  TLatex *pS1 = new TLatex(18.93,2.61, "GW150914"); //PAPER
211  pS1->SetTextFont(52);
212  pS1->SetTextSize(0.040); //PAPER
213  pS1->SetLineWidth(2);
214  pS1->SetTextColor(1);
215 // pS1->Draw();
216 
217  TPad *pad = canvas->GetPad(0);;
218  pad->cd();
219  TFile *froot = new TFile("chirp_set_low_high_rho_paper.root", "RECREATE");
220  pad->Write("pad");
221  froot->Close();
222 
223  // draw the legend
224 
225  TLegend* leg;
226  //leg = new TLegend(0.65,0.24,0.87,0.40,NULL,"brNDC");
227  //leg = new TLegend(0.55,0.14,0.87,0.50,NULL,"brNDC");
228 // leg = new TLegend(0.55,0.14,0.87,0.40,NULL,"brNDC");
229 // leg = new TLegend(0.404,0.495,0.704,0.855,NULL,"brNDC"); // 3 sets
230 // leg = new TLegend(0.5791457,0.6751055,0.879397,0.8586498,NULL,"brNDC");
231 // leg = new TLegend(0.3278894,0.6603376,0.6281407,0.8438819,NULL,"brNDC");
232  leg = new TLegend(0.4120603,0.6265823,0.6306533,0.8607595,NULL,"brNDC");
233 
234 
235  leg->SetBorderSize(1);
236  leg->SetTextAlign(22);
237  leg->SetTextFont(12);
238  leg->SetLineColor(1);
239  leg->SetLineStyle(1);
240  leg->SetLineWidth(1);
241  leg->SetFillColor(0);
242  leg->SetFillStyle(1001);
243  leg->SetTextSize(0.03);
244  leg->SetLineColor(kBlack);
245  leg->SetFillColor(kWhite);
246 
247 cout << nGR << endl;
248  for(int n=0;n<nGR;n++) {
249  if(n==3) continue;
250  if(n==4) continue;
251  if(n==5) continue;
252  char legLabel[256];
253 #if ( MODE == "inclusive")
254  //if(n==0) strcpy(legLabel,"inclusive UnModeled");
255  //if(n==1) strcpy(legLabel,"inclusive Constrained");
256  if(n==0) strcpy(legLabel,"UnModeled");
257  if(n==1) strcpy(legLabel,"Constrained");
258 #endif
259 #if ( MODE == "exclusive")
260  //if(n==0) strcpy(legLabel,"exclusive UnModeled");
261  //if(n==1) strcpy(legLabel,"exclusive Constrained");
262  //if(n==0) strcpy(legLabel,"Edge");
263  //if(n==1) strcpy(legLabel,"Bulk");
264  if(n==0) strcpy(legLabel,"B1");
265  if(n==1) strcpy(legLabel,"B2");
266 #endif
267  if(n==2) strcpy(legLabel,"Chirp");
268  //if(n==2) strcpy(legLabel,"B3");
269  if(n==6) strcpy(legLabel,"GW150914");
270  //sprintf(legLabel,"%s",FAR_name[n].Data());
271  TLegendEntry* eleg = leg->AddEntry(gr[n],legLabel,"lp");
272  //eleg->SetMarkerSize(5);
273  //eleg->SetMarkerColor(kBlack);
274  }
275  leg->SetBorderSize(1);
276  leg->SetTextAlign(22);
277  leg->SetTextFont(12);
278  leg->SetLineColor(1);
279  leg->SetLineStyle(1);
280  leg->SetLineWidth(1);
281  leg->SetFillColor(0);
282  leg->SetFillStyle(1001);
283  leg->SetTextSize(0.04);
284  leg->SetLineColor(kBlack);
285  leg->Draw();
286 
287  // draw markers in the legend (the defaults are too small)
288 
289  TMarker *mP1 = new TMarker(13.2658,2512.81, 20);
290  mP1->SetMarkerStyle(20);
291  mP1->SetMarkerSize(1);
292  mP1->SetMarkerColor(kGreen);
293  mP1->Draw();
294 
295  TMarker *mP2 = new TMarker(13.2658,479.617, 20);
296  mP2->SetMarkerStyle(20);
297  mP2->SetMarkerSize(1);
298  mP2->SetMarkerColor(kBlack);
299  mP2->Draw();
300 
301  TMarker *mP3 = new TMarker(13.2658,91.7268, 20);
302  mP3->SetMarkerStyle(20);
303  mP3->SetMarkerSize(1);
304  mP3->SetMarkerColor(kRed);
305  mP3->Draw();
306 
307  // save plot
308 #if ( MODE == "inclusive")
309  far_plot_name = PLOT_PATH+"CompareFAR_C0101_UnModeled_Constrained_Chirp_run1ato10a_inclusive_LTDQ";
310 #endif
311 #if ( MODE == "exclusive")
312  far_plot_name = PLOT_PATH+"CompareFAR_C0101_eUnModeled_eConstrained_Chirp_run1ato10a_exclusive_LTDQ";
313 #endif
314  if(far_plot_name!="") {
315  char gfileName[1024];
316  sprintf(gfileName,"%s.gif",far_plot_name.Data());
317  canvas->Print(gfileName);
318  TString pfileName=gfileName;
319  pfileName.ReplaceAll(".gif",".png");
320  char cmd[1024];
321  sprintf(cmd,"convert %s %s",gfileName,pfileName.Data());
322  cout << cmd << endl;
323  gSystem->Exec(cmd);
324  sprintf(cmd,"rm %s",gfileName);
325  cout << cmd << endl;
326  gSystem->Exec(cmd);
327 // gSystem->Exit(0);
328  }
329 
330  return;
331 }
332 
334 
335  double rho;
336  double erho;
337  double far;
338  double efar;
339 
340  double year = (24.*3600.*365.);
341 
342  RHO.resize(1000000);
343  eRHO.resize(1000000);
344  FAR.resize(1000000);
345  eFAR.resize(1000000);
346 
347  ifstream in;
348  in.open(fname.Data(),ios::in);
349  if (!in.good()) {cout << "Error Opening File : " << fname.Data() << endl;exit(1);}
350 
351  int n=0;
352  while (1) {
353  //in >> rho >> far >> erho >> efar;
354  in >> rho >> far;
355  if (!in.good()) break;
356 rho*=sqrt(2.);
357 if(rho>22.) continue;
358 far*=year;
359  RHO[n] = rho;
360  eRHO[n] = erho;
361  FAR[n] = far;
362 // eFAR[n] = efar;
363  eFAR[n] = 0;
364 
365  n++;
366  }
367  in.close();
368 
369  RHO.resize(n);
370  eRHO.resize(n);
371  FAR.resize(n);
372  eFAR.resize(n);
373 
374  return n;
375 }
376 
378 
379  ofstream out;
380  out.open(fname.Data(),ios::out);
381  if (!out.good()) {cout << "Error Opening File : " << fname.Data() << endl;exit(1);}
382 
383  for(int i=0;i<RHO.size();i++) {
384  out << RHO[i] << "\t" << FAR[i] << endl;
385  }
386 
387  out.close();
388 }
389 
390 
double rho
virtual size_t size() const
Definition: wavearray.hh:127
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
ofstream out
Definition: cwb_merge.C:196
int readParameters(TString fname, wavearray< double > &RHO, wavearray< double > &eRHO, wavearray< double > &FAR, wavearray< double > &eFAR)
TGraph * gr
double rho_max
int writeParameters(TString fname, wavearray< double > &RHO, wavearray< double > &FAR)
char fname[1024]
TFile * froot
void PlotFAR(int nfar, TString far_plot_name, double rho_min=-1, double rho_max=-1)
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)