Functions | Variables
plot_energy_res.C File Reference
#include "CAFAna/Core/Spectrum.h"
#include "CAFAna/Core/HistAxis.h"
#include "Utilities/rootlogon.C"
#include "TH1.h"
#include "TH2.h"
#include "TFile.h"
#include "TCanvas.h"
#include "TF1.h"
#include "TFitResult.h"
#include <iostream>

Go to the source code of this file.

Functions

void plot_energy_res (string infile, string outputdir=".")
 

Variables

double POT = 11E20
 

Function Documentation

void plot_energy_res ( string  infile,
string  outputdir = "." 
)

Definition at line 19 of file plot_energy_res.C.

References demo5::c1, fin, ana::Spectrum::LoadFrom(), POT, and Simulation().

20 {
21  TFile * fin = TFile::Open(infile.c_str(), "READ");
22  unique_ptr<Spectrum> spec = Spectrum::LoadFrom(fin, "energy_2D");
23  TH2* recotruehist = spec->ToTH2(POT);
24  recotruehist->SetTitle("Selected Sig / 11E20 POT;Reco T_{#mu} (GeV);True T_{#mu} (GeV)");
25 
26  TH1 * recohist = Spectrum::LoadFrom(fin, "reco_muke")->ToTH1(POT);
27  TH1 * truehist = Spectrum::LoadFrom(fin, "true_muke")->ToTH1(POT);
28  TH1 * reshist = Spectrum::LoadFrom(fin, "res_muke")->ToTH1(POT);
29 
30  TCanvas * c1 = new TCanvas("c1", "c1", 1600, 900);
31  recotruehist->Draw("COLZ");
32  c1->SaveAs((outputdir + "/recotruehist.png").c_str());
33  c1->SaveAs((outputdir + "/recotruehist.pdf").c_str());
34 
35  recohist->SetTitle(";Reco T_{#mu};Events / 11E20 POT");
36  recohist->Draw("hist");
37  Simulation();
38  c1->SaveAs((outputdir + "/recohist.png").c_str());
39  c1->SaveAs((outputdir + "/recohist.pdf").c_str());
40 
41  truehist->SetTitle(";True T_{#mu};Events / 11E20 POT");
42  truehist->Draw("hist");
43  Simulation();
44  c1->SaveAs((outputdir + "/truehist.png").c_str());
45  c1->SaveAs((outputdir + "/truehist.pdf").c_str());
46 
47  reshist->SetTitle(";(Reco - True) / True T_{#mu};Events / 11E20 POT");
48  reshist->Draw("hist");
49  Simulation();
50  c1->SaveAs((outputdir + "/resolution.png").c_str());
51  c1->SaveAs((outputdir + "/resolution.pdf").c_str());
52 
53  reshist->GetXaxis()->SetRangeUser(-1.0, 1.0);
54  reshist->Draw("hist");
55  Simulation();
56  c1->SaveAs((outputdir + "/resolution_zoom.png").c_str());
57  c1->SaveAs((outputdir + "/resolution_zoom.pdf").c_str());
58 
59  gStyle->SetOptFit(1);
60  gStyle->SetStatX(0.9);
61  gStyle->SetStatY(0.9);
62  gStyle->SetStatW(0.2);
63  gStyle->SetStatH(0.2);
64  c1->UseCurrentStyle();
65  TFitResultPtr gausfit = reshist->Fit("gaus", "S");
66  TF1* gausfitfunc = reshist->GetFunction("gaus");
67  gausfit->Draw("hist");
68  gausfitfunc->Draw("same");
69  Simulation();
70  c1->Update();
71  c1->SaveAs((outputdir + "/resolution_fit.png").c_str());
72  c1->SaveAs((outputdir + "/resolution_fit.pdf").c_str());
73 
74  // TH1 * differenceHist = *recohist - *truehist;
75  // differenceHist->SetTitle("Reco - True")
76 
77  fin->Close();
78 }
void Simulation()
Definition: tools.h:16
TString fin
Definition: Style.C:24
std::unique_ptr< T > LoadFrom(TDirectory *dir, const std::string &label)
Definition: LoadFromFile.h:17
string infile
double POT
c1
Definition: demo5.py:24

Variable Documentation

double POT = 11E20

Definition at line 17 of file plot_energy_res.C.

Referenced by plot_energy_res().