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