ra4_stats  0341147a0dc35f80f4e12c6003afb76a38e2ed6e
two_exp.cxx
Go to the documentation of this file.
1 #include <cmath>
2 
3 #include <limits>
4 
5 #include "TH2D.h"
6 #include "TAxis.h"
7 #include "TMath.h"
8 #include "TCanvas.h"
9 #include "TColor.h"
10 #include "TROOT.h"
11 #include "TStyle.h"
12 
13 using namespace std;
14 
15 int main(){
16  const int bands = 999;
17  int colors[bands];
18  const unsigned num = 6;
19  double red[num] = {1.,0.,0.,0.,1.,1.};
20  double green[num] = {0.,0.,1.,1.,1.,0.};
21  double blue[num] = {1.,1.,1.,0.,0.,0.};
22  double stops[num] = {0.,0.2,0.4,0.6,0.8,1.};
23  int fi = TColor::CreateGradientColorTable(num,stops,red,green,blue,bands);
24  for(int i = 0; i < bands; ++i){
25  colors[i] = fi+i;
26  }
27  gStyle->SetNumberContours(bands);
28  gStyle->SetPalette(bands, colors);
29 
30  double inf = numeric_limits<double>::infinity();
31  TH2D h("h", "Combined Significance;Significance A;Significance B", 55, 0., 5., 55, 0., 5.);
32  h.SetMinimum(0.);
33  h.SetMaximum(7.);
34  h.SetStats(false);
35  for(int ix = 1; ix <= h.GetNbinsX(); ++ix){
36  double zx = h.GetXaxis()->GetBinCenter(ix);
37  double px = erfc(zx/sqrt(2.));
38  double qx = -2.*log(px);
39  for(int iy = 1; iy <= h.GetNbinsY(); ++iy){
40  double zy = h.GetYaxis()->GetBinCenter(iy);
41  double py = erfc(zy/sqrt(2.));
42  double qy = -2.*log(py);
43 
44  double q = qx + qy;
45  double p = TMath::Prob(q, 4);
46  double cp = 1.-0.5*p;
47  double z = cp <= 0. ? -inf
48  : cp >= 1. ? inf
49  : TMath::NormQuantile(cp);
50  h.SetBinContent(ix, iy, z);
51  }
52  }
53  TCanvas c;
54  h.Draw("colz");
55  c.Print("combined_significance.pdf");
56 }
STL namespace.
int main()
Definition: two_exp.cxx:15