Skip to content
Snippets Groups Projects
Commit a3dc2907 authored by Marshall Scott's avatar Marshall Scott
Browse files

First test of pi0 ecal_barrel

parent 8096e970
No related branches found
No related tags found
No related merge requests found
...@@ -9,6 +9,10 @@ ...@@ -9,6 +9,10 @@
#include "dd4pod/Geant4ParticleCollection.h" #include "dd4pod/Geant4ParticleCollection.h"
#include "dd4pod/CalorimeterHitCollection.h" #include "dd4pod/CalorimeterHitCollection.h"
#include <benchmark.h>
#include <mt.h>
#include <util.h>
#include "TCanvas.h" #include "TCanvas.h"
#include "TStyle.h" #include "TStyle.h"
#include "TMath.h" #include "TMath.h"
...@@ -32,6 +36,19 @@ void emcal_barrel_pions_analysis(const char* input_fname = "sim_output/sim_emcal ...@@ -32,6 +36,19 @@ void emcal_barrel_pions_analysis(const char* input_fname = "sim_output/sim_emcal
gStyle->SetPadLeftMargin(0.14); gStyle->SetPadLeftMargin(0.14);
gStyle->SetPadRightMargin(0.14); gStyle->SetPadRightMargin(0.14);
//Tests
std::string test_tag = "Barrel_emcal_pi0";
//TODO: Change test_tag to something else
std:string detector = "Barrel_emcal";
double resolutionTarget = 0.1;
eic::util::Test pion0_Energy_resolution{
{{"name", fmt::format("{}_energy_resolution", test_tag)},
{"title", "Pion0 Energy resolution"},
{"description",
fmt::format("Pion0 energy resolution with {}, estimated using a Gaussian fit.", detector)},
{"quantity", "resolution (in %)"},
{"target", std::to_string(resolutionTarget)}}};
ROOT::EnableImplicitMT(); ROOT::EnableImplicitMT();
ROOT::RDataFrame d0("events", input_fname); ROOT::RDataFrame d0("events", input_fname);
...@@ -70,6 +87,8 @@ void emcal_barrel_pions_analysis(const char* input_fname = "sim_output/sim_emcal ...@@ -70,6 +87,8 @@ void emcal_barrel_pions_analysis(const char* input_fname = "sim_output/sim_emcal
.Define("nhits", nhits, {"EcalBarrelHits"}) .Define("nhits", nhits, {"EcalBarrelHits"})
.Define("Esim", Esim, {"EcalBarrelHits"}) .Define("Esim", Esim, {"EcalBarrelHits"})
.Define("fsam", fsam, {"Esim","Ethr"}) .Define("fsam", fsam, {"Esim","Ethr"})
.Define("dE", "Ethr-Esim")
.Define("dE_rel", "(Ethr - Esim)/Esim")
; ;
// Define Histograms // Define Histograms
...@@ -77,6 +96,7 @@ void emcal_barrel_pions_analysis(const char* input_fname = "sim_output/sim_emcal ...@@ -77,6 +96,7 @@ void emcal_barrel_pions_analysis(const char* input_fname = "sim_output/sim_emcal
auto hNhits = d1.Histo1D({"hNhits", "Number of hits per events; Number of hits; Events", 100, 0.0, 2000.0}, "nhits"); auto hNhits = d1.Histo1D({"hNhits", "Number of hits per events; Number of hits; Events", 100, 0.0, 2000.0}, "nhits");
auto hEsim = d1.Histo1D({"hEsim", "Energy Deposit; Energy Deposit [GeV]; Events", 100, 0.0, 1.0}, "Esim"); auto hEsim = d1.Histo1D({"hEsim", "Energy Deposit; Energy Deposit [GeV]; Events", 100, 0.0, 1.0}, "Esim");
auto hfsam = d1.Histo1D({"hfsam", "Sampling Fraction; Sampling Fraction; Events", 100, 0.0, 0.1}, "fsam"); auto hfsam = d1.Histo1D({"hfsam", "Sampling Fraction; Sampling Fraction; Events", 100, 0.0, 0.1}, "fsam");
// Event Counts // Event Counts
auto nevents_thrown = d1.Count(); auto nevents_thrown = d1.Count();
...@@ -121,4 +141,40 @@ void emcal_barrel_pions_analysis(const char* input_fname = "sim_output/sim_emcal ...@@ -121,4 +141,40 @@ void emcal_barrel_pions_analysis(const char* input_fname = "sim_output/sim_emcal
hfsam->DrawClone(); hfsam->DrawClone();
c4->SaveAs("results/emcal_barrel_pions_fsam.png"); c4->SaveAs("results/emcal_barrel_pions_fsam.png");
c4->SaveAs("results/emcal_barrel_pions_fsam.pdf"); c4->SaveAs("results/emcal_barrel_pions_fsam.pdf");
//Energy Resolution Work
auto hdE = d1.Histo1D({"hdE", "dE; dE[GeV]; Events", 100, -7.5, 7.5}, "dE");
auto hdE_rel = d1.Histo1D({"hdE_rel", "dE Relative; dE Relative; Events", 100, -7.5, 7.5}, "dE_rel");
auto f1 = hdE_rel->Fit("gaus", "S");
const double* res = f1->GetParams();
if (res[2] <= resolutionTarget) {
pion0_energy_resolution.pass(res[2]);
} else {
pion0_energy_resolution.fail(res[2]);
}
auto *cdE = new TCanvas("cdE", "cdE", 700, 500);
cDE->SetLogy(1);
hdE->GetYaxis()->SetTitleOffset(1.4);
hdE->SetLineWidth(2);
hdE->SetLineColor(kBlue);
hdE->DrawClone();
cdE->SaveAs("results/emcal_barrel_pi0_dE.png");
cdE->SaveAs("results/emcal_barrel_pi0_dE.pdf");
auto *cdE_rel = new TCanvas("cdE_rel", "cdE_rel", 700, 500);
cdE_rel->SetLogy(1);
hdE_rel->GetYaxis()->SetTitleOffset(1.4);
hdE_rel->SetLineWidth(2);
hdE_rel->SetLineColor(kBlue);
f1->SetLineWidth(2);
f1->SetLineColor(kRed);
hdE_rel->DrawClone();
f1->Draw("SAME");
cdE_rel->SaveAs("results/emcal_barrel_pi0_dE_rel.png");
cdE_rel->SaveAs("results/emcal_barrel_pi0_dE_rel.pdf");
eic::util::write_test({pion0_Energy_resolution}, fmt::format("{}_pions.json", detector));
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment