DrawSensitivityDip.C
Go to the documentation of this file.
1 /// DrawSensitivityDip by J. Hewes <jhewes15@fnal.gov>
2 
3 // CAFAna headers
4 #include "CAFAna/Core/Progress.h"
7 
8 // ROOT headers
9 #include "TCanvas.h"
10 #include "TH2.h"
11 #include "THStack.h"
12 #include "TMarker.h"
13 #include "TLegend.h"
14 #include "TView.h"
15 #include "TSystem.h"
16 
17 using namespace ana;
18 
20 
21  gErrorIgnoreLevel = kError;
22  std::vector<float> margin = { 0.15, 0.05 };
23 
24  // Load predictions
25  IPrediction* ndPred = LoadPrediction(kNusFHCNearDet, "nosysts", kUseCVMFS);
26  IPrediction* fdPred = LoadPrediction(kNusFHCFarDet, "nosysts", kUseCVMFS);
27  auto calc = DefaultSterileCalc(4);
29  double potND = kAna2018SensitivityFHCNDPOT;
30  double potFD = kAna2018FHCPOT;
31 
32  // 3-flavour ND spectra
33  TH1D* hNominalNDNC = ndPred->PredictComponent(calc,
35  hNominalNDNC->SetLineColor(kBlue-10);
36  TH1D* hNominalNDCC = ndPred->PredictComponent(calc,
38  hNominalNDCC->SetLineColor(kRed-10);
39  THStack hsNominalND(UniqueName().c_str(), ";;");
40  hsNominalND.Add(hNominalNDNC);
41  hsNominalND.Add(hNominalNDCC);
42 
43  // 3-flavour FD spectra
44  TH1D* hNominalFDNC = fdPred->PredictComponent(calc,
46  hNominalFDNC->SetLineColor(kBlue-10);
47  TH1D* hNominalFDCC = fdPred->PredictComponent(calc,
49  hNominalFDCC->SetLineColor(kRed-10);
50  THStack hsNominalFD(UniqueName().c_str(), ";;");
51  hsNominalFD.Add(hNominalFDNC);
52  hsNominalFD.Add(hNominalFDCC);
53 
54  // Loop over each bin and make plot
55  Binning xBins(Binning::Simple(50, 0, 1));
56  Binning yBins(Binning::Simple(50, 0.29, 0.32));
57  TH2D* hSurface = new TH2D(UniqueName().c_str(),
58  ";sin^{2}#theta_{24};#Deltam_{41}^{2}",
59  xBins.NBins(), &xBins.Edges()[0], yBins.NBins(), &yBins.Edges()[0]);
60 
61  Progress* p = new Progress("Drawing spectra");
62 
63  for (size_t xBin = 1; xBin <= 50; ++xBin) {
64  for (size_t yBin = 1; yBin <= 50; ++yBin) {
65 
66  // Create canvas
67  TCanvas c("c", "c", 1600, 900);
68  c.Divide(3, 1);
69 
70  // Set oscillation variables
71  double x = hSurface->GetXaxis()->GetBinCenter(xBin);
72  double y = hSurface->GetYaxis()->GetBinCenter(yBin);
75 
76  // ND oscillated spectra
77  TH1D* hOscNDNC = ndPred->PredictComponent(calc,
79  hOscNDNC->SetLineColor(kBlue-2);
80  TH1D* hOscNDCC = ndPred->PredictComponent(calc,
82  hOscNDCC->SetLineColor(kRed-2);
83  THStack hsOscND(UniqueName().c_str(), ";;");
84  hsOscND.Add(hOscNDNC);
85  hsOscND.Add(hOscNDCC);
86 
87  // FD oscillated spectra
88  TH1D* hOscFDNC = fdPred->PredictComponent(calc,
90  hOscFDNC->SetLineColor(kBlue-2);
91  TH1D* hOscFDCC = fdPred->PredictComponent(calc,
93  hOscFDCC->SetLineColor(kRed-2);
94  THStack hsOscFD(UniqueName().c_str(), ";;");
95  hsOscFD.Add(hOscFDNC);
96  hsOscFD.Add(hOscFDCC);
97 
98  // ND spectrum
99  c.cd(1);
100  gPad->SetPad(0.01, 0.51, 0.49, 0.99);
101  gPad->SetLeftMargin(margin[0]);
102  gPad->SetRightMargin(margin[1]);
103  hsNominalND.Draw("hist");
104  hsOscND.Draw("hist same");
105  TLegend lND(0.6, 0.6, 0.85, 0.85);
106  lND.AddEntry(hOscNDNC, "ND 4-flav NC spectrum", "l");
107  lND.AddEntry(hOscNDCC, "ND 4-flav CC spectrum", "l");
108  lND.AddEntry(hNominalNDNC, "ND 3-flav NC spectrum", "l");
109  lND.AddEntry(hNominalNDCC, "ND 3-flav CC spectrum", "l");
110  lND.Draw();
111 
112  // FD spectrum
113  c.cd(2);
114  gPad->SetPad(0.01, 0.01, 0.49, 0.49);
115  gPad->SetLeftMargin(margin[0]);
116  gPad->SetRightMargin(margin[1]);
117  hsNominalFD.Draw("hist");
118  hsOscFD.Draw("hist same");
119  TLegend lFD(0.6, 0.15, 0.85, 0.4);
120  lFD.AddEntry(hOscFDNC, "FD 4-flav NC spectrum", "l");
121  lFD.AddEntry(hOscFDCC, "FD 4-flav CC spectrum", "l");
122  lFD.AddEntry(hNominalFDNC, "FD 3-flav NC spectrum", "l");
123  lFD.AddEntry(hNominalFDCC, "FD 3-flav CC spectrum", "l");
124  lFD.Draw();
125 
126  c.cd(3);
127  gPad->SetPad(0.51, 0.01, 0.99, 0.99);
128  gPad->SetLeftMargin(margin[0]);
129  gPad->SetRightMargin(margin[1]);
130  hSurface->Draw();
131  hSurface->GetXaxis()->CenterTitle();
132  hSurface->GetYaxis()->CenterTitle();
133  TMarker m(x, y, 29);
134  m.SetMarkerSize(3);
135  m.Draw("same");
136  gPad->Update();
137 
138  std::ostringstream fileName;
139  fileName << "plots/sensitivity_dip/spectra/spectrum_"
140  << xBin << "_" << yBin << ".png";
141  c.cd(0);
142  c.SaveAs(fileName.str().c_str());
143 
144  p->SetProgress(double((50*(xBin-1))+yBin)/2500.);
145  }
146  }
147 
148  p->Done();
149  delete p;
150 
151  p = new Progress("Drawing gifs");
152  for (size_t xBin = 1; xBin <= 50; ++xBin) {
153  std::vector<std::string> pngNames;
154  for (size_t yBin = 1; yBin <= 50; ++yBin) {
155  std::ostringstream name;
156  name << "plots/sensitivity_dip/spectra/spectrum_"
157  << xBin << "_" << yBin << ".png";
158  pngNames.push_back(name.str());
159  }
160  std::ostringstream gifName;
161  gifName << "plots/sensitivity_dip/slices/slice_" << xBin << ".gif";
162  MakeGif(pngNames, gifName.str());
163  p->SetProgress(double(xBin)/50.);
164  }
165  p->Done();
166  delete p;
167  return;
168 
169 } // Main macro function
const XML_Char * name
Definition: expat.h:151
const FitSinSqTheta24Sterile kFitSinSqTheta24Sterile
fileName
Definition: plotROC.py:78
enum BeamMode kRed
Represent the binning of a Spectrum&#39;s x-axis.
Definition: Binning.h:16
Cuts and Vars for the 2020 FD DiF Study.
Definition: vars.h:6
virtual Spectrum PredictComponent(osc::IOscCalc *calc, Flavors::Flavors_t flav, Current::Current_t curr, Sign::Sign_t sign) const =0
TH1D * ToTH1(double exposure, Color_t col=kBlack, Style_t style=kSolid, EExposureType expotype=kPOT, EBinType bintype=kBinContent) const
Histogram made from this Spectrum, scaled to some exposure.
Definition: Spectrum.cxx:176
const char * p
Definition: xmltok.h:285
void SetNus20Params(osc::IOscCalcSterile *calc, std::string type)
Definition: Calcs.cxx:29
const double kAna2018SensitivityFHCNDPOT
Definition: Exposures.h:210
osc::OscCalcDumb calc
Charged-current interactions.
Definition: IPrediction.h:39
osc::OscCalcSterile * DefaultSterileCalc(int nflavors)
Create a sterile calculator with default assumptions for all parameters.
Definition: Calcs.cxx:97
void DrawSensitivityDip()
const covmx::Sample kNusFHCFarDet(covmx::Analysis::kNC, covmx::Polarity::kFHC, covmx::Detector::kFarDet)
const std::vector< double > & Edges() const
Definition: Binning.h:34
IPrediction * LoadPrediction(std::string detector, bool rhc=false, std::string syst_type="all")
Function to load prediction object.
int NBins() const
Definition: Binning.h:29
Neutral-current interactions.
Definition: IPrediction.h:40
void SetValue(osc::IOscCalcAdjustable *osc, double val) const override
A simple ascii-art progress bar.
Definition: Progress.h:9
Both neutrinos and antineutrinos.
Definition: IPrediction.h:52
void SetValue(osc::IOscCalcAdjustable *osc, double val) const override
Standard interface to all prediction techniques.
Definition: IPrediction.h:57
const double kAna2018FHCPOT
Definition: Exposures.h:207
All neutrinos, any flavor.
Definition: IPrediction.h:26
enum BeamMode kBlue
static Binning Simple(int n, double lo, double hi, const std::vector< std::string > &labels={})
Definition: Binning.cxx:107
const covmx::Sample kNusFHCNearDet(covmx::Analysis::kNC, covmx::Polarity::kFHC, covmx::Detector::kNearDet)
std::string UniqueName()
Return a different string each time, for creating histograms.
Definition: Utilities.cxx:28
const FitDmSq41Sterile kFitDmSq41Sterile