Skip to content
Snippets Groups Projects

Electron data set

Merged Jihee Kim requested to merge jihee.kim/reconstruction_benchmarks:electron into master
Files
8
+ 84
0
int cal_eng_res(const char* input_fname = "sim_output/read_eng_output.root")
{
// Setting Figures
gROOT->SetStyle("Plain");
gStyle->SetLineWidth(3);
gStyle->SetOptStat("nem");
gStyle->SetOptFit(1);
gStyle->SetPadTickX(1);
gStyle->SetPadTickY(1);
gStyle->SetPadGridX(1);
gStyle->SetPadGridY(1);
gStyle->SetPadLeftMargin(0.14);
// Read ROOT File
TFile *f = new TFile(input_fname,"r");
TTree *tEngRes = (TTree *)f->Get("tEngRes");
// Variables from ROOT tree
Int_t ievent;
Double_t tot_clust_eng; // total cluster energy [GeV]
Int_t ncluster; // number of clusters per event
Double_t mc_eng; // thrown energy [GeV]
Double_t sim_tru_eng; // total truth simulated energy [GeV]
Double_t sim_eng; // total simulated energy [GeV]
// Read Branches
tEngRes->SetBranchAddress("ievent", &ievent);
tEngRes->SetBranchAddress("tot_clust_eng", &tot_clust_eng);
tEngRes->SetBranchAddress("ncluster", &ncluster);
tEngRes->SetBranchAddress("mc_eng", &mc_eng);
tEngRes->SetBranchAddress("sim_tru_eng", &sim_tru_eng);
tEngRes->SetBranchAddress("sim_eng", &sim_eng);
// Setting for Canvas
TCanvas *c1 = new TCanvas("c1", "c1", 700, 500);
TCanvas *c2 = new TCanvas("c2", "c2", 700, 500);
// Declare Histrograms
TH1D *h1 = new TH1D("hEnergyRes","Energy Resolution", 100,-0.3,0.3);
TH1D *h2 = new TH1D("hEnergyResCUT","Energy Resolution with CUT", 100,-0.3,0.3);
// Variables that used in calculations
Double_t diff_energy;
Double_t eng_res;
Int_t nentries = tEngRes->GetEntries();
for(Int_t ievent = 0; ievent < nentries; ievent++)
{
tEngRes->GetEntry(ievent);
if(ncluster == 1)
{
diff_energy = tot_clust_eng - mc_eng;
eng_res = (diff_energy / mc_eng);
cout << tot_clust_eng << "\t" << mc_eng << "\t" << eng_res << endl;
h1->Fill(eng_res, 1.0);
if(tot_clust_eng > 0.5)
h2->Fill(eng_res, 1.0);
}
}
// Drawing and Saving Figures
c1->cd();
h1->SetLineColor(kBlue);
h1->SetLineWidth(2);
h1->GetXaxis()->SetTitle("#DeltaE/E");
h1->GetYaxis()->SetTitle("events");
h1->GetYaxis()->SetTitleOffset(1.4);
h1->Fit("gaus");
h1->Draw();
c1->SaveAs("results/hEngRes.png");
c2->cd();
h2->SetLineColor(kBlue);
h2->SetLineWidth(2);
h2->GetXaxis()->SetTitle("#DeltaE/E");
h2->GetYaxis()->SetTitle("events");
h2->GetYaxis()->SetTitleOffset(1.4);
h2->Fit("gaus");
h2->Draw();
c2->SaveAs("results/hEngRes_CUT.png");
return 0;
}
Loading