NuSPlotFunctions.h
Go to the documentation of this file.
1 /*
2  This file contains functions for plotting
3  In this file:
4 
5  TLatex* DrawLatexLines(double x, double y, std::string sPOT)
6 
7  void DrawLineArrow(double cut, bool left, TH1* h)
8 
9  void SetHistOptions(TH1* h, double max, std::string title,
10  int ndiv, Color_t col, bool fill)
11 
12  void SetLegendOptions(TLegend* leg)
13 
14  void PlotSpectra(Spectrum spectra[], TDirectory* rootOut, FILE* textOFS,
15  std::string name, std::string title, std::string det, int POT,
16  std::string option = "");
17 
18  void PlotSpectra(Spectrum spectraND[],
19  Spectrum spectraFD[],
20  Spectrum spectraSt[],
21  Spectrum spectraUn[],
22  TDirectory* rootOut, FILE* textOFS,
23  std::string name, std::string title, int POT,
24  std::string option = "");
25 
26  void PlotSpectra(Spectrum spectraND[],
27  Spectrum spectraFD[],
28  Spectrum spectraFS[],
29  TDirectory* rootOut, FILE* textOFS,
30  std::string name, std::string title, int POT,
31  std::string option = "");
32 
33  void PlotSpectra(IDecomp* decomp,
34  IPrediction* predFD, osc::IOscCalc* calc,
35  IPrediction* predSt, osc::IOscCalc* calcst,
36  Spectrum sCos,
37  TDirectory* rootOut, FILE* textOFS,
38  std::string name, std::string title, int POT,
39  std::string option = "");
40 
41  void PlotSpectra(IDecomp* decomp,
42  IPrediction* predFD,
43  Spectrum sCos,
44  TDirectory* rootOut, FILE* textOFS,
45  std::string name, std::string title, int POT,
46  std::string option = "");
47 
48  void PlotSpectra(IPrediction* predFD, Spectrum sCos, osc::IOscCalc* calc,
49  TDirectory* rootOut, FILE* textOFS,
50  std::string name, std::string title, int POT,
51  std::string option = "");
52 
53  void PlotPurEff(Spectrum pureff[], Spectrum effcyD[],
54  TDirectory* out, std::string name, std::string title);
55 
56  void PlotPurEff(Spectrum pureffND[], Spectrum effcyDND[],
57  Spectrum pureffFD[], Spectrum effcyDFD[],
58  Spectrum pureffFS[], Spectrum effcyDFS[],
59  TDirectory* out, std::string name, std::string title);
60 
61  Make2DFrom1D functions may be deprecated from 2D Spectrum functionality improvements
62  I haven't audited those changes and how they affect these functions yet, however
63 
64  void Make2DFrom1D(Spectrum spectra[],
65  const Binning& binsX, const Binning& binsY,
66  TDirectory* rootOut,
67  std::string name, std::string det,
68  std::string labelX, std::string labelY,
69  std::string option = "");
70 
71  void Make2DFrom1D(Spectrum spectraND[], Spectrum spectraFD[], Spectrum spectraFS[],
72  const Binning& binsX, const Binning& binsY,
73  TDirectory* rootOut,
74  std::string name,
75  std::string labelX, std::string labelY,
76  std::string option = "");
77 */
78 #pragma once
79 
80 #include <cmath>
81 #include <iostream>
82 #include <stdio.h>
83 #include <string>
84 
85 #include "TArrow.h"
86 #include "TCanvas.h"
87 #include "TColor.h"
88 #include "TDirectory.h"
89 #include "TFile.h"
90 #include "TH1.h"
91 #include "TH2D.h"
92 #include "THStack.h"
93 #include "TLatex.h"
94 #include "TLegend.h"
95 #include "TLine.h"
96 #include "TMath.h"
97 
98 #include "CAFAna/Analysis/Calcs.h"
100 #include "CAFAna/Analysis/Style.h"
101 #include "CAFAna/Core/Binning.h"
102 #include "CAFAna/Core/Cut.h"
103 #include "CAFAna/Core/Loaders.h"
104 #include "CAFAna/Core/Spectrum.h"
105 #include "CAFAna/Cuts/Cuts.h"
106 #include "NuXAna/Cuts/NusCuts.h"
107 #include "CAFAna/Cuts/TruthCuts.h"
108 #include "CAFAna/Decomp/IDecomp.h"
110 #include "CAFAna/Vars/Vars.h"
111 
112 #include "OscLib/IOscCalc.h"
113 #include "OscLib/OscCalcPMNSOpt.h"
114 
115 #include "Utilities/func/MathUtil.h"
116 #include "Utilities/rootlogon.C"
117 
118 #define MAXSPEC 6
119 // Put a "NOvA Preliminary" tag in the corner
120 
121 namespace ana
122 {
123  std::vector<std::string> flavors{"All", "NC", "NuMu", "NuE", "Cos"};
124 
125  static double NCSCALE = 9e20;
126 
127  struct PlotOptions {
128  int ndiv;
129  double xL;
130  double xR;
131  double yB;
132  double yT;
133  double texX;
134  double texY;
135 
136  double cutL;
137  double cutR;
138  };
139 
140  /// Draw common TLatex lines
141  TLatex* DrawLatexLines(double x, double y, std::string sPOT)
142  {
143  TLatex *tex = new TLatex();
144  tex->SetNDC();
145  tex->SetTextFont(42);
146  tex->SetTextSize(0.037);
147  tex->SetTextAlign(11);
148 
149  std::string potStr = sPOT + " #times 10^{20} POT-equiv.";
150 
151  tex->DrawLatex(x, y, "#Deltam^{2}_{32} = 2.44x10^{-3} eV^{2}");
152  tex->DrawLatex(x, y - 0.055, "#theta_{13} = 8.5#circ, ^{}#theta_{23} = 45#circ");
153  tex->DrawLatex(x, y - 0.110, potStr.c_str());
154 
155  return tex;
156  }
157 
158  //......................................................................
159 
160  /// Draw a dashed line and an arrow where a cut is made
161  /// \param cut The point at which the cut is made
162  /// \param left Bool to determine whether arrow should start at left and move right (true)
163  /// or start at right and move left (false)
164  void DrawLineArrow(double cut, bool left, TH1* h)
165  {
166  double axLen = h->GetXaxis()->GetXmax() - h->GetXaxis()->GetXmin();
167  double ayTop = h->GetMaximum();
168  double delta = axLen/20.;
169  if(!left) { delta *= -1.; }
170  TLine* line = new TLine(cut, 0, cut, ayTop);
171  TArrow* arrow = new TArrow(cut, ayTop*0.95,
172  cut + delta, ayTop*0.95,
173  0.02, "|>");
174  line->SetLineColor(kRed);
175  line->SetLineStyle(2);
176  line->SetLineWidth(3);
177  line->Draw("same");
178 
179  arrow->SetFillColor(kRed);
180  arrow->SetFillStyle(1001);
181  arrow->SetLineColor(kRed);
182  arrow->SetLineWidth(3);
183  arrow->Draw();
184  }
185 
186  //......................................................................
187 
188  /// Set common options for a TLegend
189  void SetHistOptions(TH1* h, double max, std::string title,
190  int ndiv, Color_t col, bool fill)
191  {
192  CenterTitles(h);
193  h->SetLineColor(col);
194  if(fill) {
195  FillWithDimColor(h);
196  }
197  h->SetMinimum(0);
198  h->SetMaximum(max*1.05);
199  if(ndiv) { h->GetXaxis()->SetNdivisions(ndiv); }
200  h->SetTitle(title.c_str());
201  }
202 
203  //......................................................................
204 
205  /// Set common options for a TLegend
206  void SetLegendOptions(TLegend* leg)
207  {
208  leg->SetBorderSize(0);
209  leg->SetFillColor(kWhite);
210  leg->SetFillStyle(0);
211  leg->SetFillStyle(0);
212  leg->SetTextFont(42);
213  leg->SetTextSize(0.037);
214  }
215 
216  //......................................................................
217  void PlotStack(Spectrum spectra[], TDirectory* rootOut, FILE* textOFS,
219  double POT, double potEquiv,
220  PlotOptions opt, Spectrum* dataspec)
221  {
222  char pot[4];
223  sprintf(pot, "%4.2f", potEquiv);
224  std::string spot = std::string(pot);
225  std::string potStr = spot + " #times 10^{20} POT-equiv.";
226  std::string NDpotStr = spot + " #times 10^{20} POT";
227 
228  std::cout << "POT: " << POT << std::endl;
229  // Get each histogram from the Spectrum array
230  TH1* hAll = spectra[0].ToTH1(POT);
231  TH1* hNC = spectra[1].ToTH1(POT);
232  TH1* hNumu = spectra[2].ToTH1(POT);
233  TH1* hNue = spectra[3].ToTH1(POT);
234  TH1* hNutau = spectra[4].ToTH1(POT);
235  TH1* hCos = spectra[5].ToTH1(POT);
236  // The default for these inputs are nullptr, only get a TH1 if they exist
237  TH1* hData = (dataspec ? dataspec->ToTH1(dataspec->POT()) : nullptr);
238 
239  // Create the title and axis labels, which is an empty title,
240  // the x label from an input Spectrum, and Events/POT
241  std::string fullname = det + name;
242  std::string xLabel(hNC->GetXaxis()->GetTitle());
243  if(name.find("PTP") != std::string::npos) { xLabel = "p_{T}/p"; }
244  if(name.find("CVN") != std::string::npos) { xLabel = "CVN NC Classifier"; }
245  std::string yLabel = (det.compare("ND") == 0 ? "10^{3} Events": "Events");
246  if(det.compare("FD") == 0){
247  if(name.find("CalE") != std::string::npos ||
248  name.find("ECal") != std::string::npos) { yLabel += " / 0.25 GeV"; }
249  }
250 
251  if(det.compare("ND") == 0){
252  if(name.find("CalE") != std::string::npos ||
253  name.find("ECal") != std::string::npos) { yLabel += " / 0.25 GeV / "+NDpotStr; }
254  else{
255  yLabel += " / "+NDpotStr;
256  }
257  }
258  std::string histTitle = ";" + xLabel + ";" + yLabel;
259 
260  // Print the column title and headers
261  fprintf(textOFS, "Event numbers at the %2.2s for %s %.2fe20 POT-equiv.:\n", det.c_str(), name.c_str(), potEquiv);
262  if(hData) { fprintf(textOFS, "%12.12s, ", "Data"); }
263  else { fprintf(textOFS, "%14.14s", ""); }
264  fprintf(textOFS, "%12.12s, %12.12s, %12.12s, %12.12s, %12.12s, %12.12s\n",
265  "All", "NC (3 Flav)", "Numu", "Nue", "Cosmic", "FOM");
266 
267  // Get the integral number of events, then print them
268  double nAll = hAll ->Integral();
269  double nNC3F = hNC ->Integral();
270  double nNumu = hNumu->Integral();
271  double nNue = hNue ->Integral();
272  double nCos = hCos ->Integral();
273  double fom = nNC3F/sqrt(nAll);
274  if(hData) {
275  double nData = hData->Integral(1, hData->GetNbinsX());
276  fprintf(textOFS, "%10E, ", nData);
277  }
278  else {
279  fprintf(textOFS, "%14.14s", "");
280  }
281  fprintf(textOFS, "%10E, %10E, %10E, %10E, %10E, %10E\n\n",
282  nAll, nNC3F, nNumu, nNue, nCos, fom);
283 
284  int ndiv = opt.ndiv;
285 
286  // Create "stacked" copies of flavored histograms
287  // Cos Stack = Cos
288  TH1* hCosStack = (TH1*)hCos->Clone();
289 
290  // Numu Stack = Cos Stack + Numu = Cos + Numu
291  TH1* hNumuStack = (TH1*)hCosStack->Clone();
292  hNumuStack->Add(hNumu);
293 
294  // Nue Stack = Numu Stack + Nue = Cos + Numu + Nue
295  TH1* hNueStack = (TH1*)hNumuStack->Clone();
296  hNueStack->Add(hNue);
297 
298  // NC Stack = Nue Stack + NC = Cos + Numu + Nue + NC
299  TH1* hNCStack = (TH1*)hNueStack->Clone();
300  hNCStack->Add(hNC);
301 
302  // Manually set errors, and calculate the max value (including errors)
303  double maxval = hAll->GetBinContent(hAll->GetMaximumBin());
304  for(int i = 1, n = hNC->GetNbinsX(); i <= n; ++i) {
305  double error = sqrt(hNC->GetBinContent(i));
306  //hNC ->SetBinError(i, error);
307  //hNCStack->SetBinError(i, error);
308  if(hData) {
309  double data_value = hData->GetBinContent(i);
310  double data_error = sqrt(data_value);
311  //hData->SetBinError(i, data_error);
312  maxval = std::max(maxval, data_value + data_error);
313  }
314  }
315 
316  // Scale down the ND by 10e3 (don't forget the max values!)
317  if(det.compare("ND") == 0) {
318  double ndScale = 1./1000.;
319  hAll ->Scale(ndScale);
320  hNC ->Scale(ndScale);
321  hNue ->Scale(ndScale);
322  hNumu->Scale(ndScale);
323  hNCStack ->Scale(ndScale);
324  hNueStack ->Scale(ndScale);
325  hNumuStack->Scale(ndScale);
326  maxval *= ndScale;
327  if(hData) { hData->Scale(ndScale); }
328  }
329 
330  // Stylize the unstacked plots
331  const Color_t kCosmicBackgroundColor = kOrange+7;
332  SetHistOptions(hNue, maxval, histTitle, ndiv, kNueSignalColor, false);
333  SetHistOptions(hNumu, maxval, histTitle, ndiv, kNumuBackgroundColor, false);
334  SetHistOptions(hNC, maxval, histTitle, ndiv, kNCBackgroundColor, false);
335  SetHistOptions(hCos, maxval, histTitle, ndiv, kCosmicBackgroundColor, false);
336  SetHistOptions(hAll, maxval, histTitle, ndiv, kTotalMCColor, false);
337  if(hData) { SetHistOptions(hData, maxval, histTitle, ndiv, kBlack, false); }
338 
339  if(name.find("CosBDT") != std::string::npos) {
340  hAll ->GetXaxis()->SetRangeUser(0.31, 0.7);
341  hNC ->GetXaxis()->SetRangeUser(0.31, 0.7);
342  hNumu->GetXaxis()->SetRangeUser(0.31, 0.7);
343  hNue ->GetXaxis()->SetRangeUser(0.31, 0.7);
344  hCos ->GetXaxis()->SetRangeUser(0.31, 0.7);
345  hNCStack ->GetXaxis()->SetRangeUser(0.31, 0.7);
346  hNueStack ->GetXaxis()->SetRangeUser(0.31, 0.7);
347  hNumuStack->GetXaxis()->SetRangeUser(0.31, 0.7);
348  hCosStack ->GetXaxis()->SetRangeUser(0.31, 0.7);
349  if(hData) { hData->GetXaxis()->SetRangeUser(0.31, 0.7); }
350  }
351 
352  if(hData) { hData->SetMarkerStyle(kFullCircle); }
353 
354  // Stylize the stacked plots
355  SetHistOptions(hNueStack, maxval, histTitle, ndiv, kNueSignalColor, true);
356  SetHistOptions(hNumuStack, maxval, histTitle, ndiv, kNumuBackgroundColor, true);
357  SetHistOptions(hNCStack, maxval, histTitle, ndiv, kNCBackgroundColor, true);
358  SetHistOptions(hCosStack, maxval, histTitle, ndiv, kCosmicBackgroundColor, true);
359 
360  std::string dataleg = ( (det.compare("ND") == 0) ? "ND Data" : "FD Data" );
361 
362  // Create a canvas for and draw the unstacked histograms
363  TCanvas* c = new TCanvas(fullname.c_str(), fullname.c_str(), 800, 500);
364  gPad->SetFillStyle(0);
365 
366  // Create a legend for the unstacked histograms
367  double xL = opt.xL, xR = opt.xR, yB = opt.yB, yT = opt.yT;
368  TLegend* leg = new TLegend(xL, yB, xR, yT);
369  SetLegendOptions(leg);
370  if(hData) { leg->AddEntry(hData, dataleg.c_str(), "lp"); }
371  leg->AddEntry(hAll, "Total Prediction", "l");
372  leg->AddEntry(hNC, "NC 3 Flavor Prediction", "l");
373  leg->AddEntry(hNue, "#nu_{e} CC Background", "l");
374  leg->AddEntry(hNumu, "#nu_{#mu} CC Background", "l");
375  if(det.compare("FD") == 0) {
376  leg->AddEntry(hCos, "Cosmic Background", "l");
377  }
378  leg->SetY1(leg->GetY2() - leg->GetNRows()*0.05);
379  if(std::abs(opt.texX - xL) < 0.2) { opt.texY = leg->GetY1() - 0.045; }
380 
381  hNue ->Draw("hist");
382  hNumu->Draw("hist same");
383  if(det.compare("FD") == 0) { hCos->Draw("hist same"); }
384  hAll ->Draw("hist same");
385  hNC ->Draw("hist same");
386  if(hData) { hData->Draw("same"); }
387  if(opt.cutL != 1.) { DrawLineArrow(opt.cutL, true, hNue); }
388  if(opt.cutR != 0.) { DrawLineArrow(opt.cutR, false, hNue); }
389  leg->Draw();
390  if(det.compare("FD") == 0) { DrawLatexLines(opt.texX, opt.texY, spot); }
391 
392  gPad->RedrawAxis();
393  if(hData) { Preliminary(); }
394  else { Simulation(); }
395 
396  // Save the canvas
397  rootOut->WriteTObject(c);
398 
399  // Create a canvas for and draw the stacked histograms
400  fullname += "Stack";
401  TCanvas* cStack = new TCanvas(fullname.c_str(), fullname.c_str(), 800, 500);
402  gPad->SetFillStyle(0);
403 
404  TLegend* legStack = new TLegend(xL, yB, xR, yT);
405  SetLegendOptions(legStack);
406  if(hData) { legStack->AddEntry(hData, dataleg.c_str(), "lp"); }
407  legStack->AddEntry(hNCStack, "NC 3 Flavor Prediction", "f");
408  legStack->AddEntry(hNueStack, "#nu_{e} CC Background", "f");
409  legStack->AddEntry(hNumuStack, "#nu_{#mu} CC Background", "f");
410  if(det.compare("FD") == 0) {
411  legStack->AddEntry(hCosStack, "Cosmic Background", "f");
412  }
413  legStack->SetY1(legStack->GetY2() - legStack->GetNRows()*0.05);
414  if(std::abs(opt.texX - xL) < 0.2) { opt.texY = leg->GetY1() - 0.045; }
415 
416  hNCStack ->Draw("hist");
417  hNueStack ->Draw("hist same");
418  hNumuStack->Draw("hist same");
419  if(det.compare("FD") == 0) { hCosStack->Draw("hist same"); }
420  if(hData) { hData->Draw("same"); }
421  if(opt.cutL != 1.) { DrawLineArrow(opt.cutL, true, hNCStack); }
422  if(opt.cutR != 0.) { DrawLineArrow(opt.cutR, false, hNCStack); }
423  legStack->Draw();
424  if(det.compare("FD") == 0) { DrawLatexLines(opt.texX, opt.texY, spot); }
425  gPad->RedrawAxis();
426  if(hData) { Preliminary(); }
427  else { Simulation(); }
428 
429  rootOut->WriteTObject(cStack);
430 
431  return;
432  }
433 
434  //......................................................................
435 
436  /// Function for NuS group to plot spectra
437  /// You probably won't call this version directly,
438  /// but here are the parameters commmon to all versions:
439  /// \param spectra Array of spectra, should match the output of the SPECARR macro
440  /// \param rootOut Already open file for root output
441  /// \param textOFS Already open filestream for text output
442  /// \param name A name for the output, only part of the saved output object's name
443  /// \param title Title for the histograms. Typically this is the x axis label
444  /// \param det The detector the spectra correspond to, should be 2 chars long for nice formatting
445  /// \param POT INTEGER number of POT, in units of e20, i.e., a value of 6 means 6e20
446  /// \param option Additional options; see the function definition for its uses
447  void PlotSpectra(Spectrum spectra[], TDirectory* rootOut, FILE* textOFS,
448  std::string name, std::string title, std::string det, int POT,
449  std::string option)
450  {
451  // The input is in units of 1e20, turn this into the real scale
452  double realPOT = (double)POT*1e20;
453  double livetime = realPOT/2.5e18;
454 
455  char potBuff[2];
456  sprintf(potBuff, "%d", POT);
457  std::string spot = std::string(potBuff);
458  std::string potStr = spot + " #times 10^{20} POT";
459 
460  // Get each histogram from the Spectrum array
461  TH1* hAll = spectra[0].ToTH1(realPOT);
462  TH1* hNC = spectra[1].ToTH1(realPOT);
463  TH1* hNumu = spectra[2].ToTH1(realPOT);
464  TH1* hNue = spectra[3].ToTH1(realPOT);
465  TH1* hCos = spectra[4].ToTH1(livetime, kLivetime);
466 
467  // Create the title and axis labels, which is an empty title,
468  // the x label from an input Spectrum, and Events/POT
469  std::string xLabel(hAll->GetXaxis()->GetTitle());
470  std::string yLabel = (det.compare("ND") == 0 ? "10^{3} Events" : "Event");
471  std::string histTitle = ";" + xLabel + ";" + yLabel;
472 
473  if(option.find("label") != std::string::npos) {
474  fprintf(textOFS, " %12.12s, %12.12s, %8.8s, %12.12s, %12.12s, %12.12s, %12.12s\n",
475  "NC", "All", "Numu", "Nue", "Cosmic", "Purity", "FOM");
476  }
477 
478  double nNC = hNC ->Integral();
479  double nAll = hAll->Integral();
480  double nNumu = hNumu->Integral();
481  double nNue = hNue ->Integral();
482  double nCos = hCos->Integral();
483  double fom = nNC/sqrt(nAll);
484  fprintf(textOFS, "%2.2s -- %10E, %10E, %10E, %10E, %10E, %.6f, %10E\n",
485  det.c_str(), nNC, nAll, nNumu, nNue, nCos, nNC/nAll, fom);
486 
487  // Create "stacked" copies of flavored histograms
488  // Cos Stack = Cos
489  TH1* hCosStack = (TH1*)hCos->Clone();
490 
491  // Numu Stack = Cos Stack + Numu = Cos + Numu
492  TH1* hNumuStack = (TH1*)hCosStack->Clone();
493  hNumuStack->Add(hNumu);
494 
495  // Nue Stack = Numu Stack + Nue = Cos + Numu + Nue
496  TH1* hNueStack = (TH1*)hNumuStack->Clone();
497  hNueStack->Add(hNue);
498 
499  // NC Stack = Nue Stack + NC = Cos + Numu + Nue + NC
500  TH1* hNCStack = (TH1*)hNueStack->Clone();
501  hNCStack->Add(hNC);
502 
503  // Manually set errors, and calculate the max value (including errors)
504  double maxval = 0.;
505  double maxvalstack = 0.;
506  for(int i = 1, n = hNC->GetNbinsX(); i <= n; ++i) {
507  double error = sqrt(hNC->GetBinContent(i));
508  //hNC ->SetBinError(i, error);
509  //hNCStack->SetBinError(i, error);
510  maxval = std::max(maxval, std::max(hAll->GetBinContent(i), hNC->GetBinContent(i) + error));
511  maxvalstack = std::max(maxvalstack, hNCStack->GetBinContent(i) + error);
512  }
513 
514  if(det.compare("ND") == 0) {
515  double ndScale = 1./1000.;
516  hAll ->Scale(ndScale);
517  hNC ->Scale(ndScale);
518  hNumu->Scale(ndScale);
519  hNue ->Scale(ndScale);
520  hCos ->Scale(ndScale);
521  hNCStack ->Scale(ndScale);
522  hNueStack ->Scale(ndScale);
523  hNumuStack->Scale(ndScale);
524  maxval *= ndScale;
525  maxvalstack *= ndScale;
526  }
527 
528  if(option.find("logy") != std::string::npos) {
529  maxval = maxval*2/1.05;
530  maxvalstack = maxvalstack*2/1.05;
531  }
532 
533  const Color_t kCosmicBackgroundColor = kOrange+7;
534  SetHistOptions(hAll, maxval, histTitle, -404, kTotalMCColor, false);
535  SetHistOptions(hNC, maxval, histTitle, -404, kNCBackgroundColor, false);
536  SetHistOptions(hNue, maxval, histTitle, -404, kNueSignalColor, false);
537  SetHistOptions(hNumu, maxval, histTitle, -404, kNumuBackgroundColor, false);
538  SetHistOptions(hCos, maxval, histTitle, -404, kCosmicBackgroundColor, false);
539 
540  // Stylize the stacked plots
541  SetHistOptions(hNCStack, maxval, histTitle, -404, kNCBackgroundColor, true);
542  SetHistOptions(hNueStack, maxval, histTitle, -404, kNueSignalColor, true);
543  SetHistOptions(hNumuStack, maxval, histTitle, -404, kNumuBackgroundColor, true);
544  SetHistOptions(hCosStack, maxval, histTitle, -404, kCosmicBackgroundColor, true);
545 
546  if(option.find("logy") != std::string::npos) {
547  hAll ->SetMinimum(0.001);
548  hNC ->SetMinimum(0.001);
549  hNumu->SetMinimum(0.001);
550  hNue ->SetMinimum(0.001);
551  hCos ->SetMinimum(0.001);
552  hNCStack ->SetMinimum(0.001);
553  hNumuStack->SetMinimum(0.001);
554  hNueStack ->SetMinimum(0.001);
555  hCosStack ->SetMinimum(0.001);
556  }
557 
558  double xL = 0.5, xR = 0.7, yB = 0.64, yT = 0.84;
559 
560  if(option.find("area") != std::string::npos) {
561  TLegend* leg = new TLegend(xL, yB, xR, yT);
562  leg->AddEntry(hNC, "NC Signal", "L");
563  leg->AddEntry(hNue, "#nu_{e} CC Background", "L");
564  leg->AddEntry(hNumu, "#nu_{#mu} CC Background", "L");
565  if(det.compare("ND") != 0) { leg->AddEntry(hCos, "Cosmic Background", "L"); }
566  leg->SetY1(leg->GetY2() - leg->GetNRows()*0.05);
567 
568  hNC ->Scale(1./nNC);
569  hNumu->Scale(1./nNumu);
570  hNue ->Scale(1./nNue);
571  if(nCos > 0.) { hCos->Scale(1./nCos); }
572 
573  double maxval = 0.;
574  maxval = std::max(maxval, hNC ->GetBinContent(hNC ->GetMaximumBin()));
575  maxval = std::max(maxval, hNumu->GetBinContent(hNumu->GetMaximumBin()));
576  maxval = std::max(maxval, hNue ->GetBinContent(hNue ->GetMaximumBin()));
577  maxval = std::max(maxval, hCos ->GetBinContent(hCos ->GetMaximumBin()));
578 
579  maxval *= 1.1;
580  hNC ->SetMaximum(maxval);
581  hNumu->SetMaximum(maxval);
582  hNue ->SetMaximum(maxval);
583  hCos ->SetMaximum(maxval);
584 
585  TCanvas* c = new TCanvas(name.c_str(), title.c_str(), 800, 500);
586  gPad->SetFillStyle(0);
587  hNC ->Draw("hist");
588  hNumu->Draw("hist same");
589  hNue ->Draw("hist same");
590  if(det.compare("ND") != 0) { hCos ->Draw("hist same"); }
591  leg->Draw();
592 
593  Simulation();
594 
595  rootOut->WriteTObject(c);
596 
597  return;
598  }
599 
600  // Create a legend for the histograms
601  TLegend* leg = new TLegend(xL, yB, xR, yT);
602  SetLegendOptions(leg);
603  leg->AddEntry(hAll, "Total Prediction", "l");
604  if(option.find("hist") != std::string::npos) {
605  leg->AddEntry(hNC, "NC Prediction", "l");
606  }
607  else {
608  leg->AddEntry(hNC, "NC Prediction", "le");
609  }
610  leg->AddEntry(hNue, "#nu_{e} CC Background", "l");
611  leg->AddEntry(hNumu, "#nu_{#mu} CC Background", "l");
612  if(det.compare("ND") != 0) {
613  leg->AddEntry(hCos, "Cosmic Background", "l");
614  }
615  leg->SetY1(leg->GetY2() - leg->GetNRows()*0.05);
616 
617  TLegend* legStack = new TLegend(xL, yB, xR, yT);
618  SetLegendOptions(legStack);
619  if(option.find("hist") != std::string::npos) {
620  legStack->AddEntry(hNCStack, "NC Prediction", "f");
621  }
622  else {
623  legStack->AddEntry(hNCStack, "NC Prediction", "le");
624  }
625  legStack->AddEntry(hNueStack, "#nu_{e} CC Background", "f");
626  legStack->AddEntry(hNumuStack, "#nu_{#mu} CC Background", "f");
627  if(det.compare("ND") != 0) {
628  legStack->AddEntry(hCosStack, "Cosmic Background", "f");
629  }
630  legStack->SetY1(legStack->GetY2() - legStack->GetNRows()*0.05);
631 
632  // Create a canvas
633  TCanvas* c = new TCanvas(name.c_str(), title.c_str(), 800, 500);
634  gPad->SetFillStyle(0);
635 
636  hNue ->Draw("hist");
637  hNumu->Draw("hist same");
638  if(det.compare("ND") != 0) { hCos ->Draw("hist same"); }
639 
640  if(option.find("hist") != std::string::npos) { hNC->Draw("hist same"); }
641  else { hNC->Draw("same"); }
642 
643  hAll ->Draw("hist same");
644  leg->Draw();
645  if(det.compare("FD") == 0) { DrawLatexLines(xL + .025, leg->GetY1() - 0.045, spot); }
646  if(option.find("logy") != std::string::npos) { c->SetLogy(); }
647 
648  Simulation();
649  rootOut->WriteTObject(c);
650 
651  TCanvas* cStack = new TCanvas((name + "Stack").c_str(), title.c_str(), 800, 500);
652  gPad->SetFillStyle(0);
653 
654  hNueStack ->Draw("hist");
655  hNumuStack->Draw("hist same");
656  if(det.compare("ND") != 0) { hCosStack ->Draw("hist same"); }
657 
658  if(option.find("hist") != std::string::npos) { hNCStack->Draw("hist same"); }
659  else { hNCStack->Draw("same"); }
660 
661  legStack->Draw();
662  if(det.compare("FD") == 0) { DrawLatexLines(xL + .025, legStack->GetY1() - 0.045, spot); }
663  if(option.find("logy") != std::string::npos) { cStack->SetLogy(); }
664 
665  Simulation();
666 
667  // Save the canvas
668  rootOut->WriteTObject(cStack);
669 
670  return;
671  }
672 
673  //......................................................................
674 
675  /// Make canvases for ND, FD with 3 flavor osc, FD with 4 flavor osc, FD with no osc
676  void PlotSpectra(Spectrum spectraND[],
677  Spectrum spectraFD[],
678  Spectrum spectraSt[],
679  Spectrum spectraUn[],
680  TDirectory* rootOut, FILE* textOFS,
681  std::string name, std::string title, int POT,
682  std::string option)
683  {
684  fprintf(textOFS, "%s\n", name.c_str());
685 
686  std::string label = "ND " + title;
687  std::string fullname = name + "ND";
688  std::string fulloption = option + "label";
689  PlotSpectra(spectraND, rootOut, textOFS, fullname, label, "ND", POT, fulloption);
690 
691  label = "FD " + title;
692  fullname = name + "FD";
693  PlotSpectra(spectraFD, rootOut, textOFS, fullname, label, "FD", POT, option);
694 
695  label = "FD (sterile) " + title;
696  fullname = name + "St";
697  PlotSpectra(spectraSt, rootOut, textOFS, fullname, label, "St", POT, option);
698 
699  label = "FD (Unoscillated) " + title;
700  fullname = name + "Un";
701  PlotSpectra(spectraUn, rootOut, textOFS, fullname, label, "Un", POT, option);
702 
703  fprintf(textOFS, "\n\n");
704 
705  return;
706  }
707 
708  //......................................................................
709 
710  /// Make canvases for ND, FD with 3 flavor orsc, FD with 4 flavor osc
711  void PlotSpectra(Spectrum spectraND[],
712  Spectrum spectraFD[],
713  Spectrum spectraFS[],
714  TDirectory* rootOut, FILE* textOFS,
715  std::string name, std::string title, int POT,
716  std::string option)
717  {
718  fprintf(textOFS, "%s\n", name.c_str());
719 
720  std::string label = "ND " + title;
721  std::string fullname = name + "ND";
722  std::string fulloption = option + "label";
723  PlotSpectra(spectraND, rootOut, textOFS, fullname, label, "ND", POT, fulloption);
724 
725  label = "FD " + title;
726  fullname = name + "FD";
727  PlotSpectra(spectraFD, rootOut, textOFS, fullname, label, "FD", POT, option);
728 
729  label = "FD (swap) " + title;
730  fullname = name + "FS";
731  PlotSpectra(spectraFS, rootOut, textOFS, fullname, label, "FS", POT, option);
732 
733  fprintf(textOFS, "\n\n");
734 
735  return;
736  }
737 
738  //......................................................................
739 
740  /// Make canvases for ND, FD with 3 flavor osc, FD with 4 flavor osc, FD with no osc
741  /// Directly use the CAFAna object inputs
742  void PlotSpectra(IDecomp* decomp,
743  IPrediction* predFD, osc::IOscCalc* calc,
744  IPrediction* predSt, osc::IOscCalc* calcst,
745  Spectrum sCos,
746  TDirectory* rootOut, FILE* textOFS,
747  std::string name, std::string title, int POT,
748  std::string option)
749  {
750  Spectrum empty = decomp->NCTotalComponent();
751  empty.Clear();
752 
753  if(!sCos.POT()) {
754  sCos.OverridePOT(sCos.Livetime()*2.5e18);
755  }
756 
757  Spectrum spectraND[MAXSPEC] = {
758  decomp->NCTotalComponent() +
759  decomp->NueComponent() + decomp->AntiNueComponent() +
760  decomp->NumuComponent() + decomp->AntiNumuComponent(),
761  decomp->NCTotalComponent(),
762  decomp->NumuComponent() + decomp->AntiNumuComponent(),
763  decomp->NueComponent() + decomp->AntiNueComponent(),
764  empty,
765  empty
766  };
767 
768  Spectrum spectraFD[MAXSPEC] = {
769  predFD->Predict(calc) + sCos,
774  sCos
775  };
776 
777  Spectrum spectraSt[MAXSPEC] = {
778  predSt->Predict(calcst) + sCos,
783  sCos
784  };
785 
787 
788  Spectrum spectraUn[MAXSPEC] = {
789  predFD->Predict(&noosc) + sCos,
794  sCos
795  };
796 
797  PlotSpectra(spectraND, spectraFD, spectraSt, spectraUn,
798  rootOut, textOFS, name, title, POT, option);
799 
800  return;
801  }
802 
803  //......................................................................
804 
805  /// Make canvases for ND, FD with 3 flavor osc, FD with no osc
806  /// Directly use the CAFAna object inputs
807  void PlotSpectra(IDecomp* decomp,
808  IPrediction* predFD,
809  Spectrum sCos,
810  TDirectory* rootOut, FILE* textOFS,
811  std::string name, std::string title, int POT,
812  std::string option)
813  {
814  Spectrum empty = decomp->NCTotalComponent();
815  empty.Clear();
816 
817  if(!sCos.POT()) {
818  sCos.OverridePOT(sCos.Livetime()*2.5e18);
819  }
820 
821  Spectrum spectraND[MAXSPEC] = {
822  decomp->NCTotalComponent() +
823  decomp->NumuComponent() + decomp->AntiNumuComponent() +
824  decomp->NueComponent() + decomp->AntiNueComponent(),
825  decomp->NCTotalComponent(),
826  decomp->NumuComponent() + decomp->AntiNumuComponent(),
827  decomp->NueComponent() + decomp->AntiNueComponent(),
828  empty,
829  empty
830  };
831 
834  Spectrum spectraFD[MAXSPEC] = {
835  predFD->Predict(calc) + sCos,
840  sCos
841  };
842 
843  Spectrum spectraUn[MAXSPEC] = {
844  predFD->Predict(&noosc) + sCos,
849  sCos
850  };
851 
852  fprintf(textOFS, "%s\n", name.c_str());
853 
854  std::string label = "ND " + title;
855  std::string fullname = name + "ND";
856  std::string fulloption = option + "label";
857  PlotSpectra(spectraND, rootOut, textOFS, fullname, label, "ND", POT, fulloption);
858 
859  label = "FD " + title;
860  fullname = name + "FD";
861  PlotSpectra(spectraFD, rootOut, textOFS, fullname, label, "FD", POT, option);
862 
863  label = "FD (Unoscillated) " + title;
864  fullname = name + "Un";
865  PlotSpectra(spectraUn, rootOut, textOFS, fullname, label, "Un", POT, option);
866 
867  fprintf(textOFS, "\n\n");
868 
869  return;
870  }
871 
872  //......................................................................
873 
874  /// Make canvas for FD with 3 flavor osc directly from CAFAna object inputs
875  void PlotSpectra(IPrediction* predFD, Spectrum sCos, osc::IOscCalc* calc,
876  TDirectory* rootOut, FILE* textOFS,
877  std::string name, std::string title, int POT, std::string option)
878  {
879  fprintf(textOFS, "%s\n", name.c_str());
880 
881  if(!sCos.POT()) {
882  sCos.OverridePOT(sCos.Livetime()*2.5e18);
883  }
884 
885  Spectrum spectraFD[MAXSPEC] = {
886  predFD->Predict(calc) + sCos,
891  sCos
892  };
893 
894  PlotSpectra(spectraFD, rootOut, textOFS, name, title, "FD", POT, option);
895 
896  return;
897  }
898 
899  //......................................................................
900 
901  /// Function for NuS group to plot purity/efficiency
902  /// Purity is pureff[1]/pureff[0], Efficiency is pureff[1]/effcyD[1]
903  /// \param pureff[] array of spectra, should match the output of the SPECARR macro
904  /// \param effcyD[] array of spectra, should match the output of the SPECARR macro
905  /// \param out Already open file for root output
906  /// \param name A name for the output, only part of the saved output object's name
907  /// \param title Title for the histograms. Typically this is the x axis label
908  void PlotPurEff(Spectrum pureff[], Spectrum effcyD[],
909  TDirectory* out, std::string name, std::string title)
910  {
911  std::string fullname = name + "PurEff";
912  std::string fulltitle = title + " Purity and Efficiency";
913 
914  TH1* hpur = pureff[1].ToTH1(NCSCALE);
915  TH1* hpurD = pureff[0].ToTH1(NCSCALE);
916  hpur->Divide(hpurD);
917  TH1* heff = pureff[1].ToTH1(NCSCALE);
918  TH1* heffD = effcyD[1].ToTH1(NCSCALE);
919  heff->Divide(heffD);
920 
921  heff->SetLineColor(kRed);
922 
923  TH1* hnum = pureff[1].ToTH1(NCSCALE);
924  double numerator = 0., efcncyD = 0., purityD = 0.;
925  for(int i = 1, n = hnum->GetNbinsX(); i <= n; ++i) {
926  numerator += hnum->GetBinContent(i);
927  efcncyD += heffD->GetBinContent(i);
928  purityD += hpurD->GetBinContent(i);
929  }
930  double efcncy = numerator/efcncyD;
931  double purity = numerator/purityD;
932  std::cout << title << " Efficiency, Purity: " << efcncy << ", " << purity << std::endl;
933 
934  TLegend* leg = new TLegend(0.5, 0.8, 0.8, 0.9);
935  leg->AddEntry(hpur, "Purity", "L");
936  leg->AddEntry(heff, "Efficiency", "L");
937 
938  TCanvas* c = new TCanvas(fullname.c_str(), fulltitle.c_str(), 800, 500);
939  gPad->SetFillStyle(0);
940  if(hpur->GetBinContent(hpur->GetMaximumBin()) > heff->GetBinContent(heff->GetMaximumBin())) {
941  hpur->SetTitle(fulltitle.c_str());
942  hpur->Draw("hist");
943  heff->Draw("hist same");
944  }
945  else {
946  heff->SetTitle(fulltitle.c_str());
947  heff->Draw("hist");
948  hpur->Draw("hist same");
949  }
950 
951  leg->Draw();
952  out->WriteTObject(c);
953 
954  return;
955  }
956 
957  //......................................................................
958 
959  /// Plot pur/eff for ND, FD assuming 3 flavor osc, FD assuming 4 flavor osc
960  void PlotPurEff(Spectrum pureffND[], Spectrum effcyDND[],
961  Spectrum pureffFD[], Spectrum effcyDFD[],
962  Spectrum pureffFS[], Spectrum effcyDFS[],
963  TDirectory* out, std::string name, std::string title)
964  {
965  std::string label = "ND " + title;
966  std::string fullname = name + "ND";
967  PlotPurEff(pureffND, effcyDND, out, fullname, label);
968 
969  label = "FD " + title;
970  fullname = name + "FD";
971  PlotPurEff(pureffFD, effcyDFD, out, fullname, label);
972 
973  label = "FD (swap) " + title;
974  fullname = name + "FS";
975  PlotPurEff(pureffFS, effcyDFS, out, fullname, label);
976 
977  return;
978  }
979 
980  //......................................................................
981 
982  /// Function for NuS group to create output plots for 'pseudo-2D spectra'
983  /// spectra Array of spectra, should match the output of the SPECARR2D macro
984  /// \param binsX Binning that describes the desired x axis
985  /// \param binsY Binning that describes the desired y axis
986  /// \param rootOut Already open file for root output
987  /// \param name A name for the output, only part of the saved output object's name
988  /// \param det The detector the spectra correspond to, should be 2 chars long
989  /// \param labelX String for the x axis label
990  /// \param labelY String for the y axis label
991  /// \param option Additional options; see the function definition for its uses
992  void Make2DFrom1D(Spectrum spectra[],
993  const Binning& binsX, const Binning& binsY,
994  TDirectory* rootOut,
995  std::string name, std::string det,
996  std::string labelX, std::string labelY,
997  std::string option)
998  {
999  spectra[0] += spectra[MAXSPEC - 1];
1000 
1001  int NX = binsX.NBins();
1002  int NY = binsY.NBins();
1003 
1004  std::string titlehelper = det + " " + labelY + " vs " + labelX + ", ";
1005  std::string labelhelper = ";" + labelX + ";" + labelY;
1006  std::string fulltitle = titlehelper;
1007  std::string namehelper = name + det;
1008  std::string fullname = namehelper;
1009 
1010  std::vector<TH2*> h2;
1011 
1012  for(unsigned int i = 0, n = MAXSPEC; i < n; ++i) {
1013  h2.push_back(spectra[i].ToTH2(NCSCALE));
1014 
1015  fulltitle = titlehelper + flavors[i] + labelhelper;
1016  fullname = namehelper + flavors[i];
1017  h2[i]->SetNameTitle(fullname.c_str(), fulltitle.c_str());
1018 
1019  if(option.find("norm") != std::string::npos) {
1020  for(int i_x = 1; i_x <= NX; ++i_x) {
1021  double column_norm = 0.;
1022 
1023  for(int i_y = 1; i_y <= NY; ++i_y) {
1024  column_norm += h2[i]->GetBinContent(i_x, i_y);
1025  }
1026 
1027  for(int i_y = 1; i_y <= NY; ++i_y) {
1028  double h2bin = ( (column_norm > 0.) ? h2[i]->GetBinContent(i_x, i_y)/column_norm : 0. );
1029  h2[i]->SetBinContent(i_x, i_y, h2bin);
1030  }
1031  } // end of for loop over x bins
1032  }
1033  } // end of loop over component plots
1034 
1035  if(option.find("avg") != std::string::npos) {
1036  std::vector<TH1*> hp;
1037 
1038  fulltitle = titlehelper + labelhelper;
1039  fullname = namehelper;
1040 
1041  for(int i = 0, n = MAXSPEC; i < n; ++i) {
1042  hp.push_back(h2[i]->ProjectionX(fullname.c_str(), 1, NY));
1043 
1044  TAxis* ay = h2[i]->GetYaxis();
1045  for(int i_x = 1; i_x <= NX; ++i_x) {
1046  double weighted_val = 0.;
1047 
1048  for(int i_y = 1; i_y <= NY; ++i_y) {
1049  weighted_val += h2[i]->GetBinContent(i_x, i_y) * ay->GetBinCenter(i_y);
1050  }
1051 
1052  double val_norm = hp[i]->GetBinContent(i_x);
1053  hp[i]->SetBinContent(i_x, ((val_norm > 0.) ? weighted_val/val_norm : 0.));
1054  }
1055 
1056  hp[i]->SetTitle(fulltitle.c_str());
1057  }
1058 
1059  const Color_t kCosmicBackgroundColor = kOrange+1;
1060  hp[0]->SetLineColor(kTotalMCColor);
1061  hp[0]->SetLineStyle(2);
1062  hp[1]->SetLineColor(kNCBackgroundColor);
1063  hp[2]->SetLineColor(kNumuBackgroundColor);
1064  hp[3]->SetLineColor(kNueSignalColor);
1065  hp[4]->SetLineColor(kCosmicBackgroundColor);
1066 
1067  TLegend* leg = new TLegend(0.5, 0.7, 0.8, 0.9);
1068  double maxval = 0.;
1069 
1070  for(int i = 0, n = MAXSPEC; i < n; ++i) {
1071  leg->AddEntry(hp[i], flavors[i].c_str(), "L");
1072 
1073  if(hp[i]->GetBinContent(hp[i]->GetMaximumBin()) > maxval) {
1074  maxval = hp[i]->GetBinContent(hp[i]->GetMaximumBin());
1075  }
1076  }
1077 
1078  fulltitle = titlehelper;
1079  TCanvas* c = new TCanvas(fullname.c_str(), fulltitle.c_str(), 800, 500);
1080  gPad->SetFillStyle(0);
1081 
1082  maxval *= 1.1;
1083  hp[0]->SetMaximum(maxval);
1084  hp[0]->Draw("hist");
1085 
1086  for(int i = 1, n = MAXSPEC; i < n; ++i) {
1087  CenterTitles(hp[i]);
1088  hp[i]->SetMaximum(maxval);
1089  hp[i]->Draw("hist same");
1090  }
1091 
1092  leg->Draw();
1093 
1094  Simulation();
1095  rootOut->WriteTObject(c);
1096  }
1097  else {
1098  for(int i = 0, n = MAXSPEC; i < n; ++i) {
1099  fulltitle = titlehelper + flavors[i];
1100  fullname = namehelper + flavors[i];
1101 
1102  TCanvas* c = new TCanvas(fullname.c_str(), fulltitle.c_str(), 800, 500);
1103  gPad->SetFillStyle(0);
1104 
1105  CenterTitles(h2[i]);
1106  h2[i]->Draw("colz");
1107  Simulation();
1108 
1109  rootOut->WriteTObject(c);
1110  }
1111  }
1112 
1113  return;
1114  }
1115 
1116  //......................................................................
1117 
1118  /// Create output for 'pseudo-2D spectra' at ND, FD with 3 flavor osc, FD with 4 flavor osc
1119  void Make2DFrom1D(Spectrum spectraND[], Spectrum spectraFD[], Spectrum spectraFS[],
1120  const Binning& binsX, const Binning& binsY,
1121  TDirectory* rootOut,
1122  std::string name,
1123  std::string labelX, std::string labelY,
1124  std::string option)
1125  {
1126  Make2DFrom1D(spectraND, binsX, binsY, rootOut, name, "ND", labelX, labelY, option);
1127  Make2DFrom1D(spectraFD, binsX, binsY, rootOut, name, "FD", labelX, labelY, option);
1128  Make2DFrom1D(spectraFS, binsX, binsY, rootOut, name, "FS", labelX, labelY, option);
1129  }
1130 }
1131 //#endif
void PlotStack(Spectrum spectra[], TDirectory *rootOut, FILE *textOFS, std::string name, std::string det, double POT, double potEquiv, PlotOptions opt, Spectrum *dataspec)
void Simulation()
Definition: tools.h:16
void SetHistOptions(TH1 *h, double max, std::string title, int ndiv, Color_t col, bool fill)
Set common options for a TLegend.
T max(const caf::Proxy< T > &a, T b)
const XML_Char * name
Definition: expat.h:151
enum BeamMode kOrange
Pass neutrinos through unchanged.
Definition: IOscCalc.h:45
TLatex * DrawLatexLines(double x, double y, std::string sPOT)
Draw common TLatex lines.
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
virtual Spectrum AntiNueComponent() const =0
Eigen::ArrayXd ProjectionX(const Eigen::MatrixXd &mat)
Helper for Unweighted.
void PlotPurEff(Spectrum pureff[], Spectrum effcyD[], TDirectory *out, std::string name, std::string title)
const Color_t kCosmicBackgroundColor
Definition: Style.h:41
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:149
void Make2DFrom1D(Spectrum spectra[], const Binning &binsX, const Binning &binsY, TDirectory *rootOut, std::string name, std::string det, std::string labelX, std::string labelY, std::string option)
virtual Spectrum NumuComponent() const =0
double delta
Definition: runWimpSim.h:98
virtual Spectrum Predict(osc::IOscCalc *calc) const =0
void OverridePOT(double newpot)
DO NOT USE UNLESS YOU ARE 110% CERTAIN THERE ISN&#39;T A BETTER WAY!
Definition: Spectrum.h:233
#define MAXSPEC
T sqrt(T number)
Definition: d0nt_math.hpp:156
General interface to oscillation calculators.
Definition: StanTypedefs.h:23
void Clear()
Definition: Spectrum.cxx:362
void CenterTitles(TH1 *histo)
Definition: Plots.cxx:1483
osc::OscCalcDumb calc
osc::IOscCalcAdjustable * DefaultOscCalc()
Create a new calculator with default assumptions for all parameters.
Definition: Calcs.cxx:49
const Color_t kNumuBackgroundColor
Definition: Style.h:30
float abs(float number)
Definition: d0nt_math.hpp:39
Representation of a spectrum in any variable, with associated POT.
Definition: Spectrum.h:40
const Color_t kNueSignalColor
Definition: Style.h:19
const char * label
Charged-current interactions.
Definition: IPrediction.h:39
std::void_t< T > n
Int_t col[ntarg]
Definition: Style.C:29
std::vector< std::string > flavors
Optimized version of OscCalcPMNS.
Definition: StanTypedefs.h:32
#define pot
void purity()
Definition: purity.C:35
virtual Spectrum AntiNumuComponent() const =0
osc::NoOscillations noosc
Definition: NueSystFuncs.h:44
double POT() const
Definition: Spectrum.h:227
void Preliminary()
void DrawLineArrow(double cut, bool left, TH1 *h)
OStream cout
Definition: OStream.cxx:6
std::vector< double > POT
TH1F * h2
Definition: plot.C:45
constexpr auto const & left(const_AssnsIter< L, R, D, Dir > const &a, const_AssnsIter< L, R, D, Dir > const &b)
Definition: AssnsIter.h:96
void SetLegendOptions(TLegend *leg)
Set common options for a TLegend.
const Cut cut
Definition: exporter_fd.C:30
double livetime
Definition: saveFDMCHists.C:21
int NBins() const
Definition: Binning.h:29
virtual Spectrum NCTotalComponent() const
Definition: IDecomp.h:18
TLatex * tex
Definition: f2_nu.C:499
Standard interface to all decomposition techniques.
Definition: IDecomp.h:13
Neutral-current interactions.
Definition: IPrediction.h:40
Both neutrinos and antineutrinos.
Definition: IPrediction.h:52
Standard interface to all prediction techniques.
Definition: IPrediction.h:57
static double NCSCALE
const Color_t kTotalMCColor
Definition: Style.h:16
All neutrinos, any flavor.
Definition: IPrediction.h:26
void PlotSpectra(Spectrum spectra[], TDirectory *rootOut, FILE *textOFS, std::string name, std::string title, std::string det, int POT, std::string option)
T max(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
Definition: statistics.h:66
const Color_t kNCBackgroundColor
Definition: Style.h:22
double Livetime() const
Seconds. For informational purposes only. No calculations use this.
Definition: Spectrum.h:230
void FillWithDimColor(TH1 *h, bool usealpha, float dim)
TH2 * ToTH2(const Spectrum &s, double exposure, ana::EExposureType expotype, const Binning &binsx, const Binning &binsy, ana::EBinType bintype)
For use with Var2D.
Definition: UtilsExt.cxx:115
virtual Spectrum NueComponent() const =0
enum BeamMode string