7 #define REBIN_MIN_EVTS_PER_BIN 10.0
9 cout<<
"Checking ENV "<<endl;
10 TB.
checkFile(gSystem->Getenv(
"CWB_ROOTLOGON_FILE"));
11 TB.
checkFile(gSystem->Getenv(
"CWB_PARAMETERS_FILE"));
12 TB.
checkFile(gSystem->Getenv(
"CWB_UPARAMETERS_FILE"));
13 TB.
checkFile(gSystem->Getenv(
"CWB_PPARAMETERS_FILE"));
14 TB.
checkFile(gSystem->Getenv(
"CWB_UPPARAMETERS_FILE"));
15 TB.
checkFile(gSystem->Getenv(
"CWB_EPPARAMETERS_FILE"));
21 TCanvas *c0 =
new TCanvas(
"c0",
"c0",0,0,800,600);
28 c0->SetRightMargin(0.1154618);
29 c0->SetTopMargin(0.07642487);
30 c0->SetBottomMargin(0.1450777);
32 cout <<
"Setting up the canvas and the pads..."<<endl;
33 TCanvas *canvas1 =
new TCanvas(
"canvas1",
"C1",0,0,1200,800);
36 canvas1->GetPad(1)->SetGridx();
37 canvas1->GetPad(1)->SetGridy();
38 canvas1->GetPad(1)->SetLogy(kTRUE);
39 canvas1->GetPad(1)->SetLogx(kTRUE);
40 canvas1->GetPad(2)->SetLogx(kTRUE);
41 canvas1->GetPad(2)->SetLogy(kTRUE);
42 canvas1->GetPad(2)->SetGridx();
43 canvas1->GetPad(2)->SetGridy();
44 canvas1->GetPad(3)->SetGridx();
45 canvas1->GetPad(3)->SetGridy();
46 canvas1->GetPad(3)->SetLogx(kTRUE);
47 canvas1->GetPad(4)->SetGridx();
48 canvas1->GetPad(4)->SetGridy();
49 canvas1->GetPad(4)->SetLogx(kTRUE);
50 canvas1->GetPad(5)->SetLogy(kTRUE);
51 canvas1->GetPad(5)->SetGridx();
52 canvas1->GetPad(5)->SetGridy();
53 canvas1->GetPad(6)->SetLogy(kTRUE);
54 canvas1->GetPad(6)->SetGridx();
55 canvas1->GetPad(6)->SetGridy();
57 TCanvas *
canvas2 =
new TCanvas(
"canvas2",
"C2",0,0,800,600);
64 TCanvas *
canvas3 =
new TCanvas(
"canvas3",
"C3",0,0,800,600);
75 gStyle->SetTitleFillColor(kWhite);
77 gStyle->SetNumberContours(256);
78 gStyle->SetCanvasColor(kWhite);
79 gStyle->SetStatBorderSize(1);
83 gStyle->SetFrameBorderMode(0);
90 TChain
wave(
"waveburst");
91 TChain
live(
"liveTime");
100 if(gSystem->Getenv(
"CWB_COMPARE_TREE")==NULL) {
101 cout <<
"Error : environment CWB_COMPARE_TREE is not defined!!!" << endl;
exit(1);
103 Compare_tree=
TString(gSystem->Getenv(
"CWB_COMPARE_TREE"));
108 TString comp_tag =((TObjString *)(token->At(token->GetEntries()-1)))->String();
109 comp_tag.ReplaceAll(
"wave_",
"");
110 comp_tag.ReplaceAll(
".root",
"");
118 Compare_live.ReplaceAll(
"wave_",
"live_");
119 sprintf(cnet_file_name,
"%s",Compare_tree.Data());
120 sprintf(cnet_file_name,
"%s",Compare_tree.Data());
121 sprintf(cliv_file_name,
"%s",Compare_live.Data());
122 cout << cnet_file_name << endl;
123 cout << cliv_file_name << endl;
128 TChain cnet(
"waveburst");
129 TChain cliv(
"liveTime");
130 cnet.Add(cnet_file_name);
131 cliv.Add(cliv_file_name);
134 Int_t bkg_size = (Int_t)
wave.GetEntries();
135 cout <<
"bkg_size current dir : " << bkg_size << endl;
136 Int_t bkg_size2 = (Int_t)cnet.GetEntries();
137 cout <<
"bkg_size compare dir : " << bkg_size2 << endl;
145 double cliveTot = 0.;
164 cout <<
"Start CWB::CBCTool::getLiveTime2 of current ntuple : " << endl;
166 cout <<
"Start CWB::CBCTool::getLiveTime2 of current ntuple : " << endl;
169 double K = liveTot/cliveTot;
170 cout <<
"K (ratio of live times) : "<< K <<endl;
179 TH1D* Sh2 =
new TH1D(
"Sh2",
"Distribution of significance",200,-10.,10.);
185 cout<<
"Rho min: "<<
T_cut<<endl;
186 mycut +=
"&& rho["+mycut.Itoa(
pp_irho,10)+
"]>";
198 cout<<
"Comparison bkg events above threshold: "<< entriesx <<endl;
199 double* rhox = cnet.GetV1();
201 comph = (TH1D*)gDirectory->Get(
"hcomp");
206 cout<<
"Current bkg events above threshold: "<< entriesy <<endl;
208 double* rhoy =
wave.GetV1();
209 double RHOMAX=TMath::Max(TMath::MaxElement(entriesy,rhoy),TMath::MaxElement(entriesx,rhox));
210 cout<<
"Rho max: "<<RHOMAX<<endl;
213 curh = (TH1D*)gDirectory->Get(
"hcur");
220 cout<<
"Un-binned KS test"<<endl;
222 cout<<
"Binned KS test (no rescaling)"<<endl;
223 curh->KolmogorovTest(comph,
"D");
224 curh->AndersonDarlingTest(comph,
"D");
227 curh->GetXaxis()->SetTitle(
"#rho");
228 curh->GetXaxis()->CenterTitle(
true);
229 curh->GetYaxis()->SetTitle(
"#events");
230 curh->GetYaxis()->CenterTitle(
true);
231 curh->SetFillColor(kBlue);
232 curh->SetTitle(
"Distribution of rho");
234 TH1D*
comphr=(TH1D*)comph->Clone(
"comphr");
236 double maxy = TMath::Max(comphr->GetMaximum(),curh->GetMaximum());
237 curh->GetYaxis()->SetRangeUser(0.1,1.2*maxy);
238 curh->GetXaxis()->SetRangeUser(
T_cut,1.2*RHOMAX);
241 comphr->SetLineColor(kRed);
242 comphr->SetFillColor(kRed);
243 comphr->SetFillStyle(3001);
246 TLegend*
leg =
new TLegend(0.65,0.7,0.99,0.96);
249 leg->SetTextSize(0.03);
251 sprintf(entry,
"Rescaling factor K = %f", K);
252 leg->SetHeader(entry);
254 leg->AddEntry(curh,entry,
"f");
255 sprintf(entry,
"Rescaled Comparison BKG");
256 leg->AddEntry(comphr,entry,
"f");
265 comphr->Draw(
"same");
273 cout <<
"Plotting pad 1"<<endl;
276 comphr->Draw(
"same");
282 Double_t*
xq =
new Double_t[
nq];
283 Double_t*
yq =
new Double_t[
nq];
284 Double_t*
yq2 =
new Double_t[nq+1];
285 for (Int_t
i=0;
i<
nq;
i++) xq[
i] = Float_t(
i+1)/
nq;
286 curh->GetQuantiles(nq,yq,xq);
288 for(
int i=1;
i<nq+1;
i++){yq2[
i]=yq[
i-1];}
291 TH1D *
hnew2 =
new TH1D(
"hnew",
"rebinned",nq,yq2);
292 TH1D *
hnew3 =
new TH1D(
"hnew3",
"rebinned",nq,yq2);
293 TH1D*
Sh3 =
new TH1D(
"Sh3",
"Significance vs rho bin",nq,yq2);
294 TH1D*
Sh4 =
new TH1D(
"Sh4",
"Distribution of significance",200,-10.,10.);
295 TH1D*
Shn =
new TH1D(
"Shn",
"Normal Distribution",200,-10.,10.);
301 hnew2->GetXaxis()->SetTitle(
"#rho");
302 hnew2->GetXaxis()->CenterTitle(
true);
303 hnew2->GetYaxis()->SetTitle(
"#events");
304 hnew2->GetYaxis()->CenterTitle(
true);
305 hnew2->SetFillColor(kBlue);
306 hnew2->SetTitle(
"Distribution of rho");
307 hnew3->Scale(liveTot/cliveTot);
308 hnew3->SetLineColor(kRed);
309 hnew3->SetFillColor(kRed);
310 hnew3->SetFillStyle(3001);
325 cout<<
"Plotting pad 2"<<endl;
331 cout<<
"After Rebinning"<<endl;
332 cout <<
"Anderson-Darling test (no rescaling)"<<endl;
333 hnew2->AndersonDarlingTest(hnew3,
"D");
340 if((curh->GetBinContent(
i+1)>0) || (comph->GetBinContent(
i+1)>0)){
342 Sh->SetBinContent(
i+1,(curh->GetBinContent(
i+1)-comph->GetBinContent(
i+1)*
K)/TMath::Sqrt(pow(curh->GetBinError(
i+1),2)+pow(comph->GetBinError(
i+1)*
K,2)));
343 Sh2->Fill(Sh->GetBinContent(
i+1));
345 else{Sh->SetBinContent(
i+1,0.0);}
348 Sh->GetXaxis()->SetTitle(
"#rho");
349 Sh->GetXaxis()->CenterTitle(
true);
350 Sh->GetYaxis()->SetTitle(
"Observed normalized significances");
351 Sh->GetYaxis()->CenterTitle(
true);
359 Sh->GetXaxis()->SetRangeUser(
T_cut,1.2*RHOMAX);
365 cout<<
"Plotting pad 3"<<endl;
374 for(
int i=0;
i<nq+2;
i++){
376 if((hnew2->GetBinContent(
i+1)>0) ||(hnew3->GetBinContent(
i+1)>0)){
377 w_tmp = (hnew2->GetBinContent(
i+1)-hnew3->GetBinContent(
i+1))/TMath::Sqrt(pow(hnew2->GetBinError(
i+1),2)+pow(hnew3->GetBinError(
i+1),2));
378 Sh3->SetBinContent(
i+1,w_tmp);
379 Sh4->Fill(Sh3->GetBinContent(
i+1));
383 else{Sh3->SetBinContent(
i+1,0.0);w[
i]=0.0;}
387 Sh3->GetXaxis()->SetTitle(
"#rho");
388 Sh3->GetXaxis()->CenterTitle(
true);
389 Sh3->GetYaxis()->SetTitle(
"Observed normalized significances");
390 Sh3->GetYaxis()->CenterTitle(
true);
396 Sh3->GetXaxis()->SetRangeUser(
T_cut,1.2*RHOMAX);
402 cout<<
"Plotting pad 4"<<endl;
407 Sh2->GetXaxis()->SetTitle(
"Observed normalized significances");
408 Sh2->GetXaxis()->CenterTitle(
true);
409 Sh2->GetYaxis()->SetTitle(
"#bins");
410 Sh2->GetYaxis()->CenterTitle(
true);
411 Sh2->SetFillColor(kBlue);
412 Sh2->SetFillStyle(3001);
425 cout<<
"Plotting pad 5"<<endl;
430 Sh4->GetXaxis()->SetTitle(
"Observed normalized significances");
431 Sh4->GetXaxis()->CenterTitle(
true);
432 Sh4->GetYaxis()->SetTitle(
"#bins");
433 Sh4->GetYaxis()->CenterTitle(
true);
434 Sh4->SetFillColor(kBlue);
435 Sh4->SetFillStyle(3001);
447 cout<<
"Plotting pad 6"<<endl;
452 for(
int i=0;
i<(
int)Sh4->GetEntries();
i++){Shn->Fill(P.Gaus(0,1));}
453 cout <<
"Anderson-Darling 2-sample test significance distribution vs Normal (no rescaling)"<<endl;
454 Sh4->AndersonDarlingTest(Shn,
"D");
456 ROOT::Math::GoFTest*
goftest_1 =
new ROOT::Math::GoFTest(count, w, ROOT::Math::GoFTest::kGaussian);
458 cout <<
"Anderson-Darling 1-sample test significance distribution vs Normal (no rescaling) : "<<pvalueAD_1<<endl;
460 cout<<
"Starting Q-Q plot ..."<<endl;
462 if (entriesy>=entriesx){
464 gr =
new TGraphQQ(entriesy,rhoy,entriesx,rhox);
465 gr->GetHistogram()->GetXaxis()->SetTitle(
"Quantiles current histogram");
466 gr->GetHistogram()->GetYaxis()->SetTitle(
"Quantiles compare histogram");
469 gr =
new TGraphQQ(entriesx,rhox,entriesy,rhoy);
470 gr->GetHistogram()->GetXaxis()->SetTitle(
"Quantiles compare histogram");
471 gr->GetHistogram()->GetYaxis()->SetTitle(
"Quantiles current histogram");
475 gr->SetMarkerColor(kRed);
476 gr->GetHistogram()->GetYaxis()->CenterTitle(
true);
477 gr->GetHistogram()->GetXaxis()->CenterTitle(
true);
479 gr->SetMarkerSize(1.0);
480 gr->SetMarkerStyle(20);
481 gr->SetTitle(
"Quantile-Quantile Plot");
483 line->SetLineColor(kGreen);
484 line->SetLineWidth(2);
485 line->SetLineStyle(2);
491 cout<<
"Drawing Q-Q plot ..."<<endl;
493 cout<<
"Finished Q-Q plot ..."<<endl;
505 TF1*
g1 =
new TF1(
"g1",
"gaus",-10.,10.);
506 g1->SetParameter(0,count/sqrt(TMath::TwoPi()));
507 g1->SetParameter(1,0.);
508 g1->SetParameter(2,1.);
510 TGraphQQ*
gr2 =
new TGraphQQ(nq,w,g1);
511 gr2->SetMarkerColor(kRed);
512 gr2->GetHistogram()->GetYaxis()->CenterTitle(
true);
513 gr2->GetHistogram()->GetXaxis()->CenterTitle(
true);
515 gr2->SetMarkerSize(1.0);
516 gr2->SetMarkerStyle(20);
517 gr2->SetTitle(
"Quantile-Quantile Plot");
518 double binmin = TMath::Max(gr2->GetX()[0],gr2->GetY()[0]);
519 double binmax = TMath::Min(gr2->GetX()[nq-1],gr2->GetY()[nq-1]);
520 TLine *line =
new TLine(binmin,binmin,binmax,binmax);
521 line->SetLineColor(kGreen);
522 line->SetLineWidth(2);
523 line->SetLineStyle(2);
524 cout <<
"Normalized significance distribution vs Gauss(0,1)"<<endl;
525 cout <<
"Correlation Factor : "<<gr2->GetCorrelationFactor()<<endl;
526 cout <<
"Covariance : " <<gr2->GetCovariance()<<endl;;
544 sprintf(exec,
"cp $CWB_MACROS/../postproduction/burst/compare_bkg.html %s/body.html",
netdir);
cout<<"Un-binned KS test"<< endl;TMath::KolmogorovTest(entriesx, rhox, entriesy, rhoy,"D");cout<<"Binned KS test (no rescaling)"<< endl;curh-> KolmogorovTest(comph,"D")
char cliv_file_name[1024]
#define REBIN_MIN_EVTS_PER_BIN
char cnet_file_name[1024]
curh AndersonDarlingTest(comph,"D")
sprintf(cnet_file_name,"%s", Compare_tree.Data())
char veto_not_vetoed[1024]
ROOT::Math::GoFTest * goftest_1