Logo Coherent WaveBurst  
Reference Guide
Logo
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
DrawCosOmegaPRC.C
Go to the documentation of this file.
1 //
2 // Draw PRC Cos Omega distribution
3 // Note : this macro is used to generate the PRC report (cwb_report merge_label prc)
4 // Author : Gabriele Vedovato
5 
6 #include "TROOT.h"
7 #include "TSystem.h"
8 #include "TFile.h"
9 #include "TTree.h"
10 #include <fstream>
11 #include <iostream>
12 #include "TGraph.h"
13 #include "TMultiGraph.h"
14 #include "TCanvas.h"
15 #include "TH1F.h"
16 #include "TMath.h"
17 #include "TH1F.h"
18 #include "TH2F.h"
19 #include <TComplex.h>
20 #include <TStyle.h>
21 #include <TRandom.h>
22 #include "TVector3.h"
23 #include "TRotation.h"
24 #include "Math/Vector3Dfwd.h"
25 #include "Math/Rotation3D.h"
26 
27 TH1F* co_hist;
28 TCanvas* co_canvas;
29 
30 void
32  int pp_inetcc, float T_cor, int pp_irho, float T_cut, float T_vED, float T_pen, float T_ifar) {
33 
34  if (!gROOT->GetClass("Polar3DVector")) gSystem->Load("libMathCore");
35 
36  using namespace ROOT::Math;
37 
38  char wave_file_name[1024];
39  sprintf(wave_file_name,"merge/wave_%s.%s.root",data_label.Data(),merge_label.Data());
40 
41  TFile* ifile = TFile::Open(wave_file_name);
42  TTree* itree = (TTree *) gROOT->FindObject("waveburst");
43 
44  char cut[1024];
45  char tmp[1024];
46  sprintf(cut,"abs(time[0]-time[%d])<%f && netcc[%d]>%f && rho[%d]>%f",
47  nIFO,T_win,pp_inetcc,T_cor,pp_irho,T_cut);
48  if(T_vED>0) {strcpy(tmp,cut);sprintf(cut,"%s && neted[0]/ecor<%f",tmp,T_vED);}
49  if(T_pen>0) {strcpy(tmp,cut);sprintf(cut,"%s && penalty>%f",tmp,T_pen);}
50  if(T_ifar>0) {strcpy(tmp,cut);sprintf(cut,"%s && ifar>(24.*3600.*365.)*%f",tmp,T_ifar);}
51 
52  itree->Draw("theta[0]:phi[0]:theta[1]:phi[1]",cut,"goff");
53  int size = itree->GetSelectedRows();
54  cout << "detected events : " << size << endl;
55 
56  double* th0 = itree->GetV1();
57  double* ph0 = itree->GetV2();
58  double* th1 = itree->GetV3();
59  double* ph1 = itree->GetV4();
60 
61  co_hist = new TH1F("co_hist","co_hist",24,-1,1);
62  //co_hist = new TH1F("co_hist","co_hist",100,0,180);
63 
64  double deg2rad = TMath::Pi()/180.;
65 
66  for(int i=0;i<size;i++) {
67 
68  //cout << i << " " << th0[i] << " " << ph0[i] << endl;
69  //cout << i << " " << th1[i] << " " << ph1[i] << endl;
70 
71  Polar3DVector v0(1, th0[i]*deg2rad, ph0[i]*deg2rad);
72  Polar3DVector v1(1, th1[i]*deg2rad, ph1[i]*deg2rad);
73 
74  double Dot = v0.Dot(v1);
75  double dOmega = 180.*TMath::ACos(Dot)/TMath::Pi();
76 
77 /*
78  double inj_phi = ph1[i]*deg2rad;
79  double est_phi = ph0[i]*deg2rad;
80  double inj_theta = th1[i]*deg2rad;
81  double est_theta = th0[i]*deg2rad;
82  cos_delta_theta = cos(inj_theta)*cos(est_theta) + sin(inj_theta)*sin(est_theta)*cos(inj_phi-est_phi);
83  //co_hist->Fill(cos_delta_theta);
84 */
85 
86  //cout << i << "Dot : " << Dot << " dOmega : " << dOmega << endl;
87  co_hist->Fill(Dot);
88  //co_hist->Fill(dOmega);
89  }
90 
91  // Normalization
92  double integral = 0;
93  for (int i=0;i<=co_hist->GetNbinsX();i++) integral+=co_hist->GetBinContent(i);
94  for (int i=0;i<=co_hist->GetNbinsX();i++) co_hist->SetBinContent(i,co_hist->GetBinContent(i)/integral);
95 
96  char title[256];
97  sprintf(title,"angle offset : #events = %d",size);
98  co_hist->SetTitle(title);
99  co_hist->GetXaxis()->SetTitle("cos(angle offset)");
100  co_hist->GetYaxis()->SetTitle("probability density");
101  co_hist->GetXaxis()->SetRangeUser(-1,1);
102  co_hist->GetYaxis()->SetRangeUser(0.001,1);
103 // co_hist->GetYaxis()->SetRangeUser(1e-3,1);
104  co_hist->GetXaxis()->SetTitleOffset(1.35);
105  co_hist->GetYaxis()->SetTitleOffset(1.35);
106  co_hist->GetXaxis()->CenterTitle(true);
107  co_hist->GetYaxis()->CenterTitle(true);
108  co_hist->GetXaxis()->SetLabelFont(42);
109  co_hist->GetXaxis()->SetTitleFont(42);
110  co_hist->GetYaxis()->SetLabelFont(42);
111  co_hist->GetYaxis()->SetTitleFont(42);
112  co_hist->SetLineColor(kRed);
113  co_hist->SetFillColor(kRed);
114 
115  co_hist->SetStats(kFALSE);
116  co_canvas = new TCanvas("fom", "PRC", 300,40, 600, 500);
117  co_canvas->SetGridx();
118  co_canvas->SetGridy();
119  co_canvas->SetLogy();
120  co_hist->Draw();
121 
122  char ofname[1024];
123  sprintf(ofname,"%s/cos_theta.gif",odir.Data());
124  co_canvas->Print(ofname);
125  char cmd[1024];
126  TString pfname(ofname);
127  pfname.ReplaceAll(".gif",".png");
128  sprintf(cmd,"convert %s %s",ofname,pfname.Data());
129  cout << cmd << endl;
130  gSystem->Exec(cmd);
131  sprintf(cmd,"rm %s",ofname);
132  cout << cmd << endl;
133  gSystem->Exec(cmd);
134  //exit(0);
135 
136 }
137 
char cut[512]
double T_ifar
void DrawCosOmegaPRC(TString data_label, TString odir, TString merge_label, int nIFO, float T_win, int pp_inetcc, float T_cor, int pp_irho, float T_cut, float T_vED, float T_pen, float T_ifar)
double T_pen
char cmd[1024]
TString("c")
double T_cor
char odir[1024]
i pp_inetcc
Long_t size
i drho i
#define nIFO
char data_label[512]
Definition: test_config1.C:160
double deg2rad
double Pi
double * tmp
Definition: testWDM_5.C:31
TString merge_label
TFile * ifile
char title[256]
Definition: SSeriesExample.C:1
TH1F * co_hist
double T_win
strcpy(RunLabel, RUN_LABEL)
sprintf(tfres,"(1/%g)x(%g) (sec)x(Hz)", 2 *df, df)
double T_cut
TTree * itree
double T_vED
i drho pp_irho
TCanvas * co_canvas