Logo Coherent WaveBurst  
Reference Guide
Logo
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
lag.C
Go to the documentation of this file.
1 {
2 
3  cout<<"Lag starts..."<<endl;
4 
5  if(nIFO!=3) {cout << "lag.C : Skipping plot production - wave tree should come from a 3-fold network : " << net_file_name << endl;exit(0);}
6 
8 
9  TB.checkFile(gSystem->Getenv("CWB_ROOTLOGON_FILE"));
10  TB.checkFile(gSystem->Getenv("CWB_PARAMETERS_FILE"));
11  TB.checkFile(gSystem->Getenv("CWB_UPARAMETERS_FILE"));
12  TB.checkFile(gSystem->Getenv("CWB_PPARAMETERS_FILE"));
13  TB.checkFile(gSystem->Getenv("CWB_UPPARAMETERS_FILE"));
14  TB.checkFile(gSystem->Getenv("CWB_EPPARAMETERS_FILE"));
15 
16  gStyle->SetTitleFillColor(kWhite);
17  gStyle->SetLineColor(kWhite);
18  gStyle->SetNumberContours(256);
19  gStyle->SetCanvasColor(kWhite);
20  gStyle->SetStatBorderSize(1);
21  gStyle->SetOptStat(kFALSE);
22 
23  // remove the red box around canvas
24  gStyle->SetFrameBorderMode(0);
25  gROOT->ForceStyle();
26 
27 
28  // ----------------------------------------------------------
29  // canvas
30  // ----------------------------------------------------------
31  TCanvas *c1 = new TCanvas("lag", "lag",32,55,750,502);
32  c1->Range(-0.75,-1.23433,6.75,8.17182);
33  c1->SetBorderSize(1);
34  c1->SetFillColor(0);
35  c1->SetGridx();
36  c1->SetGridy();
37  c1->SetFrameFillColor(0);
38  gStyle->SetPalette(1,0);
39 
40  TChain wave("waveburst");
41  TChain live("liveTime");
42 
43  wave.Add(net_file_name);
44  live.Add(liv_file_name);
45 
46 
47  char fname[1024];
48 char cut[512];
49 char cut2[256];
50 sprintf(cut,"rho[1]>%f",T_cut);
51 
52 //test if vetoes are applied
54 if(!test_veto.IsNull())sprintf(cut,"%s && %s",cut,veto_not_vetoed);
55 sprintf(cut2,"!(lag[%d]==0&&slag[%d]==0)",nIFO,nIFO);
56 
57  int num = (int)wave.GetEntries(cut);
58  wave.SetEstimate(num);
59  wave.Draw("lag[0]-lag[1]:lag[1]-lag[2]",cut,"goff");
60  cout<<"Number of Entries: "<<num<<endl;
61  double* lag01 = wave.GetV1();
62  double* lag12 = wave.GetV2();
63 
64 
65  int num2 = (int)live.GetEntries(cut2);
66  live.SetEstimate(num2);
67  live.Draw("lag[0]-lag[1]:lag[1]-lag[2]:live",cut2,"goff");
68  double* llag01 = live.GetV1();
69  double* llag12 = live.GetV2();
70  double* Live = live.GetV3();
71 
72  char title[256];
73  double xplotlagMax = TMath::MaxElement(num,lag01);
74  double xplotlagMin = TMath::MinElement(num,lag01);
75 double yplotlagMax = TMath::MaxElement(num,lag12);
76  double yplotlagMin = TMath::MinElement(num,lag12);
77 
78  cout<<xplotlagMin<<" < lag[o]-lag[1] < "<<xplotlagMax<<endl;
79  cout<<yplotlagMin<<" < lag[1]-lag[2] < "<<yplotlagMax<<endl;
80 // int Nlag = TMath::FloorNint((plotlagMax-plotlagMin)/segLen);
81 
82 //double plotlagMax = 300;
83 //double plotlagMin = -300;
84 int Nlag = 100;
85 
86 sprintf(title,"FAR distribution over lags (post cat3 & rho>%f)",T_cut);
87  TH2F* lag = new TH2F("SLAG",title,Nlag,xplotlagMin,xplotlagMax,Nlag,yplotlagMin,yplotlagMax);
88  lag->GetXaxis()->SetTitle("lag[0]-lag[1] shift [s]");
89  lag->GetXaxis()->SetNdivisions(10,kFALSE);
90  lag->GetYaxis()->SetTitle("lag[1]-lag[2] shift [s]");
91  lag->GetYaxis()->SetNdivisions(10,kFALSE);
92  lag->SetStats(kFALSE);
93  TH2F* llag = new TH2F("LSLAG","FAR distribution over lags",Nlag,xplotlagMin,xplotlagMax,Nlag,yplotlagMin,yplotlagMax);
94  for(int i =0 ;i<num;i++){
95  lag->Fill(lag01[i],lag12[i]);
96 
97  }
98  for(int i =0 ;i<num2;i++){
99  llag->Fill(llag01[i],llag12[i],Live[i]);
100 
101  }
102 
103  lag->Divide(llag);
104  c1->Clear();
105  lag->Draw("colz");
106  sprintf(fname,"%s/lag.png",netdir);
107  c1->Update(); c1->SaveAs(fname);
108 
109  TAxis *xaxis = lag->GetXaxis();
110  TAxis *yaxis = lag->GetYaxis();
111  int count = 0;
112  double FAR[100000];
113  double eFAR[100000];
114  double D[100000];
115  for(int i =1 ;i<Nlag+1;i++){
116  for(int j =1 ;j<Nlag+1;j++){
117  if(lag->GetBinContent(i,j)>=1.E-15){
118  FAR[count] = lag->GetBinContent(i,j);
119  D[count] = TMath::Sqrt(pow(xaxis->GetBinCenter(i),2)+pow(yaxis->GetBinCenter(j),2));
120  eFAR[count] = lag->GetBinError(i,j)/llag->GetBinError(i,j);
121  count++;
122  cout << "i :"<<i<<" j :"<<j<<" FAR :"<<FAR[count-1] << "+/-" <<eFAR[count-1] << " " <<endl;
123  }
124 
125  }
126  }
127 
128 
129  cout << "Number of lags : " << count << endl;
130  double liveTot = llag->GetSumOfWeights();
131  double liveMax = llag->GetMaximum();
132  cout << "Total BKG live time : " << liveTot << endl;
133  double FAR2[count];
134  double eFAR2[count];
135  double N[count];
136  double eN[count];
137  for(int i =0 ;i<count;i++){N[i]=D[i];}
138  Int_t *index = new Int_t[count];
139  TMath::Sort(count,N,index,false);
140  for(int i =0 ;i<count;i++){FAR2[i]=FAR[index[i]];eFAR2[i]=eFAR[index[i]];N[i]=D[index[i]];eN[i]=0.0;}
141  TGraphErrors* FarPlot= new TGraphErrors(count, N, FAR2, eN, eFAR2);
142  FarPlot->SetLineColor(kBlue);
143  FarPlot->SetMarkerColor(kBlue);
144  //FarPlot->GetHistogram()->GetYaxis()->SetRangeUser(1.e-9,1.e-7);
145  FarPlot->SetTitle("FAR vs lag distance");
146  FarPlot->SetMarkerStyle(20);
147  FarPlot->SetMarkerSize(1);
148  //FarPlot->SetMinimum(0.5/liveMax);
149  FarPlot->GetHistogram()->SetXTitle("#lag distance [s]");
150  FarPlot->GetHistogram()->SetYTitle("rate, Hz");
151  c1->Clear();
152  //c1->SetLogy(kTRUE);
153  FarPlot->Draw("AP");
154  sprintf(fname,"%s/FAR_vs_lag.png",netdir);
155  c1->Update(); c1->SaveAs(fname);
156 
157  exit(0);
158 
159 }
TCanvas * c1
Definition: lag.C:31
char cut[512]
Definition: lag.C:48
double Live
TString("c")
double D[100000]
Definition: lag.C:114
char fname[1024]
Definition: lag.C:47
int j
Definition: cwb_net.C:10
i drho i
s veto_not_vetoed
Definition: lag.C:54
static bool checkFile(TString fName, bool question=false, TString message="")
Definition: Toolbox.cc:3956
#define N
TString test_veto
Definition: lag.C:53
TChain live("liveTime")
exit(0)
#define nIFO
double eFAR[100000]
Definition: lag.C:113
i() int(T_cor *100))
TH2F * llag
Definition: lag.C:93
char netdir[1024]
int num
Definition: lag.C:57
CWB::Toolbox TB
Definition: lag.C:7
double liveTot
sprintf(cut,"rho[1]>%f", T_cut)
char net_file_name[256]
char liv_file_name[256]
TChain wave("waveburst")
char cut2[256]
Definition: lag.C:49
char title[256]
Definition: SSeriesExample.C:1
wavearray< int > index
TAxis * xaxis
Definition: lag.C:109
double liveMax
Definition: lag.C:131
double T_cut
double FAR[100000]
Definition: lag.C:112
TAxis * yaxis
Definition: lag.C:110
int count
Definition: lag.C:111