Ana01PaperPlot.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 "TArrow.h"
10 #include "TAxis.h"
11 #include "TROOT.h"
12 #include "TStyle.h"
13 #include "TLine.h"
14 #include "TLegend.h"
15 #include "TCollection.h"
16 #include "TGraph.h"
17 #include "TObjArray.h"
18 #include "TObject.h"
19 #include "TVirtualPad.h"
20 #include "TFile.h"
21 #include "TMarker.h"
22 #include "TLatex.h"
23 #include "TMath.h"
24 #include "TColor.h"
25 #include "TFrame.h"
26 
27 #include "CAFAna/Analysis/Style.h"
28 #include "Utilities/rootlogon.C"
29 
30 
31 void DrawAxes(TH2* surface)
32 {
33  double th24lo = 0.;
34  double th24hi = 40.;
35 
36  double th34lo = 0.;
37  double th34hi = 40.;
38 
39  TString dummyName = surface->GetName();
40  dummyName += "_dummy";
41  TH2* hDummy = (TH2*)surface->Clone(dummyName);
42  hDummy->SetDirectory(0);
43  hDummy->Reset();
44  hDummy->SetTitle("");
45  hDummy->GetXaxis()->SetRangeUser(th34lo, th34hi);
46  hDummy->GetXaxis()->SetTitle("#theta_{34} (deg.)");
47  hDummy->GetXaxis()->CenterTitle();
48  hDummy->GetXaxis()->SetTitleOffset(0.9);
49  hDummy->GetYaxis()->SetRangeUser(th24lo, th24hi);
50  hDummy->GetYaxis()->SetTitle("#theta_{24} (deg.)");
51  hDummy->GetYaxis()->CenterTitle();
52  hDummy->GetYaxis()->SetTitleOffset(0.9);
53  hDummy->GetXaxis()->SetTitleSize(0.07);
54  hDummy->GetYaxis()->SetTitleSize(0.07);
55  hDummy->GetXaxis()->SetLabelSize(0.06);
56  hDummy->GetYaxis()->SetLabelSize(0.06);
57 
58  hDummy->Draw();
59 
60  return;
61 }
62 
63 
64 vector<TGraph*> GetContour(TH2* surface, double up, int color, int style, int fillcolor, bool fill=false)
65 {
66  TVirtualPad* bak = gPad;
67 
68  const bool wasbatch = gROOT->IsBatch();
69  gROOT->SetBatch(); // User doesn't want to see our temporary canvas
70  gROOT->ForceStyle();
71 
72  TCanvas tmp;
73  gStyle->SetOptStat(0);
74  gPad->SetFillStyle(0);
75 
76  vector<TGraph*> results;
77 
78  tmp.cd();
79  double minLike = surface->GetBinContent( surface->GetMinimumBin() );
80  double maxLike = surface->GetBinContent( surface->GetMaximumBin() );
81  cout << "TH1 Name = " << surface->GetName() << " : minLike = " << minLike << " maxLike = " << maxLike << " up = " << up << endl;
82  const double level = up;
83  surface->SetContour(1, &level);
84  //surface->SetContourLevel(0, up - minLike);
85  surface->Smooth();
86  surface->Draw("cont list");
87  tmp.Update();
88  tmp.Paint();
89 
90  gROOT->SetBatch(wasbatch);
91  gPad = bak;
92 
93  TObjArray* contArr = (TObjArray*)gROOT->GetListOfSpecials()->FindObject("contours");
94  TList* contList = (TList*)contArr->At(0);
95  TIter next(contList);
96  TGraph* gr(0);
97  while ( gr = (TGraph*)next() )
98  {
99  TGraph* toSave = (TGraph*)gr->Clone();
100  TGraph* toSave2 = (TGraph*)gr->Clone();
101  toSave->SetLineWidth(2);
102  toSave->SetLineColor(color);
103  toSave->SetLineStyle(style);
104  toSave2->SetLineWidth(2);
105  toSave2->SetLineColor(color);
106  toSave2->SetLineStyle(style);
107  if(fill){
108  toSave->SetPoint(toSave->GetN(), 0, 0);
109  toSave->SetFillColor(fillcolor);
110  toSave->Draw("f same");
111  }
112  toSave->Draw("l same");
113  results.push_back( toSave );
114  results.push_back( toSave2 );
115  }
116  return results;
117 }
118 
119 
121 {
122 
123  const bool wasbatch = gROOT->IsBatch();
124 
125  gROOT->ForceStyle();
126 
127  gStyle->SetFillStyle(0);
128  gStyle->SetPadBottomMargin(0.15);
129  gStyle->SetPadLeftMargin(0.15);
130  gStyle->SetLabelOffset(0.01,"y");
131 
132  double up68 = TMath::ChisquareQuantile(0.68, 1);
133  double up90 = TMath::ChisquareQuantile(0.90, 1);
134 
135  TFile fFCfile("$NOVA_ANA/steriles/Ana01/input_FC_ana01_t2434_paperplot.root","READ");
136  // TFile fNus17file("$NOVA_ANA/steriles/Nus17/plot_predInterpSysts_nus17_shape_2D_lower.root","READ");
137  TH2F *hFCcorr;
138  //TH2F *hNus17;
139 
140  TCanvas *c1 = (TCanvas*)fFCfile.Get("cFCChi2");
141  gROOT->SetBatch();
142  gPad->SetFillStyle(0);
143  hFCcorr = (TH2F*)c1->GetPrimitive("chi_me"); //hFCChi
144  hFCcorr->SetDirectory(0);
145  c1->Clear();
146  c1->Draw();
147  hFCcorr->Draw();
148 
149  std::string cname = "cFCcorr";
150  std::string ctitle = "FC Correction";
151  gROOT->SetBatch(wasbatch);
152  TCanvas* c = new TCanvas(cname.c_str(), ctitle.c_str());
153  gPad->SetFillStyle(0);
154  DrawAxes(hFCcorr);
155  TH2* hDummy2 = (TH2*)hFCcorr->Clone("hFCcorr");
156 
157  //TH2* hDummy1 = (TH2*)fNus17file.Get("h34vs24_9e20_shapestatS");
158 
159  Color_t kSigmaConfidenceColor = kAzure+2;
160  //Color_t k17SigmaConfidenceColor = kAzure+2;
161 
162  Int_t kFillColor68 = TColor::GetColorTransparent(kSigmaConfidenceColor, .20);
163  Int_t kFillColor90 = TColor::GetColorTransparent(kSigmaConfidenceColor, .35);
164  //Int_t k17FillColor68 = TColor::GetColorTransparent(k17SigmaConfidenceColor, .20);
165  //Int_t k17FillColor90 = TColor::GetColorTransparent(k17SigmaConfidenceColor, .35);
166 
167  vector<TGraph*> vecFC68 = GetContour(hDummy2, up68, kBlack, kDashed, kFillColor68, true);
168  vector<TGraph*> vecFC90 = GetContour(hDummy2, up90, kBlack, kSolid, kFillColor90, true);
169 
170  //vector<TGraph*> vec1768 = GetContour(hDummy1, up68, kAzure+2, kDashed, k17FillColor68, true);
171  //vector<TGraph*> vec1790 = GetContour(hDummy1, up90, kAzure+2, kSolid, k17FillColor90, true);
172 
173 
174  TLatex *tex = new TLatex();
175  tex->SetNDC();
176  tex->SetTextFont(42);
177  tex->SetTextSize(0.05);
178  tex->SetTextAlign(11);
179  tex->DrawLatex(0.2, 0.80, "NOvA 6.05#times10^{20} POT-equiv.");
180  tex->DrawLatex(0.2, 0.8-1.*0.055, "#Deltam^{2}_{32} = 2.44#times10^{-3} eV^{2}");
181  tex->DrawLatex(0.2, 0.8-2.*0.055, "#theta_{13} = 8.5#circ, ^{}#theta_{23} = 45#circ");
182  tex->DrawLatex(0.2, 0.8-3.*0.055, "#Deltam^{2}_{41} = 0.5 eV^{2}");
183 
184  TLegend* leg = new TLegend(0.62, 0.53, 0.87, 0.73);
185  leg->SetBorderSize(0);
186  leg->SetFillColor(kWhite);
187  leg->SetFillStyle(0);
188  leg->SetFillStyle(0);
189  leg->SetTextFont(42);
190 
191  leg->AddEntry(vecFC68[0],"68% C.L.","L");
192  leg->AddEntry(vecFC90[0],"90% C.L.","L");
193  //leg->AddEntry(vec1768[0],"NOvA 2017: 68% C.L.","L");
194  //leg->AddEntry(vec1790[0],"NOvA 2017: 90% C.L.","L");
195 
196  leg->SetTextSize(0.05);
197  leg->Draw();
198 
199  gPad->RedrawAxis();
200 
201  gPad->Modified();
202  gPad->Update();
203 
204  gPad->Print("ana01_paper_plot_fc_t2434.pdf");
205 
206 }
vector< TGraph * > GetContour(TH2 *surface, double up, int color, int style, int fillcolor, bool fill=false)
Float_t tmp
Definition: plot.C:36
void DrawAxes(TH2 *surface)
OStream cout
Definition: OStream.cxx:6
::xsd::cxx::tree::string< char, simple_type > string
Definition: Database.h:154
TLatex * tex
Definition: f2_nu.C:499
c1
Definition: demo5.py:24
void fill(std::vector< T > &x, const S &y)
Definition: fill.hpp:22
void Ana01PaperPlot()
void next()
Definition: show_event.C:84