DrawExtrapSurface.C
Go to the documentation of this file.
1 //////////////////////////////////////////////////////////////
2 // DrawExtrapSurface.C
3 // Mike Wallbank (wallbank@fnal.gov)
4 //
5 // Make 1D profiles and 2D surface in th24-th34 parameter
6 // space, using extrapolated predictions.
7 //////////////////////////////////////////////////////////////
8 
9 // framwork
12 
13 // root
14 #include "TFile.h"
15 #include "TCanvas.h"
16 #include "TDirectory.h"
17 #include "TH1.h"
18 #include "TH2.h"
19 #include "TLegend.h"
20 #include "TText.h"
21 #include "TLine.h"
22 
23 // stl
24 #include <iomanip>
25 
26 using namespace ana;
27 
28 void Draw1DProfile(TH1* hist, std::string name, TFile* outFile);
30 
31 // -------------------------------------------------------------------------------------------
33 
34  TH1::AddDirectory(0);
35 
36  // Get running options
37  bool oned = opt.Contains("1D", TString::kIgnoreCase);
38  bool twod = opt.Contains("2D", TString::kIgnoreCase);
39  assert(oned or twod);
40 
41  // Get the input and output file names
42  std::string fileName = inFileName.substr(0, inFileName.find(".root"));
43  std::string saveName = fileName + "Ana.root";
44 
45  // Load the analysis objects from the in file
46  TFile* inFile = new TFile(inFileName.c_str(), "READ");
47  TH1* ProfileTh24 = (TH1*)inFile->Get("ProfileTh24");
48  TH1* ProfileTh34 = (TH1*)inFile->Get("ProfileTh34");
49  FrequentistSurface* Surface = FrequentistSurface::LoadFrom(inFile, TString("SurfaceTh34Th24")).release();
50 
51  // Drawing
52  TFile* outFile = new TFile(saveName.c_str(), "RECREATE");
53 
54  // Draw 1D profiles
55  if (oned) {
56  Draw1DProfile(ProfileTh24, "1DProfileTheta24", outFile);
57  Draw1DProfile(ProfileTh34, "1DProfileTheta34", outFile);
58  }
59 
60  // Draw 2D surface
61  if (twod)
62  Draw2DSurface(Surface, "2DSurfaceTheta24Theta34", outFile);
63 
64  // Clean up
65  outFile->Close();
66  delete outFile;
67 
68 }
69 
70 // -------------------------------------------------------------------------------------------
71 void Draw1DProfile(TH1* hist, std::string name, TFile* outFile) {
72 
73  TCanvas* canv = new TCanvas("canv", "", 800, 600);
74  TLine line;
75  TText text;
76 
77  float xmin = hist->GetBinLowEdge(1);
78  float xmax = hist->GetBinLowEdge(hist->GetXaxis()->GetLast()+1);
79  float ymin = hist->GetMinimum();
80  float ymax = hist->GetMaximum();
81 
82  canv->cd();
83  canv->Clear();
84  hist->Draw("hist");
85  line.SetLineStyle(kDashed);
86  line.SetLineColor(kBlack);
87  line.SetLineWidth(2);
88  text.SetTextColor(kBlack);
89  text.SetTextFont(42);
90  text.SetTextSize(0.037);
91  text.SetTextAlign(11);
92  line.DrawLine(xmin, 1, xmax, 1);
93  text.DrawText(0+(xmax-xmin)/10., 1+(ymax-ymin)/100., "68% C.L.");
94  line.DrawLine(xmin, 9, xmax, 9);
95  text.DrawText(0+(xmax-xmin)/10., 9+(ymax-ymin)/100., "90% C.L.");
96  Preliminary();
97  outFile->cd();
98  canv->Write(name.c_str());
99 
100  delete canv;
101 
102  return;
103 
104 }
105 
106 // -------------------------------------------------------------------------------------------
108 
109  TCanvas* canv = new TCanvas("canv", "", 800, 600);
110  TLine line;
111  TText text;
112 
113  surface->DrawContour(Gaussian68Percent1D(*surface), kDashed, kOfficialNus18RHCColor);
114  surface->DrawContour(Gaussian90Percent1D(*surface), kSolid, kOfficialNus18RHCColor);
115 
116  // Draw legend
117  //TLegend* leg = new TLegend(0.6,0.6,0.88,0.85);
118  TLegend* leg = new TLegend(0.645,0.7,0.82,0.88);
119  TH1* dummy = new TH1F("","",1,0,1);
120  dummy->SetLineColor(kOfficialNus18RHCColor);
121  dummy->SetLineWidth(2);
122  dummy->SetLineStyle(kDashed);
123  leg->AddEntry(dummy->Clone(), "68% C.L.", "l");
124  dummy->SetLineStyle(kSolid);
125  leg->AddEntry(dummy->Clone(), "90% C.L.", "l");
126  leg->Draw();
127 
128  // Annotate
129  Simulation();
131  calc->SetNFlavors(4);
132  SetAngles(calc);
133  std::stringstream description, params4f, params3f, paramsDelta;
134  description << "#bf{NOvA Sensitivity}, 12 #times 10^{20} POT";
135  params4f << "#Deltam^{2}_{41} = " << setprecision(3) << calc->GetDm(4) << " eV^{2}";
136  params3f << "sin^{2}#theta_{23} = " << setprecision(3) << TMath::Power(TMath::Sin(calc->GetAngle(2,3)),2) << ", "
137  << "#Deltam^{2}_{32} = " << setprecision(3) << (calc->GetDm(3)-calc->GetDm(2))/1e-3 << " #times 10^{-3} eV^{2}";
138  paramsDelta << "#delta_{13} = " << setprecision(3) << calc->GetDelta(1,3)/TMath::Pi() << "#pi";
139  //<< "#delta_{24} = " << setprecision(3) << calc->GetDelta(2,4)/TMath::Pi() << "#pi";
140  TLatex* tex = new TLatex();
141  tex->SetNDC();
142  tex->SetTextFont(42);
143  tex->SetTextSize(0.037);
144  tex->SetTextAlign(11);
145  tex->DrawLatex(0.135, 0.82, description.str().c_str());
146  tex->DrawLatex(0.135, 0.82 - 1*0.055, params3f.str().c_str());
147  tex->DrawLatex(0.135, 0.82 - 2*0.055, params4f.str().c_str());
148  tex->DrawLatex(0.135, 0.82 - 3*0.055, paramsDelta.str().c_str());
149  canv->RedrawAxis();
150 
151  outFile->cd();
152  canv->Write(name.c_str());
153 
154  return;
155 
156 }
void Simulation()
Definition: tools.h:16
const XML_Char * name
Definition: expat.h:151
TH2 * Gaussian90Percent1D(const FrequentistSurface &s)
Up-value surface for 90% confidence in 1D in gaussian approximation.
fileName
Definition: plotROC.py:78
double GetDelta(int i, int j) const
Cuts and Vars for the 2020 FD DiF Study.
Definition: vars.h:6
void SetNFlavors(int nflavors)
std::map< std::string, double > xmax
void DrawExtrapSurface(std::string inFileName, TString opt)
TCanvas * canv
Adapt the PMNS_Sterile calculator to standard interface.
osc::OscCalcDumb calc
void SetAngles(osc::OscCalcSterile *calc)
void Draw1DProfile(TH1 *hist, std::string name, TFile *outFile)
Double_t ymax
Definition: plot.C:25
const int kOfficialNus18RHCColor
Log-likelihood scan across two parameters.
ifstream inFile
Definition: AnaPlotMaker.h:34
osc::OscCalcSterile * DefaultSterileCalc(int nflavors)
Create a sterile calculator with default assumptions for all parameters.
Definition: Calcs.cxx:97
TFile * outFile
Definition: PlotXSec.C:135
void DrawContour(TH2 *fc, Style_t style, Color_t color, double minchi=-1)
Definition: ISurface.cxx:44
inFileName
if we get here, we&#39;re doing the base definitions:
Definition: mkDefs.py:168
void Preliminary()
void Draw2DSurface(FrequentistSurface *surface, std::string name, TFile *outFile)
::xsd::cxx::tree::string< char, simple_type > string
Definition: Database.h:154
TLatex * tex
Definition: f2_nu.C:499
assert(nhit_max >=nhit_nbins)
double GetDm(int i) const
Double_t ymin
Definition: plot.C:24
Float_t e
Definition: plot.C:35
static std::unique_ptr< FrequentistSurface > LoadFrom(TDirectory *dir, const std::string &name)
TH2 * Gaussian68Percent1D(const FrequentistSurface &s)
Up-value surface for 68% confidence in 1D in gaussian approximation.
double GetAngle(int i, int j) const