MatrixElementContours.C
Go to the documentation of this file.
1 #include <vector>
2 #include <iostream>
3 #include <iomanip>
4 
5 #include "TString.h"
6 #include "TH1.h"
7 #include "TH2.h"
8 #include "TCanvas.h"
9 #include "TAxis.h"
10 #include "TROOT.h"
11 #include "TStyle.h"
12 #include "TLine.h"
13 #include "TLegend.h"
14 #include "TCollection.h"
15 #include "TGraph.h"
16 #include "TObjArray.h"
17 #include "TObject.h"
18 #include "TVirtualPad.h"
19 #include "TFile.h"
20 #include "TMarker.h"
21 #include "TLatex.h"
22 #include "TMath.h"
23 #include "TColor.h"
24 #include "TFrame.h"
25 
26 #include "Utilities/rootlogon.C"
27 
28 using namespace std;
29 
30 
31 void DrawAxes(TH2* surface)
32 {
33  TString dummyName = surface->GetName();
34  dummyName += "_dummy";
35  TH2* hDummy = (TH2*)surface->Clone(dummyName);
36  hDummy->Reset();
37  hDummy->Draw();
38 
39  return;
40 }
41 
42 TLegend* MakeLegend(double x1, double y1, double x2, double y2, double textsize = 0.03)
43 {
44  TLegend* leg = new TLegend(x1, y1, x2, y2);
45  leg->SetBorderSize(0);
46  leg->SetFillColor(kWhite);
47  leg->SetFillStyle(0);
48  leg->SetFillStyle(0);
49  leg->SetTextFont(42);
50  leg->SetTextSize(textsize);
51  return leg;
52 }
53 
54 
55 vector<TGraph*> GetContour(TH2* surface, double up, int color, int style)
56 {
57  TVirtualPad* bak = gPad;
58 
59  const bool wasbatch = gROOT->IsBatch();
60  gROOT->SetBatch(); // User doesn't want to see our temporary canvas
61 
62  TCanvas tmp;
63  gStyle->SetOptStat(0);
64  gPad->SetFillStyle(0);
65  vector<TGraph*> results;
66 
67  tmp.cd();
68  double minLike = surface->GetBinContent( surface->GetMinimumBin() );
69  double maxLike = surface->GetBinContent( surface->GetMaximumBin() );
70  cout << "TH1 Name = " << surface->GetName() << " : minLike = " << minLike << " maxLike = " << maxLike << " up = " << up << endl;
71  surface->SetContour(1);
72  surface->SetContourLevel(0, minLike + up);
73  surface->Draw("cont list");
74  tmp.Update();
75  tmp.Paint();
76 
77  gROOT->SetBatch(wasbatch);
78  gPad = bak;
79 
80  TObjArray* contArr = (TObjArray*)gROOT->GetListOfSpecials()->FindObject("contours");
81  TList* contList = (TList*)contArr->At(0);
82  TIter next(contList);
83  TGraph* gr(0);
84  while ( gr = (TGraph*)next() )
85  {
86  TGraph* toSave = (TGraph*)gr->Clone();
87  toSave->SetLineWidth(2);
88  toSave->SetLineColor(color);
89  toSave->SetLineStyle(style);
90  toSave->Draw("same");
91  results.push_back( toSave );
92  }
93  return results;
94 }
95 
97 {
98  TLine* line2 = new TLine();
99  line2->SetLineWidth(2);
100  line2->SetLineStyle(kSolid);
101  line2->SetLineColor(kBlack);
102 
103  double start(0), step(0);
104 
105  //TFile* fData = new TFile("nus_ana01_results_final.root");
106  TFile* fData = new TFile("matrixElements_osc_syst_incl_fix.root");
107  TFile* fSK = new TFile("SKContour.root");
108  TGraph* gSK = (TGraph*)fSK->Get("SK90");
109  gSK->SetLineColor(kRed);
110  gSK->SetLineWidth(2);
111  gSK->SetLineStyle(kDashed);
112 
113  gROOT->ForceStyle();
114  gStyle->SetPadBottomMargin(0.13);
115  gStyle->SetPadLeftMargin(0.12);
116  gStyle->SetLabelOffset(0.01,"y");
117 
118  double Utau4lo = 0.;
119  double Utau4hi = 0.35;
120 
121  double Umu4lo = 0.;
122  double Umu4hi = 0.3;
123 
124  TLatex *tex = new TLatex();
125  tex->SetNDC();
126  tex->SetTextFont(42);
127  tex->SetTextSize(0.04);
128  tex->SetTextAlign(11);
129 
130  TLatex *tex2 = new TLatex();
131  tex2->SetNDC();
132  tex2->SetTextFont(42);
133  tex2->SetTextSize(0.04);
134  tex2->SetTextAlign(11);
135 
136  //---------------------------------------------------------------------------
137  //-------------------------2D Profiles - All together------------------------
138 
139  double up68 = TMath::ChisquareQuantile(0.68, 1);
140  double up90 = TMath::ChisquareQuantile(0.90, 1);
141 
142 
143  TH2D* hDummyUtau4Umu4 = new TH2D("hDummyUtau4Umu4", ";|U_{#mu4}^{}|^{2};|U_{#tau4}^{}|^{2}", 200, Umu4lo, Umu4hi, 200, Utau4lo, Utau4hi);
144  hDummyUtau4Umu4->GetXaxis()->SetTitleOffset(1.0);
145  hDummyUtau4Umu4->GetYaxis()->SetTitleOffset(1.0);
146  CenterTitles(hDummyUtau4Umu4);
147 
148  TCanvas* cContoursUtau4Umu4 = new TCanvas("cContoursUtau4Umu4", "cContoursUtau4Umu4");
149  gPad->SetFillStyle(0);
150  DrawAxes(hDummyUtau4Umu4);
151  TH2F* hUtau4Umu4 = (TH2F*)fData->Get("hUmu4Utau4");
152  hUtau4Umu4->SetTitle(";|U_{#mu4}^{}|^{2};|U_{#tau4}^{}|^{2}");
153 
154 
155  vector<TGraph*> vecUtau4Umu4_68 = GetContour(hUtau4Umu4, up68, kBlack, kDashed);
156  vector<TGraph*> vecUtau4Umu4_90 = GetContour(hUtau4Umu4, up90, kBlack, kSolid);
157 
158  gSK->Draw("l same");
159 
160 
161  tex2->DrawLatex(0.53, 0.82, "NOvA 6.05#times10^{20} POT-equiv.");
162  tex2->DrawLatex(0.53, 0.82-1.*0.058, "#Deltam^{2}_{32} = 2.44#times10^{-3} eV^{2}");
163  tex2->DrawLatex(0.53, 0.82-2.*0.058, "#theta_{13}^{} = 8.5#circ^{}, #theta_{23} = 45#circ");
164  tex2->DrawLatex(0.53, 0.82-3.*0.058, "#Deltam^{2}_{41} = 0.5 eV^{2}");
165 
166  TLegend* legUtau4Umu4 = new TLegend(0.51, 0.43, 0.76, 0.58);
167  legUtau4Umu4->SetBorderSize(0);
168  legUtau4Umu4->SetFillColor(kWhite);
169  legUtau4Umu4->SetFillStyle(0);
170  legUtau4Umu4->SetFillStyle(0);
171  legUtau4Umu4->SetTextFont(42);
172  legUtau4Umu4->SetTextSize(0.037);
173  legUtau4Umu4->AddEntry(vecUtau4Umu4_68[0],"68% C.L.","L");
174  legUtau4Umu4->AddEntry(vecUtau4Umu4_90[0],"90% C.L.","L");
175  legUtau4Umu4->AddEntry(gSK, "Sk* 90% C.L.","L");
176  legUtau4Umu4->Draw();
177 
178  tex = new TLatex(0.42,0.15,"* PRD 91, 052019 (2015)");
179  tex->SetNDC();
180  tex->SetTextFont(42);
181  tex->SetTextSize(0.037);
182  tex->SetLineWidth(2);
183  tex->Draw();
184 
185 }
void DrawAxes(TH2 *surface)
vector< TGraph * > GetContour(TH2 *surface, double up, int color, int style)
enum BeamMode kRed
Float_t y1[n_points_granero]
Definition: compare.C:5
Float_t x1[n_points_granero]
Definition: compare.C:5
Float_t tmp
Definition: plot.C:36
void MatrixElementContours()
void CenterTitles(TH1 *h)
OStream cout
Definition: OStream.cxx:6
TLegend * MakeLegend(double x1, double y1, double x2, double y2, double textsize=0.03)
TLatex * tex
Definition: f2_nu.C:499
void next()
Definition: show_event.C:84