nue_draw_michelDataMC.C
Go to the documentation of this file.
1 #include "CAFAna/Core/Spectrum.h"
4 
5 #include "Utilities/func/MathUtil.h"
6 
7 #include "TCanvas.h"
8 #include "TH2.h"
9 #include "TH1.h"
10 #include "TFile.h"
11 #include "TLegend.h"
12 
13 #include <iostream>
14 #include <cmath>
15 
16 using namespace ana;
17 
18 
20 {
21  Spectrum *da = LoadFromFile<Spectrum>(fname,type+"/"+type+"_DA").release();
22  Spectrum *mc = LoadFromFile<Spectrum>(fname,type+"/"+type+"_MC").release();
23  Spectrum *me = LoadFromFile<Spectrum>(fname,
24  type+"/"+type+"_MCTrueME").release();
25 
26  double pot = da->POT();
27  TH1 *hda = da->ToTH1(pot);
28  TH1 *hmc = mc->ToTH1(pot);
29  TH1 *hme = me->ToTH1(pot);
30  TH1 *hbg = mc->ToTH1(pot);
31  hbg->Add(hme,-1); // Background is total - true MEs
32 
33  // Scale histograms down to make them prettier
34  hmc->Scale(1e-3);
35  hme->Scale(1e-3);
36  hbg->Scale(1e-3);
37  for (int i = 1; i <= hmc->GetNbinsX(); i++){
38  hda->SetBinContent(i,1e-3*hda->GetBinContent(i));
39  hda->SetBinError(i,1e-3*hda->GetBinError(i)); // Do this to fix errors too
40  }
41 
42  hmc->SetLineColor(kRed);
43  hbg->SetLineColor(kGreen+2);
44  hme->SetLineColor(kBlue);
45 
46  hmc->SetMaximum(1.2*std::max(hmc->GetMaximum(),hda->GetMaximum()));
47  hmc->SetMinimum(0);
48 
49  hmc->GetXaxis()->CenterTitle();
50  hmc->GetYaxis()->SetTitle("10^{3} Events / 8.09#times10^{20}");
51  hmc->GetYaxis()->CenterTitle();
52 
53  hmc->Draw("hist");
54  hbg->Draw("hist,same");
55  hme->Draw("hist,same");
56  hda->Draw("E,same");
57 
58  TLegend *leg = AutoPlaceLegend(0.3,0.35);
59  leg->AddEntry(hda,"Data","le");
60  leg->AddEntry(hmc,"Total MC","l");
61  leg->AddEntry(hme,"True Michel","l");
62  leg->AddEntry(hbg,"Non-Michel Bkgd","l");
63  leg->Draw();
64 }
65 
67 {
68  TCanvas *canMID = new TCanvas();
69  MakePlot(fname,"MID");
70  TCanvas *canInput = new TCanvas(UniqueName().c_str(),"",1000,750);
71  canInput->Divide(2,2);
72  canInput->cd(1);
73  MakePlot(fname,"calE");
74  canInput->cd(2);
75  MakePlot(fname,"NHit");
76  canInput->cd(3);
77  MakePlot(fname,"DeltaT");
78  canInput->cd(4);
79  MakePlot(fname,"Dist");
80 }
81 
83 {
84  MakePlots(fname);
85 }
T max(const caf::Proxy< T > &a, T b)
void MakePlots(std::string fname)
enum BeamMode kRed
Cuts and Vars for the 2020 FD DiF Study.
Definition: vars.h:6
void nue_draw_michelDataMC(std::string fname)
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:148
void MakePlot(std::string fname, std::string type)
Representation of a spectrum in any variable, with associated POT.
Definition: Spectrum.h:40
Definition: NueSkimmer.h:24
#define pot
double POT() const
Definition: Spectrum.h:227
TLegend * AutoPlaceLegend(double dx, double dy, double yPin)
Create a legend, maximizing distance from all histograms.
Definition: Plots.cxx:717
Float_t e
Definition: plot.C:35
enum BeamMode kGreen
enum BeamMode kBlue
std::string UniqueName()
Return a different string each time, for creating histograms.
Definition: Utilities.cxx:29
enum BeamMode string