DrawCovMx.C
Go to the documentation of this file.
1 /*
2  * DrawCovMx.C
3  *
4  * Created on: February 15, 2018
5  * Author: J. Hewes <jhewes15@fnal.gov>
6  *
7  * Make a whole bunch o' plots :)
8  */
9 
10 #ifdef __CINT__
11 
12 #include <iostream>
13 void DrawCovMx(bool rhc = false)
14 {
15  std::cerr << "Sorry, you must run in compiled mode" << std::endl;
16 }
17 
18 #else
19 
20 #include "TH2.h"
21 #include "TLine.h"
22 #include "TLatex.h"
23 
29 
31 
32 using namespace ana;
33 
34 void DrawCovMx(bool rhc = false)
35 {
36  DontAddDirectory guard;
37  FormatCanvas();
38 
39  std::string polarity = rhc? "RHC" : "FHC";
40 
41  // Set the total POT and livetime
43  double fd_pot = rhc? kAna2018RHCPOT : kAna2018FHCPOT;
44  double fd_livetime = rhc? kAna2018RHCLivetime : kAna2018FHCLivetime;
45 
46  // Get simulation
47  PredictionConcat* sim = GetDefaultSimulation();
48 
49  // Define oscillation calculator
51  SetAngles(calc);
52 
53  // Get matrix
54  CovarianceMatrix* mx = GetFullCovMx(sim, calc, fd_pot);
55 
56  // Draw some plots
57  TCanvas* c = new TCanvas();
58 
59  // First up, a bunch of covariance matrices
60  auto components = GetComponents();
61 
62  TFile* plotfile = new TFile(Form("plots/covmx/%sPlots.root",polarity.c_str()),"recreate");
63 
64  //
65  // Full covariance matrix
66  //
67 
68  TH2D* h_full = mx->GetFullCovMxTH2();
69  FormatFullCovMxPlot(h_full, sim);
70 
71  c->Write(Form("CovMx%sFull",polarity.c_str()));
72  c->SaveAs(Form("plots/covmx/CovMx%sFull.png",polarity.c_str()));
73  c->SaveAs(Form("plots/covmx/CovMx%sFull.pdf",polarity.c_str()));
74  c->Clear();
75 
76  //
77  // Absolute covariance matrix
78  //
79 
80  std::vector<double> bin_edges = sim->GetBinEdges();
81 
82  TH2D* h_osc_abs = mx->GetCovMxAbsoluteTH2();
83  h_osc_abs->Draw("colz");
84  c->Write(Form("CovMx%sOscAbs",polarity.c_str()));
85  c->SaveAs(Form("plots/covmx/CovMx%sOscAbs.png",polarity.c_str()));
86  c->SaveAs(Form("plots/covmx/CovMx%sOscAbs.pdf",polarity.c_str()));
87  c->Clear();
88 
89  //
90  // Relative covariance matrix
91  //
92 
93  auto nominal = sim->Predict(calc).ToTH1(fd_pot);
94  int nbins = nominal->GetNbinsX();
95  TVectorD v_pred(nbins);
96  for (int i = 0; i < nbins; ++i)
97  v_pred(i) = nominal->GetBinContent(i+1);
98  TH2D* h_osc_rel = mx->GetCovMxRelativeTH2(v_pred);
99  h_osc_rel->Draw("colz");
100  h_osc_rel->GetYaxis()->SetTitle("");
101  h_osc_rel->GetXaxis()->SetTitle("Deposited energy bins");
102  h_osc_rel->GetXaxis()->CenterTitle();
103 
104  Preliminary();
105 
106  double max_e = 20;
107 
108  TLine lx(0, max_e, 2 * max_e, max_e);
109  lx.Draw();
110  TLine ly(max_e, 0, max_e, 2 * max_e);
111  ly.Draw();
112  MiscText(0.32,0.88,0.06,"ND");
113  MiscText(0.68,0.88,0.06,"FD");
114  MiscText(0.04,0.3,0.06,"ND");
115  MiscText(0.04,0.7,0.06,"FD");
116  c->Write(Form("CovMx%sRelative",polarity.c_str()));
117  c->SaveAs(Form("plots/covmx/CovMx%sOscRel.png",polarity.c_str()));
118  c->SaveAs(Form("plots/covmx/CovMx%sOscRel.pdf",polarity.c_str()));
119  c->Clear();
120 
121  plotfile->Close();
122 
123  delete sim;
124 }
125 
126 #endif
127 
Cuts and Vars for the 2020 FD DiF Study.
Definition: vars.h:6
std::vector< std::tuple< ana::Flavors::Flavors_t, ana::Current::Current_t, ana::Sign::Sign_t > > GetComponents()
void FormatFullCovMxPlot(TH2D *h, PredictionConcat *sim)
dictionary components
void DrawCovMx(bool rhc=false)
Definition: DrawCovMx.C:34
Adapt the PMNS_Sterile calculator to standard interface.
OStream cerr
Definition: OStream.cxx:7
TLatex * MiscText(float x, float y, float size, TString text)
const double kAna2018SensitivityFHCNDPOT
Definition: Exposures.h:210
osc::OscCalcDumb calc
void FormatCanvas()
Canvas formatting utility.
void SetAngles(osc::OscCalcSterile *calc)
const double kAna2018RHCPOT
Definition: Exposures.h:208
const int nbins
Definition: cellShifts.C:15
osc::OscCalcSterile * DefaultSterileCalc(int nflavors)
Create a sterile calculator with default assumptions for all parameters.
Definition: Calcs.cxx:97
Example routine for calculating the "ultimate e-m mother" of a particle in a simulated event...
Definition: FillTruth.h:16
void Preliminary()
const double kAna2018SensitivityRHCNDPOT
Definition: Exposures.h:211
const double kAna2018FHCPOT
Definition: Exposures.h:207
Prevent histograms being added to the current directory.
Definition: UtilsExt.h:46
const double kAna2018FHCLivetime
Definition: Exposures.h:213
const double kAna2018RHCLivetime
Definition: Exposures.h:214
enum BeamMode string